/* ChessLadder — Midnight Coral theme */
:root {
  --bg:           #161a2e;   /* deep midnight navy */
  --bg-2:         #1f2440;
  --bg-3:         #2b3157;
  --line:         #3a4170;
  --text:         #eef0ff;
  --muted:        #8e95b8;
  --accent:       #ff7a59;   /* coral */
  --accent-dark:  #e65a3a;
  --gold:         #ffd166;
  --red:          #e0455e;
  --teal:         #4fd1c5;   /* secondary accent */
  --light:        #f3dab0;   /* warm maple board light */
  --dark:         #a06a3c;   /* rich walnut board dark */
  --light-2:      #ffe9c2;
  --dark-2:       #c08350;
  --hl:           rgba(255,225,80,0.85);
  --legal:        rgba(0,0,0,0.25);
  --last-light:   #f7eb6a;   /* solid yellow on light squares */
  --last-dark:    #d4c138;   /* mustard yellow on dark squares */
  --drop:         rgba(79,209,197,0.55);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255,122,89,0.10), transparent 60%),
    radial-gradient(1000px 500px at 110% 10%, rgba(79,209,197,0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout ---------- */
header.topbar {
  background: var(--bg-2);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
header.topbar .brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
}
header.topbar .brand .pawn {
  color: var(--accent);
  text-shadow: 0 0 18px rgba(255,122,89,0.55);
}
header.topbar .brand .sub {
  color: var(--teal);
  font-weight: 500;
  font-size: 14px;
  margin-left: 6px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
header.topbar .user { display: flex; gap: 14px; align-items: center; font-size: 14px; }
header.topbar .user .rating { font-weight: 700; color: var(--gold); }

main {
  padding: 28px;
  max-width: 1200px;
  margin: 0 auto;
}

h1, h2, h3 { margin: 0 0 12px 0; }
h1 { font-size: 28px; }
h2 { font-size: 20px; color: var(--accent); }
h3 { font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
  box-shadow: 0 2px 0 rgba(0,0,0,0.25), 0 0 0 1px rgba(255,255,255,0.04) inset;
}
.btn:hover    { filter: brightness(1.07); }
.btn:active   { transform: translateY(1px); }
.btn.ghost    { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--bg-3); }
.btn.danger   { background: var(--red); }
.btn.danger:hover { background: #a82e2e; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards & grids ---------- */
.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
}
.grid {
  display: grid;
  gap: 16px;
}
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 800px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
}

.mode-card {
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
}
.mode-card::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(255,122,89,0.10), transparent 60%);
  pointer-events: none;
}
.mode-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.mode-card .icon { font-size: 40px; margin-bottom: 8px; }

/* ---------- Auth ---------- */
.auth-wrap {
  max-width: 380px; margin: 80px auto;
}
.auth-wrap input {
  width: 100%; padding: 10px;
  background: var(--bg-3); border: 1px solid var(--line);
  color: var(--text); border-radius: 6px;
  margin-bottom: 10px; font-size: 15px;
}
.auth-wrap .tab-row { display: flex; gap: 8px; margin-bottom: 16px; }
.auth-wrap .tab-row .btn { flex: 1; }
.auth-wrap .tab-row .btn.ghost.active { background: var(--bg-3); border-color: var(--accent); color: var(--accent); }
.error-msg { color: var(--red); font-size: 13px; min-height: 18px; margin-bottom: 8px; }

/* ---------- Profile ---------- */
.stats-row { display: flex; gap: 24px; flex-wrap: wrap; }
.stat { background: var(--bg-3); padding: 12px 18px; border-radius: 8px; min-width: 110px; }
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.stat .value { font-size: 22px; font-weight: 800; }
.progress {
  margin: 14px 0 4px 0;
  background: var(--bg-3);
  height: 14px; border-radius: 7px;
  overflow: hidden;
}
.progress > div {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--gold));
  width: 0%;
}
.history-table { width: 100%; border-collapse: collapse; }
.history-table th, .history-table td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.history-table th { color: var(--muted); font-weight: 600; }
.tag-w { color: var(--accent); font-weight: 700; }
.tag-l { color: var(--red);    font-weight: 700; }
.tag-d { color: var(--gold);   font-weight: 700; }

/* ---------- Game page ---------- */
.game-wrap {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 320px;
  gap: 20px;
  align-items: flex-start;
}
@media (max-width: 900px) {
  .game-wrap { grid-template-columns: 1fr; }
}
.board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.board-col .player-bar { width: 100%; max-width: var(--board-size, 100%); }

.player-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--bg-2); border: 1px solid var(--line);
  padding: 8px 14px; border-radius: 8px;
  margin: 6px 0;
}
.player-bar .name { font-weight: 700; }
.player-bar .meta { color: var(--muted); font-size: 13px; }
.player-bar .flag { font-size: 22px; margin-right: 6px; }

