/* Snowball Showdown — full-screen game. Club colours: red #cc0000, black #111. */
:root {
  --red: #cc0000;
  --red-dark: #9e0000;
  --ink: #111;
  --gold: #f2c14e;
  --ice: #e8f4ff;
  --night: #0b1730;
  --font-h: 'Bebas Neue', Impact, sans-serif;
  --font-b: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: #fff; font-family: var(--font-b); }
body { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; }
canvas#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

/* Screens */
.screen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(11, 23, 48, .55), rgba(11, 23, 48, .85)); z-index: 20; overflow-y: auto; }
.screen[hidden] { display: none; }
.card { width: min(440px, 100%); background: rgba(255, 255, 255, .97); color: var(--ink); border-radius: 18px; padding: 22px 22px 18px;
  text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); position: relative; border-top: 8px solid var(--red); margin: auto; }
.card.left { text-align: left; }
.card h1 { font-family: var(--font-h); font-weight: 400; font-size: clamp(44px, 12vw, 64px); line-height: .9; margin: 4px 0 10px; letter-spacing: 1px; color: var(--red); }
.card h2 { font-family: var(--font-h); font-weight: 400; font-size: 36px; margin: 0 0 10px; letter-spacing: .5px; }
.kicker { text-transform: uppercase; letter-spacing: .14em; font-size: 12px; font-weight: 800; color: #555; margin: 0; }
.lead { font-size: 15px; margin: 0 0 14px; color: #333; }
.badge-hero { width: 96px; height: 96px; margin: -60px auto 4px; display: block; filter: drop-shadow(0 6px 12px rgba(0,0,0,.35)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-4deg); } }
@media (prefers-reduced-motion: reduce) { .badge-hero { animation: none; } }

.btn { display: inline-block; border: 0; border-radius: 999px; padding: 11px 20px; font: 700 15px var(--font-b); cursor: pointer;
  background: var(--ink); color: #fff; margin: 4px; text-decoration: none; }
.btn.big { display: block; width: 100%; margin: 12px 0 6px; padding: 15px; font-size: 20px; background: var(--red); box-shadow: 0 5px 0 var(--red-dark); }
.btn.big:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--red-dark); }
.btn.ghost { background: transparent; color: var(--ink); border: 2px solid var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; }
.link { background: none; border: 0; color: var(--red); text-decoration: underline; cursor: pointer; font: inherit; padding: 0 4px; }
.back { display: inline-block; margin-top: 10px; color: #555; font-size: 14px; }

.player { background: #f3f6fb; border-radius: 12px; padding: 10px; margin: 6px 0; font-size: 15px; }
.pill { display: inline-block; background: var(--ink); color: #fff; border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 700; vertical-align: 1px; }
.player-form { display: grid; gap: 10px; text-align: left; margin: 6px 0; }
.player-form[hidden] { display: none; }
.player-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 700; }
.player-form input, .player-form select { font: 16px var(--font-b); padding: 10px 12px; border: 2px solid #d8dde6; border-radius: 10px; background: #fff; color: var(--ink); width: 100%; }
.player-form input:focus, .player-form select:focus { outline: none; border-color: var(--red); }
.player-form small { color: #666; font-size: 12px; }
.msg { font-size: 14px; font-weight: 600; margin: 4px 0; color: var(--red-dark); }
.msg.good { color: #1f6b45; }

.how { padding-left: 4px; list-style: none; margin: 0 0 6px; }
.how li { margin: 9px 0; font-size: 15px; line-height: 1.35; }
.new { background: #fff7e0; border: 2px dashed var(--gold); border-radius: 12px; padding: 10px; font-size: 15px; font-weight: 600; margin: 4px 0 6px; }
.tally { list-style: none; padding: 0; margin: 8px 0; font-size: 16px; }
.tally li { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 1px solid #eee; }
.tally li.total { font-weight: 800; font-size: 18px; border-bottom: 0; }

/* Leaderboard */
.board .tabs { display: flex; gap: 6px; justify-content: center; margin-bottom: 8px; }
.tab { border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 6px 14px; font: 700 13px var(--font-b); cursor: pointer; }
.tab.on { background: var(--ink); color: #fff; }
.board-list { list-style: none; counter-reset: r; padding: 0; margin: 0 0 8px; text-align: left; }
.board-list li { counter-increment: r; display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 8px; padding: 8px 6px; border-bottom: 1px solid #eee; font-size: 15px; }
.board-list li::before { content: counter(r); font-family: var(--font-h); font-size: 24px; color: #999; text-align: center; }
.board-list li:nth-child(1)::before { content: '🥇'; font-size: 22px; }
.board-list li:nth-child(2)::before { content: '🥈'; font-size: 22px; }
.board-list li:nth-child(3)::before { content: '🥉'; font-size: 22px; }
.board-list li.me { background: #fff1f1; border-radius: 8px; font-weight: 800; }
.board-list li.muted { display: block; color: #777; text-align: center; }
.board-list li.muted::before { content: none; }
.board-list .who small { color: #777; font-weight: 600; margin-left: 4px; }
.board-list .pts { font-family: var(--font-h); font-size: 22px; letter-spacing: .5px; }

/* HUD */
.hud { position: absolute; top: 0; left: 0; right: 0; z-index: 10; display: grid; grid-template-columns: 1fr auto 1fr; align-items: start;
  padding: max(10px, env(safe-area-inset-top)) 12px 18px; pointer-events: none; text-shadow: 0 2px 6px rgba(0,0,0,.6);
  background: linear-gradient(rgba(6,13,31,.35), rgba(6,13,31,.2) 70%, rgba(6,13,31,0)); }
.hud[hidden] { display: none; }
.hud-level { font-family: var(--font-h); font-size: 26px; letter-spacing: .5px; }
.hud-hits { font-size: 14px; font-weight: 700; }
.hud-hits b { color: var(--gold); font-size: 18px; }
.hud-mid { text-align: center; }
.hud-balls { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; max-width: 46vw; }
.hud-balls i { width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff, #cfe3f7 70%, #9fbfe0); box-shadow: 0 1px 3px rgba(0,0,0,.5); display: inline-block; }
.hud-balls i.used { opacity: .18; }
.hud-wind { margin-top: 6px; font-size: 14px; font-weight: 700; background: rgba(0,0,0,.35); border-radius: 999px; padding: 2px 10px; display: inline-block; }
.hud-wind[hidden] { display: none; }
#windArrow { display: inline-block; transition: transform .4s; }
.hud-right { text-align: right; padding-right: 88px; }
.hud-score { font-family: var(--font-h); font-size: 34px; line-height: 1; letter-spacing: 1px; }
.hud-combo { font-weight: 800; color: var(--gold); font-size: 15px; min-height: 18px; }
.hud-buttons { position: absolute; right: 12px; top: max(58px, calc(env(safe-area-inset-top) + 48px)); pointer-events: auto; }

.corner { position: absolute; top: max(10px, env(safe-area-inset-top)); right: 12px; z-index: 30; display: flex; gap: 6px; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 17px; cursor: pointer; backdrop-filter: blur(4px); }
.icon-btn:hover { background: rgba(255,255,255,.3); }
.hud-buttons .icon-btn { font-size: 13px; }

@media (max-width: 560px) {
  .hud { grid-template-columns: 1fr 1fr; }
  .hud-mid { grid-column: 1 / -1; grid-row: 2; margin-top: 4px; }
  .hud-right { padding-right: 88px; }
  .hud-balls { max-width: 90vw; }
  .hud-balls i { width: 13px; height: 13px; }
}

.prize-note { background: #fff7e0; border: 2px dashed var(--gold); border-radius: 12px; padding: 8px 10px; font-size: 14px; margin: 8px 0; }
.prize-note a { color: var(--red); }

.tagline { font-weight: 800; font-size: 17px; color: var(--ink); margin: -4px 0 10px; }

/* Countdown to Father Christmas's deliveries (bottom-left, doesn't block taps) */
.santa { position: absolute; left: max(12px, env(safe-area-inset-left)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 15;
  display: flex; align-items: center; gap: 8px; pointer-events: none; background: rgba(11, 23, 48, .82); color: #fff;
  border: 2px solid rgba(255,255,255,.25); border-radius: 14px; padding: 6px 12px 6px 8px; box-shadow: 0 6px 18px rgba(0,0,0,.35); }
.santa-icon { font-size: 30px; line-height: 1; animation: santa-bob 2.4s ease-in-out infinite; }
@keyframes santa-bob { 50% { transform: translateY(-3px) rotate(-6deg); } }
.santa-text { display: flex; flex-direction: column; line-height: 1.15; }
#santaLabel { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #ffd7d7; }
#santaTime { font-family: var(--font-h); font-weight: 400; font-size: 24px; letter-spacing: 1px; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) {
  .santa { padding: 4px 9px 4px 6px; gap: 6px; }
  .santa-icon { font-size: 22px; }
  #santaLabel { font-size: 9px; }
  #santaTime { font-size: 17px; }
  .santa { max-width: calc(50vw - 36px); }
}
@media (prefers-reduced-motion: reduce) { .santa-icon { animation: none; } }

/* Penalty shoot-out bonus level */
.bonus-flash { position: absolute; left: 50%; top: max(84px, calc(env(safe-area-inset-top) + 74px)); transform: translateX(-50%); z-index: 12;
  font-family: var(--font-h); font-size: clamp(30px, 7vw, 54px); letter-spacing: 2px; color: #f2c14e; pointer-events: none; white-space: nowrap;
  text-shadow: 0 0 10px rgba(242,193,78,.9), 0 3px 0 #9e0000, 0 6px 14px rgba(0,0,0,.6); animation: bonus-flash .8s steps(1, end) infinite; }
.bonus-flash[hidden] { display: none; }
.bonus-flash small { display: block; text-align: center; font-size: .42em; letter-spacing: 1px; margin-top: 2px; }
@keyframes bonus-flash { 0% { opacity: 1; color: #f2c14e; } 50% { opacity: 1; color: #ffffff; text-shadow: 0 0 14px #fff, 0 3px 0 #cc0000, 0 6px 14px rgba(0,0,0,.6); } }
h1.flash { animation: card-flash .8s steps(1, end) infinite; }
@keyframes card-flash { 0% { color: var(--red); } 50% { color: #d99a00; } }
@media (prefers-reduced-motion: reduce) { .bonus-flash, h1.flash { animation: none; } }
.hud-balls i.pen { background: radial-gradient(circle at 50% 50%, #222 0 28%, #fff 30%); border: 1px solid #222; }
.pen-team { display: block; margin-top: 10px; font-weight: 700; }
.pen-team select { margin-left: 6px; padding: 6px 8px; border-radius: 8px; border: 1px solid #c9c9c9; font: inherit; font-weight: 600; background: #fff; }
.hud-time { margin-top: 6px; font-size: 24px; font-weight: 900; background: rgba(0,0,0,.4); border-radius: 999px; padding: 3px 16px; line-height: 1.2; display: inline-block; font-variant-numeric: tabular-nums; }
.hud-time[hidden] { display: none; }
.hud-time.low { background: #cc0000; color: #fff; animation: hud-flash .5s steps(1) infinite; }
@keyframes hud-flash { 50% { background: #fff; color: #cc0000; } }
@media (prefers-reduced-motion: reduce) { .hud-time.low { animation: none; } }
.over-title { font-family: var(--font-h); font-size: clamp(48px, 13vw, 76px); line-height: .9; letter-spacing: 2px; text-transform: uppercase; color: #0b1730; margin: 0 0 6px; }
.team-note { font-size: 13px; color: #555; margin: 0 0 8px; }
.share-btn { background: #25a35a; box-shadow: 0 4px 0 #17733e; margin: 4px auto 10px; display: block; }
.share-btn[hidden] { display: none; }
