/* 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; }

.small { font-size: 0.85rem; }
#quick-match, #cancel { width: 100%; margin-top: 8px; }
.stats { color: var(--muted); font-size: 0.85rem; }
.lobby-links { display: flex; justify-content: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }

/* the army picker: a card for each beast, with its live picture, its perk, and - / + to set how many you bring */
.panel.lobby { width: min(720px, calc(100% - 32px)); padding-bottom: 0; }
/* Quick battle stays in sight at the bottom while the cards scroll */
.lobby-foot { position: sticky; bottom: 0; background: var(--panel); padding: 4px 0 12px; margin-top: 8px; border-top: 1px solid var(--line); }
.lobby-head { display: flex; justify-content: space-between; align-items: baseline; }
.places { font-weight: 800; font-variant-numeric: tabular-nums; padding: 2px 10px; border-radius: 999px; background: #ffd23f; color: var(--charcoal); }
.places.full { background: #b4f341; color: #1b2a05; }
.army { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 8px; }
.beast { border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 4px; }
.beast.on { border: 2px solid #5a9419; padding: 5px; background: rgba(180, 243, 65, .14); }
.beast .preview { display: block; width: 100%; aspect-ratio: 150 / 110; border-radius: 8px; background: #cfe6f5; }
.beast .title { display: flex; justify-content: space-between; align-items: baseline; gap: 4px; font-weight: 700; }
.beast .title small { font-weight: 600; color: var(--muted); font-size: 0.72rem; white-space: nowrap; }
.beast p { margin: 0; font-size: 0.78rem; line-height: 1.3; color: var(--muted); flex: 1; }
.stepper { display: flex; align-items: center; justify-content: space-between; gap: 4px; }
.stepper button { min-height: 36px; width: 40px; padding: 0; font-size: 1.2rem; font-weight: 700; }
.stepper b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) {
  .army { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .beast p { font-size: 0.72rem; }
}

#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(560px, 100%); }
/* the players' cards (as in Fieldgame): dark grey, the player's colour down the left, lime round whose turn it is */
.player { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 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 .stat { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.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; }
.turn { background: var(--charcoal); color: var(--white); padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; }
.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; }
.scouted { background: rgba(255, 255, 255, .9); color: var(--charcoal); padding: 3px 12px; border-radius: 999px; font-size: 0.8rem; }

/* "Your turn" and the 10-second warning: cards that pop up in the middle (as in Fieldgame) */
.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); }
.alert-card.hurry { border-color: #c2410c; color: #c2410c; }
@media (prefers-reduced-motion: reduce) { .alert-card { transition: none; } }

/* the battle panel: what to do, the lines to beat (numbered as on the field), your beasts, Confirm */
.battle { width: min(560px, calc(100% - 32px)); padding: 12px; max-height: 58%; overflow: auto; }
.battle p { margin: 4px 0; }
.last { font-size: 0.85rem; background: rgba(255, 210, 63, .25); border-radius: 8px; padding: 4px 8px; }
.lines { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.line { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 8px 4px 4px; border-radius: 10px; font-size: 0.85rem;
  background: transparent; color: var(--text); border: 1px solid var(--line); }
.line .n { width: 24px; height: 24px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800;
  background: #2a2a2c; color: #fff; border: 3px solid var(--pc, #888); font-size: 0.75rem; }
.line.diamond .n { border-radius: 4px; }
.line.on { border: 2px solid #5a9419; background: rgba(180, 243, 65, .2); }
.line.bad { border-color: #c2410c; }
.line .vs { color: var(--muted); }
.pick { background: #ffd23f; color: var(--charcoal); border-radius: 6px; padding: 1px 6px; font-weight: 700; }
.pick.empty { background: none; border: 1px dashed var(--muted); color: var(--muted); font-weight: 400; }
.problem { color: #c2410c; font-size: 0.85rem; min-height: 1.2em; }
.tray { display: flex; flex-wrap: wrap; gap: 6px; padding-bottom: 2px; }
.tray button { flex: none; flex-direction: column; gap: 0; width: 76px; min-height: 0; padding: 4px 2px; font-size: 0.72rem; line-height: 1.2;
  background: transparent; color: var(--text); border: 1px solid var(--line); }
.tray button b { font-size: 0.95rem; }
.tray button .preview { width: 68px; aspect-ratio: 150 / 110; border-radius: 6px; background: #cfe6f5; }
.tray button:disabled { opacity: .35; }
.actions { align-items: center; margin-top: 8px; }
.actions .grow { flex: 1; }
.record { margin-top: 6px; font-size: 0.85rem; border-top: 1px solid var(--line); padding-top: 6px; }
.record ul { margin: 0; padding-left: 1.2em; }

.rules ol { margin: 0 0 10px; padding-left: 1.3em; }
.rules li { margin-bottom: 8px; }
.rules-beasts { padding-left: 1.2em; margin: 0 0 10px; }
.rules-beasts li { margin-bottom: 4px; }
/* on a phone the battle panel keeps to the bottom part, so the field shows above it */
@media (max-width: 420px) {
  .battle { max-height: 46%; padding: 10px; bottom: 10px; }
  .battle p { font-size: 0.85rem; }
  .last { font-size: 0.78rem; }
  .line { min-height: 34px; font-size: 0.8rem; }
  .tray { flex-wrap: nowrap; overflow-x: auto; }
  .tray button { width: 62px; font-size: 0.68rem; }
  .tray button .preview { width: 54px; }
  .actions { margin-top: 6px; }
  .actions button { min-height: 40px; }
}
#lobby-msg:empty { display: none; }

/* 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; }
