* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: 'Fredoka', 'Trebuchet MS', sans-serif;
  color: #fff;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  /* Letterbox: snowy stadium night with floodlight glow */
  background:
    radial-gradient(circle at 14px 14px, rgba(255,255,255,.13) 2px, transparent 3px) 0 0 / 72px 72px,
    radial-gradient(circle at 50px 46px, rgba(255,255,255,.08) 1.5px, transparent 2.5px) 0 0 / 72px 72px,
    radial-gradient(ellipse at 50% 115%, #1f5a3a 0%, #102a4a 42%, #060b1e 100%);
  background-color: #060b1e;
}

/* ---------- Stage (fixed 720x1280 portrait, scaled to fit) ---------- */
#stage {
  position: absolute; left: 50%; top: 50%;
  width: 720px; height: 1280px;
  transform-origin: center center;
  transform: translate(-50%, -50%) scale(0.5);
  overflow: hidden;
  background: #0b1433;
  box-shadow: 0 0 0 4px #e8b13a, 0 0 0 10px #1c6b3f, 0 0 90px rgba(0,0,0,.85);
}
#game { position: absolute; left: 0; top: 0; width: 720px; height: 1280px; display: block; touch-action: none; cursor: grab; }
#game:active { cursor: grabbing; }
.hidden { display: none !important; }