/* Board — dynamically sized to viewport */
.board {
  width: min(78vh, 92vw, 720px);
  height: min(78vh, 92vw, 720px);
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows:    repeat(8, 1fr);
  border: 14px solid #3a2410;
  border-radius: 6px;
  box-shadow:
    0 0 0 1px #6e4a22,
    0 18px 40px rgba(0,0,0,0.55),
    inset 0 0 0 2px rgba(0,0,0,0.35);
  user-select: none;
  overflow: hidden;
  touch-action: none;
  position: relative;
}
.sq {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  line-height: 1;
}
.sq.light { background: #eed7b5; }
.sq.dark  { background: #b58863; }

/* Pieces — cburnett SVG set (the same set Lichess uses) */
.sq .piece {
  pointer-events: none;
  position: relative;
  z-index: 2;
  display: block;
  width: 92%;
  height: 92%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform 0.08s;
  filter: drop-shadow(0 3px 3px rgba(0,0,0,0.45));
}
.sq .piece.dragging { opacity: 0; }

.sq.selected   { box-shadow: inset 0 0 0 5px rgba(255,225,80,0.85); }
/* Last-move highlight — SOLID yellow on both square colors */
.sq.last.light { background: #f6f669 !important; }
.sq.last.dark  { background: #cdcc3e !important; }
.sq.check      { box-shadow: inset 0 0 0 5px var(--red); animation: checkPulse 0.8s ease-in-out infinite alternate; }
.sq.drag-source{ box-shadow: inset 0 0 0 4px rgba(255,225,80,0.85); }
.sq.drag-target{ box-shadow: inset 0 0 0 5px var(--drop); }

@keyframes checkPulse {
  from { box-shadow: inset 0 0 0 5px var(--red); }
  to   { box-shadow: inset 0 0 0 8px rgba(224,69,94,0.6); }
}

/* Move dots */
.sq .dot {
  position: absolute;
  width: 30%; height: 30%;
  background: radial-gradient(circle at 35% 35%, rgba(0,0,0,0.48), rgba(0,0,0,0.30) 60%, rgba(0,0,0,0.20));
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
}
.sq .ring {
  position: absolute; inset: 5%;
  border: 6px solid rgba(0,0,0,0.35);
  border-radius: 50%;
  pointer-events: none;
  z-index: 1;
  box-sizing: border-box;
}

/* Coords */
.sq .coord {
  position: absolute;
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
  pointer-events: none;
  font-family: "Segoe UI", sans-serif;
  z-index: 3;
}
.sq .coord.file  { right: 4px; bottom: 2px; }
.sq .coord.rank  { left: 4px;  top: 2px; }
.sq.light .coord { color: #b58863; }
.sq.dark  .coord { color: #eed7b5; }

/* Floating drag ghost (cburnett SVG image) */
.drag-ghost {
  position: fixed;
  z-index: 9500;
  pointer-events: none;
  display: block;
  object-fit: contain;
  transform: scale(1.08);
  filter: drop-shadow(0 8px 12px rgba(0,0,0,0.6));
  user-select: none;
  -webkit-user-drag: none;
}

/* ===============================================================
   Side panel — glassy, rounded "game UI" look
   =============================================================== */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* A reusable rounded panel with a soft top-light gradient + inner glow */
.side-panel .panel {
  position: relative;
  border-radius: 16px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(255,255,255,0.06), transparent 60%),
    linear-gradient(180deg, var(--bg-2), var(--bg-2) 60%, color-mix(in srgb, var(--bg) 70%, var(--bg-2)));
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 -1px 0 rgba(0,0,0,0.25) inset,
    0 8px 22px rgba(0,0,0,0.35);
}

.side-panel .panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.side-panel .panel-head h3 {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}
.side-panel .panel-head .ico { font-size: 14px; opacity: 0.9; }
.side-panel .panel-head .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px rgba(79,209,197,0.18), 0 0 10px rgba(79,209,197,0.7);
  animation: pulseDot 2s infinite ease-in-out;
}
@keyframes pulseDot {
  0%,100% { transform: scale(1);   opacity: 1; }
  50%     { transform: scale(1.2); opacity: 0.75; }
}

/* Status dot color variants */
.status-panel.s-mine  .panel-head .dot { background: var(--teal);   box-shadow: 0 0 0 3px rgba(79,209,197,0.18), 0 0 10px rgba(79,209,197,0.7); }
.status-panel.s-opp   .panel-head .dot { background: var(--gold);   box-shadow: 0 0 0 3px rgba(255,209,102,0.18), 0 0 10px rgba(255,209,102,0.7); }
.status-panel.s-check .panel-head .dot { background: var(--accent); box-shadow: 0 0 0 3px rgba(255,122,89,0.20), 0 0 10px rgba(255,122,89,0.8); }
.status-panel.s-end   .panel-head .dot { background: var(--red);    box-shadow: 0 0 0 3px rgba(224,69,94,0.20), 0 0 10px rgba(224,69,94,0.7); animation: none; }

/* Status */
.status-panel .status-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

/* Move history */
.history-panel { padding: 12px 12px 14px; }
.move-list {
  background: rgba(0,0,0,0.22);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 8px 10px;
  max-height: 280px;
  min-height: 80px;
  overflow-y: auto;
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 13.5px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.move-list::-webkit-scrollbar         { width: 8px; }
.move-list::-webkit-scrollbar-thumb   { background: var(--line); border-radius: 8px; }
.move-list::-webkit-scrollbar-track   { background: transparent; }

.move-list .row {
  display: grid;
  grid-template-columns: 30px 1fr 1fr;
  gap: 6px;
  padding: 3px 4px;
  border-radius: 6px;
}
.move-list .row:nth-child(odd)   { background: rgba(255,255,255,0.025); }
.move-list .row .n               { color: var(--muted); }
.move-list .row .mv              { color: var(--text); }
.move-list .row .mv.current      { background: var(--bg-3); border-radius: 4px; padding: 0 4px; }
.move-list:empty::before {
  content: "No moves yet.";
  color: var(--muted);
  font-style: italic;
  font-size: 13px;
}

/* Move input */
.input-panel { padding: 10px; }
.move-input { display: flex; gap: 8px; align-items: stretch; }
.move-input input {
  flex: 1;
  padding: 11px 14px;
  background: rgba(0,0,0,0.30);
  border: 1px solid rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 12px;
  font-size: 14px;
  font-family: "JetBrains Mono", "Consolas", monospace;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.move-input input::placeholder { color: var(--muted); }
.move-input input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(0,0,0,0.36);
  box-shadow: 0 0 0 3px rgba(255,122,89,0.18);
}
.move-input .move-send {
  padding: 0 18px;
  border-radius: 12px;
  font-size: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
  color: #1a0b0a;
  border: 1px solid color-mix(in srgb, var(--accent) 60%, #000);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.30) inset,
    0 -2px 0 rgba(0,0,0,0.30) inset,
    0 4px 12px rgba(255,122,89,0.35);
  transition: transform .08s ease, box-shadow .15s ease, filter .15s ease;
}
.move-input .move-send:hover  { filter: brightness(1.08); }
.move-input .move-send:active { transform: translateY(1px); box-shadow: 0 1px 0 rgba(255,255,255,0.20) inset, 0 -1px 0 rgba(0,0,0,0.30) inset, 0 2px 6px rgba(255,122,89,0.30); }

/* Actions */
.actions-panel { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.action-row { display: flex; flex-wrap: wrap; gap: 8px; }
.action-row .icon-btn {
  flex: 1 1 0;
  min-width: 0;
  padding: 12px 0;
  font-size: 22px;
  background: linear-gradient(180deg, var(--bg-3), color-mix(in srgb, var(--bg-3) 70%, var(--bg)));
  border: 1px solid rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 14px;
  cursor: pointer;
  position: relative;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 -2px 0 rgba(0,0,0,0.25) inset,
    0 3px 8px rgba(0,0,0,0.35);
  transition: transform .08s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.action-row .icon-btn:hover {
  color: var(--accent);
  border-color: rgba(255,122,89,0.55);
  transform: translateY(-2px);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.10) inset,
    0 -2px 0 rgba(0,0,0,0.25) inset,
    0 8px 16px rgba(255,122,89,0.25);
}
.action-row .icon-btn:active {
  transform: translateY(0);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.05) inset,
    0 -1px 0 rgba(0,0,0,0.25) inset,
    0 2px 4px rgba(0,0,0,0.3);
}
.action-row .icon-btn.danger:hover {
  color: var(--red);
  border-color: rgba(224,69,94,0.6);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 -2px 0 rgba(0,0,0,0.25) inset,
    0 8px 16px rgba(224,69,94,0.25);
}

/* Lobby back button — full width pill */
.icon-btn.lobby-back {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, var(--bg-3), color-mix(in srgb, var(--bg-3) 70%, var(--bg)));
  border: 1px solid rgba(255,255,255,0.05);
  color: var(--text);
  border-radius: 14px;
  cursor: pointer;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.08) inset,
    0 -2px 0 rgba(0,0,0,0.25) inset,
    0 3px 8px rgba(0,0,0,0.35);
  transition: transform .08s ease, color .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.icon-btn.lobby-back:hover {
  color: var(--gold);
  border-color: rgba(255,209,102,0.5);
  transform: translateY(-2px);
}
.icon-btn.lobby-back span { font-size: 14px; }

.toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-2); border: 1px solid var(--accent);
  padding: 10px 18px; border-radius: 6px;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* Modal */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}
.modal {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 24px;
  width: 90%; max-width: 460px;
  text-align: center;
}
.modal h2 { margin-bottom: 12px; }
.modal .big-rating {
  font-size: 42px; font-weight: 800; color: var(--gold); margin: 8px 0;
}
.modal .delta-pos { color: var(--accent); }
.modal .delta-neg { color: var(--red); }
.modal .row-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

.hidden { display: none !important; }

/* === Added: captures, animations, promotion, confetti, thinking dots === */

/* ---------- Player bar enhancements ---------- */
.player-bar { gap: 12px; }
.player-bar .player-id { display: flex; align-items: center; gap: 8px; min-width: 0; }
.player-bar .captures {
  display: flex; align-items: center; flex: 1; min-width: 0;
  flex-wrap: wrap; gap: 1px;
  font-size: 18px; line-height: 1;
  color: #cfcfd9;
  overflow: hidden;
}
.player-bar .captures .cap {
  display: inline-flex;
  align-items: center;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.5));
}
.player-bar .captures .cap-img {
  width: 18px; height: 18px; display: block;
}
.player-bar .captures .adv {
  margin-left: 6px;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  background: rgba(0,0,0,0.25);
  padding: 1px 6px;
  border-radius: 4px;
}
.player-bar .captures.you .cap   { }
.player-bar .captures.them .cap  { }

/* ---------- Thinking dots ---------- */
.thinking-dots { display: none; gap: 3px; align-items: center; height: 18px; }
.thinking-dots.on { display: inline-flex; }
.thinking-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent);
  animation: thinkBounce 1s infinite ease-in-out;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.30s; }
