:root {
  --bg: #14161b;
  --panel: #1d2027;
  --panel2: #262a33;
  --ink: #e9e9e4;
  --muted: #969aa1;
  --accent: #e7c14a;
  --line: #313641;

  --sq-light: #e9e3d6;
  --sq-dark: #6f7d92;
  --grid: rgba(20,22,28,0.16);
  --board-void: #101218;
  --lbl-edge: #8a90a0;
  --pc-hat-w: currentColor;
  --pc-hat-b: currentColor;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -12%, #1f232c, var(--bg));
  color: var(--ink);
  font-family: system-ui, "Segoe UI", Roboto, sans-serif;
}
.app { max-width: 1180px; margin: 0 auto; padding: 18px 22px 40px; }
header h1 { font-size: 26px; font-weight: 800; letter-spacing: .3px; margin: 6px 0 18px; }
header .sub { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 10px; }

main { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; align-items: start; }

/* ---- board ---- */
.board-wrap { position: relative; }
#board {
  width: 100%; height: auto; display: block;
  background: var(--board-void); /* the void — holes and off-board space show as this */
  border-radius: 14px; padding: 0; overflow: visible;
  border: 1px solid #0d0f13;
  box-shadow: 0 20px 55px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.04);
}
.sq.lt { fill: var(--sq-light); }
.sq.dk { fill: var(--sq-dark); }
/* very mild gridlines on every square */
.sq { stroke: var(--grid); stroke-width: 0.012; }

.last { fill: rgba(231,193,74,0.20); }
.sel { fill: rgba(231,193,74,0.40); }

/* placement guide — mild outlined cell showing where a piece may be placed */
.guide { fill: rgba(231,193,74,0.10); stroke: rgba(231,193,74,0.55); stroke-width: 0.018; stroke-dasharray: 0.08 0.06; }

.target { fill: none; stroke-width: 0.03; }
.target.remove { stroke: rgba(224,72,60,0.85); }
.target.movecell { stroke: rgba(110,170,235,0.9); }
.selcell { fill: rgba(110,170,235,0.4); }

