/* Colors are overwritten at runtime from /brand.json. */
:root {
  --blue: #2392FF;
  --orange: #F78C36;
  --purple: #4C0699;
  --dark: #161616;
  --light: #F6F8FA;
  --gold: #FFC54B;
  --ruby: #FF035C;
  --night: #0B0B10;
  --success: #3DDC84;
  --grad-a: #2392FF;
  --grad-b: #4C0699;
  --team: var(--blue);
  --font-head: "MIG Header Verlag", "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --font-body: "MIG Standard Copy", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overscroll-behavior: none; }
body {
  font-family: var(--font-body);
  color: var(--light);
  background: var(--dark);
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}
h1 { font-family: var(--font-head); font-weight: 900; font-size: 2.4rem; line-height: 1.05; margin: .2em 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; margin: 0; opacity: .8; }
.muted { opacity: .75; }
.small { font-size: .85rem; }

.screen { display: none; min-height: 100vh; min-height: 100dvh; padding: max(20px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom)); }
body[data-screen="connecting"] #s-connecting,
body[data-screen="join"] #s-join,
body[data-screen="wait"] #s-wait,
body[data-screen="round"] #s-round,
body[data-screen="result"] #s-result { display: flex; }

#s-connecting, #s-join { background: linear-gradient(135deg, var(--grad-a), var(--grad-b)); }
#s-wait, #s-result { background: linear-gradient(135deg, var(--team), var(--dark)); }
#s-round { background: var(--team); flex-direction: column; }

.logo { height: 44px; width: auto; align-self: flex-start; margin-bottom: 1.2rem; }
.center { margin: auto; text-align: center; max-width: 26rem; width: 100%; }
.card { margin: auto; width: 100%; max-width: 26rem; display: flex; flex-direction: column; }

label { font-weight: 700; margin-top: 1rem; margin-bottom: .35rem; }
input[type=text], input[type=email] {
  font: inherit; font-size: 1.15rem; /* >=16px stops iOS zoom */
  padding: .8rem .9rem; border-radius: 10px; border: 2px solid transparent;
  background: var(--light); color: var(--dark); -webkit-user-select: text; user-select: text;
}
input:focus { outline: none; border-color: var(--gold); }
.consent { display: flex; gap: .7rem; align-items: flex-start; font-weight: 400; font-size: .9rem; line-height: 1.35; }
.consent input { width: 1.4rem; height: 1.4rem; flex: none; margin: 0; accent-color: var(--orange); }
.form-error { min-height: 1.3em; color: #FFD7B0; font-weight: 700; margin: .8rem 0 .2rem; }

.btn {
  font: inherit; font-family: var(--font-head); font-weight: 900; font-size: 1.25rem;
  padding: 1rem; border: 0; border-radius: 999px; background: var(--light); color: var(--dark);
  touch-action: manipulation; cursor: pointer;
}
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.97); }

/* Join card: which game is on. */
.now-playing {
  display: flex; flex-direction: column; gap: .15rem; margin-top: 1rem; padding: .8rem 1rem;
  border-radius: 12px; background: rgba(0,0,0,.22);
}
.now-playing b { font-family: var(--font-head); font-weight: 900; font-size: 1.35rem; }
.now-playing .small { opacity: .85; line-height: 1.35; }
.wait-hint { font-size: 1.05rem; line-height: 1.4; margin: .8rem auto; max-width: 20rem; }

/* Choose your adventure */
body[data-screen="vote"] #s-vote { display: flex; }
#s-vote { background: linear-gradient(135deg, var(--grad-a), var(--grad-b)); }
.vote-wrap { margin: auto; width: 100%; max-width: 26rem; display: flex; flex-direction: column; }
.vote-wrap h1 { margin-bottom: .3rem; }
.vote-cards { display: flex; flex-direction: column; gap: .8rem; margin: 1.2rem 0 .6rem; }
.vote-card {
  position: relative; overflow: hidden; text-align: left; font: inherit; color: var(--light); cursor: pointer;
  background: rgba(0,0,0,.28); border: 3px solid transparent; border-left: 8px solid var(--accent, var(--gold)); border-radius: 16px; padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .3rem; touch-action: manipulation;
}
.vote-card:active { transform: scale(.98); }
.vote-card.mine { border-color: var(--gold); background: rgba(0,0,0,.42); }
.vote-card.won { border-color: var(--gold); box-shadow: 0 0 0 6px rgba(255,197,75,.25); }
.vote-card.lost { opacity: .4; }
.vote-card b { font-family: var(--font-head); font-weight: 900; font-size: 1.45rem; text-transform: uppercase; letter-spacing: .04em; }
.vote-card .desc { font-size: .95rem; opacity: .85; line-height: 1.35; }
.vote-card .tally { display: flex; align-items: center; gap: .6rem; margin-top: .3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.vote-card .bar { flex: 1; height: 8px; border-radius: 4px; background: rgba(255,255,255,.18); overflow: hidden; }
.vote-card .bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: var(--light); transition: width .3s ease-out; }
.vote-card .pick { position: absolute; top: .8rem; right: .9rem; font-size: .7rem; font-weight: 800; letter-spacing: .1em;
  padding: .25rem .6rem; border-radius: 999px; background: var(--gold); color: var(--dark); }
.vote-timer { font-family: var(--font-head); font-weight: 900; font-size: 2.2rem; text-align: center; margin: .4rem 0 0; min-height: 1.2em; font-variant-numeric: tabular-nums; }

.countdown { font-family: var(--font-head); font-size: 3rem; font-weight: 900; margin: .3em 0; min-height: 1.2em; }
.player-name { font-size: 1.2rem; font-weight: 700; }

