/* The page's styles. Colours come from the theme variables at the top; the board and pieces are
   drawn on a canvas instead (render.js, boards.js). */

/* Fonts (in public/fonts, so no outside requests): Fraunces for titles, Alegreya Sans for text. */
@font-face { font-family: "Fraunces"; font-weight: 600; font-display: swap; src: url(fonts/fraunces-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-weight: 400; font-display: swap; src: url(fonts/alegreya-sans-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-weight: 500; font-display: swap; src: url(fonts/alegreya-sans-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Alegreya Sans"; font-weight: 700; font-display: swap; src: url(fonts/alegreya-sans-latin-700-normal.woff2) format("woff2"); }
:root {
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Alegreya Sans", system-ui, sans-serif;
  --radius: 10px;
}

/* Themes: every page colour comes from these variables. The board itself stays wooden.
   The default, "Club": a dark wooden table edge on green felt, with brass fittings. Panels are
   wood with a thin brass edge (--frame, drawn by --panel-shadow); main buttons are brass. */
:root, [data-theme="classic"] {
  --bg: radial-gradient(ellipse 120% 85% at 50% 0%, #2a5f45 0%, #1d4a35 45%, #13321f 100%) fixed;
  --text: #f0e7d4; --title-shadow: 0 2px 0 rgba(0, 0, 0, .35);
  --panel: #2a1c13; --panel-hover: #36251a; --border: rgba(212, 176, 106, .45);
  --panel-bg: linear-gradient(180deg, #2f2018 0%, #24170f 100%);
  --frame: rgba(212, 176, 106, .3);
  --panel-shadow: inset 0 0 0 1px var(--frame), 0 6px 18px rgba(0, 0, 0, .28);
  --accent: #d9b871; --accent-rgb: 217, 184, 113;
  --button: #c9a24f; --button-hover: #d8b462; --button-text: #24170c;
  --button-bg: linear-gradient(180deg, #dcbd76 0%, #bf9645 100%);
  --button-hover-bg: linear-gradient(180deg, #e6c983 0%, #c9a050 100%);
  --button-edge: #8f6d2c; --button-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 2px 0 rgba(0, 0, 0, .35);
  --good: #c3e6a2; --error: #ff9a8a; --podium: #3a2a14;
  --overlay: rgba(28, 18, 11, .94);
  --sheet-bg: linear-gradient(180deg, #2f2018 0%, #22150e 100%);
  --input-bg: #f3ead7; --input-text: #23170e; --input-border: rgba(0, 0, 0, .18);
  --bubble-bg: #f3ead7; --bubble-text: #23170e;
}
[data-theme="midnight"] {
  --panel-bg: var(--panel); --frame: transparent; --sheet-bg: var(--bg);
  --button-bg: var(--button); --button-hover-bg: var(--button-hover); --button-edge: transparent; --button-shadow: none;
  --bg: #0e1117; --text: #e6e9ef; --title-shadow: none;
  --panel: #191d26; --panel-hover: #232836; --panel-shadow: none; --border: #343b4d;
  --accent: #4cc2ff; --accent-rgb: 76, 194, 255;
  --button: #2f81f7; --button-hover: #4b93f8; --button-text: #fff;
  --good: #5ee08f; --error: #ff7b7b; --podium: #1f3550;
  --overlay: rgba(10, 12, 18, .92);
  --input-bg: #1e2330; --input-text: #e6e9ef; --input-border: #343b4d;
  --bubble-bg: #e6e9ef; --bubble-text: #0e1117;
}
[data-theme="modern"] {
  --panel-bg: var(--panel); --frame: transparent; --sheet-bg: var(--bg);
  --button-bg: var(--button); --button-hover-bg: var(--button-hover); --button-edge: transparent; --button-shadow: none;
  --bg: #f3f4f7; --text: #1f2430; --title-shadow: none;
  --panel: #ffffff; --panel-hover: #f0f1f6; --border: #d9dce5;
  --panel-shadow: 0 1px 3px rgba(20, 30, 60, .08), 0 4px 14px rgba(20, 30, 60, .06);
  --accent: #5b5bf0; --accent-rgb: 91, 91, 240;
  --button: #5b5bf0; --button-hover: #6e6ef5; --button-text: #fff;
  --good: #12a150; --error: #d93636; --podium: #e7e7ff;
  --overlay: rgba(255, 255, 255, .95);
  --input-bg: #fff; --input-text: #1f2430; --input-border: #d9dce5;
  --bubble-bg: #1f2430; --bubble-text: #fff;
}
[data-theme="synthwave"] {
  --panel-bg: var(--panel); --frame: transparent; --sheet-bg: var(--bg);
  --button-bg: var(--button); --button-hover-bg: var(--button-hover); --button-edge: transparent; --button-shadow: none;
  --bg: linear-gradient(180deg, #1a0b2e 0%, #2d0f4a 60%, #3d0f4f 100%) fixed;
  --text: #f7e9ff; --title-shadow: 0 0 10px rgba(255, 79, 163, .9), 0 0 24px rgba(76, 230, 255, .5);
  --panel: #2a1450; --panel-hover: #3a1c6b; --panel-shadow: none; --border: #6a3aa8;
  --accent: #ff4fa3; --accent-rgb: 255, 79, 163;
  --button: #ff2e88; --button-hover: #ff58a0; --button-text: #fff;
  --good: #3ef0e0; --error: #ff8a8a; --podium: #4a1a6e;
  --overlay: rgba(26, 11, 46, .93);
  --input-bg: #2a1450; --input-text: #f7e9ff; --input-border: #6a3aa8;
  --bubble-bg: #3ef0e0; --bubble-text: #1a0b2e;
}
html { background: #1d4a35; } /* behind the body while a theme's background loads */
[data-theme="midnight"] { background: #0e1117; }
[data-theme="modern"] { background: #f3f4f7; }
[data-theme="synthwave"] { background: #1a0b2e; }

* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-body); font-size: 17px;
  /* Alegreya Sans is small for its size: scale it to the x-height of a typical UI font (so every
     size in this file reads as intended), and use lining numbers rather than old-style ones. */
  font-size-adjust: .5; font-variant-numeric: lining-nums;
  background: var(--bg); color: var(--text);
  display: flex; flex-direction: column; align-items: center;
  padding: 16px;
}
h1, h2, h3, .room-title, .t-title, .practice-title, #goTitle { font-family: var(--font-display); font-weight: 600; font-size-adjust: none; }
h1 { margin: 0; font-size: 40px; letter-spacing: .2em; text-transform: uppercase; text-shadow: var(--title-shadow); }
/* The title, with the board's baseline under it: two brass lines ending in red circles. */
.masthead { display: flex; flex-direction: column; align-items: center; margin: 4px 0 20px; }
.baseline-rule { width: 190px; height: 14px; margin-top: 4px; }
.baseline-rule path { stroke: var(--accent); stroke-width: 1.2; fill: none; }
.baseline-rule circle { fill: #b3261e; stroke: var(--accent); stroke-width: 1; }
.icon { width: 1.15em; height: 1.15em; vertical-align: -0.2em; flex: none; }
input { background: var(--input-bg); color: var(--input-text); box-shadow: inset 0 0 0 2px var(--input-border); }
/* Cards and panels get a soft shadow in themes that use one (Modern). */
.card, .t-match, .t-slot:not(.empty), .t-status, .t-podium-step, .practice-bar, .room-bar, .pick-option { box-shadow: var(--panel-shadow); }

/* Pre-game lobby. */
.room-screen { width: 100%; max-width: 720px; text-align: center; }
.room-title { font-size: 24px; font-weight: 800; margin-bottom: 12px; }
.invite { background: var(--panel-bg); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--panel-shadow); }
.invite-label { font-size: 13px; opacity: .75; margin-bottom: 8px; }
.invite-row { display: flex; gap: 8px; }
.invite-row input {
  flex: 1; min-width: 0; width: auto; font-size: 14px; text-align: left; letter-spacing: normal;
  text-transform: none; padding: 8px 12px;
}
.invite-row button { font-size: 15px; padding: 8px 14px; white-space: nowrap; }
.invite-note { font-size: 13px; opacity: .75; margin-top: 8px; }
.invite-note b { color: var(--accent); letter-spacing: 2px; }
.link-btn {
  background: none; color: var(--accent); padding: 0; font-size: inherit; font-weight: 600;
  text-decoration: underline; border-radius: 0; border: none; box-shadow: none;
}
.link-btn:hover { background: none; opacity: .8; }
.room-players { display: flex; align-items: stretch; justify-content: center; gap: 14px; margin: 18px 0 10px; }
.room-vs { align-self: center; font-weight: 800; opacity: .5; }
.room-slot {
  flex: 1; min-width: 0; max-width: 240px; padding: 14px 10px 12px; border-radius: var(--radius); background: var(--panel-bg);
  border: 2px solid transparent; box-shadow: var(--panel-shadow);
  display: flex; flex-direction: column; align-items: center; gap: 6px; transition: border-color .2s;
}
.room-slot.ready { border-color: var(--good); }
.room-slot.empty { background: none; border: 2px dashed var(--border); justify-content: center; box-shadow: none; min-height: 230px; }
.room-slot .avatar { width: 96px; }
.room-slot-name { font-size: 18px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-slot-tag { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .6; }
.room-slot canvas { width: 34px; height: 34px; }
.ready-pill { font-size: 13px; font-weight: 700; padding: 3px 12px; border-radius: 999px; background: var(--panel-hover); opacity: .85; }
.room-slot.ready .ready-pill { background: var(--good); color: #10241a; opacity: 1; }
.waiting-dots::after { content: ''; animation: dots 1.4s steps(4) infinite; }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.room-status { min-height: 1.4em; margin: 8px 0 12px; color: var(--good); font-weight: 600; }
.ready-btn { font-size: 22px; padding: 14px 48px; border-radius: var(--radius); }
.ready-btn.is-ready { background: var(--good); color: #10241a; }
.room-setup { margin-top: 22px; padding: 14px; border-radius: var(--radius); background: var(--panel-bg); box-shadow: var(--panel-shadow); }
.room-setup-title { font-weight: 800; margin-bottom: 8px; }
.room-setup .picker { margin-bottom: 12px; }
@media (max-width: 520px) {
  .room-players { gap: 8px; }
  .room-slot .avatar { width: 72px; }
  .room-slot.empty { min-height: 190px; }
  .room-vs { font-size: 13px; }
}

/* Theme menu: a small button in the top-left corner of the home page that opens a dropdown. */
.theme-menu { position: fixed; top: 12px; left: 12px; z-index: 10; }
#themeBtn { font-size: 14px; padding: 6px 12px; gap: 6px; background: var(--overlay); }
.theme-picker {
  display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding: 8px;
  background: var(--overlay); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .3); animation: open-down .2s ease-out;
}
.theme-picker.hidden { display: none; }
@media (max-width: 640px) {
  .theme-menu { top: 8px; left: 8px; }
  #themeBtn { padding: 6px 10px; }
}
.theme-option {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px;
  background: var(--panel-bg); color: var(--text); border: 2px solid transparent; border-radius: 999px;
  font-size: 13px; font-weight: 600; box-shadow: var(--panel-shadow);
}
.theme-option:hover { background: var(--panel-hover); }
.theme-option[aria-checked="true"] { border-color: var(--accent); }
.theme-swatch { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.panel { text-align: center; }

/* ---------- Home page: profile bar, play cards, code row, pop-up sheets ---------- */
.home { width: min(100%, 960px); }
.profile-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 18px;
  padding: 14px 18px; border-radius: var(--radius); background: var(--panel-bg); box-shadow: var(--panel-shadow); text-align: left;
}
.profile-main { flex: 1 1 240px; min-width: 0; }
.profile-main .name-label { display: block; margin: 0 0 4px; }
.profile-bar .name-input { width: 100%; max-width: 280px; text-align: left; }
.profile-line { margin-top: 5px; font-size: 13px; opacity: .8; }
.profile-line b { color: var(--accent); }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.play-cards {
  display: grid; grid-template-columns: repeat(3, 1fr); margin: 14px 0 18px;
  border-radius: var(--radius); background: var(--panel-bg); box-shadow: var(--panel-shadow);
}
/* The three ways to play share one panel, divided by brass lines (rather than three cards). */
.play-card { display: flex; flex-direction: column; padding: 18px 20px; text-align: left; }
.play-card + .play-card { box-shadow: inset 1px 0 0 var(--frame); }
@media (max-width: 760px) {
  .play-cards { grid-template-columns: 1fr; }
  .play-card + .play-card { box-shadow: inset 0 1px 0 var(--frame); }
}
/* Quick Play: the main way in, on its own panel. */
.quick-card {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 28px;
  margin-top: 14px; padding: 20px 22px; text-align: left;
  border-radius: var(--radius); background: var(--panel-bg); box-shadow: var(--panel-shadow);
}
.quick-card h2 { margin: 0 0 4px; font-size: 26px; }
.quick-card p { margin: 0 0 8px; opacity: .78; }
.quick-info { flex: 1 1 300px; }
.quick-info p { margin-bottom: 8px; }
.presence { font-size: 14px; opacity: .9; }
.quick-note { margin-top: 8px; padding: 8px 10px; border-radius: 10px; font-size: 13.5px; line-height: 1.4;
  background: rgba(229, 72, 77, .12); border: 1px solid rgba(229, 72, 77, .5); }
.presence b { color: var(--accent); font-variant-numeric: lining-nums tabular-nums; }
.live-dot { display: inline-block; width: 9px; height: 9px; margin-right: 4px; border-radius: 50%; background: #3ddc84;
  box-shadow: 0 0 0 0 rgba(61, 220, 132, .6); animation: live 2s ease-out infinite; vertical-align: 1px; }
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(61, 220, 132, 0); } 100% { box-shadow: 0 0 0 0 rgba(61, 220, 132, 0); } }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: 0 1 auto; }
#quickBtn { min-width: 220px; justify-content: center; font-size: 19px; padding: 12px 22px; }
#quickBtn.searching { animation: searching 1.6s ease-in-out infinite; }
@keyframes searching { 50% { filter: brightness(1.2); transform: scale(1.02); } }
#rankedBtn { justify-content: center; }
#rankedBtn small { opacity: .8; font-weight: normal; }
button:disabled, button:disabled:hover { opacity: .45; cursor: not-allowed; filter: grayscale(.6); transform: none; }
@media (max-width: 640px) { .quick-actions, #quickBtn, #rankedBtn { width: 100%; } }
.play-card h2 { margin: 0 0 4px; font-size: 21px; }
.play-card h2 .icon, .quick-card h2 .icon { color: var(--accent); margin-right: 2px; }
.play-card p { margin: 0 0 14px; font-size: 15px; opacity: .75; line-height: 1.35; }
.card-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.card-actions.row { flex-direction: row; margin-bottom: 0; }
.card-actions button { width: 100%; justify-content: center; }
.card-actions.row button { flex: 1; }
.bot-label { font-size: 12px; opacity: .65; text-align: center; margin-bottom: -2px; }
.bot-levels { display: flex; flex-wrap: wrap; gap: 6px; }
/* Sized by their labels (Medium is the longest) and never wrapped mid-label. */
/* On a narrow card (three cards on a tablet), drop the coloured dots so the three still fit. */
.play-card { container-type: inline-size; }
@container (max-width: 250px) { .bot-dot { display: none; } }
/* Bot difficulty: a small coloured coin. */
.bot-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, .25); }
.bot-dot.easy { background: #6cb07a; } .bot-dot.medium { background: #d6a03f; } .bot-dot.hard { background: #c4473a; }
/* Gold, silver and bronze coins for the top places (leaderboard, tournament podium). */
.medal { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; font-size: 13px; font-weight: 700;
  color: #2a1a0e; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .18), inset 0 0 0 5px rgba(255, 255, 255, .18); text-align: center; }
.medal-1 { background: radial-gradient(circle at 35% 35%, #f6dd8f, #c99a33); }
.medal-2 { background: radial-gradient(circle at 35% 35%, #f1f1ee, #a9abae); }
.medal-3 { background: radial-gradient(circle at 35% 35%, #ecb98c, #a8683a); }
.medal-4 { background: radial-gradient(circle at 35% 35%, #8d6a4d, #553824); color: #f0e7d4; }
.leader-list .rank.medal { justify-self: end; }
.t-medal.medal { width: 38px; height: 38px; font-size: 14px; }
.card-actions .bot-levels button { width: auto; flex: 1 1 auto; padding: 6px 8px; font-size: 13px; white-space: nowrap; gap: 5px; }
.code-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; padding: 4px 12px; }
.code-label { opacity: .75; margin-right: 4px; }
.corner-right { position: fixed; top: 12px; right: 12px; z-index: 10; display: flex; gap: 8px; }
.corner-btn { font-size: 14px; padding: 6px 12px; gap: 6px; background: var(--overlay); }
#soundBtn { font-size: 16px; padding: 6px 10px; }
@media (max-width: 640px) {
  .corner-right { top: 8px; right: 8px; gap: 6px; }
  h1 { margin-top: 38px; } /* below the corner buttons, which no longer fit beside the title */
  .corner-btn { padding: 6px 10px; }
  .profile-bar { padding: 12px; }
  .profile-actions { width: 100%; }
  .profile-actions button { flex: 1; justify-content: center; }
  .play-cards { gap: 10px; margin: 12px 0; }
}
/* Pop-up sheets over the home page. */
.sheet { position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; background: rgba(6, 18, 12, .62); animation: fade-in .15s ease-out; }
.sheet.hidden { display: none; }
.sheet-card { width: min(100%, 600px); padding: 16px 20px 22px; border-radius: var(--radius); background: var(--sheet-bg);
  box-shadow: inset 0 0 0 1px var(--frame), 0 16px 48px rgba(0, 0, 0, .5); animation: open-down .2s ease-out; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sheet-head h2 { margin: 0; font-size: 24px; }
.sheet-close { width: 36px; height: 36px; padding: 0; justify-content: center; }
/* The rules. */
.rules { text-align: left; line-height: 1.5; font-size: 15px; }
.rules h3 { margin: 16px 0 4px; font-size: 16px; color: var(--accent); }
.rules p { margin: 4px 0 8px; }
.rules ul { margin: 4px 0 8px; padding-left: 20px; }
.rules li { margin: 3px 0; }
@keyframes fade-in { from { opacity: 0; } }
@media (max-width: 640px) { .sheet { padding: 12px 8px; } .sheet-card { padding: 12px; } }
.hidden { display: none !important; }
button, input {
  font: inherit; font-size: 18px; padding: 10px 18px;
  border-radius: 7px; border: none;
}
button {
  background: var(--button-bg); color: var(--button-text); cursor: pointer; font-weight: 700;
  border: 1px solid var(--button-edge); box-shadow: var(--button-shadow);
}
button:hover { background: var(--button-hover-bg); }
button:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
input { width: 140px; text-align: center; text-transform: uppercase; letter-spacing: 4px; }
.row { display: flex; gap: 8px; justify-content: center; margin: 12px 0; }
.code { font-size: 48px; font-weight: 700; letter-spacing: 8px; color: var(--accent); margin: 8px 0; }
.error { color: var(--error); min-height: 1.4em; }
#game { width: 100%; max-width: 1200px; display: flex; flex-direction: column; align-items: center; }

/* Board in the middle, each player's score card and avatar at the sides. The board is sized
   to the window height so the title and the status line below it both stay on screen. */
#table { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; width: 100%; }
.side { display: flex; flex-direction: column; align-items: center; gap: 16px; width: 190px; }
.side.left { justify-self: end; }
.side.right { justify-self: start; }
.side .card { width: 100%; }
/* As big as fits: under 780px, the window height minus the title and the text below, and the
   window width minus the two side columns. */
.board-wrap {
  position: relative;
  width: max(280px, min(780px, calc(100vh - 195px), calc(100vw - 460px)));
  width: max(280px, min(780px, calc(100dvh - 195px), calc(100vw - 460px))); /* dvh ignores mobile browser toolbars */
}

/* Short screens (phones held sideways): smaller title, slimmer columns, and no keyboard hint
   (phones have no keyboard), so the board still fits. */
@media (max-height: 520px) {
  body { padding-top: 6px; padding-bottom: 0; }
  h1 { font-size: 20px; margin: 2px 0 6px; }
  .masthead { margin: 0; }
  .baseline-rule { display: none; }
  #controlsHint { display: none; }
  #status { min-height: 1.4em; margin: 4px 0; }
  .side { width: 170px; gap: 8px; }
  .side .avatar { width: 64px; }
  .board-wrap {
    width: max(200px, min(780px, calc(100vh - 115px), calc(100vw - 420px)));
    width: max(200px, min(780px, calc(100dvh - 115px), calc(100vw - 420px)));
  }
}
#actionsRow:not(:has(button:not(.hidden))) { display: none; } /* no empty gap when there are no buttons */

/* Striker slider: only on touch screens and narrow windows, where dragging the small striker
   along the baseline is fiddly. Hidden (but keeping its space) when it isn't your turn. */
.striker-control { display: none; align-items: center; gap: 10px; width: min(100%, 560px); margin: 8px 0 0; touch-action: none; }
.striker-control.off { visibility: hidden; }
.striker-control .nudge { flex: none; width: 46px; height: 46px; padding: 0; justify-content: center; font-size: 18px; touch-action: none; user-select: none; -webkit-user-select: none; }
#strikerSlider { flex: 1; min-width: 0; height: 46px; margin: 0; background: transparent; accent-color: var(--accent); -webkit-appearance: none; appearance: none; }
#strikerSlider::-webkit-slider-runnable-track { height: 10px; border-radius: 5px; background: rgba(127,127,127,.35); }
#strikerSlider::-webkit-slider-thumb { -webkit-appearance: none; width: 38px; height: 38px; margin-top: -14px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
#strikerSlider::-moz-range-track { height: 10px; border-radius: 5px; background: rgba(127,127,127,.35); }
#strikerSlider::-moz-range-thumb { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.hint-touch { display: none; }
@media (pointer: coarse), (max-width: 640px) {
  .striker-control { display: flex; }
  .hint-mouse { display: none; }
  .hint-touch { display: inline; }
}
/* Phones held sideways: make room for the slider under the board. */
@media (pointer: coarse) and (max-height: 520px) {
  .striker-control { margin-top: 4px; }
  .side { gap: 4px; }
  .side .card { padding: 6px 10px; }
  .side .avatar { width: 50px; }
  .side .avatar .avatar-name { display: none; }
  .home-label { display: none; } /* just the ⌂ icon, so it doesn't cover the score card */
  .board-wrap {
    width: max(180px, min(780px, calc(100vh - 150px), calc(100vw - 420px)));
    width: max(180px, min(780px, calc(100dvh - 150px), calc(100vw - 420px)));
  }
}
/* The coin toss: the cards and avatars would give away who plays White, so they appear as it lands. */
.side { transition: opacity .5s; }
#game.tossing .side { opacity: 0; }
#game.practice .card { display: none; }
#game.practice .side.right { visibility: hidden; } /* keeps the board centred */

/* Narrower screens: not enough room for a good-sized board between the side columns, so the
   two cards go in a row above the board instead. */
@media (max-width: 940px) and (orientation: portrait) {
  #table { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "left right" "board board"; gap: 8px; }
  .side { width: auto; flex-direction: row; gap: 6px; justify-self: stretch; }
  .side.left { grid-area: left; }
  .side.right { grid-area: right; flex-direction: row-reverse; }
  .side .card { flex: 1; min-width: 0; padding: 6px 8px; }
  .side .avatar { width: 52px; flex: none; }
  .coins .chip { width: 10px; height: 10px; }
  .board-wrap {
    grid-area: board; justify-self: center;
    width: min(100%, max(280px, calc(100vh - 290px)));
    width: min(100%, max(280px, calc(100dvh - 290px)));
  }
  #game.practice .side.right { display: none; }
}

/* Game over panel shown over the board. */
#gameOver {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.go-card {
  pointer-events: auto; text-align: center; padding: 22px 30px; border-radius: var(--radius);
  background: var(--overlay); box-shadow: 0 10px 40px rgba(0,0,0,.5);
  animation: go-in .4s ease-out 1.2s both; /* wait a moment so the winning fireworks show */
}
#goTitle { font-size: 30px; font-weight: 800; color: var(--accent); }
#goScore { margin: 6px 0 14px; opacity: .85; }
#rematchBtn:disabled { background: var(--border); cursor: default; }
#rematchBtn.invited { animation: pulse 1s ease-in-out infinite; }
#rematchNote { margin-top: 10px; font-size: 14px; min-height: 1.2em; color: var(--good); }
@keyframes go-in { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(var(--accent-rgb), .3); } }

.name-label { display: block; opacity: .7; font-size: 14px; }

/* Tournament screen. */
#tournament { width: 100%; max-width: 900px; text-align: center; }
.t-title { font-size: 22px; font-weight: 800; }
.t-code { margin: 4px 0 10px; opacity: .7; font-size: 14px; }
.t-code b { color: var(--accent); letter-spacing: 3px; font-size: 18px; opacity: 1; }
.t-status { margin: 0 auto 18px; padding: 10px 16px; max-width: 560px; border-radius: 10px; background: var(--panel-bg); color: var(--good); font-weight: 600; }
.t-lobby { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-bottom: 16px; }
.t-slot {
  width: 110px; padding: 10px 6px; border-radius: 12px; background: var(--panel-bg);
  display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px solid transparent;
}
.t-slot.empty { background: none; border: 2px dashed var(--border); justify-content: center; min-height: 104px; opacity: .6; }
.t-slot.me, .t-podium-step.me { border-color: var(--accent); }
.t-slot { position: relative; }
.t-slot.bot { border-style: dotted; border-color: var(--border); }
.t-remove { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; padding: 0; justify-content: center; font-size: 12px; border-width: 1px; }
.t-bots { margin: -4px auto 16px; max-width: 560px; }
.t-bots-label { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.t-bots-row { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.t-bots-row button { font-size: 14px; padding: 6px 14px; }
.t-slot-name { font-size: 13px; font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-bracket { display: flex; gap: 14px; justify-content: center; align-items: stretch; margin-bottom: 16px; }
.t-round { flex: 1; max-width: 240px; display: flex; flex-direction: column; gap: 8px; }
.t-round-body { flex: 1; display: flex; flex-direction: column; justify-content: space-around; gap: 10px; }
.t-round-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; opacity: .6; }
.t-match { background: var(--panel-bg); border-radius: 10px; padding: 8px 10px; text-align: left; border: 2px solid transparent; }
.t-match.mine { border-color: var(--border); }
.t-match.live { border-color: #e04848; box-shadow: 0 0 10px rgba(224, 72, 72, .35); }
.t-match-label { font-size: 12px; opacity: .75; margin-bottom: 4px; display: flex; justify-content: space-between; }
.t-live { background: #e04848; color: #fff; font-size: 10px; font-weight: 800; padding: 1px 6px; border-radius: 6px; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .5; } }
.t-player { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 14px; min-height: 30px; }
.t-player.tbd { opacity: .45; font-style: italic; font-size: 13px; }
.t-player.winner { color: var(--accent); font-weight: 700; }
.t-player.loser { opacity: .45; }
.t-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-watch { width: 100%; justify-content: center; margin-top: 6px; padding: 5px; font-size: 13px; }
.t-podium { display: flex; gap: 10px; justify-content: center; align-items: flex-end; margin-bottom: 18px; }
.t-podium-step { width: 110px; padding: 10px 6px; border-radius: 12px 12px 4px 4px; background: var(--panel-bg); display: flex; flex-direction: column; align-items: center; gap: 4px; border: 2px solid transparent; }
.t-podium-step.place-1 { order: 2; padding-top: 30px; background: var(--podium); }
.t-podium-step.place-2 { order: 1; padding-top: 18px; }
.t-podium-step.place-3 { order: 3; padding-top: 10px; }
.t-podium-step.place-4 { order: 4; opacity: .7; }
.t-medal { font-size: 26px; }
#goBracketBtn { margin-top: 4px; }
#goHomeBtn { margin-top: 4px; font-size: 16px; }

/* Main menu button: top-left corner on every screen except the lobby, so it never takes
   vertical space from the board. */
.home-btn {
  position: fixed; top: 12px; left: 12px; z-index: 10;
  font-size: 14px; padding: 6px 12px; gap: 6px;
  background: var(--overlay);
}
@media (max-width: 640px) {
  .home-btn { top: 8px; left: 8px; padding: 6px 10px; }
  .home-label { display: none; } /* just the ⌂ icon on phones */
}
/* A player who has lost their connection (their seat is being held for them). */
.avatar.away, .room-slot.away { opacity: .45; filter: grayscale(1); transition: opacity .3s, filter .3s; }

.go-watch { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.go-watch:empty { display: none; }
.go-watch button { justify-content: center; }
@media (max-width: 640px) {
  .t-bracket { flex-direction: column; align-items: center; }
  .t-round { width: 100%; max-width: 320px; }
}

/* Practice mode: replaces the scoreboard. */
.practice-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: space-between;
  width: 100%; max-width: 640px; margin-bottom: 10px; padding: 8px 12px;
  background: var(--panel-bg); border-radius: 10px;
}
.practice-title { font-weight: 800; color: var(--accent); }
.practice-stats { font-size: 14px; opacity: .85; flex: 1; }
.practice-actions { display: flex; gap: 8px; }
.practice-actions button { font-size: 14px; padding: 6px 12px; }

.room-bar {
  margin: -6px 0 10px; padding: 4px 14px; border-radius: 6px;
  background: var(--panel-bg); font-size: 13px; color: var(--accent); text-align: center;
}
.room-bar #watchCode { letter-spacing: 2px; }
.room-bar .link-btn { font-size: 13px; margin-left: 4px; }
/* Phones held sideways have no height to spare: no watch code there (nor the bar, if that's all it had). */
@media (max-height: 520px) {
  #roomBarWatch { display: none; }
  .room-bar:has(#roomBarText:empty) { display: none; }
}

/* "Personalize" toggle and the panel it opens. */
button.secondary {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(0, 0, 0, .12); color: var(--text); border: 1px solid var(--border); font-size: 16px; box-shadow: none;
}
button.secondary:hover { background: rgba(var(--accent-rgb), .1); border-color: var(--accent); }
.personalize-preview { display: inline-flex; align-items: center; gap: 4px; }
.avatar.preview { width: 26px; display: inline-block; }
.personalize-preview canvas { width: 22px; height: 22px; }
.chevron { transition: transform .2s; opacity: .7; }
button[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.profile-intro { margin-bottom: 10px; font-size: 14px; line-height: 1.45; }
.profile-intro b { display: block; margin-bottom: 4px; font-size: 16px; color: var(--accent); }
.profile-intro .row { margin: 10px 0 0; }
.go-profile { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 14px; line-height: 1.4; }
.go-profile .row { margin: 8px 0 0; }
.go-profile code { font-size: 15px; padding: 4px 8px; border-radius: 6px; background: var(--panel-bg); user-select: all; }
.go-profile .profile-code-row { margin-top: 8px; }
/* Achievements: the grid in My stats, and the pop-ups. */
/* My stats has two tabs: the stats themselves, and achievements. */
.stats-tabs { margin-top: 4px; }
.stats-tabs .label-note { margin-left: 2px; }
#statsPanel[data-tab="stats"] .achievements-only, #statsPanel[data-tab="achievements"] .stats-only { display: none; }
.ach-grid { margin-bottom: 4px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(116px, 1fr)); gap: 8px; }
.ach { position: relative; padding: 8px 6px; border-radius: 12px; background: var(--panel-bg); text-align: center; border: 1px solid transparent; }
.ach.got { border-color: var(--accent); box-shadow: 0 0 10px rgba(var(--accent-rgb), .25); }
.ach .ach-icon { font-size: 26px; line-height: 1.2; }
.ach b { display: block; font-size: 12.5px; margin-top: 2px; }
.ach small { display: block; font-size: 11px; opacity: .7; line-height: 1.25; margin-top: 2px; }
.ach:not(.got) .ach-icon { filter: grayscale(1); opacity: .35; }
.ach:not(.got) b { opacity: .6; }
.ach-progress { height: 4px; margin-top: 6px; border-radius: 2px; background: rgba(127, 127, 127, .3); overflow: hidden; }
.ach-progress span { display: block; height: 100%; background: var(--accent); }
.toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: min(92vw, 360px); }
.toast { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: var(--radius); background: var(--overlay);
  border: 1px solid var(--accent); box-shadow: 0 10px 30px rgba(0, 0, 0, .45); animation: toast-in .35s ease-out, toast-out .4s ease-in 3.6s forwards; }
.toast .ach-icon { font-size: 34px; }
.toast .toast-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); }
.toast b { display: block; font-size: 16px; }
.toast small { display: block; font-size: 12.5px; opacity: .8; }
.toast .toast-keep { color: var(--accent); opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.96); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }
.backup-warning { margin-bottom: 12px; padding: 10px 12px; border-radius: 12px; font-size: 14px; line-height: 1.4;
  background: rgba(229, 160, 40, .15); border: 1px solid rgba(229, 160, 40, .6); }
.backup-warning b { display: block; margin-bottom: 4px; font-size: 15px; }
.backup-warning .profile-code-row { margin-top: 8px; }
.profile-who { margin: 4px 0 6px; font-size: 15px; }
.profile-who b { color: var(--accent); }
.tag { font-weight: normal; opacity: .6; margin-left: 1px; } /* the #1234 after a name */
.leader-list .who b { font-weight: 600; }
/* Tabs (the leaderboard's boards, and My stats). */
.tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-bottom: 8px; }
.tabs button { padding: 5px 12px; font-size: 14px; }
.tabs button[aria-selected="true"] { border-color: var(--accent); background: var(--panel-hover); color: var(--accent); }
.leader-list { list-style: none; margin: 0; padding: 0; text-align: left; }
.leader-list li { display: grid; grid-template-columns: 2.4em 34px 1fr auto; align-items: center; gap: 8px; padding: 5px 8px; border-radius: 10px; }
.leader-list li:nth-child(odd) { background: var(--panel-bg); }
.leader-list li.you { outline: 2px solid var(--accent); }
.leader-list li.gap { display: block; text-align: center; background: none; opacity: .6; padding: 0; }
.leader-list .rank { text-align: right; font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }
.leader-list .avatar { width: 34px; }
.leader-list .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leader-list .score { font-weight: 700; color: var(--accent); font-variant-numeric: lining-nums tabular-nums; }
.leader-list .score small { font-weight: normal; opacity: .7; color: var(--text); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-bottom: 6px; }
.stat { padding: 8px 6px; border-radius: 10px; background: var(--panel-bg); box-shadow: var(--panel-shadow); text-align: center; }
.stat b { display: block; font-size: 22px; color: var(--accent); font-variant-numeric: lining-nums tabular-nums; }
.stat span { font-size: 12px; opacity: .75; }
.profile-code-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
#profileCode { font-size: 18px; letter-spacing: 1px; padding: 6px 10px; border-radius: 8px; background: var(--panel-bg); user-select: all; }
#profileCodeInput { width: 260px; max-width: 100%; text-transform: uppercase; font-family: monospace; }
.profile-msg { min-height: 1.3em; font-size: 14px; color: var(--good); }
.profile-msg.bad { color: #e5484d; }
.privacy { margin-top: 8px; font-size: 13px; opacity: .8; }
@keyframes open-down { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* Avatar and striker pickers in the lobby. */
.picker { display: grid; gap: 8px; justify-content: center; margin: 10px 0 18px; }
.picker.avatars { grid-template-columns: repeat(6, 76px); }
.picker.strikers { grid-template-columns: repeat(5, 76px); }
.picker.boards { grid-template-columns: repeat(3, 108px); }
.board-preview { width: 92px; height: 92px; border-radius: 8px; margin: 2px 0 4px; display: block; }
.label-note { text-transform: none; letter-spacing: 0; opacity: .7; font-weight: normal; }
.pick-option {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 6px; background: var(--panel-bg); color: var(--text);
  border: 2px solid transparent; border-radius: 12px; font-size: 12px; font-weight: 600;
}
.pick-option:hover { background: var(--panel-hover); }
.pick-option[aria-pressed="true"] { border-color: var(--accent); background: var(--panel-hover); box-shadow: 0 0 10px rgba(var(--accent-rgb), .4); }
.avatar.mini { width: 54px; }
.striker-preview { width: 46px; height: 46px; margin: 2px 0 4px; }
.striker-preview.spin { animation: spin .6s ease-out; }
@keyframes spin { from { transform: rotate(0) scale(.8); } to { transform: rotate(360deg) scale(1); } }
@media (max-width: 520px) {
  .picker.avatars { grid-template-columns: repeat(3, 76px); }
  .picker.strikers { grid-template-columns: repeat(5, 60px); gap: 6px; }
  .picker.strikers .pick-option { font-size: 10px; }
  .striker-preview { width: 38px; height: 38px; }
}
.name-input { width: 240px; text-transform: none; letter-spacing: normal; }
.avatar { flex: none; width: 110px; display: flex; flex-direction: column; align-items: center; position: relative; }
.avatar svg { width: 100%; height: auto; overflow: visible; }
.avatar-name { font-size: 12px; opacity: .6; margin-top: 4px; text-transform: uppercase; letter-spacing: 1px; }
.avatar-player {
  font-size: 15px; font-weight: 700; color: var(--accent); text-align: center;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.avatar .shadow { transform-box: fill-box; transform-origin: center; }
.avatar .figure { transform-box: fill-box; transform-origin: 50% 100%; animation: idle 2.4s ease-in-out infinite; }
.avatar.active .figure { filter: drop-shadow(0 0 8px rgba(var(--accent-rgb), .8)); }
.avatar .arm { transform-box: fill-box; transition: transform .25s; }
.avatar .arm.left { transform-origin: 100% 0%; }
.avatar .arm.right { transform-origin: 0% 0%; }
.avatar .happy, .avatar .open, .avatar .hat, .avatar .frown { display: none; }

.avatar.celebrate .figure { animation: jump .7s ease-in-out 2; }
.avatar.celebrate .arm.left { animation: wave-left .35s ease-in-out infinite alternate; }
.avatar.celebrate .arm.right { animation: wave-right .35s ease-in-out infinite alternate; }
.avatar.celebrate .eyes, .avatar.celebrate .smile { display: none; }
.avatar.celebrate .happy, .avatar.celebrate .open { display: inline; }
.avatar.celebrate .hat { display: inline; transform-box: fill-box; transform-origin: 50% 100%; animation: pop .3s ease-out; }
.avatar.celebrate .shadow { animation: shadow .7s ease-in-out 2; }

.avatar.sad .figure { animation: shake .12s linear 6; }
.avatar.sad .smile { display: none; }
.avatar.sad .frown { display: inline; }

.bubble {
  position: absolute; top: -6px; left: 50%; transform: translate(-50%, 0);
  background: var(--bubble-bg); color: var(--bubble-text); font-weight: 700; font-size: 14px;
  padding: 4px 10px; border-radius: 12px; white-space: nowrap;
  pointer-events: none; animation: bubble 1.4s ease-out forwards;
}

/* Emotes: each one plays an animation on the avatar (class emote-<id>, added for ~2s). */
.avatar.emote-wave .arm.right { animation: wave-right .3s ease-in-out 6 alternate; }
.avatar.emote-wave .eyes, .avatar.emote-dance .eyes, .avatar.emote-laugh .eyes { display: none; }
.avatar.emote-wave .happy, .avatar.emote-dance .happy, .avatar.emote-laugh .happy { display: inline; }

.avatar.emote-laugh .figure { animation: laugh .14s ease-in-out 12 alternate; }
.avatar.emote-laugh .smile, .avatar.emote-wow .smile, .avatar.emote-dance .smile { display: none; }
.avatar.emote-laugh .open, .avatar.emote-wow .open, .avatar.emote-dance .open { display: inline; }

.avatar.emote-wow .figure { animation: wow .7s ease-out; }

.avatar.emote-angry .figure { animation: shake .1s linear 14; filter: drop-shadow(0 0 10px rgba(255, 60, 60, .9)); }
.avatar.emote-angry .smile, .avatar.emote-cry .smile { display: none; }
.avatar.emote-angry .frown, .avatar.emote-cry .frown { display: inline; }

.avatar.emote-dance .figure { animation: dance .45s ease-in-out 4 alternate; }
.avatar.emote-dance .arm.left { animation: wave-left .3s ease-in-out infinite alternate; }
.avatar.emote-dance .arm.right { animation: wave-right .3s ease-in-out infinite alternate; }

.avatar.emote-cry .figure { animation: cry .9s ease-in-out 2; }

@keyframes laugh { to { transform: translateY(-5%) scale(1.03, .97); } }
@keyframes wow { 0% { transform: scale(1); } 30% { transform: translateY(-10%) scale(1.12); } 100% { transform: scale(1); } }
@keyframes dance { from { transform: rotate(-10deg) translateX(-4%); } to { transform: rotate(10deg) translateX(4%); } }
@keyframes cry { 50% { transform: scale(1.04, .9); } }

/* The emote's emoji floats up from the avatar's head. */
.emote-pop {
  position: absolute; top: 8%; left: 50%; font-size: 34px; pointer-events: none;
  animation: emote-pop 2s ease-out forwards;
}
@keyframes emote-pop {
  0% { opacity: 0; transform: translate(-50%, 0) scale(.5); }
  15% { opacity: 1; transform: translate(-50%, -30px) scale(1.2); }
  100% { opacity: 0; transform: translate(-50%, -80px) scale(1); }
}

/* Your own avatar opens the chat menu; the 💬 badge shows it can be clicked. */
.avatar.can-chat { cursor: pointer; }
.chat-badge {
  position: absolute; top: 0; right: 0; width: 30px; height: 30px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35); animation: badge-pulse 1.6s ease-in-out 3;
}
@keyframes badge-pulse { 50% { transform: scale(1.18); } }
.chat-menu {
  position: fixed; z-index: 20; width: 260px; padding: 10px;
  background: var(--overlay); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: open-down .15s ease-out;
}
.chat-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .6; margin: 2px 0 6px; text-align: left; }
.emote-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.phrase-list { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.chat-menu button {
  background: var(--panel-bg); color: var(--text); border: 2px solid transparent;
  font-weight: 600; padding: 6px 4px; border-radius: 10px;
}
.chat-menu button:hover { border-color: var(--accent); background: var(--panel-hover); }
.emote-list button { display: flex; flex-direction: column; align-items: center; font-size: 22px; line-height: 1.1; }
.emote-list button span { font-size: 11px; opacity: .8; }
.phrase-list button { font-size: 13px; }
.chat-menu.cooling button { opacity: .45; pointer-events: none; } /* short cooldown between messages */
@media (max-width: 640px) {
  .chat-badge { width: 22px; height: 22px; font-size: 11px; top: -4px; right: -4px; }
  .emote-pop { font-size: 24px; }
}

@keyframes idle { 0%, 100% { transform: scale(1, 1); } 50% { transform: scale(1.03, .97); } }
@keyframes jump {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  15% { transform: translateY(0) scale(1.12, .88); }
  50% { transform: translateY(-22%) scale(.94, 1.08); }
  85% { transform: translateY(0) scale(1.08, .92); }
}
@keyframes shadow { 0%, 100% { transform: scale(1); opacity: .35; } 50% { transform: scale(.6); opacity: .15; } }
@keyframes wave-left { from { transform: rotate(105deg); } to { transform: rotate(150deg); } }
@keyframes wave-right { from { transform: rotate(-105deg); } to { transform: rotate(-150deg); } }
@keyframes pop { from { transform: scale(0) rotate(-30deg); } to { transform: scale(1) rotate(0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-5%); } 75% { transform: translateX(5%); } }
@keyframes bubble {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); }
  15% { opacity: 1; transform: translate(-50%, -14px) scale(1.1); }
  25% { transform: translate(-50%, -14px) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -30px); }
}

@media (max-width: 640px) {
  .avatar { width: 52px; }
  .avatar-name { font-size: 9px; letter-spacing: 0; }
  .avatar-player { font-size: 11px; }
  .go-card { padding: 16px 18px; }
  #goTitle { font-size: 22px; }
  .bubble { font-size: 11px; padding: 3px 6px; }
}
.card {
  padding: 8px 10px; border-radius: 10px;
  background: var(--panel-bg); border: 2px solid transparent;
  transition: border-color .2s, box-shadow .2s;
}
.card.active { border-color: var(--accent); box-shadow: 0 0 12px rgba(var(--accent-rgb), .5); }
.who { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.name { font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip {
  display: inline-block; width: 18px; height: 18px; border-radius: 50%; flex: none;
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.25), 0 1px 2px rgba(0,0,0,.5);
}
.chip.white { background: radial-gradient(circle at 35% 35%, #ffffff, #e4e0d6); }
.chip.black { background: radial-gradient(circle at 35% 35%, #555, #0d0d0d); }
.chip.queen { background: radial-gradient(circle at 35% 35%, #ff6b6b, #8e0d0d); }
.coins { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0 4px; min-height: 12px; }
.coins .chip { width: 12px; height: 12px; }
.coins .chip.empty { opacity: .18; }
.coins .chip.pending { opacity: .5; }
.wins { font-size: 13px; opacity: .8; }
/* Turn timer on the active player's card: a draining bar and the seconds left. */
.turn-timer { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-size: 14px; }
.turn-timer.hidden { display: none; }
.turn-timer .track { flex: 1; height: 6px; border-radius: 3px; background: rgba(127,127,127,.3); overflow: hidden; }
.turn-timer .bar { display: block; height: 100%; background: var(--good); transition: width .25s linear; }
.turn-timer b { min-width: 2.4em; text-align: right; font-variant-numeric: lining-nums tabular-nums; }
.turn-timer.low .bar { background: #e5484d; }
.turn-timer.low b { color: #e5484d; animation: timer-pulse 1s ease-in-out infinite; }
@keyframes timer-pulse { 50% { opacity: .45; } }
/* Game setting in the lobby (the host can change it). */
.room-options { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 22px; row-gap: 4px; margin-top: 12px; }
.room-options #timerNote { flex-basis: 100%; text-align: center; }
.room-option { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 15px; cursor: pointer; }
.room-option input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.room-option input:disabled { cursor: default; }
.wins b { font-size: 18px; color: var(--accent); }
#status { min-height: 3em; text-align: center; margin: 10px 0; font-size: 16px; }
#status.myturn { color: var(--good); font-weight: 600; }
canvas { width: 100%; height: auto; touch-action: none; border-radius: 12px; display: block; }
#board { box-shadow: 0 16px 34px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .35); } /* sitting on the felt */
.hint { opacity: .6; font-size: 14px; text-align: center; }
