:root {
  --stage: #0b0c0e;
  --surface: #131417;
  --surface-soft: #18191d;
  --surface-hi: #222328;
  --line: rgba(255, 255, 255, .07);
  --line-strong: rgba(255, 255, 255, .12);
  --text: #ececef;
  --muted: rgba(236, 236, 239, .6);
  --faint: rgba(236, 236, 239, .38);
  --accent: #19df70;
  --accent-rgb: 25, 223, 112;
  --accent-text: #39e887;
  --accent-on: #04160b;
  --sole: color-mix(in srgb, var(--accent) 42%, #000);
  --danger: #ff5d6c;
  --font-sans: "Poppins", ui-sans-serif, system-ui, sans-serif;
  --font-arcade: "Silkscreen", "JetBrains Mono", monospace;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;
  --lift: 5px;
  --flag-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='6' y='3' width='2.2' height='17' rx='1.1' fill='%23e9e9ee'/%3E%3Cpath d='M8.2 4c3-1.6 5.2 1.4 8.2.4 1.3-.4 2.4-.9 3.4-.5v7.8c-1-.4-2.1.1-3.4.5-3 1-5.2-2-8.2-.4z' fill='%23ff4d5e'/%3E%3Cpath d='M8.2 4c3-1.6 5.2 1.4 8.2.4v2.6c-3 1-5.2-2-8.2-.4z' fill='%23fff' opacity='.2'/%3E%3Crect x='3.5' y='19' width='9' height='2.4' rx='1.2' fill='%23e9e9ee'/%3E%3C/svg%3E");
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--stage); color: var(--text); font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased; line-height: 1.5; overflow-x: hidden; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }

.beam {
  position: absolute; inset: 0 0 auto 0; height: 900px; pointer-events: none; z-index: 0;
  background:
    conic-gradient(from 162deg at 50% -320px, transparent 0deg, rgba(255,255,255,.045) 10deg, rgba(255,255,255,.075) 18deg, rgba(255,255,255,.045) 26deg, transparent 36deg),
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(255,255,255,.05), transparent 70%);
  -webkit-mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 30%, transparent 100%);
}
.wrap { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 0 16px 48px; }
@media (min-width: 640px) { .wrap { padding: 0 24px 48px; } }

nav { display: flex; align-items: center; justify-content: space-between; height: 72px; }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -.02em; font-size: 18px; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); box-shadow: 0 3px 0 var(--sole); display: grid; place-items: center; }
.logo-mark svg { width: 16px; height: 16px; }
.nav-right { display: flex; gap: 10px; align-items: center; }

