@import url('https://fonts.googleapis.com/css2?family=Rajdhani:wght@400;500;600;700&family=JetBrains+Mono:wght@300;400;500;700&family=Cinzel:wght@400;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #060810;
  --surface:       rgba(8,11,22,0.94);
  --surface-md:    rgba(10,14,26,0.88);
  --card:          rgba(16,21,38,0.96);
  --border:        rgba(255,255,255,0.07);
  --border-hi:     rgba(255,255,255,0.14);
  --accent:        #c9a84c;
  --accent-dim:    rgba(201,168,76,0.13);
  --accent-glow:   rgba(201,168,76,0.26);
  --accent-bright: #e8c870;
  --blue:          #4a8fd9;
  --text:          #cdd5ec;
  --text-dim:      #4e5a78;
  --text-muted:    #2e384e;
  --green:         #3ecf6e;
  --danger:        #e05252;

  --sq-light:      #eedcb4;
  --sq-dark:       #9c6a3a;
  --sq-light-h:    #f7e9cc;
  --sq-dark-h:     #b87d4a;
  --board-glow:    rgba(201,168,76,0.14);
  --select-glow:   rgba(201,168,76,0.85);
  --lastmove-glow: rgba(74,143,217,0.55);
  --check-glow:    rgba(224,82,82,0.75);

  --board-size: min(92vh, 92vw, 800px);
  --sq-size:    calc(var(--board-size) / 8);
  --radius:     10px;
  --radius-sm:  6px;
  --t:          0.18s cubic-bezier(0.4,0,0.2,1);
}

/* ── BOARD THEMES ─────────────────────────────────────── */
.theme-classic {
  --sq-light:      #f0d9b5;
  --sq-dark:       #b58863;
  --sq-light-h:    #f7e4c5;
  --sq-dark-h:     #c99a72;
  --board-glow:    rgba(181,136,99,0.18);
  --select-glow:   rgba(220,190,90,0.88);
  --lastmove-glow: rgba(100,160,220,0.55);
}
.theme-gold {
  --sq-light:      #eedcb4;
  --sq-dark:       #9c6a3a;
  --sq-light-h:    #f7e9cc;
  --sq-dark-h:     #b87d4a;
  --board-glow:    rgba(201,168,76,0.18);
  --select-glow:   rgba(220,190,80,0.90);
  --lastmove-glow: rgba(74,143,217,0.58);
}
.theme-emerald {
  --sq-light:      #c8dfc8;
  --sq-dark:       #4a7c59;
  --sq-light-h:    #d8ecd8;
  --sq-dark-h:     #5a9069;
  --board-glow:    rgba(60,180,100,0.18);
  --select-glow:   rgba(80,220,130,0.88);
  --lastmove-glow: rgba(60,160,220,0.55);
  --check-glow:    rgba(230,70,70,0.80);
}
.theme-obsidian {
  --sq-light:      #78788a;
  --sq-dark:       #1e1e2e;
  --sq-light-h:    #8888a0;
  --sq-dark-h:     #2e2e42;
  --board-glow:    rgba(140,130,200,0.16);
  --select-glow:   rgba(160,140,255,0.88);
  --lastmove-glow: rgba(100,180,255,0.55);
  --check-glow:    rgba(255,80,80,0.80);
}
.theme-ice {
  --sq-light:      #d4eaf7;
  --sq-dark:       #4a7fa8;
  --sq-light-h:    #e4f4ff;
  --sq-dark-h:     #5a92bc;
  --board-glow:    rgba(74,160,240,0.20);
  --select-glow:   rgba(120,210,255,0.90);
  --lastmove-glow: rgba(60,140,220,0.60);
  --check-glow:    rgba(230,70,70,0.82);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  overflow: hidden;
}

/* ── APP ──────────────────────────────────────────────── */
.app {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.app::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 65% 65% at 50% 50%,
    rgba(201,168,76,0.07) 0%,
    rgba(74,143,217,0.05) 42%,
    transparent 72%);
  pointer-events: none;
  animation: ambientBreathe 8s ease-in-out infinite;
}
@keyframes ambientBreathe { 0%,100%{opacity:0.6} 50%{opacity:1} }

