/* Shared styles for the game page (index.html) and the results page (history.html).
   Game page layout: hamster cam on the left, the game card on the right; players and the watcher log below. */
:root {
  color-scheme: dark;
  --bg: #0d1126; --panel: #161c3a; --line: #2b3463; --ink: #eef0ff; --ink-2: #aab2d8; --ink-3: #7f88b5;
  --wheel: #f2c94c; --sqk: #e8913a; --good: #3ccf7a; --bad: #ef5d5d; --warn: #f5b84a;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
}
* { box-sizing: border-box; }
/* Elements switched off with the hidden attribute stay hidden even when their own style sets a display. */
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 16px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
header, main { max-width: 1080px; margin: 0 auto; }
header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-block: 20px 8px; }
h1 { font-family: var(--pixel); font-size: 1.05rem; line-height: 1.6; margin: 0; color: var(--wheel); }
/* Squeek Out wordmark: the O of OUT is Squeektoshi's wheel, turning slowly */
.brand { display: grid; gap: 4px; text-decoration: none; color: var(--wheel); }
.wordmark { display: inline-flex; align-items: center; font-family: var(--pixel); font-size: clamp(1.05rem, 3.4vw, 1.5rem); line-height: 1; letter-spacing: 0.02em;
  text-shadow: 3px 3px 0 #1a1405; white-space: nowrap; }
.wheel-o { width: 1.05em; height: 1.05em; margin: 0 0.04em 0 0.55em; filter: drop-shadow(3px 3px 0 #1a1405); animation: wheel-turn 6s linear infinite; }
@keyframes wheel-turn { to { transform: rotate(360deg); } }
.tagline { font-family: var(--body); font-size: 0.82rem; font-weight: 700; color: var(--ink-2); letter-spacing: 0.01em; }
@media (prefers-reduced-motion: reduce) { .wheel-o { animation: none; } }
h2 { font-family: var(--pixel); font-size: 0.7rem; letter-spacing: 0.04em; margin: 0 0 12px; color: var(--ink-2); }
main { display: grid; gap: 18px; padding-block: 8px 48px; }
.top { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 780px) { .top { grid-template-columns: 1fr; } }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px; min-width: 0; }
canvas { width: 100%; aspect-ratio: 4 / 3; image-rendering: pixelated; border-radius: 8px; display: block; background: #141a33; }
.camwrap { position: relative; }
/* Cartoon or the X livestream of the real Squeektoshi */
.cam-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.cam-head h2 { margin: 0; }
.view-toggle { display: inline-flex; gap: 4px; }
.view-toggle button { padding: 6px 10px; font-size: 0.8rem; }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.livewrap { aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #000; display: grid; place-items: center; }
.livewrap iframe { width: 100%; height: 100%; border: 0; display: block; }
.livewrap p { color: var(--ink-2); padding: 16px; text-align: center; margin: 0; }
.camwrap.live canvas { display: none; }
.camwrap.live .hud-count { pointer-events: none; }
.camwrap.live .hud-feed { position: static; border-radius: 0 0 8px 8px; } /* below the video, clear of the player's controls */
.hud-count { position: absolute; top: 10px; left: 10px; display: grid; justify-items: start; gap: 2px; padding: 8px 12px;
  background: rgba(13, 17, 38, 0.82); border: 1px solid var(--line); border-radius: 8px; }
.hud-count b { font-family: var(--pixel); font-size: 1.15rem; line-height: 1.2; color: var(--wheel); font-variant-numeric: tabular-nums; }
.hud-count small { font-size: 0.7em; color: var(--ink-2); }
.hud-count > span { font-size: 0.72rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; }
.hud-feed { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; padding: 8px 12px; list-style: none; display: grid; gap: 2px;
  background: linear-gradient(to top, rgba(13, 17, 38, 0.92), rgba(13, 17, 38, 0.72)); border-radius: 0 0 8px 8px;
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.45; }
.hud-feed li { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.hud-feed li:first-child { color: var(--ink); }
.hud-feed li:nth-child(3) { opacity: 0.6; }
.hud-feed li.fresh { animation: hud-in 0.5s ease-out; }
.hud-feed .when { color: var(--ink-3); margin-right: 8px; }
.hud-feed .off { color: var(--good); } .hud-feed .bad { color: var(--bad); } .hud-feed .ham { color: var(--wheel); }
@keyframes hud-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .hud-feed li.fresh { animation: none; } }
@media (max-width: 480px) { .hud-feed li:nth-child(3) { display: none; } .hud-feed { font-size: 0.72rem; } .hud-count b { font-size: 0.9rem; } }
.cam-status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 12px; align-items: baseline; }
.mode { font-family: var(--pixel); font-size: 0.72rem; line-height: 1.7; }
.mode.running { color: var(--good); } .mode.paused { color: var(--warn); } .mode.asleep { color: var(--ink-2); } .mode.signal-lost { color: var(--bad); }
.countdown { font-family: var(--mono); font-size: 1.6rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.timer { display: grid; justify-items: end; line-height: 1.2; }
.timer-lbl { font-size: 0.75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.06em; }
.muted { color: var(--ink-2); font-size: 0.92rem; }
a { color: var(--wheel); }
.pill { display: inline-block; font-family: var(--mono); font-size: 0.8rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line); }
.facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 14px 0; }
.facts div { display: grid; }
.facts b { font-family: var(--mono); font-size: 1.05rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts span { color: var(--ink-3); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.you { border-top: 1px solid var(--line); padding-top: 14px; display: grid; gap: 10px; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 0; padding: 12px 16px; font-weight: 700; }
button.primary { background: var(--wheel); color: #1a1405; font-family: var(--pixel); font-size: 0.72rem; line-height: 1.6; padding: 16px; }
button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--wheel); outline-offset: 2px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions button.primary { flex: 1 1 100%; }
.msg { font-size: 0.9rem; min-height: 1.4em; }
.msg.error { color: var(--bad); }
.tablewrap { overflow-x: auto; }
#players td:first-child { max-width: 24ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table { border-collapse: collapse; width: 100%; font-family: var(--mono); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-3); font-family: var(--body); font-weight: 700; font-size: 0.78rem; }
.bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 780px) { .bottom { grid-template-columns: 1fr; } }
.log { font-family: var(--mono); font-size: 0.8rem; max-height: 320px; overflow: auto; display: grid; gap: 6px; }
.log div { color: var(--ink-2); overflow-wrap: anywhere; }
.log b { color: var(--ink); }
.demo-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.demo-row button { padding: 8px 12px; }
.speed { display: inline-flex; gap: 4px; }
.speed button { padding: 6px 10px; font-family: var(--mono); font-weight: 600; }
.speed button[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.beta-strip { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; justify-content: center; padding: 8px 16px;
  background: #3a2a08; color: #ffe2a3; border-bottom: 1px solid var(--warn); font-size: 0.88rem; text-align: center; }
.beta-strip b { font-family: var(--pixel); font-size: 0.62rem; color: #1a1405; background: var(--warn); padding: 4px 6px; border-radius: 4px; }
.beta-strip button { background: none; border: none; padding: 0; color: inherit; text-decoration: underline; font: inherit; cursor: pointer; }
dialog.beta { max-width: 460px; width: calc(100% - 32px); background: var(--panel, #141a33); color: var(--ink); border: 1px solid var(--warn);
  border-radius: 12px; padding: 22px; }
dialog.beta::backdrop { background: rgba(5, 7, 18, 0.75); }
dialog.beta h2 { margin: 0 0 10px; font-family: var(--pixel); font-size: 0.9rem; line-height: 1.6; color: var(--warn); }
dialog.beta ul { margin: 0 0 16px; padding-left: 20px; display: grid; gap: 6px; }
dialog.beta form { display: flex; flex-wrap: wrap; gap: 10px; }
dialog.beta button { flex: 1 1 auto; }
.wallet-list { display: grid; gap: 8px; margin-bottom: 14px; }
.wallet-list button { display: flex; align-items: center; gap: 12px; text-align: left; background: rgba(13, 17, 38, 0.6); color: var(--ink); border: 1px solid var(--line); }
.wallet-list button:hover { border-color: var(--wheel); }
.wallet-list img { width: 28px; height: 28px; border-radius: 6px; }
button.small { padding: 8px 12px; font-size: 0.85rem; }
.banner { border: 1px dashed var(--wheel); color: var(--wheel); border-radius: 10px; padding: 10px 14px; font-size: 0.92rem; }
.howto { display: grid; gap: 14px; }
.howto ol { margin: 0; padding-left: 1.4em; display: grid; gap: 10px; max-width: 70ch; }
.howto ol b { color: var(--wheel); }
.howto ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; color: var(--ink-2); max-width: 70ch; }
.howto h3 { font-family: var(--pixel); font-size: 0.62rem; color: var(--ink-2); margin: 6px 0 0; letter-spacing: 0.04em; }

/* Navigation between the game and the results */
.nav { display: flex; gap: 4px; margin-right: auto; margin-left: 12px; }
.nav a { font-family: var(--pixel); font-size: 0.6rem; text-decoration: none; color: var(--ink-2); padding: 8px 10px; border-radius: 8px; }
.nav a[aria-current="page"] { color: var(--bg); background: var(--wheel); }
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"]:hover { color: var(--bg); }
@media (max-width: 480px) { .nav { margin-left: 0; } }

/* The last 10 seconds of a break, over the wheel */
.final-count { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--pixel); font-size: clamp(4rem, 18vw, 9rem); color: var(--warn);
  text-shadow: 0 0 0 #000, 6px 6px 0 #1a1405, 0 0 40px rgba(245, 184, 74, 0.55); background: rgba(13, 17, 38, 0.35); border-radius: 8px; }
.final-count.last { color: var(--bad); text-shadow: 6px 6px 0 #2a0808, 0 0 48px rgba(239, 93, 93, 0.7); }
.final-count.tick { animation: count-pop 0.9s ease-out; }
@keyframes count-pop { 0% { transform: scale(1.6); opacity: 0; } 20% { transform: scale(1); opacity: 1; } 100% { transform: scale(0.92); opacity: 0.85; } }

/* The celebration when a game ends */
dialog.finale { width: min(560px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; padding: 0; border: 2px solid var(--wheel);
  border-radius: 16px; background: var(--panel); color: var(--ink); box-shadow: 0 0 0 6px rgba(242, 201, 76, 0.15), 0 20px 80px rgba(0, 0, 0, 0.6); }
dialog.finale::backdrop { background: rgba(5, 7, 18, 0.82); }
dialog.finale[open] { animation: finale-in 0.6s cubic-bezier(0.2, 1.4, 0.4, 1); }
@keyframes finale-in { from { transform: scale(0.6) translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; margin: 0; padding: 0; border: 0; background: transparent;
  pointer-events: none; image-rendering: pixelated; } /* a popover, so it can sit above the celebration dialog */
.finale-card { padding: 26px 22px 22px; display: grid; gap: 14px; text-align: center; }
.finale-kicker { margin: 0; font-family: var(--mono); color: var(--ink-3); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.finale-title { margin: 0; font-family: var(--pixel); font-size: clamp(1.4rem, 6vw, 2.2rem); line-height: 1.3; color: var(--wheel);
  text-shadow: 4px 4px 0 #1a1405; animation: title-glow 1.6s ease-in-out infinite alternate; }
@keyframes title-glow { from { filter: drop-shadow(0 0 0 rgba(242, 201, 76, 0)); } to { filter: drop-shadow(0 0 14px rgba(242, 201, 76, 0.6)); } }
.finale-sub { margin: 0; color: var(--ink-2); }
.finale-you { margin: 0; font-family: var(--pixel); font-size: 0.8rem; line-height: 1.8; padding: 12px; border-radius: 10px; }
.finale-you.won { background: rgba(60, 207, 122, 0.14); color: var(--good); border: 1px solid var(--good); }
.finale-you.caught { background: rgba(239, 93, 93, 0.12); color: var(--bad); border: 1px solid var(--bad); }
.podium { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; text-align: left; }
.podium li { display: grid; grid-template-columns: 2.2em minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(13, 17, 38, 0.55); animation: row-in 0.5s ease-out both; }
.podium li.mine { border-color: var(--good); }
.podium .medal { font-size: 1.4rem; text-align: center; }
.podium .rank { font-family: var(--pixel); font-size: 0.7rem; color: var(--ink-3); text-align: center; }
.podium .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium .who small { display: block; color: var(--ink-3); font-family: var(--mono); font-size: 0.75rem; }
.podium .amt { font-family: var(--mono); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--wheel); }
.tag { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px; font-family: var(--pixel); font-size: 0.5rem;
  line-height: 1.8; vertical-align: middle; background: var(--sqk); color: #1a1405; }
@keyframes row-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.finale-actions #finaleClaim { flex-basis: 100%; }
.unclaimed { display: grid; gap: 8px; border-top: 1px dashed var(--line); padding-top: 12px; }
.unclaimed p { margin: 0; color: var(--good); font-weight: 700; }
.finale-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.finale-actions > * { flex: 1 1 180px; }
a.button { display: inline-block; text-align: center; text-decoration: none; border-radius: 10px; padding: 12px 16px; font-weight: 700;
  color: var(--ink); border: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) {
  .final-count.tick, dialog.finale[open], .finale-title, .podium li { animation: none; }
}

/* Results page */
.history { display: grid; gap: 14px; }
.result { display: grid; gap: 12px; }
.result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 14px; }
.result-head h2 { margin: 0; color: var(--wheel); font-size: 0.8rem; }
.result-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; color: var(--ink-2); font-size: 0.9rem; }
.result-facts b { color: var(--ink); font-family: var(--mono); font-weight: 600; }
.pill.settled { border-color: var(--good); color: var(--good); } .pill.voided, .pill.rolled { border-color: var(--warn); color: var(--warn); }
.pill.live { border-color: var(--wheel); color: var(--wheel); }
.result details summary { cursor: pointer; color: var(--ink-2); font-size: 0.9rem; }
.result td.caught { color: var(--bad); }
/* Results table: fits a phone without sideways scrolling; long names shorten with "…". */
table.results { table-layout: fixed; }
table.results th:nth-child(1) { width: 46%; } table.results th:nth-child(2) { width: 22%; } table.results th:nth-child(3) { width: 32%; }
table.results td { white-space: normal; vertical-align: top; }
table.results td.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.results .medal { display: inline-block; width: 1.6em; }
table.results td small { display: block; color: var(--ink-3); font-size: 0.75rem; }
table.results td.pay { text-align: right; } table.results th:nth-child(3) { text-align: right; }
table.results .tag { display: block; width: max-content; margin: 4px 0 0 auto; }
@media (max-width: 480px) { table.results { font-size: 0.78rem; } table.results th, table.results td { padding: 7px 4px; } table.results .medal { width: 1.3em; } }
.result td .tag { margin-left: 8px; }
.result tr.mine td { color: var(--good); }