.movedot { fill: rgba(30,32,38,0.34); }
.capdot { fill: none; stroke: rgba(224,72,60,0.7); stroke-width: 0.05; }
.danger { fill: none; stroke: #e0483c; stroke-width: 0.05; }

.lbl { font-size: 0.24px; font-weight: 700; }
.lbl.edge { fill: var(--lbl-edge); opacity: .8; text-anchor: middle; }
.lbl.insq { font-size: 0.21px; opacity: .85; pointer-events: none; }
.lbl.insq.on-lt { fill: var(--sq-dark); }
.lbl.insq.on-dk { fill: var(--sq-light); }

/* ---- pieces (themed via inherited color + stroke) ---- */
/* applies to the live board and the review board alike */
#board .pc, #revBoard .pc { stroke-linejoin: round; stroke-linecap: round; stroke: var(--pc-line); stroke-width: 1.0; vector-effect: non-scaling-stroke; }
#board .pc.w, #revBoard .pc.w { color: #f4f2ea; --pc-line: #3a3f49; --pc-hat: var(--pc-hat-w); }
#board .pc.b, #revBoard .pc.b { color: #2b3038; --pc-line: #0c0e13; --pc-hat: var(--pc-hat-b); }

/* ---- panel ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.status { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.turn { font-size: 15px; font-weight: 700; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); }
.turn.white { background: #efeee7; color: #1a1a1a; }
.turn.black { background: #14151c; color: #e9e9e9; }
.badge { display: none; align-items: center; font-size: 12px; font-weight: 700; color: #1a1a1a; background: var(--accent); padding: 5px 10px; border-radius: 999px; }
.state { display: none; align-items: center; font-size: 12px; font-weight: 800; color: #fff; background: #d8453a; padding: 5px 10px; border-radius: 999px; }

.wild-group { margin-bottom: 16px; }
.wild-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 8px; }
.wild-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wild-btn[data-mode="movecell"] { grid-column: 1 / -1; }
.wild-btn { font-size: 13.5px; font-weight: 600; padding: 10px 6px; border-radius: 9px; cursor: pointer; background: var(--panel2); color: var(--ink); border: 1px solid var(--line); transition: .12s; }
.wild-btn:hover:not(:disabled) { border-color: var(--accent); transform: translateY(-1px); }
.wild-btn.active { background: var(--accent); color: #1a1a1a; border-color: var(--accent); }
.wild-btn:disabled { opacity: .38; cursor: not-allowed; }
.hint { font-size: 12.5px; color: var(--muted); min-height: 32px; margin: 10px 2px 0; line-height: 1.45; }

.log-wrap { margin-bottom: 14px; }
.log { height: 200px; overflow-y: auto; background: #15171c; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.logline { padding: 1px 0; color: var(--muted); }
.logline.white { color: #ece9dd; }
.logline.black { color: #b7c2db; }

.opp-group { margin-bottom: 14px; }
.opp-row { display: flex; gap: 8px; margin-bottom: 8px; }
.opp-row select {
  flex: 1; min-width: 0; padding: 8px 9px; border-radius: 9px; cursor: pointer;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  font-size: 13px; font-family: inherit; font-weight: 600;
}
.opp-row select:hover:not(:disabled) { border-color: var(--accent); }
.opp-row select:disabled { opacity: .4; cursor: not-allowed; }
.blurb { font-size: 12px; color: var(--muted); margin: 6px 2px 0; line-height: 1.45; min-height: 30px; }

.new-game { width: 100%; padding: 11px; border-radius: 10px; cursor: pointer; font-weight: 700; font-size: 14px; background: var(--panel2); color: var(--ink); border: 1px solid var(--line); }
.new-game:hover { border-color: var(--accent); }

.rules { margin-top: 14px; font-size: 12.5px; color: var(--muted); }
.rules summary { cursor: pointer; color: var(--ink); font-weight: 600; }
.rules ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.6; }
.rules b { color: var(--ink); }

/* ---- banner ---- */
.banner { position: absolute; left: 50%; top: 42%; transform: translate(-50%,-50%) scale(.96); padding: 16px 30px; border-radius: 12px; font-size: 22px; font-weight: 800; background: rgba(18,19,23,.94); border: 1px solid var(--accent); color: var(--accent); opacity: 0; pointer-events: none; transition: .25s; z-index: 5; box-shadow: 0 14px 44px rgba(0,0,0,.55); white-space: nowrap; }
.banner.show { opacity: 1; transform: translate(-50%,-50%) scale(1); }

@media (max-width: 880px) { main { grid-template-columns: 1fr; } }

/* ============ tutor / analysis ============ */
.board-row { display: flex; gap: 12px; align-items: stretch; }
.board-row #board { flex: 1; min-width: 0; }

.evalbar {
  position: relative; width: 30px; flex: none; align-self: stretch;
  background: #23262e; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.evalbar-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 50%;
  background: linear-gradient(180deg, #f2f0e8, #dcd9cd);
  transition: height .4s cubic-bezier(.4,0,.2,1);
}
.evalbar-num {
  position: absolute; left: 0; right: 0; top: 6px; text-align: center;
  font-size: 10.5px; font-weight: 800; font-variant-numeric: tabular-nums;
  letter-spacing: -.2px; z-index: 2; color: var(--muted);
}
.evalbar-num.pos { color: #eceadf; }
.evalbar-num.neg { color: #aab4cc; }

.tutor-group { margin-bottom: 16px; }
.tutor-row { display: flex; gap: 8px; align-items: center; margin-bottom: 9px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); cursor: pointer; user-select: none; white-space: nowrap; }
.chk input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
#anaDepth {
  padding: 6px 7px; border-radius: 8px; background: var(--panel2); color: var(--ink);
  border: 1px solid var(--line); font-size: 12px; font-family: inherit; font-weight: 600; cursor: pointer;
}
.hint-btn {
  flex: 1; padding: 7px 8px; border-radius: 8px; cursor: pointer; white-space: nowrap;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 700; font-family: inherit; transition: .12s;
}
.hint-btn:hover { border-color: var(--accent); color: var(--accent); }

.ana-line {
  font-size: 13px; font-weight: 700; color: var(--ink); padding: 8px 10px;
  background: #15171c; border: 1px solid var(--line); border-radius: 8px;
  font-variant-numeric: tabular-nums;
}
.ana-why { font-size: 11.5px; color: var(--muted); line-height: 1.45; margin: 6px 2px 0; min-height: 16px; }
.quality-line { margin-top: 8px; display: flex; align-items: center; gap: 8px; min-height: 22px; }
.q-meta { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.accuracy-line { margin-top: 6px; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* move-quality badges */
.q {
  display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 800;
  padding: 3px 8px; border-radius: 999px; letter-spacing: .2px;
}
.q-best       { background: rgba(95,184,95,.16);  color: #7fd07f; }
.q-excellent  { background: rgba(123,184,95,.15); color: #9ad07a; }
.q-good       { background: rgba(150,160,140,.14);color: #b6bda8; }
.q-inaccuracy { background: rgba(224,178,60,.16); color: #e8c65c; }
.q-mistake    { background: rgba(224,138,60,.16); color: #eda158; }
.q-blunder    { background: rgba(224,72,60,.18);  color: #f0736a; }

/* log gets columns + badges */
.logline { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.logline .ln { color: #6d727c; min-width: 22px; text-align: right; font-size: 11.5px; }
.logline .mv { flex: 1; }
.logline .q { padding: 1px 6px; font-size: 10.5px; }

/* best-move overlay */
.hintcell { fill: rgba(231,193,74,.18); stroke: var(--accent); stroke-width: .035; }
.hintarrow { stroke: var(--accent); stroke-width: .085; stroke-linecap: round; opacity: .95; }
.hintmark { fill: var(--accent); font-size: .5px; font-weight: 800; text-anchor: middle; }

/* ============ play by link ============ */
.share-panel { display: none; margin-top: 10px; padding: 10px; background: #15171c; border: 1px solid var(--line); border-radius: 10px; }
.share-msg { font-size: 12px; color: var(--muted); line-height: 1.45; margin-bottom: 8px; }
.share-input {
  width: 100%; padding: 7px 9px; border-radius: 8px; margin-bottom: 8px;
  background: #0f1116; color: var(--ink); border: 1px solid var(--line);
  font-size: 11px; font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  text-overflow: ellipsis;
}
.share-btn {
  width: 100%; padding: 9px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 13px;
  background: var(--accent); color: #1a1a1a; border: 1px solid var(--accent); font-family: inherit;
}
.share-btn:hover { filter: brightness(1.07); }

/* ============ header rating chip ============ */
header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.head-right { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.elo-chip {
  font-size: 14px; font-weight: 800; padding: 7px 13px; border-radius: 999px;
  background: #23262e; color: var(--accent); border: 1px solid var(--line);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.lobby-btn {
  padding: 8px 15px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13.5px;
  background: var(--accent); color: #17181c; border: 1px solid var(--accent); font-family: inherit;
  white-space: nowrap;
}
.lobby-btn:hover { filter: brightness(1.08); }

/* ============ lobby ============ */
.lobby {
  position: fixed; inset: 0; z-index: 50; display: none;
  background: rgba(8,9,12,.78); backdrop-filter: blur(6px);
  overflow-y: auto; padding: 32px 20px;
}
.lobby.show { display: block; }
.lobby-inner {
  max-width: 760px; margin: 0 auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: 16px; padding: 22px;
  box-shadow: 0 30px 80px rgba(0,0,0,.6);
}
.lobby-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.lobby-title { font-size: 21px; font-weight: 800; margin: 0 0 4px; }
.lobby-sub { font-size: 13px; color: var(--muted); margin: 0; }
.you-card { display: flex; align-items: center; gap: 11px; background: #15171c; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.you-elo { font-size: 27px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; line-height: 1; }
.you-name { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); }
.you-rec { font-size: 12.5px; color: var(--ink); font-variant-numeric: tabular-nums; }

.lobby-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.mode-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left;
  padding: 13px 15px; border-radius: 12px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: var(--ink);
  font-family: inherit; transition: .12s;
}
.mode-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.mode-ico { font-size: 19px; }
.mode-name { font-size: 14px; font-weight: 700; }
.mode-desc { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

.lobby-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 10px; }
.lobby-hint { text-transform: none; letter-spacing: 0; opacity: .75; margin-left: 6px; }

.bot-list { display: flex; flex-direction: column; gap: 7px; }
.bot-row {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  padding: 11px 14px; border-radius: 11px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: var(--ink);
  font-family: inherit; transition: .12s;
}
.bot-row:hover { border-color: var(--accent); transform: translateX(2px); }
.br-ico { font-size: 24px; flex: none; width: 30px; text-align: center; }
.br-main { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.br-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.br-name { font-size: 14.5px; font-weight: 700; }
.br-tag { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; letter-spacing: .4px; }
.br-tag.even   { background: rgba(95,184,95,.16);  color: #7fd07f; }
.br-tag.harder { background: rgba(224,72,60,.16);  color: #f0736a; }
.br-tag.easier { background: rgba(150,160,175,.15); color: #aab4cc; }
.br-style { font-size: 11px; color: var(--accent); opacity: .85; }
.br-blurb { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.br-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; flex: none; }
.br-elo { font-size: 18px; font-weight: 800; font-variant-numeric: tabular-nums; }
.br-odds { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.br-stake { font-size: 10.5px; color: #7f8695; font-variant-numeric: tabular-nums; }

.lobby-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.ghost-btn {
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 12.5px; font-weight: 600;
  background: transparent; color: var(--muted); border: 1px solid var(--line); font-family: inherit;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--accent); }

/* opponent card in the side panel */
.opp-card { display: none; align-items: center; gap: 10px; padding: 9px 11px; margin-top: 2px;
  background: #15171c; border: 1px solid var(--line); border-radius: 10px; }
.oc-ico { font-size: 21px; }
.oc-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.oc-name { font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 7px; }
.oc-elo { font-size: 11px; font-weight: 800; color: var(--accent); background: #23262e; padding: 1px 7px; border-radius: 999px; }
.oc-style { font-size: 11px; color: var(--accent); opacity: .8; }
.oc-stakes { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

@media (max-width: 700px) {
  .lobby-modes { grid-template-columns: 1fr; }
  .lobby-head { flex-direction: column; }
  .br-blurb { display: none; }
}

/* ============ queue ============ */
.queue-box { margin-bottom: 20px; }
.find-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px; width: 100%;
  padding: 18px; border-radius: 13px; cursor: pointer; font-family: inherit;
  background: var(--accent); color: #17181c; border: none; transition: .12s;
}
.find-btn:hover { filter: brightness(1.07); transform: translateY(-1px); }
.find-title { font-size: 18px; font-weight: 800; letter-spacing: .2px; }
.find-sub { font-size: 12px; font-weight: 600; opacity: .72; }

.search-state {
  display: none; align-items: center; gap: 13px;
  padding: 16px 18px; border-radius: 13px;
  background: var(--panel2); border: 1px solid var(--line);
}
.search-state.show { display: flex; }
.search-spin {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  border: 2.5px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.search-text { flex: 1; min-width: 0; }
.search-line { font-size: 14px; font-weight: 700; }
.search-band { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 2px; }

.match-found {
  display: none; align-items: center; gap: 13px;
  padding: 15px 18px; border-radius: 13px;
  background: var(--panel2); border: 1px solid var(--accent);
  animation: pop .28s cubic-bezier(.3,1.4,.5,1);
}
.match-found.show { display: flex; }
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.mf-ico { font-size: 27px; flex: none; }
.mf-body { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.mf-name { font-size: 15.5px; font-weight: 800; }
.mf-meta { font-size: 11.5px; color: var(--accent); opacity: .85; }
.mf-elo { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }

.pool-peek { margin-top: 18px; font-size: 12.5px; color: var(--muted); }
.pool-peek summary { cursor: pointer; color: var(--ink); font-weight: 600; margin-bottom: 10px; }
.pool-peek #poolCount { color: var(--muted); font-weight: 500; }
.bot-row.static { cursor: default; }
.bot-row.static:hover { border-color: var(--line); transform: none; }

/* ============ online rooms ============ */
.room-box {
  display: none; margin-top: 12px; padding: 14px;
  background: var(--panel2); border: 1px solid var(--accent); border-radius: 12px;
}
.room-box.show { display: block; }
.room-state { font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 10px; line-height: 1.45; }
.room-linkrow, .room-joinrow { display: flex; gap: 8px; margin-bottom: 8px; }
.room-linkrow .share-input, .room-joinrow .share-input { margin-bottom: 0; }
.room-copy { width: auto; flex: none; padding: 8px 16px; }
.room-joinrow .share-input { font-family: inherit; font-size: 13px; }
.room-cancel { width: 100%; margin-top: 2px; }

.corr-note { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 0 0 10px; }
.corr-card { width: 100%; align-items: center; }

/* live-connection strip in the side panel */
.net-card {
  display: none; align-items: center; gap: 10px; padding: 9px 11px; margin-bottom: 8px;
  background: #15171c; border: 1px solid var(--line); border-radius: 10px;
}
.nc-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.nc-dot.live { background: #5fb85f; box-shadow: 0 0 0 3px rgba(95,184,95,.18); animation: pulse 2s ease-in-out infinite; }
.nc-dot.dead { background: #e0483c; }
@keyframes pulse { 50% { opacity: .45; } }
.nc-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.nc-name { font-size: 13px; font-weight: 700; }
.nc-meta { font-size: 11px; color: var(--muted); }

/* ============ live game actions ============ */
.game-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 7px; margin-bottom: 10px; }
.act-btn {
  padding: 9px 6px; border-radius: 9px; cursor: pointer; font-size: 12.5px; font-weight: 700;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  font-family: inherit; transition: .12s; white-space: nowrap;
}
.act-btn:hover:not(:disabled) { border-color: var(--accent); }
.act-btn.danger:hover:not(:disabled) { border-color: #e0483c; color: #f0736a; }
.act-btn:disabled { opacity: .35; cursor: not-allowed; }

.dev-chk { margin-bottom: 9px; font-size: 11.5px; color: var(--muted); }
.dev-chk input { width: 13px; height: 13px; }

/* grades stay hidden until the game is over, unless dev mode is on */
.log.hide-grades .q { display: none; }

/* colour picker when opening a room */
.room-siderow { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.room-sidelabel { font-size: 12px; color: var(--muted); white-space: nowrap; }
#roomSide {
  flex: 1; padding: 7px 9px; border-radius: 8px; cursor: pointer;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  font-size: 12.5px; font-family: inherit; font-weight: 600;
}

/* ============ leaderboard ============ */
.leaderboard {
  background: #15171c; border: 1px solid var(--line); border-radius: 11px;
  padding: 6px; margin-bottom: 18px; max-height: 260px; overflow-y: auto;
}
.lb-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 9px; border-radius: 8px;
  font-size: 13px;
}
.lb-row.you { background: rgba(231,193,74,.12); border: 1px solid rgba(231,193,74,.35); }
.lb-rank { width: 20px; text-align: right; color: var(--muted); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.lb-ico { width: 20px; text-align: center; font-size: 15px; }
.lb-name { flex: 1; font-weight: 600; }
.lb-row.you .lb-name { color: var(--accent); }
.lb-elo { font-weight: 800; font-variant-numeric: tabular-nums; }

.you-nameinput {
  background: transparent; border: none; border-bottom: 1px dashed var(--line);
  color: var(--ink); font-family: inherit; font-size: 13px; font-weight: 700;
  padding: 1px 0 2px; width: 110px; outline: none;
}
.you-nameinput:focus { border-bottom-color: var(--accent); }
.you-nameinput::placeholder { color: var(--muted); font-weight: 500; }

/* ============ accounts ============ */
.acct-col { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.auth-btn {
  padding: 8px 14px; border-radius: 9px; cursor: pointer; font-size: 12.5px; font-weight: 700;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  font-family: inherit; white-space: nowrap; transition: .12s;
}
.auth-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.auth-btn:disabled { opacity: .5; cursor: default; }
.auth-state { font-size: 10.5px; color: var(--muted); text-align: right; max-width: 190px; }

/* ============ profile / match history ============ */
.profile-inner { max-width: 820px; }
.lobby-btn.ghosty { background: var(--panel2); color: var(--ink); border-color: var(--line); }
.lobby-btn.ghosty:hover { border-color: var(--accent); color: var(--accent); filter: none; }

.match-list { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; }
.match-empty { color: var(--muted); font-size: 13px; padding: 14px; text-align: center; }
.match-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px 13px; border-radius: 10px; cursor: pointer; font-family: inherit;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-left: 3px solid var(--line); transition: .12s;
}
.match-row:hover:not(:disabled) { border-color: var(--accent); transform: translateX(2px); }
.match-row:disabled { opacity: .5; cursor: default; }
.match-row.win  { border-left-color: #5fb85f; }
.match-row.loss { border-left-color: #e0483c; }
.match-row.draw { border-left-color: #8a90a0; }
.mr-res { font-size: 10px; font-weight: 800; letter-spacing: .5px; width: 38px; }
.mr-res.win { color: #7fd07f; } .mr-res.loss { color: #f0736a; } .mr-res.draw { color: #aab4cc; }
.mr-main { flex: 1; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.mr-opp { font-size: 13.5px; font-weight: 700; }
.mr-oelo { font-size: 10.5px; font-weight: 700; color: var(--accent); }
.mr-meta { font-size: 11px; color: var(--muted); }
.mr-right { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.mr-delta { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--muted); }
.mr-delta.up { color: #7fd07f; } .mr-delta.down { color: #f0736a; }
.mr-when { font-size: 10.5px; color: #7f8695; }

/* ---- replay ---- */
.review { display: none; }
.review.show { display: block; }
.review-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.review-title { font-size: 13.5px; font-weight: 700; color: var(--muted); }
.review-body { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 16px; align-items: start; }
.review-boardwrap { display: flex; gap: 9px; align-items: stretch; }
.review-eval { width: 22px; }
#revBoard {
  flex: 1; min-width: 0; width: 100%; height: auto; display: block;
  background: var(--board-void); border-radius: 10px; border: 1px solid #0d0f13;
}
.review-side { display: flex; flex-direction: column; gap: 9px; }
.rev-moveinfo {
  font-size: 13px; padding: 9px 11px; background: #15171c;
  border: 1px solid var(--line); border-radius: 9px; min-height: 38px;
}
.rev-log { height: 250px; }
.rev-log .logline.cur { background: rgba(231,193,74,.15); border-radius: 5px; }
.rev-controls { display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; }
.rev-controls .act-btn { padding: 8px 4px; font-size: 13px; }

@media (max-width: 760px) { .review-body { grid-template-columns: 1fr; } }
.rev-log .logline { cursor: pointer; padding: 2px 4px; border-radius: 5px; }
.rev-log .logline:hover { background: rgba(255,255,255,.05); }
.rev-log .logline.ahead { opacity: .45; }

/* ============ theme modifiers ============ */
body.brd-rounded .sq { rx: 0.13; ry: 0.13; }               /* paving stones */
body.brd-neon #board .pc.b, body.brd-neon #revBoard .pc.b { --pc-line: #5fe0f0; }
body.brd-neon #board { box-shadow: 0 20px 55px rgba(0,0,0,.6), 0 0 34px rgba(77,208,225,.10), inset 0 0 0 1px rgba(255,255,255,.04); }

/* ============ appearance panel ============ */
.appearance { margin-top: 14px; }
.appear-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.appear-label { font-size: 12px; color: var(--muted); width: 46px; }
.appear-row select {
  flex: 1; padding: 8px 9px; border-radius: 8px; cursor: pointer;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  font-size: 12.5px; font-family: inherit; font-weight: 600;
}
.appear-hint { font-size: 11.5px; color: var(--muted); margin: 4px 0 2px; min-height: 15px; }

/* ============ auth modal ============ */
.auth-inner { max-width: 420px; }
.auth-google { margin: 14px 0 18px; }
.auth-label { display: block; font-size: 11.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin: 4px 0 7px; }
.auth-row { display: flex; gap: 8px; }
.auth-email { flex: 1; font-size: 14px !important; font-family: inherit !important; padding: 11px 12px; }
.auth-send { width: auto; padding: 11px 16px; white-space: nowrap; }
.auth-msg { font-size: 12px; color: var(--muted); margin: 9px 2px 0; line-height: 1.5; min-height: 30px; }

/* ============ touch & mobile ============ */
#board, .wild-btn, .act-btn, .find-btn, .mode-card, .bot-row, .match-row,
.lobby-btn, .new-game, .share-btn, .ghost-btn, .hint-btn, .rev-controls .act-btn {
  touch-action: manipulation;                 /* kills double-tap zoom on the things you tap fast */
  -webkit-tap-highlight-color: transparent;
}
#board { -webkit-user-select: none; user-select: none; }
.wild-btn:active:not(:disabled), .act-btn:active:not(:disabled),
.find-btn:active, .mode-card:active { transform: scale(.97); }

@media (max-width: 880px) {
  .app { padding: 8px 6px 90px; }
  .board-row { gap: 6px; }
  #board { border-radius: 8px; }
  header { flex-wrap: wrap; gap: 8px; }
  header h1 { font-size: 19px; margin: 2px 0 6px; }
  header .sub { display: block; margin: 2px 0 0; font-size: 11px; }
  .head-right { margin-bottom: 4px; }

  main { grid-template-columns: 1fr; gap: 12px; }

  /* the sidebar reorders around the board: status + actions first, admin last */
  .panel { display: flex; flex-direction: column; padding: 12px; }
  .status       { order: 1; }
  .wild-group   { order: 2; }
  .game-actions { order: 3; }
  .tutor-group  { order: 4; }
  .log-wrap     { order: 5; }
  .opp-group    { order: 6; }
  .new-game     { order: 7; }
  .appearance   { order: 8; }
  .rules        { order: 9; }

  /* thumb-sized targets */
  .wild-btn { padding: 13px 6px; font-size: 14px; }
  .act-btn { padding: 12px 6px; font-size: 13.5px; }
  .new-game { padding: 14px; }
  .find-btn { padding: 16px; }
  .opp-row select, .appear-row select { padding: 11px 9px; font-size: 14px; }
  .log { height: 150px; }
  .evalbar { width: 22px; }

  .lobby { padding: 12px 8px; }
  .lobby-inner { padding: 14px; }
  .lobby-head { flex-direction: column; align-items: stretch; gap: 10px; }
  .acct-col { align-items: flex-start; }
  .review-body { grid-template-columns: 1fr; }
  .banner { font-size: 16px; padding: 12px 18px; white-space: normal; text-align: center; max-width: 88vw; }
}

/* very small phones */
@media (max-width: 380px) {
  .wild-buttons { grid-template-columns: 1fr; }
  .wild-btn[data-mode="movecell"] { grid-column: auto; }
}
.wild-buttons.one { grid-template-columns: 1fr; }

/* ============ board-turn vibe ============ */
/* The whole board glows on a board turn — you should feel the ✦ coming. */
body.wild-turn #board {
  box-shadow: 0 0 0 2px rgba(231,193,74,.55), 0 0 26px 4px rgba(231,193,74,.22);
  border-radius: 8px;
  animation: wildglow 1.8s ease-in-out infinite;
}
@keyframes wildglow {
  50% { box-shadow: 0 0 0 2px rgba(231,193,74,.85), 0 0 38px 8px rgba(231,193,74,.34); }
}
body.wild-turn .badge { animation: pulse 1.4s ease-in-out infinite; }

/* the lifted square hovers off the world */
.selcell {
  fill: rgba(231,193,74,.5);
  stroke: var(--accent); stroke-width: .045;
  filter: drop-shadow(0 .09px .12px rgba(0,0,0,.65));
  animation: hover-sq 1.1s ease-in-out infinite;
}
@keyframes hover-sq { 50% { opacity: .62; } }

/* the ground shudders when a square of the world lands somewhere new */
.board-wrap.quake { animation: quake .38s cubic-bezier(.36,.07,.19,.97); }
@keyframes quake {
  10%, 90% { transform: translate(-1px, 0); }
  20%, 80% { transform: translate(2px, 1px); }
  30%, 50%, 70% { transform: translate(-3px, -1px); }
  40%, 60% { transform: translate(3px, 1px); }
}

.sound-btn { min-width: 40px; padding-left: 8px; padding-right: 8px; }

/* ============ welcome ============ */
/* stacking: lobby/profile 50 < welcome 55 < tutorial 60 < auth modal 65 */
.welcome { z-index: 55; background: rgba(10,11,14,.92); backdrop-filter: blur(4px); }
.auth-modal { z-index: 65; }
.welcome-inner { max-width: 430px; text-align: center; padding: 34px 28px 26px; }
.welcome-mark { width: 132px; margin: 0 auto 14px; }
.welcome-mark svg { width: 100%; display: block; }
.wm-a { fill: var(--sq-light, #e9e3d6); }
.wm-b { fill: var(--sq-dark, #6f7d92); }
.wm-k { font-size: 1.05px; fill: var(--accent); }
.welcome-title { font-size: 30px; font-weight: 800; margin: 0 0 8px; letter-spacing: .5px; }
.welcome-tag { font-size: 14px; color: var(--muted); line-height: 1.55; margin: 0 0 22px; }
.welcome-btn { width: 100%; margin-bottom: 10px; }
.welcome-guest {
  width: 100%; padding: 12px; border-radius: 11px; cursor: pointer;
  font-size: 14.5px; font-weight: 700; font-family: inherit;
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
}
.welcome-guest:hover { border-color: var(--accent); }
.welcome-how { width: 100%; margin-top: 14px; border: none; background: none; color: var(--muted); }
.welcome-how:hover { color: var(--accent); }

/* ============ tutorial ============ */
.tut { z-index: 60; background: rgba(10,11,14,.88); }
.tut-inner { max-width: 480px; padding: 26px 26px 20px; }
.tut-art { margin: 0 auto 16px; max-width: 300px; }
.tut-board { width: 100%; display: block; }
.tut-sq.lt { fill: var(--sq-light, #e9e3d6); }
.tut-sq.dk { fill: var(--sq-dark, #6f7d92); }
.tut-sq.lift {
  stroke: var(--accent); stroke-width: .05;
  transform: translateY(-.12px);
  filter: drop-shadow(0 .1px .1px rgba(0,0,0,.6));
}
.tut-dash {
  fill: rgba(231,193,74,.1); stroke: var(--accent); stroke-width: .04;
  stroke-dasharray: .14 .1; }
.tut-pc { font-size: .82px; }
.tut-pc.w { fill: #f3f0e7; stroke: #26282e; stroke-width: .022px; paint-order: stroke; }
.tut-pc.b { fill: #26282e; stroke: #cfd2d8; stroke-width: .014px; paint-order: stroke; }
.tut-arrow { stroke: var(--accent); stroke-width: .07; stroke-linecap: round; }
.tut-arrowhead { fill: var(--accent); }
.tut-void { font-size: .5px; fill: #d06a6a; font-weight: 700; }
.tut-body { font-size: 14px; line-height: 1.6; color: var(--ink); min-height: 88px; }
.tut-body b { color: var(--accent); }
.tut-seq { display: inline-flex; gap: 5px; margin: 8px 0 6px; }
.tut-seq i {
  font-style: normal; font-weight: 700; font-size: 12.5px;
  padding: 4px 8px; border-radius: 7px; background: var(--panel2); border: 1px solid var(--line);
}
.tut-seq i.s { background: rgba(231,193,74,.16); border-color: var(--accent); color: var(--accent); }
.tut-dots { display: flex; gap: 7px; justify-content: center; margin: 14px 0; }
.tut-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tut-dot.on { background: var(--accent); }
.tut-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tut-navright { display: flex; gap: 10px; align-items: center; }
.tut-next { padding: 10px 22px; }