@keyframes thinkBounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* ---------- Board frame & animation overlay ---------- */
.board-frame {
  position: relative;
  display: inline-block;
}
/* Light-weight celebration flashes — box-shadow only (no `filter`,
   which on some GPUs stalls compositing while Confetti is running). */
.board-frame.flash-win  { animation: frameWin  0.55s ease-out 2; }
.board-frame.flash-loss { animation: frameLoss 0.55s ease-out 1; }
.board-frame.flash-draw { animation: frameDraw 0.55s ease-out 1; }
@keyframes frameWin {
  0%   { box-shadow: 0 0 0   0   rgba(79,209,197,0); }
  50%  { box-shadow: 0 0 40px 8px rgba(79,209,197,0.85); }
  100% { box-shadow: 0 0 0   0   rgba(79,209,197,0); }
}
@keyframes frameLoss {
  0%   { box-shadow: 0 0 0   0   rgba(224,69,94,0); }
  50%  { box-shadow: 0 0 40px 8px rgba(224,69,94,0.85); }
  100% { box-shadow: 0 0 0   0   rgba(224,69,94,0); }
}
@keyframes frameDraw {
  0%   { box-shadow: 0 0 0   0   rgba(255,209,102,0); }
  50%  { box-shadow: 0 0 30px 6px rgba(255,209,102,0.80); }
  100% { box-shadow: 0 0 0   0   rgba(255,209,102,0); }
}