.key {
  --face: var(--accent); --edge: var(--sole); --ink: var(--accent-on);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 22px; border-radius: 12px; background: var(--face); color: var(--ink);
  font-weight: 600; font-size: 15px; letter-spacing: -.01em; white-space: nowrap;
  box-shadow: 0 var(--lift) 0 var(--edge), 0 calc(var(--lift) + 10px) 24px -8px rgba(0,0,0,.6);
  transition: transform .12s cubic-bezier(.4,0,.2,1), box-shadow .12s cubic-bezier(.4,0,.2,1), filter .15s;
}
.key:hover { transform: translateY(-1px); box-shadow: 0 calc(var(--lift) + 1px) 0 var(--edge), 0 calc(var(--lift) + 12px) 26px -8px rgba(0,0,0,.6); filter: brightness(1.05); }
.key:active, .key.on { transform: translateY(var(--lift)); box-shadow: 0 0 0 var(--edge), 0 4px 10px -4px rgba(0,0,0,.6); }
.key.soft { --face: var(--surface-hi); --edge: #050506; --ink: var(--text); border: 1px solid var(--line-strong); }
.key.sm { height: 38px; padding: 0 14px; font-size: 13px; border-radius: 10px; --lift: 4px; }
.key.soft.on { --face: #2e3036; }
.key svg { width: 15px; height: 15px; }

/* ---------- match header ---------- */
.match-meta { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; margin: 12px 0 22px; font-size: 12px; color: var(--muted); }
.chip { padding: 5px 11px; border-radius: 999px; background: rgba(255,255,255,.04); border: 1px solid var(--line-strong); font-family: var(--font-mono); font-size: 11px; }

/* ---------- stage ---------- */
.stage { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 22px; align-items: stretch; max-width: 1020px; margin: 0 auto; }
.stage > * { min-width: 0; }

/* your side: lit up, labelled */
#youPanel {
  position: relative;
  border-color: rgba(var(--accent-rgb), .4);
  box-shadow: 0 0 0 1px rgba(var(--accent-rgb), .12), 0 0 70px -20px rgba(var(--accent-rgb), .3), 0 30px 60px -30px rgba(0,0,0,.8);
}
#youPanel .key.admin { --face: #3a3220; --edge: #15110a; --ink: #ffd166; border: 1px solid rgba(255, 209, 102, .45); }
.key.admin.on { --face: #4d4226; }
.cell.peek::after { content: ""; width: 34%; height: 34%; border-radius: 50%; background: rgba(255, 93, 108, .55); }
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
/* With a picture: no colored background or green edge, and only slightly rounded corners so square pictures stay square. */
.avatar:has(img), #youPanel .avatar:has(img) { background: var(--surface-hi) !important; box-shadow: 0 0 0 1px rgba(255,255,255,.16) !important; border-radius: 5px; }
.avatar { background: var(--accent) !important; color: var(--accent-on) !important; box-shadow: 0 3px 0 var(--sole); }
.side-tag {
  position: absolute; top: -11px; left: 18px; padding: 3px 10px; border-radius: 999px;
  font-family: var(--font-arcade); font-size: 10px; letter-spacing: .06em;
  background: var(--accent); color: var(--accent-on); box-shadow: 0 2px 0 var(--sole);
}
/* opponent side: present but quieter */
:is(#botPanel, #oppPanel) { position: relative; display: flex; flex-direction: column; }
.bot-foot { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bot-stat {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 10px; background: rgba(255,255,255,.03); border: 1px solid var(--line); font-size: 12px; color: var(--faint);
}
:is(#botPanel, #oppPanel) .tips { margin-top: auto; padding-top: 12px; }
.bot-stat b { font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: var(--muted); white-space: nowrap; }
:is(#botPanel, #oppPanel) .board { opacity: .82; filter: saturate(.75); }
:is(#botPanel, #oppPanel) .side-tag { background: var(--surface-hi); color: var(--muted); box-shadow: 0 2px 0 #050506; border: 1px solid var(--line-strong); }
#youPanel.lost { border-color: rgba(255,93,108,.5); box-shadow: 0 0 60px -20px rgba(255,93,108,.35); }

/* flag mode: red outline, red tag, and a flag cursor */
#youPanel.flagging { border-color: rgba(255,93,108,.6); box-shadow: 0 0 0 1px rgba(255,93,108,.15), 0 0 70px -20px rgba(255,93,108,.4), 0 30px 60px -30px rgba(0,0,0,.8); }
#youPanel.flagging .side-tag { background: var(--danger); color: #1a0a0d; box-shadow: 0 2px 0 #7a2530; }
#youPanel .side-tag { transition: background .15s; }
#youPanel.flagging .board.live,
#youPanel.flagging .board.live .cell {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32' viewBox='0 0 24 24'%3E%3Crect x='6' y='3' width='2.2' height='17' rx='1.1' fill='%23e9e9ee' stroke='%23000' stroke-width='.8'/%3E%3Cpath d='M8.2 4c3-1.6 5.2 1.4 8.2.4 1.3-.4 2.4-.9 3.4-.5v7.8c-1-.4-2.1.1-3.4.5-3 1-5.2-2-8.2-.4z' fill='%23ff4d5e' stroke='%23000' stroke-width='.8' stroke-linejoin='round'/%3E%3Crect x='3.5' y='19' width='9' height='2.4' rx='1.2' fill='%23e9e9ee' stroke='%23000' stroke-width='.8'/%3E%3C/svg%3E") 10 28, crosshair;
}

/* divider */
.divider { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 10px 0; }
.divider::before, .divider::after {
  content: ""; flex: 1; width: 2px; border-radius: 2px;
  background: linear-gradient(to bottom, transparent, var(--line-strong) 30%, var(--line-strong) 70%, transparent);
}
.vs {
  font-family: var(--font-arcade); font-size: 14px; color: var(--text);
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface-hi); border: 1px solid var(--line-strong);
  box-shadow: 0 4px 0 #050506, 0 0 30px -6px rgba(255,255,255,.15);
}

@media (max-width: 720px) {
  .stage { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  :is(#botPanel, #oppPanel) { max-width: 62%; margin: 0 auto; width: 100%; order: -2; }
  .bot-foot, :is(#botPanel, #oppPanel) .tips { display: none; }
  .divider { order: -1; flex-direction: row; padding: 0 8px; }
  .divider::before, .divider::after { width: auto; height: 2px; background: linear-gradient(to right, transparent, var(--line-strong) 30%, var(--line-strong) 70%, transparent); }
  .vs { width: 40px; height: 40px; font-size: 12px; }
  /* The opponent's panel is narrow on phones: keep the name, flag, round dots and timer. */
  :is(#botPanel, #oppPanel) .sub, :is(#botPanel, #oppPanel) .cleared, :is(#botPanel, #oppPanel) .mines-left { display: none; }
  :is(#botPanel, #oppPanel) .player-head { margin-bottom: 8px; }
  :is(#botPanel, #oppPanel) .who, :is(#botPanel, #oppPanel) .who > div { min-width: 0; }
  :is(#botPanel, #oppPanel) .name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
  :is(#botPanel, #oppPanel) .stats { gap: 8px; flex: none; }
  :is(#botPanel, #oppPanel) .timer { font-size: 15px; min-width: 0; }
}
.player {
  background: linear-gradient(180deg, var(--surface-soft), var(--surface));
  border: 1px solid var(--line); border-radius: 20px; padding: 14px;
  box-shadow: 0 30px 60px -30px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,255,255,.04);
  transition: border-color .3s, box-shadow .3s;
}
.player.won { border-color: rgba(var(--accent-rgb), .55); box-shadow: 0 0 0 1px rgba(var(--accent-rgb), .25), 0 0 60px -10px rgba(var(--accent-rgb), .35); }
.player.lost { border-color: rgba(255,93,108,.4); }
.player-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.avatar { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.name { font-size: 14px; font-weight: 600; white-space: nowrap; }
.name .flag { width: 18px; height: 13.5px; margin-left: 6px; vertical-align: -1px; border-radius: 2px; object-fit: cover; box-shadow: 0 0 0 1px rgba(255,255,255,.14); }
.sub { font-size: 11px; color: var(--faint); font-family: var(--font-mono); }
.stats { display: flex; align-items: center; gap: 12px; }
.mines-left { display: flex; align-items: center; gap: 5px; font-family: var(--font-mono); font-size: 13px; color: var(--muted); }
.mines-left::before { content: ""; width: 14px; height: 14px; background: var(--flag-img) center / contain no-repeat; }
.timer { font-family: var(--font-arcade); font-size: 20px; letter-spacing: .02em; min-width: 64px; text-align: right; transition: color .3s; }
.player.won .timer { color: var(--accent-text); }
.progress { height: 4px; border-radius: 4px; background: rgba(255,255,255,.06); margin-top: 12px; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: rgba(255,255,255,.4); transition: width .2s, background .3s; }
.player.won .progress i { background: var(--accent); }

.board { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 3px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.cell {
  aspect-ratio: 1; border-radius: 5px; display: grid; place-items: center;
  background: #2a2c32; box-shadow: inset 0 -3px 0 rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.07);
  font-family: var(--font-mono); font-weight: 700; font-size: clamp(12px, 2.1vw, 20px);
}
:is(#botPanel, #oppPanel) .cell { font-size: clamp(9px, 1.6vw, 16px); }
.board.live .cell:not(.open):hover { background: #34373e; cursor: pointer; }
.board.live .cell.open.n1, .board.live .cell.open.n2, .board.live .cell.open.n3, .board.live .cell.open.n4,
.board.live .cell.open.n5, .board.live .cell.open.n6, .board.live .cell.open.n7, .board.live .cell.open.n8 { cursor: pointer; }
.cell.open { background: #17181c; box-shadow: inset 0 0 0 1px rgba(255,255,255,.04); animation: pop .2s ease-out backwards; }
.cell.flag::after {
  content: ""; width: 68%; height: 68%; background: var(--flag-img) center / contain no-repeat;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.55)) drop-shadow(0 0 6px rgba(255,77,94,.3));
  animation: plant .2s cubic-bezier(.3,1.5,.5,1);
}
@keyframes plant { from { transform: translateY(-25%) scale(.5); opacity: 0; } }
/* after the game: right flags go green, wrong flags get a red X */
.cell.flag.right { background: rgba(var(--accent-rgb), .22); box-shadow: inset 0 0 0 2px rgba(var(--accent-rgb), .7); }
.cell.wrong { background: #4a1c23; box-shadow: inset 0 0 0 2px var(--danger); color: #fff; font-family: var(--font-sans); }
.cell.wrong::after { content: none; }
.cell.mine { background: #1c1215; box-shadow: none; }
.cell.mine::after { content: ""; width: 40%; height: 40%; border-radius: 50%; background: var(--danger); box-shadow: 0 0 10px rgba(255,93,108,.7); }
.cell.boom { background: var(--danger); }
.cell.boom::after { background: #1a0a0d; box-shadow: none; }
/* teaching marks: lettered numbers, squares being proven, and the losing click */
.cell { position: relative; }
.cell.ref { background: #24262c; box-shadow: inset 0 0 0 2px rgba(255,255,255,.75); }
.cell.ref::before, .tagref {
  font-family: var(--font-arcade); font-size: 8px; line-height: 1; color: var(--stage); background: var(--text);
  border-radius: 4px; display: inline-grid; place-items: center; min-width: 13px; height: 13px; padding: 0 2px;
}
.cell.ref::before { content: attr(data-tag); position: absolute; top: 2px; left: 2px; }
@media (max-width: 520px) { .cell.ref::before { top: 1px; left: 1px; min-width: 10px; height: 10px; font-size: 6px; border-radius: 3px; } }
.tagref { font-size: 9px; min-width: 16px; height: 16px; vertical-align: 1px; box-shadow: 0 2px 0 #050506; }
.cell.sure-safe { background: rgba(var(--accent-rgb), .2); box-shadow: inset 0 0 0 2px var(--accent); animation: glow 1s ease-in-out infinite; }
.cell.sure-safe::after { content: ""; width: 42%; height: 42%; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2339e887' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat; }
.cell.proved::after { content: ""; width: 62%; height: 62%; background: var(--flag-img) center / contain no-repeat; opacity: .75; }
.cell.proved { background: #2a1b1f; box-shadow: inset 0 0 0 2px rgba(255,93,108,.6); }
@keyframes glow { 50% { box-shadow: inset 0 0 0 2px var(--accent), 0 0 16px rgba(var(--accent-rgb), .55); } }

.coach {
  margin-top: 14px; padding: 12px 14px; border-radius: 14px; font-size: 13px; color: var(--muted); line-height: 1.55;
  background: rgba(var(--accent-rgb), .06); border: 1px solid rgba(var(--accent-rgb), .3);
}
.coach-kicker { font-family: var(--font-arcade); font-size: 9px; letter-spacing: .12em; color: var(--accent-text); margin-bottom: 6px; }
.coach ol { padding-left: 18px; display: grid; gap: 6px; }
.coach b { color: var(--text); }
.coach-note { display: block; margin-top: 6px; font-size: 12px; color: var(--faint); }
@keyframes pop { from { transform: scale(.75); opacity: .4; } }
.n1 { color: #5ab0ff; } .n2 { color: #39e887; } .n3 { color: #ff6b78; } .n4 { color: #b48cff; }
.n5 { color: #ffb347; } .n6 { color: #3fe0d0; } .n7 { color: #fff; } .n8 { color: #9aa59d; }

.controls { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.controls .spacer { flex: 1; }
.hint-count { font-size: 12px; color: var(--faint); align-self: center; }
.tips { margin-top: 12px; text-align: center; }
.tip { font-size: 12px; color: var(--faint); }
.tip.touch { display: none; }
/* Flag mode is only for touch screens; mouse players flag with right-click or Space. */
@media (hover: none), (pointer: coarse) {
  .tip.mouse { display: none; }
  .tip.touch { display: inline; }
}
@media (hover: hover) and (pointer: fine) { #flagBtn { display: none; } }

.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 16px; font-size: 12px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.sw { width: 18px; height: 18px; flex: none; border-radius: 5px; display: grid; place-items: center; box-sizing: border-box; }
.sw svg { width: 10px; height: 10px; }
.sw.right { background: rgba(var(--accent-rgb), .22); border: 2px solid rgba(var(--accent-rgb), .7); }
.sw.right::after { content: ""; width: 12px; height: 12px; background: var(--flag-img) center / contain no-repeat; }
.sw.wrong { background: #4a1c23; border: 2px solid var(--danger); color: #fff; font-size: 10px; line-height: 1; }
.sw.missed { background: #1c1215; border: 1px solid var(--line-strong); }
.sw.missed::after, .sw.hit::after { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.sw.hit { background: var(--danger); }
.sw.hit::after { background: #1a0a0d; }

/* ---------- overlay ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: rgba(5,5,7,.62); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
/* The ✕ on pop-ups that can be closed (Escape does the same). */
.panel-x {
  position: absolute; top: 14px; right: 14px; z-index: 2; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center; font-size: 15px; color: var(--faint); background: rgba(255,255,255,.04); border: 1px solid var(--line);
  transition: color .15s, background .15s;
}
.panel-x:hover { color: var(--text); background: rgba(255,255,255,.09); }
.panel > .panel-x { position: absolute; }
.panel {
  position: relative;
  width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 22px; padding: 26px;
  box-shadow: 0 40px 80px -20px rgba(0,0,0,.8);
}
.panel h2 { font-size: 24px; font-weight: 600; letter-spacing: -.03em; line-height: 1.2; }
.panel .lede { color: var(--muted); font-size: 14px; margin-top: 6px; }
.field { margin-top: 22px; }
.field-label { font-size: 12px; font-weight: 500; color: rgba(255,255,255,.8); margin-bottom: 8px; }
.panel .actions { margin-top: 24px; display: flex; gap: 10px; flex-wrap: wrap; }
.panel .actions .key { flex: 1; }

.rules { list-style: none; margin-top: 18px; display: grid; gap: 14px; }
.rules li { display: grid; grid-template-columns: 28px 1fr; gap: 12px; font-size: 14px; color: var(--muted); }
.rules b { color: var(--text); font-weight: 600; }
.rules .num { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-hi); border: 1px solid var(--line-strong); font-family: var(--font-arcade); font-size: 11px; color: var(--text); }
.kbd { font-family: var(--font-mono); font-size: 12px; padding: 1px 6px; border-radius: 5px; background: var(--surface-hi); border: 1px solid var(--line-strong); color: var(--text); }
.example { display: grid; grid-template-columns: repeat(3, 26px); gap: 3px; margin-top: 8px; }
.example .cell { font-size: 12px; animation: none; }

.countdown { font-family: var(--font-arcade); font-size: clamp(80px, 18vw, 160px); color: var(--text); text-shadow: 0 0 60px rgba(255,255,255,.25); animation: tick .9s ease-out; }
.countdown.go { color: var(--accent-text); text-shadow: 0 0 60px rgba(var(--accent-rgb), .5); }
@keyframes tick { from { transform: scale(1.4); opacity: 0; } 30% { opacity: 1; } to { transform: scale(1); } }

/* ---------- result screen ---------- */
.result { --tone: var(--danger); --tone-rgb: 255, 93, 108; position: relative; overflow: hidden; text-align: center; padding-top: 34px; }
.result.win { --tone: var(--accent-text); --tone-rgb: var(--accent-rgb); }
.result.lose { --tone: #b48cff; --tone-rgb: 180, 140, 255; }
.result::before, .lobby::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 180px; pointer-events: none;
  background: radial-gradient(ellipse 70% 100% at 50% 0%, rgba(var(--tone-rgb), .2), transparent 70%);
}
.result > *, .lobby > * { position: relative; }
.result-icon {
  width: 72px; height: 72px; margin: 0 auto; border-radius: 20px; display: grid; place-items: center;
  background: rgba(var(--tone-rgb), .14); border: 1px solid rgba(var(--tone-rgb), .4);
  box-shadow: 0 5px 0 rgba(0,0,0,.5), 0 0 44px -6px rgba(var(--tone-rgb), .6);
  animation: drop .5s cubic-bezier(.3,1.6,.5,1);
}
.result-icon svg { width: 36px; height: 36px; }
@keyframes drop { from { transform: translateY(-14px) scale(.8); opacity: 0; } }
.result-kicker { margin-top: 18px; font-family: var(--font-arcade); font-size: 11px; letter-spacing: .14em; color: var(--tone); }
.result-title { margin-top: 2px; font-size: 28px; font-weight: 600; letter-spacing: -.04em; line-height: 1.15; }
.result .lede { max-width: 330px; margin: 8px auto 0; }

.faceoff { margin-top: 22px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; text-align: left; }
.fo { background: var(--stage); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.fo.best { border-color: rgba(var(--accent-rgb), .45); box-shadow: 0 0 30px -12px rgba(var(--accent-rgb), .5); }
.fo-name { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.fo-crown { font-family: var(--font-arcade); font-size: 9px; color: var(--accent-text); align-self: center; }
.fo-val { font-family: var(--font-arcade); font-size: 22px; margin-top: 4px; white-space: nowrap; }
.fo-val small { font-size: 11px; color: var(--faint); margin-left: 2px; }
.fo-bar { height: 4px; border-radius: 4px; background: rgba(255,255,255,.06); margin-top: 10px; overflow: hidden; }
.fo-bar i { display: block; height: 100%; background: rgba(255,255,255,.4); }
.fo.best .fo-bar i { background: var(--accent); }
.fo-vs { align-self: center; font-family: var(--font-arcade); font-size: 10px; color: var(--faint); }
@media (max-width: 420px) { .fo { padding: 10px 11px; } .fo-val { font-size: 17px; } }

.result-chips { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.result-chips .chip { color: var(--muted); }
.result-chips .chip b { color: var(--text); }
.result .actions { margin-top: 24px; }
.text-btns { margin-top: 14px; display: flex; justify-content: center; gap: 10px; font-size: 13px; color: var(--faint); }
.text-btn { font-size: 13px; color: var(--muted); }

.text-btn:hover { color: var(--text); }
.fine { font-size: 11px; color: var(--faint); margin-top: 10px; }

/* ---------- lobby ---------- */
.lobby { --tone: var(--accent-text); --tone-rgb: var(--accent-rgb); position: relative; overflow: hidden; padding-top: 30px; }
.lobby-head { text-align: center; }
.lobby .lede { max-width: 340px; margin: 8px auto 0; }
.lobby .result-chips { margin-top: 16px; }
.lobby .field-label { display: flex; justify-content: space-between; align-items: baseline; }
.lobby .field-label span { font-family: var(--font-mono); font-size: 11px; color: var(--faint); font-weight: 500; }

.bots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bot-card {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px 12px; border-radius: 14px; text-align: center;
  background: var(--stage); border: 1px solid var(--line);
  box-shadow: 0 4px 0 #050506; transition: border-color .15s, box-shadow .15s, transform .12s;
}
.bot-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.bot-card:active { transform: translateY(3px); box-shadow: 0 1px 0 #050506; }
.bot-card.sel {
  border-color: rgba(var(--accent-rgb), .55); background: linear-gradient(180deg, rgba(var(--accent-rgb), .07), var(--stage));
  box-shadow: 0 4px 0 #050506, 0 0 30px -10px rgba(var(--accent-rgb), .6);
}
.bot-card.sel::after {
  content: "PICKED"; position: absolute; top: -9px; left: 50%; transform: translateX(-50%);
  padding: 2px 8px; border-radius: 999px; font-family: var(--font-arcade); font-size: 8px; letter-spacing: .06em;
  background: var(--accent); color: var(--accent-on); box-shadow: 0 2px 0 var(--sole);
}
.bot-av {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700; background: rgba(180,140,255,.16); color: #b48cff;
  box-shadow: 0 3px 0 #050506;
}
.bot-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.pips { display: flex; gap: 3px; }
.pips i { width: 12px; height: 5px; border-radius: 2px; background: rgba(255,255,255,.1); }
.pips i.on { background: #b48cff; }
.bot-card.sel .pips i.on { background: var(--accent); }
.bot-sub { font-size: 10px; color: var(--faint); font-family: var(--font-mono); }
@media (max-width: 420px) { .bot-card { padding: 12px 4px 10px; } .bot-sub { font-size: 9px; } }

.how { margin-top: 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.how summary { list-style: none; cursor: pointer; padding: 14px 0; display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 500; color: rgba(255,255,255,.8); }
.how summary::-webkit-details-marker { display: none; }
.how summary::after { content: "+"; font-family: var(--font-mono); color: var(--faint); font-size: 18px; line-height: 1; transition: transform .2s; }
.how[open] summary::after { transform: rotate(45deg); }
.how .rules { margin: 4px 0 18px; }
.lobby .actions { margin-top: 22px; }
.lobby .fine { text-align: center; }

/* bar shown while reviewing the boards */
.review {
  position: fixed; left: 50%; bottom: 16px; z-index: 15; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  width: max-content; max-width: calc(100% - 32px); padding: 12px 14px 12px 18px;
  background: var(--surface-hi); border: 1px solid var(--line-strong); border-radius: 16px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,.8); transition: opacity .2s, transform .2s;
}
.review.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.review-row { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; }
.review .legend { flex: 1 1 auto; min-width: min(300px, 100%); }
.review-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
body.reviewing .wrap { padding-bottom: 150px; }
@media (max-width: 520px) {
  .review { bottom: 10px; padding: 10px 12px; gap: 10px; }
  .review .legend { gap: 6px 12px; font-size: 11px; }
  .review-actions { width: 100%; }
  .review-actions .key { flex: 1; }
}

/* ---------- effects (js/fx.js) ---------- */
.fx-canvas { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }
.shake { animation: shake .45s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake {
  10%, 90% { transform: translate(-1px, 0); }
  20%, 80% { transform: translate(3px, -1px); }
  30%, 50%, 70% { transform: translate(-6px, 2px); }
  40%, 60% { transform: translate(6px, -2px); }
}
.player.flash::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255,93,108,.35), rgba(255,93,108,0) 70%);
  animation: flash .6s ease-out forwards;
}
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
.cell.boom { animation: boom-pop .35s cubic-bezier(.3,1.6,.5,1); }
@keyframes boom-pop { from { transform: scale(.5); } }
.player.won .progress i { animation: bar-glow 1.2s ease-out; }
@keyframes bar-glow { from { box-shadow: 0 0 18px rgba(var(--accent-rgb), .9); } }
.sound-btn { width: 38px; padding: 0; }
.sound-btn svg { width: 17px; height: 17px; }
.sound-btn.off { color: var(--faint); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  /* Without its fade-out, the hit flash would stay on the board, so it's skipped. */
  .player.flash::after { display: none; }
}
