/* Squedrill's own colours (Squedrill/Website brand/): charcoal, lime and white */
:root {
  --charcoal: #2b2f2d;
  --lime: #8cc63f;
  --lime-dark: #6ea32b;
  --white: #ffffff;
  --panel: rgba(255, 255, 255, 0.92);
  --text: #1d2420;
  --muted: #5d6862;
  --line: rgba(43, 47, 45, 0.15);
}
@media (prefers-color-scheme: dark) {
  :root {
    --panel: rgba(36, 40, 38, 0.92);
    --text: #eef2ee;
    --muted: #a7b1ab;
    --line: rgba(255, 255, 255, 0.14);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body { font: 15px/1.45 system-ui, sans-serif; color: var(--text); background: #cfe3ea; }
#stage { position: fixed; inset: 0; }
#stage canvas { width: 100%; height: 100%; display: block; touch-action: none; }

#topbar {
  position: fixed; top: 0; left: 0; right: 0; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; background: var(--charcoal); color: var(--white); z-index: 5;
}
.who { display: inline-flex; align-items: center; gap: 6px; }
/* the top bar (user, 2026-10-17): the menu (three bars) on the left; your name on the right, which centres the board */
#topbar button { background: none; color: var(--white); min-height: 32px; padding: 0 4px; border-radius: 8px; }
.menu-btn { flex-direction: column; justify-content: center; gap: 4px; width: 36px; }
.menu-btn span { display: block; width: 22px; height: 3px; border-radius: 2px; background: currentColor; }
.menu-btn[aria-expanded='true'] { background: rgba(255, 255, 255, .14); }
.menu { position: fixed; top: 50px; left: 10px; z-index: 6; display: flex; flex-direction: column; min-width: 220px; padding: 6px;
  background: #2a2a2c; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.menu a, .menu button { display: block; text-align: left; color: #fff; background: none; padding: 10px 12px; border-radius: 8px; text-decoration: none; min-height: 0; font: inherit; }
.menu a:hover, .menu button:hover { background: rgba(255, 255, 255, .1); }
.menu #leave { color: #ff9b70; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff; }
.dot.diamond { border-radius: 2px; transform: rotate(45deg); width: 11px; height: 11px; }

.panel {
  position: fixed; z-index: 4; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 16px; backdrop-filter: blur(6px); box-shadow: 0 6px 24px rgba(0, 0, 0, 0.15);
}
.panel.center { top: calc(50% + 21px); left: 50%; transform: translate(-50%, -50%); width: min(460px, calc(100% - 32px)); max-height: calc(100% - 100px); overflow: auto; }
.panel.bottom { bottom: 16px; left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 32px)); }
h2 { font-size: 1rem; margin: 0 0 8px; }
h2:not(:first-child) { margin-top: 14px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }

/* buttons as on squedrill.com (Squedrill/Website site/index.html; user, 2026-10-17): grey with white text, the main one
   bright lime with a darker edge underneath, and quiet ones as underlined text */
button, .button {
  font: inherit; min-height: 44px; padding: 0 16px; border-radius: 12px; border: 0; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; background: #5a5a5a; color: #fff;
}
button.primary, .button.primary { color: #1b2a05; background: linear-gradient(#cfff7a, #b4f341 55%, #93d22c); box-shadow: 0 3px 0 #5a9419; font-weight: 600; }
button.quiet, .button.quiet { background: none; color: var(--text); text-decoration: underline; padding: 0 8px; }
button:disabled { opacity: 0.6; cursor: default; }
button:focus-visible, .button:focus-visible { outline: 3px solid #b4f341; outline-offset: 2px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }

.creatures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.creatures button { display: block; padding: 8px 4px; font-size: 0.85rem; line-height: 1.2; background: transparent; color: var(--text); border: 1px solid var(--line); }
.creatures button small { display: block; color: var(--muted); font-size: 0.75rem; }
.creatures .preview { display: block; width: 100%; aspect-ratio: 160 / 110; margin-bottom: 4px; border-radius: 8px; background: #cfe6f5; }
/* the chosen creature: solid lime like squedrill.com's main button, the same in light and dark (user, 2026-10-17) */
.creatures button[aria-pressed='true'], .options button[aria-pressed='true'] { border: 2px solid #5a9419; color: #1b2a05; background: linear-gradient(#cfff7a, #b4f341 55%, #93d22c); box-shadow: 0 3px 0 #5a9419; }
.creatures button[aria-pressed='true'] small { color: #3d5a10; }
.options { display: flex; flex-direction: column; gap: 6px; }
.options button { text-align: left; display: flex; justify-content: space-between; }
#quick-match, #cancel, #learn { width: 100%; margin-top: 8px; }
.stats { color: var(--muted); font-size: 0.85rem; }

#hud { position: fixed; top: 62px; left: 0; right: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 16px; pointer-events: none; }
.players { display: flex; gap: 8px; width: min(660px, 100%); }
/* the players' cards: dark grey like squedrill.com's buttons, the player's colour as a stripe down the left, the total
   value big on the right; lime round the player whose turn it is */
.player { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 10px;
  background: rgba(42, 42, 44, 0.92); color: #fff; border-radius: 12px; border-left: 6px solid var(--pc, #888);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.player.active { outline: 2px solid #b4f341; box-shadow: 0 0 0 5px rgba(180, 243, 65, .28), 0 4px 14px rgba(0, 0, 0, .25); }
.player .main { flex: 1; min-width: 0; }
.player .name { font-weight: 700; white-space: nowrap; display: flex; align-items: center; gap: 6px; min-width: 0; }
.player .who { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.player .you { flex: none; font-size: 0.65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: #1b2a05; background: #b4f341; border-radius: 6px; padding: 1px 5px; }
.player .nums { font-size: 0.75rem; color: #cfcfcb; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
/* labelled numbers in the player's colour (lightened if it's dark: main.js readable) */
.player .stats { flex: none; display: flex; gap: 7px; }
.player .stat { display: flex; flex-direction: column; align-items: center; line-height: 1; min-width: 26px; position: relative; }
.player .stat small { font-size: 0.58rem; text-transform: uppercase; letter-spacing: .06em; color: #cfcfcb; margin-bottom: 3px; }
.player .stat b { font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.player .stat b.over { text-decoration: underline wavy #ff7a45; }
.player .stat .change { margin-top: 3px; }
/* the move's capacity change: lime going up, orange going down, a dash when there's no move (user, 2026-10-17) */
.player .stat.move b { color: #8a8a86; }
.player .stat.move b.up { color: #b4f341; }
.player .stat.move b.down { color: #ff7a45; }
/* what the move being set up would change: up or down */
.player .change { font-size: 0.7rem; font-weight: 800; padding: 0 5px; border-radius: 999px; }
.player .change.up { background: #b4f341; color: #1b2a05; }
.player .change.down { background: #ff7a45; color: #2a2a2c; }
/* on a phone: the numbers go on their own row under the name, so the name keeps its room */
@media (max-width: 420px) {
  .players { gap: 6px; }
  .player { flex-wrap: wrap; padding: 6px 8px; gap: 4px; border-left-width: 5px; }
  .player .main { flex-basis: 100%; }
  .player .nums { display: none; }
  .player .stats { width: 100%; justify-content: space-between; gap: 4px; }
  .player .change { font-size: 0.65rem; padding: 0 4px; }
  .player .you { font-size: 0.6rem; padding: 0 4px; }
}
.turn { background: var(--charcoal); color: var(--white); padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; }
.left { background: #ffd23f; color: var(--charcoal); padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; }   /* the value still to place: the move's yellow */

@media (max-width: 420px) {
  .creatures { grid-template-columns: repeat(3, 1fr); gap: 6px; }
}

/* "Your turn": a card that pops up in the middle when the turn passes to you (user, 2026-10-17) */
.alert-card { position: fixed; left: 50%; top: 40%; z-index: 6; transform: translate(-50%, -50%) scale(0.9); opacity: 0; pointer-events: none;
  background: var(--white); color: var(--charcoal); border: 3px solid #ffd23f; border-radius: 14px; padding: 16px 28px;
  font-size: 1.4rem; font-weight: 700; box-shadow: 0 10px 30px rgba(0, 0, 0, .25); transition: opacity .25s, transform .25s; }
.alert-card.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
@media (prefers-reduced-motion: reduce) { .alert-card { transition: none; } }

/* the turn's countdown, next to whose turn it is: a minute a turn, red for the last 10 seconds (user, 2026-10-17) */
.turn-row { display: flex; gap: 6px; align-items: center; }
.clock { background: var(--charcoal); color: var(--white); padding: 2px 10px; border-radius: 999px; font-size: 1.1rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.clock.low { background: #c2410c; }
/* the warning 10 seconds before your time runs out (user, 2026-10-17) */
.alert-card.hurry { border-color: #c2410c; color: #c2410c; }
.lobby-links { display: flex; justify-content: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
/* the leaderboard in the lobby: the top 10, then your own rating and place (user, 2026-10-17) */
.board ol { margin: 0; padding: 0; list-style: none; counter-reset: place; }
.board li { counter-increment: place; display: flex; align-items: center; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
.board li::before { content: counter(place); width: 1.4em; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.board li .who { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li b { font-variant-numeric: tabular-nums; }
.board li.you { font-weight: 700; }
/* the coach in "Learn to play" (user, 2026-10-17): what to do next, above the move's own line */
.coach { border-left: 5px solid #b4f341; background: rgba(180, 243, 65, .16); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; }
.coach p { margin: 0; font-weight: 600; }
.coach button { margin-top: 8px; }
/* How to play (user, 2026-10-17): six short steps, each with a picture from the practice game */
.rules ol { margin: 0 0 10px; padding-left: 1.3em; }
.rules li { margin-bottom: 12px; }
.rules li img { display: block; width: 100%; height: auto; border-radius: 10px; margin: 6px 0 2px; }

/* while the server wakes (user, 2026-11-10): a little scene, a bar that fills over a minute (and races to the end as
   soon as the server answers) and a changing funny line */
.wake-scene { display: block; width: 100%; aspect-ratio: 2 / 1; border-radius: 10px; background: linear-gradient(#bfe3f5, #e3f3fb); margin-bottom: 10px; }
.wake-bar { height: 12px; border-radius: 999px; background: #dfe7e2; overflow: hidden; margin: 10px 0 6px; box-shadow: inset 0 1px 2px rgba(0,0,0,.15); }
.wake-bar span { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(#cfff7a, #b4f341 55%, #93d22c); transition: width .3s linear; }
.wake-bar.done span { transition: width .45s ease-out; }
.wake-line { min-height: 1.3em; margin: 0; font-size: .9rem; }