/* ── VICTORY OVERLAY ──────────────────────────────────── */
.victory-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4,5,14,0.86);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.55s ease;
}
.victory-overlay.show {
  opacity: 1;
  pointer-events: all;
}
.victory-card {
  background: linear-gradient(150deg,
    rgba(18,22,44,0.99) 0%,
    rgba(10,14,28,0.99) 100%);
  border: 1px solid rgba(201,168,76,0.38);
  border-radius: 22px;
  padding: 48px 58px;
  text-align: center;
  box-shadow:
    0 0 0 1px rgba(201,168,76,0.10) inset,
    0 2px 0 rgba(201,168,76,0.22) inset,
    0 0 90px rgba(201,168,76,0.18),
    0 50px 140px rgba(0,0,0,0.92);
  transform: scale(0.82) translateY(24px);
  transition: transform 0.52s cubic-bezier(0.34,1.56,0.64,1);
}
.victory-overlay.show .victory-card {
  transform: scale(1) translateY(0);
}
.victory-crown {
  font-size: 68px;
  line-height: 1;
  margin-bottom: 18px;
  display: block;
  animation: crownFloat 2.8s ease-in-out infinite;
  filter: drop-shadow(0 0 22px rgba(201,168,76,0.75));
}
@keyframes crownFloat {
  0%,100% { transform: translateY(0) rotate(-4deg); }
  50%     { transform: translateY(-9px) rotate(4deg); }
}
.victory-title {
  font-family: 'Cinzel', serif;
  font-size: 34px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 4px;
  text-shadow: 0 0 34px var(--accent-glow);
  margin-bottom: 10px;
}
.victory-sub {
  font-size: 14px;
  color: var(--text-dim);
  letter-spacing: 2.5px;
  text-transform: uppercase;
  margin-bottom: 30px;
}
.victory-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(201,168,76,0.45), transparent);
  margin-bottom: 30px;
}
.victory-btn { margin: 0 auto; width: auto; padding: 13px 36px; }

/* ── BOARD SECTION ────────────────────────────────────── */
.board-section {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
}
.board-atmosphere { display: none; }

.game-message {
  height: 28px;
  margin-bottom: 7px;
  font-family: 'Cinzel', serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 2px;
  text-align: center;
  text-shadow: 0 0 26px var(--accent-glow);
}

/* ── COORDS ───────────────────────────────────────────── */
.coords-top, .coords-bottom {
  display: flex;
  width: var(--board-size);
  height: 16px;
  padding-left: 16px;
}
.coords-left, .coords-right {
  display: flex;
  flex-direction: column;
  width: 16px;
  height: var(--board-size);
}
.coord-label {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; font-weight: 400;
  color: var(--text-muted);
  user-select: none;
}
.board-wrap { display: flex; align-items: center; }

/* ── BOARD FRAME ──────────────────────────────────────── */
.board-frame {
  position: relative;
  padding: 3px;
  border-radius: 5px;
  background: linear-gradient(145deg,
    rgba(201,168,76,0.52) 0%,
    rgba(201,168,76,0.10) 32%,
    rgba(28,38,68,0.32) 62%,
    rgba(201,168,76,0.30) 100%
  );
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.72),
    0 44px 130px rgba(0,0,0,0.94),
    0 0 100px var(--board-glow),
    inset 0 0 32px rgba(0,0,0,0.52);
  transition: box-shadow 0.5s ease;
}
.board-frame.thinking {
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.72),
    0 44px 130px rgba(0,0,0,0.94),
    0 0 88px rgba(74,143,217,0.26),
    inset 0 0 32px rgba(0,0,0,0.52);
}

/* ── BOARD GRID ───────────────────────────────────────── */
.board {
  display: grid;
  grid-template-columns: repeat(8, var(--sq-size));
  grid-template-rows:    repeat(8, var(--sq-size));
  width:  var(--board-size);
  height: var(--board-size);
  border-radius: 2px;
  overflow: hidden;
}

/* ── SQUARES ──────────────────────────────────────────── */
.square {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: background 0.09s ease, box-shadow 0.09s ease;
  overflow: hidden;
}
.square.light { background: var(--sq-light); }
.square.dark  { background: var(--sq-dark); }

.square.light:hover {
  background: var(--sq-light-h);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.18);
}
.square.dark:hover {
  background: var(--sq-dark-h);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.10);
}