/* Hover preview on legal squares */
.sq:not(.selected):hover .piece { transform: translateY(-2px); }

/* Sliding piece animation overlay (cburnett SVG) */
.anim-piece {
  position: absolute;
  z-index: 50;
  display: block;
  object-fit: contain;
  pointer-events: none;
  transition: transform 220ms cubic-bezier(0.4, 0.1, 0.2, 1);
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.5));
}

/* Right-click "manual" highlight */
.sq.user-mark { box-shadow: inset 0 0 0 5px rgba(255,80,80,0.85); }

/* Move-quality glyphs in history */
.move-list .row .mv .mark {
  font-weight: 800;
  margin-left: 2px;
}
.move-list .row .mv .mark.best     { color: #4fd1c5; }   /* !! */
.move-list .row .mv .mark.good     { color: #81b64c; }   /* !  */
.move-list .row .mv .mark.inacc    { color: var(--gold); }
.move-list .row .mv .mark.mistake  { color: #ff9655; }
.move-list .row .mv .mark.blunder  { color: var(--red); }

/* ---------- Promotion picker ---------- */
.promo-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 10px;
}
.promo-row .promo-btn {
  background: var(--bg-3);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 10px 0;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.08s, border-color 0.15s, background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.promo-row .promo-btn .promo-img {
  width: 64px;
  height: 64px;
  display: block;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.45));
}
.promo-row .promo-btn:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  background: var(--bg-2);
}

/* ---------- Confetti ---------- */
#confetti {
  position: fixed; inset: 0;
  width: 100vw; height: 100vh;
  pointer-events: none;
  /* must be BELOW the result modal so the modal is always visible & clickable */
  z-index: 8500;
}

/* ---------- Toast variants ---------- */
.toast.success { border-color: var(--teal); color: var(--teal); }
.toast.warn    { border-color: var(--gold); color: var(--gold); }
.toast.error   { border-color: var(--red);  color: var(--red);  }

/* ====================================================================
   Profile hero (lobby header)
   ==================================================================== */
.profile-hero {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 22px;
  padding: 22px 26px;
  background:
    linear-gradient(135deg, rgba(255,122,89,0.12), rgba(79,209,197,0.06) 55%, rgba(255,209,102,0.05)),
    var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.30);
}
@media (max-width: 700px) {
  .profile-hero {
    grid-template-columns: auto 1fr;
    grid-template-areas:
      "avatar main"
      "rating rating";
    gap: 16px;
    padding: 18px;
  }
  .profile-hero .hero-avatar { grid-area: avatar; }
  .profile-hero .hero-main   { grid-area: main; }
  .profile-hero .hero-rating { grid-area: rating; justify-self: stretch; text-align: center; }
}

