/* Walkers Serve - frame, screens, buttons, menu, result, form, leaderboard.
   Portrait-only: everything lives inside a centred 9:16 (max) frame.
   --u is 1% of the frame width, set from JS (main.js layout()).
   Palette follows the Walkers brand: red + yellow primary, with the
   Cheese & Onion blue as the secondary accent. */

:root {
  --u: 4px;
  --ink: #2b1810;
  --red: #e2231a;
  --red-dk: #a3140d;
  --teal: #1e5fb4;
  --teal-dk: #123f7a;
  --yellow: #ffcc00;
  --cream: #fff4d6;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none;
  background: #2b1533; color: var(--ink);
  font-family: "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-weight: 700; -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}

#app {
  position: fixed; inset: 0; display: flex; justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(226,35,26,.30), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255,204,0,.22), transparent 40%),
    #22120c;
}

#frame {
  position: relative; height: 100%; width: min(100%, 56.25vh); width: min(100%, 56.25dvh);
  overflow: hidden; background: linear-gradient(180deg, #ffd94d 0%, #e2231a 100%);
  box-shadow: 0 0 0 4px rgba(0,0,0,.35), 0 0 80px rgba(0,0,0,.6);
  font-size: calc(var(--u) * 4.3);
  user-select: none; -webkit-user-select: none;
}

.screen {
  position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
  padding: 1em; overflow: hidden;
}
.screen.active { display: flex; }

/* ---------- shared bits ---------- */
.panel {
  position: relative; width: 100%; max-width: 24em; text-align: center;
  background: #fff; border: .2em solid var(--ink); border-radius: 1.4em;
  box-shadow: 0 .35em 0 rgba(0,0,0,.25); padding: 1.1em 1.2em 1.3em;
}
h1, h2 { margin: 0; font-weight: 900; line-height: 1; }
h2 { font-size: 1.7em; color: var(--red); text-shadow: 0 .06em 0 rgba(0,0,0,.12); }