/* ---------- Letterbox side panels ---------- */
.side {
  position: fixed; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; text-align: center;
}
.side-inner {
  width: 100%; max-width: 300px; padding: 28px 22px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(18,40,80,.88), rgba(8,18,40,.88));
  border: 3px solid rgba(232,177,58,.75);
  box-shadow: 0 0 0 6px rgba(28,107,63,.6), 0 12px 40px rgba(0,0,0,.5);
}
.side h3 { font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 30px; line-height: 1.05; letter-spacing: 1px; color: #fff; text-shadow: 0 3px 0 #3a0710; }
.side h3 span { color: #ffd23f; }
.side p { margin-top: 14px; font-size: 17px; color: #cfe3ff; line-height: 1.35; }
.side ul { list-style: none; margin-top: 16px; text-align: left; font-size: 16px; color: #e6efff; }
.side li { padding: 8px 0 8px 22px; position: relative; border-bottom: 1px dashed rgba(255,255,255,.15); }
.side li::before { content: '❄'; position: absolute; left: 0; color: #8fd3ff; }
.side li b { color: #ffd23f; }
.side-tag { display: inline-block; font-family: 'Luckiest Guy', sans-serif; font-size: 20px; letter-spacing: 3px; background: #d42a36; padding: 6px 14px 2px; border-radius: 10px; border: 2px solid #fff; margin-bottom: 14px; transform: rotate(-3deg); }
.side-art { font-size: 64px; margin-top: 14px; filter: drop-shadow(0 0 14px rgba(255,220,120,.45)); }
.side-cta { margin-top: 14px; font-size: 14px; color: #9fb3d9; border: 2px dashed rgba(255,255,255,.25); border-radius: 12px; padding: 12px; }

/* zone chips */
em.z { font-style: normal; display: inline-block; min-width: 1.6em; text-align: center; font-family: 'Luckiest Guy', sans-serif; padding: 2px 6px 0; border-radius: 6px; margin: 0 2px; color: #fff; text-shadow: 0 2px 0 rgba(0,0,0,.4); }
em.z1 { background: #2fae66; } em.z2 { background: #2f80ed; } em.z4 { background: #f2a900; } em.z6 { background: #e63946; }
em.zx { background: repeating-linear-gradient(45deg, #111 0 6px, #ffd400 6px 12px); color: #fff; -webkit-text-stroke: 1px #000; }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; text-align: center;
}
.screen.dim { background: rgba(5, 10, 30, .62); }

.brand-tag {
  font-family: 'Luckiest Guy', 'Fredoka', sans-serif;
  font-size: 36px; letter-spacing: 6px;
  background: #d42a36; color: #fff; padding: 10px 26px 4px; border-radius: 14px;
  border: 4px solid #fff; box-shadow: 0 6px 0 #6e0f1a, 0 10px 24px rgba(0,0,0,.4);
  transform: rotate(-4deg);
}
.title {
  font-family: 'Luckiest Guy', 'Fredoka', sans-serif; font-weight: normal;
  display: flex; flex-direction: column; line-height: .9; margin-top: 22px;
}
.title span { paint-order: stroke fill; -webkit-text-stroke: 10px #3a0710; letter-spacing: 2px; }
.title .t1 { font-size: 92px; color: #fff; text-shadow: 0 7px 0 #3a0710, 0 0 30px rgba(140,210,255,.5); }
.title .t2 { font-size: 140px; color: #ffd23f; text-shadow: 0 9px 0 #3a0710, 0 0 34px rgba(255,210,63,.55); }
.title .t3 { font-size: 86px; color: #8ff0b0; -webkit-text-stroke: 9px #0d3a22; text-shadow: 0 7px 0 #0d3a22; margin-top: 4px; }
#menu { justify-content: flex-start; padding-top: 70px; }
.menu-spacer { flex: 0 0 34px; }
#menu .btn { margin: 7px 0; }

.btn {
  font-family: 'Fredoka', sans-serif; font-weight: 700; color: #fff;
  border: none; cursor: pointer; border-radius: 22px;
  font-size: 34px; padding: 16px 40px; min-width: 340px; margin: 9px 0;
  transition: transform .08s ease, filter .15s;
}
.btn:active { transform: translateY(4px) scale(.98); }
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn.primary { background: linear-gradient(180deg, #ff4a55, #c41d2b); box-shadow: 0 7px 0 #6e0f1a, 0 12px 26px rgba(0,0,0,.35); border: 4px solid #ffd23f; }
.btn.big { font-size: 48px; padding: 18px 60px; min-width: 400px; animation: breathe 1.6s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.btn.ghost { background: rgba(10,20,50,.55); border: 3px solid rgba(255,255,255,.7); box-shadow: 0 5px 0 rgba(0,0,0,.3); }
.btn.music { font-size: 28px; min-width: 300px; padding: 12px 30px; background: linear-gradient(180deg, #2e9a5e, #1c6b3f); border: 3px solid #bff5d2; box-shadow: 0 5px 0 #0c3a21; }
.btn.music .note { display: inline-block; margin-right: 6px; }
.btn.music.on .note { animation: bob 1s ease-in-out infinite; }
.btn.music.off { background: linear-gradient(180deg, #5b6378, #3a4152); border-color: #9aa3b8; box-shadow: 0 5px 0 #23283a; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-8deg); } 50% { transform: translateY(-6px) rotate(8deg); } }

.campaign { position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%); width: 600px; background: rgba(10,16,48,.85); border: 2px solid rgba(255,210,63,.6); border-radius: 18px; padding: 10px 16px; font-size: 22px; color: #dbe8ff; line-height: 1.35; text-shadow: 0 2px 0 rgba(0,0,0,.5); }
.campaign-tag { display: inline-block; font-family: 'Luckiest Guy', sans-serif; background: #ffd23f; color: #6e0f1a; padding: 4px 10px 0; border-radius: 8px; margin-right: 6px; }

/* ---------- Cards ---------- */
.card {
  width: 620px; max-width: 100%;
  background: linear-gradient(180deg, #1c2b63 0%, #121d47 100%);
  border: 4px solid #e8b13a; border-radius: 30px;
  box-shadow: 0 0 0 8px #1c6b3f, 0 18px 50px rgba(0,0,0,.55);
  padding: 30px 34px 26px;
  display: flex; flex-direction: column; align-items: center;
  position: relative;
}
.card::before { /* snow cap */
  content: ''; position: absolute; left: 18px; right: 18px; top: -14px; height: 22px;
  background: #fff; border-radius: 14px 14px 18px 18px;
  box-shadow: 0 4px 0 rgba(180,210,240,.8);
}
.card-title { font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 52px; letter-spacing: 1px; color: #ffd23f; text-shadow: 0 4px 0 #3a0710; margin: 6px 0 14px; }

.tut { width: 100%; display: flex; justify-content: center; margin-bottom: 8px; }
.tut svg { width: 420px; height: 238px; border-radius: 18px; border: 3px solid rgba(255,255,255,.35); }
.tut-bat { animation: tutBat 2.8s ease-in-out infinite; }
.tut-ball { animation: tutBall 2.8s linear infinite; }
.tut-hand { animation: tutHand 2.8s ease-in-out infinite; }
@keyframes tutBat {
  0%, 32% { transform: translate(130px, 100px) rotate(140deg); }
  46% { transform: translate(130px, 100px) rotate(-40deg); }
  58% { transform: translate(130px, 100px) rotate(-75deg); }
  80%, 100% { transform: translate(130px, 100px) rotate(140deg); }
}
@keyframes tutBall {
  0% { transform: translate(310px, 118px); opacity: 1; }
  25% { transform: translate(230px, 140px); }
  43% { transform: translate(170px, 128px); }
  46% { transform: translate(166px, 126px); }
  72% { transform: translate(205px, 8px); opacity: 1; }
  73%, 100% { transform: translate(205px, 8px); opacity: 0; }
}
@keyframes tutHand {
  0%, 30% { transform: translate(98px, 52px); opacity: .0; }
  33% { transform: translate(98px, 52px); opacity: 1; }
  46% { transform: translate(190px, 120px); opacity: 1; }
  58% { transform: translate(215px, 80px); opacity: 1; }
  66%, 100% { transform: translate(215px, 80px); opacity: 0; }
}

.howto-list { list-style: none; width: 100%; margin-bottom: 12px; }
.howto-list li { display: flex; align-items: center; gap: 14px; text-align: left; font-size: 24px; font-weight: 600; padding: 8px 6px; border-bottom: 2px dashed rgba(255,255,255,.12); text-transform: uppercase; letter-spacing: .5px; }
.howto-list li:last-child { border-bottom: none; color: #ffd23f; }
.howto-list i { font-style: normal; font-size: 32px; width: 48px; text-align: center; flex: 0 0 48px; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 10; pointer-events: none; }
.hud-top {
  position: absolute; left: 0; right: 0; top: 0; height: 112px;
  display: flex; align-items: center; justify-content: space-between; padding: 0 22px 0 18px;
  background: linear-gradient(180deg, rgba(6,10,30,.9), rgba(6,10,30,.55));
  border-bottom: 3px solid rgba(232,177,58,.6);
}
.hud-score, .hud-stat { display: flex; flex-direction: column; align-items: center; text-shadow: 0 3px 0 rgba(0,0,0,.5); }
.hud-score span, .hud-stat span { font-size: 17px; font-weight: 700; letter-spacing: 2px; color: #bfe6ff; }
.hud-score b { font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 64px; line-height: 1; color: #fff; }
.hud-stat b { font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 46px; line-height: 1.05; color: #ffd23f; }
.hud-stat { width: 140px; }
.hud-score.pop b { animation: pop .3s ease-out; }
@keyframes pop { 0% { transform: scale(1.4); color: #ffd23f; } 100% { transform: scale(1); } }
#hudTimeBox.urgent b { color: #ff4a55; animation: tpulse .5s ease-in-out infinite alternate; }
@keyframes tpulse { from { transform: scale(1); } to { transform: scale(1.18); } }
#hudLives { display: flex; gap: 8px; margin-top: 8px; }
#hudLives i { width: 32px; height: 32px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ff7b7b, #c41d2b 60%, #7a0e18); border: 2px solid #fff; position: relative; transition: transform .3s, opacity .3s, filter .3s; }
#hudLives i::after { content: ''; position: absolute; left: 50%; top: 2px; bottom: 2px; width: 0; border-left: 2px dashed rgba(255,255,255,.85); }
#hudLives i.lost { filter: grayscale(1) brightness(.45); opacity: .5; transform: scale(.8); }
#hudLives i.boom { animation: lifeBoom .6s ease-out; }
@keyframes lifeBoom { 0% { transform: scale(1.6); } 100% { transform: scale(.8); } }
.hud-sub {
  position: absolute; left: 50%; top: 116px; transform: translateX(-50%);
  display: flex; gap: 22px; font-size: 18px; font-weight: 700; letter-spacing: 1px; color: #cfe3ff;
  background: rgba(6,10,30,.55); border-radius: 0 0 14px 14px; padding: 2px 16px 4px;
}
.hud-sub b { color: #fff; }

.icon-btn {
  pointer-events: auto; width: 72px; height: 72px; border-radius: 50%;
  background: rgba(255,255,255,.14); border: 3px solid rgba(255,255,255,.7);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 38px; height: 38px; fill: #fff; }

/* ---------- Result ---------- */
.banner { font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 74px; color: #fff; -webkit-text-stroke: 8px #3a0710; paint-order: stroke fill; text-shadow: 0 7px 0 #3a0710; margin-bottom: 28px; }
.banner.newbest { color: #ffd23f; animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.label { font-size: 22px; font-weight: 700; letter-spacing: 3px; color: #bfe6ff; }
.score-big { font-family: 'Luckiest Guy', sans-serif; font-size: 130px; line-height: 1; color: #ffd23f; text-shadow: 0 6px 0 #3a0710; margin: 6px 0; }
.best { font-size: 24px; color: #dbe8ff; }
.best b { color: #fff; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; margin: 20px 0 10px; }
.stats div { background: rgba(255,255,255,.08); border-radius: 16px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; }
.stats b { font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 40px; color: #fff; }
.stats span { font-size: 16px; color: #bfe6ff; font-weight: 600; }
.result-cta { font-size: 20px; color: #dbe8ff; margin: 8px 0 12px; }
.result-cta b { color: #ffd23f; }

/* ---------- Form ---------- */
.scorecard { background: linear-gradient(180deg, #fff8ea 0%, #f2e6cc 100%); color: #3a1a10; border-color: #c41d2b; box-shadow: 0 0 0 8px #1c6b3f, 0 18px 50px rgba(0,0,0,.55); }
.scorecard::before { display: none; }
.sc-head { font-weight: 700; letter-spacing: 3px; font-size: 20px; color: #fff; background: #1c6b3f; padding: 6px 18px; border-radius: 10px; }
.scorecard .card-title { color: #c41d2b; text-shadow: none; }
.form-score { font-size: 26px; margin-bottom: 14px; }
.form-score b { color: #c41d2b; }
#playerForm { width: 100%; display: flex; flex-direction: column; align-items: center; }
#playerForm label { width: 100%; text-align: left; font-weight: 700; font-size: 22px; margin-bottom: 12px; }
#playerForm input[type=email], #playerForm input:not([type]) {
  display: block; width: 100%; margin-top: 6px; font: 600 28px 'Fredoka', sans-serif;
  padding: 12px 16px; border-radius: 14px; border: 3px solid #c9b59a; background: #fff; color: #3a1a10; user-select: text; -webkit-user-select: text;
}
#playerForm input:focus { outline: none; border-color: #c41d2b; }
#playerForm label.consent { display: flex; align-items: center; gap: 12px; font-size: 19px; font-weight: 600; }
#playerForm label.consent input { width: 30px; height: 30px; accent-color: #c41d2b; flex: 0 0 auto; }
.err { min-height: 28px; color: #c41d2b; font-weight: 700; font-size: 20px; }
.scorecard .btn.ghost { color: #3a1a10; border-color: #3a1a10; background: transparent; box-shadow: none; }
.privacy { font-size: 16px; color: #7a5a40; margin-top: 8px; }

/* ---------- Leaderboard ---------- */
.board-head, #boardList li { display: grid; grid-template-columns: 56px 1fr 100px 120px; align-items: center; width: 100%; }
.board-head { font-size: 16px; font-weight: 700; letter-spacing: 2px; color: #bfe6ff; padding: 0 14px 8px; }
.board-head span:nth-child(3), .board-head span:nth-child(4) { text-align: right; }
#boardList { list-style: none; width: 100%; max-height: 560px; overflow: hidden; }
#boardList li { font-size: 26px; font-weight: 600; padding: 10px 14px; border-radius: 14px; margin-bottom: 6px; background: rgba(255,255,255,.07); }
#boardList li .rk { font-family: 'Luckiest Guy', sans-serif; color: #ffd23f; }
#boardList li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
#boardList li .bl, #boardList li .sc { text-align: right; }
#boardList li .sc { font-family: 'Luckiest Guy', sans-serif; font-size: 30px; }
#boardList li.you { background: linear-gradient(90deg, #c41d2b, #8e1b26); border: 2px solid #ffd23f; }
.board-msg { min-height: 30px; font-size: 20px; color: #ffd23f; margin: 6px 0; }

/* ---------- Tutorial overlay ---------- */
#tutUI { position: absolute; inset: 0; z-index: 12; pointer-events: none; }
.tut-card {
  position: absolute; left: 50%; top: 200px; transform: translateX(-50%);
  width: 600px; padding: 20px 28px 22px; text-align: center;
  background: rgba(12,22,58,.9); border: 4px solid #ffd23f; border-radius: 26px;
  box-shadow: 0 0 0 6px #1c6b3f, 0 14px 40px rgba(0,0,0,.5);
  animation: tutIn .35s ease-out;
}
.tut-card.bump { animation: tutIn .35s ease-out; }
@keyframes tutIn { 0% { transform: translateX(-50%) scale(.85); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }
.tut-card h3 { font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 46px; color: #ffd23f; text-shadow: 0 4px 0 #3a0710; letter-spacing: 1px; margin: 6px 0 6px; }
.tut-card p { font-size: 27px; font-weight: 600; line-height: 1.3; color: #eef4ff; }
.tut-card p b { color: #ffd23f; }
.tut-card .btn { pointer-events: auto; margin-top: 16px; }
.tut-dots { display: flex; gap: 10px; justify-content: center; }
.tut-dots i { width: 16px; height: 16px; border-radius: 50%; background: rgba(255,255,255,.25); }
.tut-dots i.on { background: #ffd23f; box-shadow: 0 0 10px #ffd23f; }
.tut-dots i.done { background: #2fae66; }
.tut-skip { pointer-events: auto; position: absolute; right: 20px; top: 26px; min-width: 0; font-size: 26px; padding: 10px 22px; }