.hero-avatar {
  position: relative;
  appearance: none;
  cursor: pointer;
  width: 96px; height: 96px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: linear-gradient(160deg, var(--bg-3), var(--bg));
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4), 0 0 0 4px rgba(255,122,89,0.10);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.hero-avatar:hover {
  transform: scale(1.04);
  border-color: var(--gold);
  box-shadow: 0 6px 22px rgba(255,209,102,0.35), 0 0 0 4px rgba(255,209,102,0.15);
}
.hero-avatar:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.hero-avatar-inner {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%;
  font-size: 56px;
  line-height: 1;
  color: var(--text);
}
.hero-avatar-inner img {
  width: 86%; height: 86%; object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.5));
  pointer-events: none;
}
.hero-avatar-edit {
  position: absolute;
  right: 2px; bottom: 2px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.4);
  border: 2px solid var(--bg-2);
}

.hero-main { min-width: 0; }
.hero-name-row {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.hero-name { font-size: 26px; margin: 0; }
.hero-level {
  background: var(--bg-3);
  color: var(--gold);
  font-weight: 700;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  letter-spacing: 0.5px;
}
.hero-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 10px;
}
.hero-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
}
.hero-chip .chip-label { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; }
.hero-chip .chip-value { font-weight: 700; }
.hero-chip.win  .chip-value { color: var(--teal); }
.hero-chip.loss .chip-value { color: var(--red); }
.hero-chip.draw .chip-value { color: var(--gold); }
.hero-chip.streak .chip-value { color: var(--accent); }

.hero-progress { margin-top: 4px; }
.hero-progress-text { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

.hero-rating {
  text-align: center;
  padding: 10px 18px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-width: 110px;
}
.hero-rating-num {
  font-size: 36px;
  font-weight: 800;
  color: var(--gold);
  line-height: 1;
}
.hero-rating-label {
  font-size: 11px;
  letter-spacing: 1.5px;
  color: var(--muted);
  margin-top: 4px;
}

/* ====================================================================
   Avatar picker
   ==================================================================== */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  margin: 14px 0;
}
@media (max-width: 520px) {
  .avatar-grid { grid-template-columns: repeat(4, 1fr); }
}
.avatar-opt {
  appearance: none;
  cursor: pointer;
  aspect-ratio: 1 / 1;
  background: var(--bg-3);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: transform .12s ease, border-color .12s ease, background .12s ease;
}
.avatar-opt:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.avatar-opt.selected {
  border-color: var(--gold);
  background: linear-gradient(160deg, rgba(255,209,102,0.18), var(--bg-3));
  box-shadow: 0 0 0 2px rgba(255,209,102,0.25);
}
.avatar-opt img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.5));
  pointer-events: none;
}

/* ====================================================================
   Lobby action buttons (replaces the old 4-card grid)
   ==================================================================== */
.lobby-actions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 18px;
}
@media (min-width: 1100px) {
  .lobby-actions { grid-template-columns: repeat(4, 1fr); }
}
.lobby-btn {
  appearance: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 18px 18px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(255,122,89,0.10), rgba(79,209,197,0.06) 60%, rgba(255,209,102,0.05)),
    var(--bg-2);
  color: var(--text);
  font: inherit;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.lobby-btn:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(255,122,89,0.25), 0 2px 4px rgba(0,0,0,0.3);
  background:
    linear-gradient(135deg, rgba(255,122,89,0.20), rgba(79,209,197,0.10) 60%, rgba(255,209,102,0.08)),
    var(--bg-2);
}
.lobby-btn:active { transform: translateY(-1px); }
.lobby-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.lobby-btn .lb-icon {
  font-size: 30px; line-height: 1;
  flex: 0 0 auto;
  width: 52px; height: 52px;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  border: 1px solid var(--line);
}
.lobby-btn .lb-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.lobby-btn .lb-title { color: var(--accent); font-weight: 800; font-size: 16px; }
.lobby-btn .lb-sub   { color: var(--muted); font-size: 13px; line-height: 1.35; }
.lobby-btn .lb-arrow {
  color: var(--muted);
  font-size: 28px;
  font-weight: 800;
  margin-left: 4px;
  transition: transform .15s ease, color .15s ease;
}
.lobby-btn:hover .lb-arrow { color: var(--accent); transform: translateX(4px); }

/* ====================================================================
   Bot Ladder (vertical climb)
   ==================================================================== */
.ladder-progress {
  margin: 12px 0 18px;
  color: var(--muted);
  font-size: 14px;
}
.ladder-progress b { color: var(--text); }