.btn {
  font: inherit; font-weight: 900; font-size: 1.1em; color: #fff; letter-spacing: .02em;
  background: var(--red); border: 0; border-bottom: .28em solid var(--red-dk); border-radius: 1em;
  padding: .55em 1.5em; min-height: 48px; cursor: pointer; touch-action: manipulation;
  text-shadow: 0 .08em 0 rgba(0,0,0,.25); transition: transform .08s, filter .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:active { transform: translateY(.15em); border-bottom-width: .13em; }
.btn:disabled { filter: grayscale(.6) brightness(.9); cursor: default; }
.btn-big { font-size: 1.6em; padding: .5em 1.8em; }
.btn-alt { background: var(--teal); border-bottom-color: var(--teal-dk); }
.btn-row { display: flex; gap: .7em; justify-content: center; flex-wrap: wrap; margin-top: .9em; }

#btn-play { animation: breathe 1.7s ease-in-out infinite; }
#btn-play:hover, #btn-play:active { animation-play-state: paused; }
.btn-play-label { display: inline-block; font-size: 1.3em; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.045); } }
.btn:focus-visible, input:focus-visible, .icon-btn:focus-visible { outline: .18em solid #2b6fe0; outline-offset: .1em; }

.icon-btn {
  position: absolute; top: 10px; right: 10px; width: 48px; height: 48px; padding: 9px; z-index: 30;
  border-radius: 50%; border: 4px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.25); touch-action: manipulation;
}
.icon-btn svg { width: 100%; height: 100%; display: block; }
.icon-btn.muted { color: #9a8f8f; }

/* ---------- menu ---------- */
#screen-menu { background: radial-gradient(circle at 50% 30%, #ffdc5c, #e2231a 75%); }
.menu-decor { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.menu-decor span {
  position: absolute; bottom: -140px; opacity: .55; animation: rise linear infinite;
}
.menu-decor svg, .menu-decor img { width: 100%; height: 100%; display: block; object-fit: contain; }
@keyframes rise { from { transform: translateY(0) rotate(0); } to { transform: translateY(-125vh) rotate(360deg); } }

.menu-panel { background: rgba(255,255,255,.92); }
.logo { position: relative; padding-top: 1.5em; margin-bottom: .4em; }
.logo-badge {
  position: absolute; left: 50%; top: -3.9em; width: 5.6em; height: auto; margin-left: -2.8em;
  filter: drop-shadow(0 .25em 0 rgba(0,0,0,.25));
}
.game-name { display: block; width: 82%; max-width: 19em; height: auto; margin: 0 auto; }
.tagline { margin: .6em 0 1em; font-size: .95em; }
.how { list-style: none; margin: 1.1em 0 0; padding: 0; text-align: left; font-size: .8em; display: grid; gap: .5em; }
.how li { display: flex; align-items: center; gap: .7em; }
.how b { flex: none; width: 1.8em; height: 1.8em; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; }

/* ---------- result ---------- */
#screen-result { background: rgba(20,8,30,0); z-index: 5; }
#screen-result.active { animation: fadebg .5s forwards; }
@keyframes fadebg { to { background: rgba(20,8,30,.72); } }
.result-card { opacity: 0; }
.result-card.in { animation: slidein .6s cubic-bezier(.2,1.3,.4,1) forwards; }
@keyframes slidein { from { transform: translateY(-70vh); opacity: 1; } to { transform: translateY(0); opacity: 1; } }
.result-label { margin-top: .9em; font-size: .9em; text-transform: uppercase; letter-spacing: .12em; color: #7b5a4a; }
.result-score { font-size: 5em; font-weight: 900; line-height: 1; color: var(--red); text-shadow: 0 .05em 0 rgba(0,0,0,.15); }
.result-sub { margin: .3em 0 1em; font-size: .95em; }

/* ---------- form ---------- */
.form-card { text-align: left; }
.form-card h2 { text-align: center; }
.form-score { text-align: center; margin: .4em 0 .8em; font-size: 1em; }
.form-card label:not(.consent) { display: block; margin-top: .6em; font-size: .85em; }
.form-card input[type=text], .form-card input[type=email] {
  width: 100%; font: inherit; font-weight: 700; font-size: max(16px, 1em); color: var(--ink);
  padding: .55em .8em; margin-top: .25em; background: #fff9ea;
  border: .15em solid var(--ink); border-radius: .7em; user-select: text; -webkit-user-select: text;
}
.form-card input[aria-invalid=true] { border-color: #e02b2b; background: #fff0ee; }
.consent { display: flex; gap: .6em; align-items: flex-start; margin-top: .9em; font-size: .72em; line-height: 1.3; cursor: pointer; }
.consent input { flex: none; width: 1.6em; height: 1.6em; margin: 0; accent-color: var(--red); }
.field-error { min-height: 1.1em; margin-top: .2em; font-size: .75em; color: #d62828; }
.field-error.center { text-align: center; }
.form-card .btn { display: block; width: 100%; margin-top: .8em; }

/* ---------- leaderboard ---------- */
.board-card { max-width: 26em; font-size: .92em; }
.board-head, .row { display: grid; grid-template-columns: 3em 1fr 4em; gap: .5em; align-items: center; padding: .4em .8em; text-align: left; }
.board-head { margin-top: .7em; font-size: .75em; text-transform: uppercase; letter-spacing: .1em; color: #7b5a4a; }
.board-head span:last-child, .row .sc { text-align: right; }
.board-rows { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; display: grid; gap: .3em; }
.row { background: #fff4d6; border-radius: .8em; }
.row:nth-child(even) { background: #ffeab8; }
.row .rk { font-weight: 900; text-align: center; }
.row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sc { font-weight: 900; color: var(--red); }
.row.r1 .rk { color: #d99a00; } .row.r2 .rk { color: #7d8a96; } .row.r3 .rk { color: #b06a34; }
.row.me { background: #ffe066; outline: .13em solid var(--ink); animation: meGlow 1.3s ease-in-out infinite; }
@keyframes meGlow {
  0%, 100% { background: #ffe066; box-shadow: 0 0 0 0 rgba(255,204,0,.55); }
  50% { background: #ffd23f; box-shadow: 0 0 0 .45em rgba(255,204,0,0); }
}
.board-empty { padding: 1.4em 0; color: #7b5a4a; }
.board-foot { display: flex; justify-content: space-between; gap: .5em; margin-top: .6em; font-size: .72em; color: #7b5a4a; min-height: 1.2em; }
.board-timer { height: .5em; margin-top: .4em; border-radius: 1em; background: rgba(0,0,0,.12); overflow: hidden; }
.board-timer i { display: block; width: 100%; height: 100%; background: var(--teal); transform-origin: left; }
.board-timer.run i { animation: drain var(--dur, 5s) linear forwards; }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
  .menu-decor span, .row.me, #btn-play { animation: none; }
}