.round-top { display: flex; justify-content: space-between; align-items: center; font-family: var(--font-head); font-weight: 900; font-size: 1.4rem; }
.timer { font-variant-numeric: tabular-nums; font-size: 2rem; }
/* Rope meter: dark track with team-colored ends; the fill grows from the center toward whoever is winning. */
.rope { position: relative; height: 18px; margin: 14px 0 6px; border-radius: 9px; overflow: hidden;
  background: linear-gradient(90deg, var(--blue) 0 6%, rgba(0,0,0,.28) 6% 94%, var(--orange) 94%); border: 2px solid var(--light); }
.rope::after { content: ""; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(255,255,255,.55); }
/* Spans center -> right edge; scaleX(rope) grows it right for Orange, a negative scale flips it left for Blue. */
.rope-fill { position: absolute; top: 0; bottom: 0; left: 50%; width: 50%; transform-origin: left center; transform: scaleX(0);
  transition: transform .25s linear, background-color .25s; }
.rope-marker { position: absolute; top: -2px; bottom: -2px; width: 8px; margin-left: -4px; left: 50%; background: var(--light); border-radius: 3px; transition: left .25s linear; z-index: 1; }
.lead-text { text-align: center; font-weight: 700; margin: 4px 0; min-height: 1.3em; }

.tap-area { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; }
.tap {
  width: min(78vw, 52vh); height: min(78vw, 52vh); border-radius: 50%;
  border: 6px solid var(--light); background: rgba(255,255,255,.15); color: var(--light);
  font-family: var(--font-head); font-weight: 900; font-size: 3rem;
  touch-action: none; transition: transform 60ms ease-out;
}
.tap.hit { transform: scale(.93); background: rgba(255,255,255,.3); }
/* On fire (8+ taps/s): the button glows gold and pulses. */
.tap.fire { border-color: var(--gold); animation: fire .35s ease-in-out infinite alternate; }
@keyframes fire { from { box-shadow: 0 0 0 0 rgba(255,197,75,.0); } to { box-shadow: 0 0 0 14px rgba(255,197,75,.45); } }
.pops { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.pop { position: absolute; font-family: var(--font-head); font-weight: 900; font-size: 1.6rem; color: var(--light);
  transform: translate(-50%, -50%); animation: pop .6s ease-out forwards; will-change: transform, opacity; }
@keyframes pop { from { opacity: 1; transform: translate(-50%, -50%) scale(.8); } to { opacity: 0; transform: translate(-50%, -150%) scale(1.25); } }
.ring { position: absolute; left: 50%; top: 50%; width: min(78vw, 52vh); height: min(78vw, 52vh); border-radius: 50%;
  border: 4px solid var(--light); transform: translate(-50%, -50%); pointer-events: none; animation: ring .45s ease-out forwards; }
@keyframes ring { from { opacity: .6; transform: translate(-50%, -50%) scale(1); } to { opacity: 0; transform: translate(-50%, -50%) scale(1.25); } }
.rate { text-align: center; margin: 2px 0 0; font-weight: 700; min-height: 1.3em; opacity: .9; }
.rate.fire { color: var(--gold); opacity: 1; }
.timer.final { color: var(--ruby); animation: beat 1s ease-out infinite; text-shadow: 0 0 0 transparent; }

/* Full-screen flash when your team takes (or loses) the lead. */
#flash { position: fixed; inset: 0; pointer-events: none; opacity: 0; z-index: 5; }
#flash.good { background: #fff; animation: flash .45s ease-out; }
#flash.bad { background: #000; animation: flash .45s ease-out; }
@keyframes flash { from { opacity: .45; } to { opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 6; }
.shake { animation: shake .5s ease-in-out; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
.power {
  position: absolute; bottom: 4%; left: 50%; transform: translateX(-50%);
  padding: 1rem 1.6rem; border: 0; border-radius: 999px; overflow: hidden; white-space: nowrap;
  background: var(--gold); color: var(--dark); font-family: var(--font-head); font-weight: 900; font-size: 1.4rem;
  box-shadow: 0 0 0 4px var(--light); touch-action: none; animation: pulse .5s ease-in-out infinite alternate;
}
.power-bar { position: absolute; left: 0; bottom: 0; height: 5px; width: 100%; background: var(--dark); transform-origin: left; }
@keyframes pulse { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.08); } }
@keyframes drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.tap-count { text-align: center; font-size: 1.2rem; margin: 6px 0 0; }
.tap-count span { font-family: var(--font-head); font-weight: 900; font-size: 1.8rem; font-variant-numeric: tabular-nums; }

.countdown.final { font-size: 6rem; animation: beat 1s ease-out infinite; }
@keyframes beat { from { transform: scale(1.3); } to { transform: scale(1); } }
.go { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none;
  font-family: var(--font-head); font-weight: 900; font-size: 6rem; color: var(--light); animation: go .9s ease-out forwards; }
@keyframes go { from { transform: scale(.6); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.today { font-weight: 700; color: var(--gold); font-size: 1.15rem; }

.stats { display: flex; justify-content: center; gap: 2.5rem; margin: 1.5rem 0; }
.stats div { display: flex; flex-direction: column; }
.stats b { font-family: var(--font-head); font-size: 2.6rem; }

@media (prefers-reduced-motion: reduce) {
  .tap.fire, .timer.final, .countdown.final, .power, .shake { animation: none; }
  .pop, .ring, #flash.good, #flash.bad { animation-duration: .01s; }
}

#banner { position: fixed; top: 0; left: 0; right: 0; padding: 6px; padding-top: max(6px, env(safe-area-inset-top));
  text-align: center; font-weight: 700; background: var(--orange); color: var(--dark); z-index: 10; }