.bot-ladder {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.rung {
  position: relative;
  display: grid;
  grid-template-columns: 48px 56px 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.rung .rung-rank {
  font-weight: 800;
  font-size: 18px;
  color: var(--muted);
  text-align: center;
}
.rung .rung-avatar {
  font-size: 32px;
  width: 48px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
}
.rung .rung-info { min-width: 0; }
.rung .rung-name {
  font-weight: 800;
  color: var(--text);
  font-size: 15px;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.rung .rung-rating {
  color: var(--gold);
  font-weight: 800;
}
.rung .rung-style {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rung .rung-bio {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rung .rung-action {
  display: flex; align-items: center; gap: 10px;
}
.rung .rung-status {
  font-size: 18px;
  width: 32px; text-align: center;
}
.rung .rung-btn {
  appearance: none;
  cursor: pointer;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #18121e;
  font-weight: 800;
  font-size: 13px;
  transition: background .12s ease, transform .12s ease, box-shadow .12s ease;
}
.rung .rung-btn:hover {
  background: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(255,122,89,0.35);
  transform: translateY(-1px);
}

/* States */
.rung.defeated {
  border-color: rgba(129,182,76,0.45);
  background:
    linear-gradient(90deg, rgba(129,182,76,0.10), transparent 60%),
    var(--bg-2);
  opacity: 0.92;
}
.rung.defeated .rung-status { color: #81b64c; }
.rung.defeated .rung-btn {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}
.rung.defeated .rung-btn:hover {
  border-color: var(--accent);
  background: rgba(255,122,89,0.10);
  box-shadow: none;
}

.rung.current {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(255,122,89,0.25), 0 6px 18px rgba(255,122,89,0.20);
  background:
    linear-gradient(90deg, rgba(255,122,89,0.16), transparent 70%),
    var(--bg-2);
}
.rung.current .rung-status { color: var(--accent); }
.rung.current .rung-name::after {
  content: "NEXT CHALLENGE";
  font-size: 10px;
  font-weight: 800;
  color: #18121e;
  background: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}

.rung.locked {
  opacity: 0.55;
  background: var(--bg-2);
  filter: grayscale(0.4);
}
.rung.locked .rung-status { color: var(--muted); }
.rung.locked .rung-btn {
  cursor: not-allowed;
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.rung.locked .rung-btn:hover {
  background: transparent;
  box-shadow: none;
  transform: none;
}

@media (max-width: 640px) {
  .rung { grid-template-columns: 36px 44px 1fr auto; gap: 8px; padding: 10px; }
  .rung .rung-avatar { font-size: 26px; width: 40px; height: 40px; }
  .rung .rung-bio { display: none; }
}

/* ====================================================================
   Pre-game color picker modal
   ==================================================================== */
.color-modal { max-width: 560px; padding: 28px; }
.color-modal .color-sub {
  margin: -6px 0 18px;
  color: var(--muted);
  font-size: 14px;
}
.color-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 520px) {
  .color-row { grid-template-columns: 1fr; }
}
.color-btn {
  appearance: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 12px 18px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  font: inherit;
  transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.color-btn .cp-piece {
  width: 64px; height: 64px;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 4px 5px rgba(0,0,0,0.4));
}
.color-btn .cp-piece.cp-random {
  width: auto; height: auto;
  font-size: 56px; line-height: 1;
  font-family: "Arial Unicode MS","Segoe UI Symbol","DejaVu Sans",sans-serif;
  color: var(--gold);
  filter: none;
}
.color-btn .cp-label { font-weight: 800; font-size: 15px; }
.color-btn .cp-sub   { color: var(--muted); font-size: 12px; }

.color-btn.white .cp-piece,
.color-btn.black .cp-piece,
.color-btn.random .cp-piece { /* legacy filter rules cleared above */ }

.color-btn:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: 0 10px 24px rgba(255,122,89,0.22);
}
.color-btn.white:hover  { border-color: #ffffff; box-shadow: 0 10px 24px rgba(255,255,255,0.18); }
.color-btn.black:hover  { border-color: #4fd1c5; box-shadow: 0 10px 24px rgba(0,0,0,0.50); }
.color-btn.random:hover { border-color: var(--gold); box-shadow: 0 10px 24px rgba(255,209,102,0.25); }
.color-btn:active { transform: translateY(-1px); }
.color-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ====================================================================
   Post-game analysis breakdown (Stockfish)
   ==================================================================== */
.cls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 4px;
}
.cls {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  color: var(--text);
  letter-spacing: 0.2px;
}
.cls.best    { color: #1e2a18; background: #b6e388; border-color: #8fc861; }
.cls.good    { color: #102a26; background: #7fe2d4; border-color: #4fd1c5; }
.cls.inacc   { color: #2a2310; background: #ffd166; border-color: #d9ad4d; }
.cls.mistake { color: #2a1610; background: #ffa477; border-color: #e98359; }
.cls.blunder { color: #fff;    background: #c83a52; border-color: #a32a40; }
.engine-tag {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  vertical-align: middle;
}

/* ====================================================================
   Background falling-pieces canvas (decorative, never interactive).
   Sits BEHIND all page content (negative z-index) so the chess board
   and lobby cards never show pieces bleeding through them.
   ==================================================================== */
#bg-pieces {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: -1;
}
body { position: relative; }

/* ====================================================================
   Game Review screen
   ==================================================================== */
.history-row { cursor: pointer; transition: background 0.15s; }
.history-row:hover { background: rgba(255,122,89,0.08); }

.review-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  padding: 18px 22px;
  max-width: 1280px;
  margin: 0 auto;
}
@media (max-width: 900px) {
  .review-wrap { grid-template-columns: 1fr; }
}
.review-board-col { display: flex; flex-direction: column; gap: 14px; }

.review-header {
  display: flex; align-items: center; gap: 14px;
}
.review-title {
  display: flex; flex-direction: column; line-height: 1.25;
}
.review-title > :first-child { font-size: 20px; font-weight: 700; }
.review-sub { color: var(--muted); font-size: 13px; }

.review-board-frame { position: relative; }

.review-eval-bar {
  position: relative;
  width: 100%;
  height: 16px;
  border-radius: 10px;
  background: #1a1d2e;
  border: 1px solid var(--line);
  overflow: hidden;
}
.review-eval-fill {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%; height: 50%;
  background: linear-gradient(180deg, #f4f1e6 0%, #d8d0b8 100%);
  transition: height 0.25s ease;
}
.review-eval-label {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  font-size: 11px; font-weight: 700;
  color: #1a1d2e;
  background: rgba(255,255,255,0.85);
  padding: 1px 6px; border-radius: 4px;
  pointer-events: none;
}

.review-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.review-controls .icon-btn { width: 44px; height: 40px; font-size: 18px; }
.review-controls .icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.review-ply {
  min-width: 90px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.5px;
}

.review-summary {
  padding: 10px 0;
  display: flex; justify-content: center;
}
.rv-summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: 100%;
}
.rv-sum-cell {
  display: flex; flex-direction: column; align-items: center;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 6px;
}
.rv-sum-num { font-size: 22px; font-weight: 800; color: var(--text); }
.rv-sum-lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.rv-blunders .rv-sum-num { color: var(--red); }

.review-side .panel { padding: 12px 14px; }
.review-moves {
  max-height: 60vh;
  overflow-y: auto;
  font-variant-numeric: tabular-nums;
}
.rv-row {
  display: grid;
  grid-template-columns: 36px 1fr 1fr;
  gap: 6px;
  padding: 3px 2px;
  align-items: center;
}
.rv-row:nth-child(even) { background: rgba(255,255,255,0.02); }
.rv-num { color: var(--muted); font-size: 13px; }
.rv-move {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.12s;
}
.rv-move:hover { background: rgba(255,122,89,0.18); }
.rv-move.active {
  background: var(--accent);
  color: #1a1d2e;
}
.rv-move.empty { cursor: default; }
.rv-move.empty:hover { background: transparent; }

.rv-blunder    { color: #ff6b6b; }
.rv-mistake    { color: #ffae3a; }
.rv-inaccuracy { color: #f1d860; }
.rv-best       { color: #81b64c; }

.rv-tag {
  font-size: 10px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 3px;
  background: rgba(0,0,0,0.35);
}
.rv-tag.blunder    { background: #c0392b; color: #fff; }
.rv-tag.mistake    { background: #e67e22; color: #fff; }
.rv-tag.inaccuracy { background: #b8a020; color: #fff; }
.rv-tag.best       { background: #81b64c; color: #fff; }

/* ====================================================================
   Leaderboard
   ==================================================================== */
.lb-table {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
}
.lb-head, .lb-row {
  display: grid;
  grid-template-columns: 60px 1fr 130px 200px 80px;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
}
.lb-head {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding-bottom: 6px;
}
.lb-row {
  background: var(--bg-2);
  border: 1px solid var(--line);
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.lb-row:hover {
  transform: translateX(2px);
  border-color: rgba(255,122,89,0.35);
}
.lb-row.lb-me {
  border-color: var(--accent);
  background: linear-gradient(90deg, rgba(255,122,89,0.12), transparent 70%), var(--bg-2);
}
.lb-row.lb-podium-1 {
  border-color: rgba(255,215,0,0.55);
  background: linear-gradient(90deg, rgba(255,215,0,0.10), transparent 70%), var(--bg-2);
}
.lb-row.lb-podium-2 {
  border-color: rgba(192,192,192,0.45);
  background: linear-gradient(90deg, rgba(192,192,192,0.08), transparent 70%), var(--bg-2);
}
.lb-row.lb-podium-3 {
  border-color: rgba(205,127,50,0.45);
  background: linear-gradient(90deg, rgba(205,127,50,0.10), transparent 70%), var(--bg-2);
}
.lb-rank {
  font-size: 20px;
  font-weight: 800;
  text-align: center;
  color: var(--muted);
}
.lb-row.lb-podium-1 .lb-rank,
.lb-row.lb-podium-2 .lb-rank,
.lb-row.lb-podium-3 .lb-rank { font-size: 24px; }
.lb-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-you {
  background: var(--accent);
  color: #1a1d2e;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}
.lb-rating {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.lb-rating b {
  font-size: 18px;
  color: var(--gold);
}
.lb-peak {
  font-size: 11px;
  color: var(--muted);
}
.lb-stats {
  display: flex;
  gap: 10px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.lb-stats .lb-w   { color: var(--accent); font-weight: 700; }
.lb-stats .lb-l   { color: var(--red);    font-weight: 700; }
.lb-stats .lb-d   { color: var(--muted); }
.lb-stats .lb-pct { color: var(--text); font-weight: 700; margin-left: auto; }
.lb-streak {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--text);
}
@media (max-width: 720px) {
  .lb-head, .lb-row { grid-template-columns: 40px 1fr 90px; }
  .lb-stats, .lb-streak, .lb-head > :nth-child(n+4) { display: none; }
}

/* ---------- Auth: password hint + add-email banner ---------- */
.auth-hint {
  font-size: 12px;
  color: var(--muted);
  margin: -4px 0 8px;
  line-height: 1.4;
}
.add-email-card {
  border: 1px solid rgba(255,170,80,0.45);
  background: linear-gradient(180deg, rgba(255,170,80,0.08), var(--bg-2));
  margin: 12px 0 16px;
  padding: 16px 18px;
  border-radius: 12px;
}
.add-email-card input {
  width: 100%;
  margin: 6px 0;
}
.add-email-card .error-msg {
  min-height: 1.2em;
  color: #ff9a7a;
  font-size: 13px;
  margin: 4px 0 8px;
}

/* ---------- Admin panel ---------- */
.admin-wrap {
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 18px;
}
.admin-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.admin-title {
  font-size: 22px;
  margin: 0;
  flex: 1;
}
.admin-header input[type="search"] {
  min-width: 260px;
  max-width: 360px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  background: var(--bg-2);
  color: var(--text, #fff);
}
.admin-list-card { padding: 0; overflow: hidden; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.admin-table thead th {
  text-align: left;
  padding: 10px 12px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.admin-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.admin-table tbody tr:hover { background: rgba(255,255,255,0.03); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
}
.badge-ok     { background: rgba(80,200,120,0.15); color: #6fd594; }
.badge-locked { background: rgba(255,90,90,0.18);  color: #ff8c8c; }
.badge-admin  { background: rgba(255,170,80,0.18); color: #ffb86b; margin-left: 4px; }

.btn-tiny { padding: 4px 10px; font-size: 12px; }
.btn.danger {
  background: linear-gradient(180deg, #c0392b, #962d22);
  color: #fff;
}
.btn.danger:hover { filter: brightness(1.1); }

/* Admin user modal */
.admin-modal {
  max-width: 760px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
}
.admin-modal h4 {
  margin: 0 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.admin-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
@media (max-width: 720px) { .admin-detail-grid { grid-template-columns: 1fr; } }

.admin-detail-section label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin: 8px 0 2px;
}
.admin-detail-section input[type="text"],
.admin-detail-section input[type="email"],
.admin-detail-section input[type="number"] {
  width: 100%;
  padding: 7px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--bg-2);
  color: var(--text, #fff);
  font-size: 13px;
}
.admin-detail-section .admin-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.admin-detail-section .admin-row label { margin-top: 4px; }
.admin-detail-section .btn { margin-top: 10px; }
.admin-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 13px !important;
  color: var(--text, #fff) !important;
  margin: 8px 0 !important;
}
.admin-meta {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  margin: 0 0 10px;
}
.admin-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 14px 0;
}

.admin-games-wrap {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
}
.admin-games {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.admin-games th, .admin-games td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  text-align: left;
}
.admin-games thead th { background: rgba(255,255,255,0.04); color: var(--muted); font-size: 11px; }

/* ---------- Hint highlight (yellow frame from/to squares) ---------- */
.sq.hint-from,
.sq.hint-to {
  position: relative;
}
.sq.hint-from::after,
.sq.hint-to::after {
  content: "";
  position: absolute;
  inset: 4%;
  border-radius: 6px;
  pointer-events: none;
  box-sizing: border-box;
  z-index: 4;
  animation: hint-pulse 1.1s ease-in-out infinite;
}
.sq.hint-from::after {
  border: 4px solid #ffd84a;
  box-shadow:
    0 0 0 2px rgba(0,0,0,0.35) inset,
    0 0 12px rgba(255,216,74,0.65);
}
.sq.hint-to::after {
  border: 4px dashed #ffd84a;
  box-shadow:
    0 0 0 2px rgba(0,0,0,0.35) inset,
    0 0 16px rgba(255,216,74,0.75);
}
@keyframes hint-pulse {
  0%, 100% { opacity: 0.95; transform: scale(1); }
  50%      { opacity: 0.65; transform: scale(0.96); }
}