.square.selected {
  background: rgba(201,168,76,0.70) !important;
  box-shadow:
    inset 0 0 0 3px var(--select-glow),
    inset 0 0 18px rgba(201,168,76,0.30) !important;
}
.square.last-move {
  background: rgba(74,143,217,0.40) !important;
  box-shadow: inset 0 0 0 2.5px var(--lastmove-glow) !important;
}
.square.in-check {
  background: rgba(224,82,82,0.72) !important;
  box-shadow:
    inset 0 0 0 3px var(--check-glow),
    inset 0 0 24px rgba(224,82,82,0.40) !important;
  animation: checkPulse 0.75s ease-in-out infinite alternate;
}
@keyframes checkPulse {
  from { box-shadow: inset 0 0 0 3px var(--check-glow), 0 0 0 rgba(224,82,82,0); }
  to   { box-shadow: inset 0 0 0 3px var(--check-glow), 0 0 24px rgba(224,82,82,0.45); }
}

.square.legal-move::after {
  content: '';
  position: absolute;
  width: 30%; height: 30%;
  border-radius: 50%;
  background: rgba(0,0,0,0.20);
  box-shadow: 0 0 0 2.5px rgba(201,168,76,0.62);
  pointer-events: none;
  animation: dotIn 0.13s ease-out;
}
.square.legal-capture::after {
  content: '';
  position: absolute;
  inset: 3px;
  background: transparent;
  border: 3.5px solid rgba(201,168,76,0.68);
  border-radius: 2px;
  pointer-events: none;
  animation: dotIn 0.13s ease-out;
}
@keyframes dotIn {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── SVG PIECES ───────────────────────────────────────── */
.piece-svg {
  width: 88%;
  height: 88%;
  position: relative;
  z-index: 1;
  pointer-events: none;
  transition: transform 0.13s ease, filter 0.13s ease;
  filter: drop-shadow(0 3px 7px rgba(0,0,0,0.58));
  will-change: transform;
}
.square:hover .piece-svg {
  transform: scale(1.11) translateY(-2px);
  filter: drop-shadow(0 6px 12px rgba(0,0,0,0.70));
}
.square.selected .piece-svg { transform: scale(1.07); }

.piece-svg.moving {
  animation: pieceMove 0.20s cubic-bezier(0.22,1,0.36,1);
}
@keyframes pieceMove {
  from { transform: scale(1.18) translateY(-5px); opacity: 0.8; }
  to   { transform: scale(1) translateY(0);       opacity: 1; }
}
.piece-svg.capturing {
  animation: captureFade 0.22s ease-out forwards;
}
@keyframes captureFade {
  0%   { transform: scale(1.2) rotate(8deg); opacity: 1; }
  100% { transform: scale(0)   rotate(20deg); opacity: 0; }
}

/* Legacy unicode piece support */
.piece {
  font-size: calc(var(--sq-size) * 0.82);
  line-height: 1; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  pointer-events: none;
  transition: transform 0.12s ease;
}
.piece.white-piece {
  color: #f4ede0;
  text-shadow: 0 1px 0 #8a6a30, 0 2px 7px rgba(0,0,0,0.65);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.55));
}
.piece.black-piece {
  color: #181818;
  text-shadow: 0 1px 0 #555, 0 2px 7px rgba(0,0,0,0.85);
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.75)) drop-shadow(0 0 1px rgba(160,160,160,0.28));
}
.square:hover .piece    { transform: scale(1.09); }
.square.selected .piece { transform: scale(1.05); }

/* ── PANELS — glassmorphism ───────────────────────────── */
.panel {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 192px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  z-index: 10;
  padding: 13px 11px;
  border-radius: 16px;
  background: rgba(8,12,24,0.82);
  border: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(32px) saturate(1.7);
  -webkit-backdrop-filter: blur(32px) saturate(1.7);
  box-shadow:
    0 10px 52px rgba(0,0,0,0.78),
    0 2px 0 rgba(255,255,255,0.06) inset,
    0 0 0 0.5px rgba(255,255,255,0.05) inset;
}
.panel::-webkit-scrollbar { display: none; }

.panel-left  { left:  calc(50% - var(--board-size)/2 - 212px); }
.panel-right { right: calc(50% - var(--board-size)/2 - 212px); }

