@font-face { font-family: 'Fredoka'; src: url('../fonts/fredoka-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('../fonts/fredoka-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('../fonts/fredoka-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --sun: #ffd27a;
  --peach: #ff9f68;
  --brown: #7a2e12;
  --wood: #a5652b;
  --red: #e2603b;
  --red-dark: #a8401f;
  --blue: #3b7de2;
  --green: #2f9e5b;
  --cream: #fff3df;
  --card: #ffffff;
  --ink: #4a1c0b;
  --muted: #8a5a3a;
  --font: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: linear-gradient(180deg, var(--sun) 0%, var(--peach) 100%) fixed;
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: manipulation;
}
#app {
  position: relative;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}
@media (min-width: 520px) {
  #app { box-shadow: 0 0 0 1px rgba(122, 46, 18, .15), 0 20px 60px rgba(122, 46, 18, .25); }
}
#stage { position: absolute; inset: 0; }
#stage canvas { display: block; touch-action: none; }

.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, var(--sun) 0%, var(--peach) 100%);
  overflow-y: auto;
  animation: pop-in .28s ease-out;
}
.screen.overlay { background: rgba(74, 28, 11, .45); backdrop-filter: blur(2px); }
.screen[hidden] { display: none; }
@keyframes pop-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: none; } }

h1, h2 { font-weight: 700; margin: 0; letter-spacing: .5px; }
h1 { font-size: clamp(40px, 12vw, 54px); line-height: .95; color: var(--brown); text-align: center; text-shadow: 0 4px 0 rgba(255,255,255,.5); }
h2 { font-size: 26px; color: var(--brown); text-align: center; }

.title-wrap { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.badge-top { background: var(--brown); color: var(--sun); font-weight: 600; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; padding: 6px 14px; border-radius: 99px; }
.logo svg { width: 112px; height: 112px; animation: bob 2.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
.lede { margin: 0; text-align: center; color: var(--brown); font-size: 17px; line-height: 1.35; }
.round-list { list-style: none; margin: 4px 0; padding: 0; display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.round-list li { background: rgba(255,255,255,.75); border-radius: 99px; padding: 6px 12px 6px 6px; font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 6px; }
.round-list span { background: var(--red); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 13px; }

.pill { background: #fff; border-radius: 16px; padding: 10px 14px; font-size: 15px; box-shadow: 0 3px 0 rgba(122,46,18,.12); text-align: center; }
.pill.best b { color: var(--red); }

.btn {
  font: 700 18px var(--font); letter-spacing: .5px;
  color: #fff; background: var(--red); border: 0; border-radius: 99px;
  padding: 14px 26px; box-shadow: 0 5px 0 var(--red-dark);
  cursor: pointer; transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--red-dark); }
.btn.big { font-size: 22px; padding: 16px 44px; min-width: 220px; }
.btn.alt { background: var(--blue); box-shadow: 0 5px 0 #2756a3; }
.btn.alt:active { box-shadow: 0 1px 0 #2756a3; }
.btn:focus-visible, .link:focus-visible, input:focus-visible, select:focus-visible, .tabs button:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.link { background: none; border: 0; font: 600 16px var(--font); color: var(--brown); text-decoration: underline; padding: 8px; cursor: pointer; }

.mute { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.8); font-size: 20px; cursor: pointer; }

.card { width: 100%; background: var(--card); border-radius: 24px; padding: 22px 18px; box-shadow: 0 8px 0 rgba(122,46,18,.18), 0 20px 40px rgba(122,46,18,.18); }
.form { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: var(--brown); }
.form input, .form select {
  font: 600 20px var(--font); color: var(--ink); background: var(--cream);
  border: 3px solid #f0d2a8; border-radius: 14px; padding: 12px 14px; width: 100%;
}
.form .btn { align-self: center; }
.small { font-size: 14px; color: var(--muted); margin: 0; text-align: center; }
.error { background: #ffe1d8; color: var(--red-dark); border-radius: 12px; padding: 10px 12px; margin: 0; font-weight: 600; text-align: center; }

.intro { text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; max-width: 420px; }
.eyebrow { font-weight: 700; color: var(--red); letter-spacing: 2px; font-size: 13px; }
.intro-icon svg { width: 96px; height: 96px; }
.quote { background: var(--cream); border-radius: 14px; padding: 8px 14px; font-size: 16px; }
.quote b { color: var(--green); font-size: 20px; }
.howto { text-align: left; margin: 0; padding: 0 0 0 4px; list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 16px; line-height: 1.3; }
.howto li { display: flex; gap: 10px; align-items: flex-start; }
.howto li::before { content: ''; flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 3px; background: var(--peach); }
.count { font-size: 96px; font-weight: 700; color: var(--red); line-height: 1; animation: count-pop .9s ease-out infinite; }
@keyframes count-pop { 0% { transform: scale(1.4); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 100% { opacity: .9; } }

.results { display: flex; flex-direction: column; gap: 14px; }
.res-total { text-align: center; }
.res-total span { display: block; font-size: 16px; color: var(--muted); }
.res-total b { font-size: 56px; color: var(--green); line-height: 1.05; }
.res-rounds { display: flex; flex-direction: column; gap: 8px; }
.res-row { display: grid; grid-template-columns: 110px 1fr 72px; gap: 8px; align-items: center; font-size: 15px; }
.res-row .bar { height: 14px; background: #f3e3cf; border-radius: 99px; overflow: hidden; }
.res-row .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #4cc27d, var(--green)); border-radius: 99px; transition: width .9s cubic-bezier(.2,.8,.2,1); }
.res-row b { text-align: right; }
.res-rank { text-align: center; font-size: 16px; background: #fff7e6; border-radius: 14px; padding: 10px; }
.res-rank b { color: var(--red); }
.fact { background: #eaf3ff; border-radius: 14px; padding: 12px 14px; font-size: 15px; line-height: 1.35; display: flex; flex-direction: column; gap: 4px; }
.fact b { color: var(--blue); }
.row-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.board { display: flex; flex-direction: column; gap: 12px; max-height: 100%; }
.tabs { display: flex; background: var(--cream); border-radius: 99px; padding: 4px; gap: 4px; }
.tabs button { flex: 1; border: 0; background: none; font: 600 15px var(--font); color: var(--brown); padding: 9px 4px; border-radius: 99px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--red); color: #fff; }
.board-body { overflow-y: auto; min-height: 200px; max-height: 52dvh; }
.lb-row { display: grid; grid-template-columns: 34px 1fr auto; gap: 8px; align-items: center; padding: 10px 6px; border-bottom: 2px dashed #f3e3cf; font-size: 16px; }
.lb-row.me { background: #ffe9c7; border-radius: 10px; }
.lb-rank { font-weight: 700; color: var(--muted); text-align: center; }
.lb-row:nth-child(1) .lb-rank { color: #d4a017; }
.lb-name small { display: block; color: var(--muted); font-size: 13px; }
.lb-score { font-weight: 700; color: var(--green); }
.lb-empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.lb-note { font-size: 13px; color: var(--muted); padding: 8px 6px; }
#btn-board-play { align-self: center; }

.hidden-visually { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