/* ── LOGO ─────────────────────────────────────────────── */
.logo {
  display: flex; align-items: center; gap: 10px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-icon {
  font-size: 22px;
  filter: drop-shadow(0 0 10px rgba(201,168,76,0.92));
  animation: float 3.5s ease-in-out infinite;
  line-height: 1; flex-shrink: 0;
}
@keyframes float { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-3px)} }
.logo-title { font-family:'Cinzel',serif; font-size:12px; font-weight:700; color:var(--accent); letter-spacing:1px; line-height:1; }
.logo-sub   { font-size:7px; letter-spacing:1.5px; color:var(--text-muted); margin-top:3px; text-transform:uppercase; }

/* ── ENGINE STATUS ────────────────────────────────────── */
.engine-status {
  display:flex; align-items:center; gap:8px;
  padding:7px 9px;
  background:rgba(255,255,255,0.03);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  flex-shrink:0;
}
.status-dot {
  width:6px; height:6px; border-radius:50%;
  background:var(--text-muted); flex-shrink:0;
  transition:background var(--t), box-shadow var(--t);
}
.status-dot.loading  { background:var(--accent); box-shadow:0 0 6px var(--accent); animation:pulse 1.2s ease-in-out infinite; }
.status-dot.ready    { background:var(--green);  box-shadow:0 0 6px rgba(62,207,110,0.65); }
.status-dot.error    { background:var(--danger); }
.status-dot.thinking { background:var(--blue);   box-shadow:0 0 6px rgba(74,143,217,0.85); animation:pulse 0.7s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.18} }

.status-info { flex:1; min-width:0; }
.status-label { display:block; font-size:7px; letter-spacing:1.5px; color:var(--text-muted); margin-bottom:1px; text-transform:uppercase; }
#statusText { font-size:10px; font-weight:600; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }

/* ── PLAYERS ──────────────────────────────────────────── */
.players-section { display:flex; flex-direction:column; gap:5px; flex-shrink:0; }
.player-card {
  display:flex; align-items:center; gap:8px;
  padding:8px 9px;
  background:rgba(255,255,255,0.03);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  transition:all var(--t);
  position:relative; overflow:hidden;
}
.player-card::before {
  content:''; position:absolute; left:0; top:0; bottom:0; width:2px;
  background:transparent;
  transition:background var(--t), box-shadow var(--t);
}
.player-card.active-turn {
  border-color:rgba(255,255,255,0.12);
  background:rgba(201,168,76,0.07);
}
.player-card.active-turn::before {
  background:var(--accent);
  box-shadow:0 0 12px var(--accent);
}
.player-avatar {
  width:30px; height:30px; border-radius:50%;
  display:flex; align-items:center; justify-content:center;
  font-size:15px; flex-shrink:0;
}
.white-avatar { background:linear-gradient(135deg,#ede4ce,#d4c8a8); color:#1a1a1a; }
.black-avatar { background:linear-gradient(135deg,#222,#151515); color:#c0c0c0; border:1px solid #2e2e2e; }
.player-info { flex:1; min-width:0; }
.player-name   { font-size:12px; font-weight:700; color:var(--text); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.player-rating { font-size:8.5px; color:var(--text-dim); margin-top:1px; }
.player-turn { flex-shrink:0; }
.turn-dot {
  display:block; width:6px; height:6px; border-radius:50%;
  background:var(--text-muted); transition:all var(--t);
}
.turn-dot.active {
  background:var(--accent);
  box-shadow:0 0 9px var(--accent),0 0 18px var(--accent-dim);
  animation:pulse 1.6s ease-in-out infinite;
}
.vs-divider { display:flex; align-items:center; gap:8px; }
.vs-line    { flex:1; height:1px; background:var(--border); }
.vs-text    { font-size:7.5px; font-weight:700; letter-spacing:2px; color:var(--text-muted); }

/* ── CARDS ────────────────────────────────────────────── */
.settings-card, .pv-card, .moves-card, .eval-card, .clock-card {
  background:rgba(255,255,255,0.026);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  padding:9px 10px;
  flex-shrink:0;
}
.card-title {
  font-size:7px; font-weight:700;
  letter-spacing:2px; color:var(--text-muted);
  text-transform:uppercase; margin-bottom:8px;
  display:flex; align-items:center; gap:6px;
}
.card-title::after { content:''; flex:1; height:1px; background:var(--border); }

/* ── SETTINGS ─────────────────────────────────────────── */
.setting-row { display:flex; flex-direction:column; gap:4px; margin-bottom:7px; }
.setting-row:last-child { margin-bottom:0; }
.setting-label { font-size:8px; font-weight:600; letter-spacing:1.5px; color:var(--text-dim); text-transform:uppercase; }

.select {
  background:rgba(0,0,0,0.46);
  border:1px solid var(--border-hi);
  color:var(--text);
  padding:7px 26px 7px 9px;
  border-radius:var(--radius-sm);
  font-family:'Rajdhani',sans-serif;
  font-size:12px; font-weight:600;
  cursor:pointer; outline:none; width:100%;
  appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%234e5a78'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 9px center;
  transition:border-color var(--t), box-shadow var(--t);
}
.select:focus {
  border-color:var(--accent);
  box-shadow:0 0 0 2px rgba(201,168,76,0.14);
}

/* ── BUTTONS ──────────────────────────────────────────── */
.action-buttons { display:flex; flex-direction:column; gap:6px; flex-shrink:0; }
.btn {
  display:flex; align-items:center; justify-content:center; gap:7px;
  padding:10px 12px; border:none; border-radius:var(--radius);
  font-family:'Rajdhani',sans-serif;
  font-size:12px; font-weight:700;
  letter-spacing:1px; cursor:pointer;
  transition:all var(--t); text-transform:uppercase; width:100%;
}
.btn-icon { font-size:11px; }
.btn-primary {
  background:linear-gradient(135deg,#b8891e 0%,#d4a843 50%,#e8c060 100%);
  color:#0a0700;
  box-shadow:0 4px 22px rgba(201,168,76,0.34),0 0 0 1px rgba(201,168,76,0.24);
}
.btn-primary:hover {
  background:linear-gradient(135deg,#cfa030 0%,#e8c060 50%,#f5d578 100%);
  box-shadow:0 6px 30px rgba(201,168,76,0.50),0 0 0 1px rgba(201,168,76,0.34);
  transform:translateY(-1px);
}
.btn-primary:active { transform:translateY(0); }
.btn-secondary {
  background:rgba(255,255,255,0.04);
  border:1px solid var(--border-hi);
  color:var(--text-dim);
}
.btn-secondary:hover {
  border-color:rgba(201,168,76,0.42);
  color:var(--accent);
  background:var(--accent-dim);
}

/* ── EVAL ─────────────────────────────────────────────── */
.eval-main { display:flex; align-items:baseline; gap:7px; margin-bottom:8px; }
.eval-score {
  font-family:'JetBrains Mono',monospace;
  font-size:26px; font-weight:700;
  color:var(--accent); line-height:1;
  text-shadow:0 0 22px rgba(201,168,76,0.34);
}
.eval-label { font-size:9px; font-weight:600; color:var(--text-dim); letter-spacing:0.5px; text-transform:uppercase; }
.eval-bar-wrap {
  height:5px; background:rgba(0,0,0,0.56);
  border-radius:3px; overflow:hidden;
  display:flex; margin-bottom:5px;
  border:1px solid var(--border);
}
.eval-bar-black { flex:1; background:#1a1a1a; }
.eval-bar-white {
  width:50%;
  background:linear-gradient(90deg,#b8891e,#e8c060);
  transition:width 0.55s cubic-bezier(0.4,0,0.2,1);
  flex-shrink:0;
}
.eval-sides { display:flex; justify-content:space-between; font-size:7.5px; color:var(--text-muted); }

/* ── STATS ────────────────────────────────────────────── */
.stats-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:5px; flex-shrink:0; }
.stat-card {
  background:rgba(0,0,0,0.34);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  padding:7px 5px; text-align:center;
}
.stat-label { display:block; font-size:6.5px; letter-spacing:1px; color:var(--text-muted); margin-bottom:3px; text-transform:uppercase; }
.stat-val   { font-family:'JetBrains Mono',monospace; font-size:10px; font-weight:700; color:var(--blue); }

/* ── PV ───────────────────────────────────────────────── */
.pv-line {
  font-family:'JetBrains Mono',monospace;
  font-size:9.5px; color:var(--text-dim);
  line-height:1.6; word-break:break-all; min-height:30px;
}

/* ── MOVES ────────────────────────────────────────────── */
.moves-card { flex:1 1 auto; min-height:0; display:flex; flex-direction:column; }
.moves-list {
  flex:1; overflow-y:auto;
  display:grid; grid-template-columns:1fr 1fr;
  gap:1px 5px; align-content:start;
  scrollbar-width:thin; scrollbar-color:var(--border) transparent;
  max-height:140px;
}
.moves-list::-webkit-scrollbar { width:2px; }
.moves-list::-webkit-scrollbar-thumb { background:var(--border-hi); }
.move-item { padding:2px 3px; border-radius:3px; font-family:'JetBrains Mono',monospace; font-size:9.5px; }
.move-item.white  { color:var(--text); }
.move-item.black  { color:var(--text-dim); }
.move-item.latest { color:var(--accent); background:var(--accent-dim); font-weight:700; }
.move-num { color:var(--text-muted); font-size:7.5px; margin-right:2px; }

/* ── TIMER ────────────────────────────────────────────── */
.clock-card { padding:8px 10px; }
.timer-row {
  display:flex; align-items:center; gap:7px;
  padding:6px 7px;
  border-radius:var(--radius-sm);
  transition:background var(--t), border-color var(--t);
  border:1px solid transparent;
}
.timer-row.active-timer {
  background:rgba(201,168,76,0.08);
  border-color:rgba(201,168,76,0.20);
}
.timer-avatar { font-size:13px; line-height:1; flex-shrink:0; opacity:0.7; }
.timer-name {
  flex:1; font-size:9px; font-weight:600; letter-spacing:0.8px;
  color:var(--text-dim); text-transform:uppercase;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.timer-val {
  font-family:'JetBrains Mono',monospace;
  font-size:15px; font-weight:700;
  color:var(--blue); letter-spacing:1.5px;
  flex-shrink:0; transition:color var(--t);
}
.timer-val.urgent    { color:var(--danger); animation:pulse 0.8s ease-in-out infinite; }
.timer-val.unlimited { color:var(--text-muted); font-size:11px; letter-spacing:1px; }
.timer-divider { height:1px; background:var(--border); margin:4px 0; }
.active-timer .timer-val    { color:var(--accent); }
.active-timer .timer-avatar { opacity:1; }

/* ── SOUND BUTTON ─────────────────────────────────────── */
.setting-row-inline {
  flex-direction:row; align-items:center;
  justify-content:space-between; margin-bottom:0;
}
.btn-sound {
  display:flex; align-items:center; gap:5px;
  padding:5px 10px;
  background:rgba(255,255,255,0.04);
  border:1px solid var(--border-hi);
  border-radius:var(--radius-sm);
  color:var(--text-dim);
  font-family:'Rajdhani',sans-serif;
  font-size:11px; font-weight:600; letter-spacing:0.5px;
  cursor:pointer; transition:all var(--t); white-space:nowrap;
}
.btn-sound:hover { border-color:rgba(201,168,76,0.42); color:var(--accent); background:var(--accent-dim); }
.btn-sound.muted { color:var(--text-muted); border-color:var(--border); opacity:0.6; }

/* ══════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════ */
@media (max-width:1200px) {
  :root { --board-size:min(88vh,85vw,720px); }
  .panel { width:172px; }
  .panel-left  { left:calc(50% - var(--board-size)/2 - 190px); }
  .panel-right { right:calc(50% - var(--board-size)/2 - 190px); }
}
@media (max-width:1000px) {
  :root { --board-size:min(84vh,80vw,640px); }
  .panel { width:156px; font-size:12px; }
  .panel-left  { left:calc(50% - var(--board-size)/2 - 174px); }
  .panel-right { right:calc(50% - var(--board-size)/2 - 174px); }
  .pv-card { display:none; }
}
@media (max-width:820px) {
  :root { --board-size:min(82vh,92vw,600px); }
  .panel { width:150px; top:50%; transform:translateY(-50%); }
  .panel-left  { left:6px; }
  .panel-right { right:6px; }
  .pv-card, .moves-card { display:none; }
}
@media (max-width:600px) {
  :root { --board-size:min(96vw,480px); }
  html, body { overflow-y:auto; }
  .app {
    position:static; display:flex; flex-direction:column;
    align-items:center; width:100%; height:auto;
    min-height:100vh; padding:0; gap:0;
  }
  .app::before { display:none; }
  .panel-left {
    position:static; transform:none; width:100%; max-height:none;
    border-radius:0; flex-direction:row; flex-wrap:wrap;
    align-items:center; gap:8px; padding:10px 12px;
    border:none; border-bottom:1px solid var(--border-hi);
    backdrop-filter:none; background:var(--surface);
    z-index:10; order:1;
  }
  .panel-left .logo { padding-bottom:0; border-bottom:none; flex-shrink:0; }
  .panel-left .engine-status { flex:1; min-width:100px; }
  .panel-left .players-section { display:none; }
  .panel-left .settings-card {
    flex:1; min-width:130px; max-width:220px;
    background:transparent; border:none; padding:0;
  }
  .panel-left .settings-card .card-title { display:none; }
  .panel-left .settings-card .setting-row { margin-bottom:0; flex-direction:row; align-items:center; gap:6px; }
  .panel-left .settings-card .setting-label { display:none; }
  .panel-left .settings-card .setting-row-inline { flex-direction:row; align-items:center; }
  .panel-left .settings-card .setting-row-inline .setting-label { display:none; }
  .panel-left .action-buttons { flex-direction:row; gap:6px; flex-shrink:0; }
  .panel-left .action-buttons .btn { width:auto; padding:7px 10px; font-size:10px; }
  .board-section { order:2; padding:10px 0 8px; width:100%; }
  .panel-right {
    position:static; transform:none; width:100%; max-height:none;
    border-radius:0; flex-direction:row; flex-wrap:wrap;
    align-items:flex-start; gap:8px; padding:10px 12px;
    border:none; border-top:1px solid var(--border-hi);
    backdrop-filter:none; background:var(--surface); order:3;
  }
  .panel-right .eval-card  { flex:1; min-width:130px; }
  .panel-right .stats-grid { min-width:140px; flex-shrink:0; }
  .panel-right .pv-card    { display:none; }
  .panel-right .moves-card { flex:1; min-width:130px; }
  .panel-right .moves-list { max-height:80px; }
  .panel-right .clock-card { flex-shrink:0; min-width:130px; }
  .timer-val { font-size:13px; }
  .timer-name { font-size:8px; }
  .timer-avatar { font-size:11px; }
  .victory-card { padding:32px 28px; }
  .victory-title { font-size:24px; }
  .victory-crown { font-size:48px; }
}
@media (max-width:380px) {
  :root { --board-size:98vw; }
  .panel-left .settings-card { display:none; }
}

/* ── ANALYZE BUTTON ───────────────────────────────────── */
.btn-analyze {
  background: linear-gradient(135deg,#1a3a6e 0%,#2a5aae 50%,#3a7ade 100%);
  color:#e0ecff;
  box-shadow:0 4px 20px rgba(58,122,222,0.32),0 0 0 1px rgba(74,143,217,0.22);
  border:none;
}
.btn-analyze:hover {
  background:linear-gradient(135deg,#2a4a8e 0%,#3a6abe 50%,#4a8aee 100%);
  box-shadow:0 6px 28px rgba(58,122,222,0.48),0 0 0 1px rgba(74,143,217,0.34);
  transform:translateY(-1px);
}
.btn-analyze:disabled { opacity:0.5; cursor:not-allowed; transform:none; }

/* ── REVIEW PANEL ─────────────────────────────────────── */
.review-panel {
  position:absolute;
  bottom: calc(50% - var(--board-size)/2 - 48px);
  left:50%;
  transform:translateX(-50%);
  z-index:50;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  pointer-events:all;
}
.review-nav {
  display:flex;
  align-items:center;
  gap:8px;
  background:rgba(8,12,24,0.92);
  border:1px solid var(--border-hi);
  border-radius:12px;
  padding:8px 14px;
  backdrop-filter:blur(20px);
  box-shadow:0 8px 32px rgba(0,0,0,0.7);
}
.review-nav-btn {
  width:36px; height:36px; padding:0;
  border-radius:8px; font-size:14px;
}
.review-move-num {
  font-family:'JetBrains Mono',monospace;
  font-size:11px; color:var(--text-dim);
  min-width:90px; text-align:center;
}
.review-badge {
  font-family:'JetBrains Mono',monospace;
  font-size:12px; font-weight:700;
  padding:4px 12px;
  border-radius:8px;
  letter-spacing:1px;
  min-height:24px;
  text-align:center;
}
.badge-brilliant { background:rgba(100,200,255,0.18); color:#64c8ff; border:1px solid rgba(100,200,255,0.3); }
.badge-great     { background:rgba(100,255,160,0.18); color:#64ffa0; border:1px solid rgba(100,255,160,0.3); }
.badge-best      { background:rgba(201,168,76,0.18);  color:var(--accent); border:1px solid rgba(201,168,76,0.3); }
.badge-inaccuracy{ background:rgba(255,200,80,0.18);  color:#ffc850; border:1px solid rgba(255,200,80,0.3); }
.badge-mistake   { background:rgba(255,140,60,0.18);  color:#ff8c3c; border:1px solid rgba(255,140,60,0.3); }
.badge-blunder   { background:rgba(224,82,82,0.18);   color:var(--danger); border:1px solid rgba(224,82,82,0.3); }

/* ── MOVE CLASSIFICATION COLORS ───────────────────────── */
.move-brilliant { color:#64c8ff !important; }
.move-great     { color:#64ffa0 !important; }
.move-best      { color:var(--accent) !important; }
.move-inaccuracy{ color:#ffc850 !important; }
.move-mistake   { color:#ff8c3c !important; }
.move-blunder   { color:var(--danger) !important; }
.move-badge { font-size:8px; margin-left:2px; opacity:0.85; }

/* ── ANALYSIS PANEL ───────────────────────────────────── */
.analysis-panel {
  background:rgba(255,255,255,0.026);
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  padding:9px 10px;
  flex-shrink:0;
  font-size:11px;
}
.analysis-opening {
  font-family:'Cinzel',serif;
  font-size:9px; color:var(--accent);
  letter-spacing:0.8px;
  margin-bottom:8px;
  padding-bottom:6px;
  border-bottom:1px solid var(--border);
}
.analysis-accuracy {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:6px;
  margin-bottom:8px;
}
.acc-block { text-align:center; }
.acc-val {
  font-family:'JetBrains Mono',monospace;
  font-size:16px; font-weight:700;
  color:var(--accent); margin-bottom:3px;
}
.acc-bar-wrap {
  height:3px; background:rgba(0,0,0,0.4);
  border-radius:2px; overflow:hidden; margin-bottom:3px;
}
.acc-bar {
  height:100%;
  background:linear-gradient(90deg,#b8891e,#e8c060);
  transition:width 0.6s ease;
}
.acc-lbl { font-size:7px; color:var(--text-muted); letter-spacing:0.8px; text-transform:uppercase; }
.analysis-table { font-size:9px; }
.at-header {
  display:grid; grid-template-columns:1fr auto auto;
  gap:4px; padding:3px 0;
  color:var(--text-muted); font-size:7.5px;
  letter-spacing:0.8px; text-transform:uppercase;
  border-bottom:1px solid var(--border);
  margin-bottom:2px;
}
.at-row {
  display:grid; grid-template-columns:1fr auto auto;
  gap:4px; padding:2px 0;
  align-items:center;
}
.at-row span:nth-child(2), .at-row span:nth-child(3) {
  font-family:'JetBrains Mono',monospace;
  font-size:10px; font-weight:700;
  text-align:center; min-width:18px;
}
.at-brilliant span:first-child { color:#64c8ff; }
.at-great     span:first-child { color:#64ffa0; }
.at-best      span:first-child { color:var(--accent); }
.at-inaccuracy span:first-child{ color:#ffc850; }
.at-mistake   span:first-child { color:#ff8c3c; }
.at-blunder   span:first-child { color:var(--danger); }

/* ── MOBILE REVIEW ────────────────────────────────────── */
@media (max-width:600px) {
  .review-panel { bottom:auto; top:70px; }
  .panel-right .analysis-panel { flex:1; min-width:100%; }
}