* { 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 night with a soft city glow */
  background:
    radial-gradient(circle at 14px 14px, rgba(255,255,255,.12) 2px, transparent 3px) 0 0 / 72px 72px,
    radial-gradient(circle at 50px 46px, rgba(255,255,255,.07) 1.5px, transparent 2.5px) 0 0 / 72px 72px,
    radial-gradient(ellipse at 50% 120%, #3b2a6a 0%, #121c48 45%, #070b1e 100%);
  background-color: #070b1e;
}

/* ---------- 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: #0a1230;
  box-shadow: 0 0 0 4px #e8b13a, 0 0 0 10px #8e1b26, 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: pointer; }
.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(20,30,70,.85), rgba(10,16,40,.85));
  border: 3px solid rgba(232,177,58,.7);
  box-shadow: 0 0 0 6px rgba(142,27,38,.55), 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: 16px; 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-tree { font-size: 70px; margin-top: 14px; filter: drop-shadow(0 0 14px rgba(255,220,120,.45)); }
.side-gifts { font-size: 34px; margin-top: 14px; letter-spacing: 6px; }
.side-cta { margin-top: 12px; font-size: 14px; color: #9fb3d9; border: 2px dashed rgba(255,255,255,.25); border-radius: 12px; padding: 12px; }

/* ---------- 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: 150px; color: #ffd23f; text-shadow: 0 9px 0 #3a0710, 0 0 34px rgba(255,210,63,.55); }
.title .t3 { font-size: 58px; color: #8ff0b0; -webkit-text-stroke: 8px #0d3a22; text-shadow: 0 6px 0 #0d3a22; margin-top: 6px; }
#menu { justify-content: flex-start; padding-top: 56px; }
.menu-spacer { flex: 0 0 18px; }
#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.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; }
.btn.ghost { background: rgba(255,255,255,.12); border: 3px solid rgba(255,255,255,.65); 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: 34px; left: 50%; transform: translateX(-50%); width: 620px; background: rgba(10,16,48,.82); border: 2px solid rgba(255,210,63,.6); border-radius: 18px; padding: 10px 16px; font-size: 22px; color: #dbe8ff; max-width: 560px; 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: 600px; max-width: 100%;
  background: linear-gradient(180deg, #1c2b63 0%, #121d47 100%);
  border: 4px solid #e8b13a; border-radius: 30px;
  box-shadow: 0 0 0 8px #8e1b26, 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 16px; }

.howto-list { list-style: none; width: 100%; margin-bottom: 14px; }
.howto-list li { display: flex; align-items: center; gap: 16px; text-align: left; font-size: 25px; font-weight: 600; padding: 10px 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: 36px; width: 52px; text-align: center; flex: 0 0 52px; }

/* ---------- 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 18px;
  background: linear-gradient(180deg, rgba(6,10,30,.75), rgba(6,10,30,0));
}
.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: 18px; 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: 40px; line-height: 1.05; color: #ffd23f; }
.hud-stat { width: 130px; }
.hud-score.pop b { animation: pop .25s ease-out; }
@keyframes pop { 0% { transform: scale(1.35); color: #ffd23f; } 100% { transform: scale(1); } }

.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; stroke: #fff; }
.icon-btn .slash { display: none; }
.icon-btn.muted .wave { display: none; }
.icon-btn.muted .slash { display: inline; }

.hud-power {
  position: absolute; left: 0; right: 0; bottom: 0; height: 128px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  background: linear-gradient(0deg, rgba(6,10,30,.8), rgba(6,10,30,0));
}
.pw {
  pointer-events: auto; position: relative;
  width: 150px; height: 98px; border-radius: 20px;
  background: linear-gradient(180deg, #d42a36, #8e1b26);
  border: 3px solid #ffd23f; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: 'Fredoka', sans-serif; box-shadow: 0 5px 0 #4e0a12;
  transition: filter .2s, opacity .2s, transform .08s;
}
.pw:active { transform: translateY(3px); }
.pw i { font-style: normal; font-size: 38px; line-height: 1; font-weight: 700; }
.pw em { font-style: normal; font-size: 15px; font-weight: 700; letter-spacing: 1px; margin-top: 4px; }
.pw u { text-decoration: none; position: absolute; top: -12px; right: -10px; min-width: 36px; height: 36px; border-radius: 18px; background: #fff; color: #8e1b26; font-weight: 700; font-size: 22px; display: flex; align-items: center; justify-content: center; border: 3px solid #ffd23f; padding: 0 6px; }
.pw.passive { background: linear-gradient(180deg, #2e9a5e, #1c6b3f); box-shadow: 0 5px 0 #0c3a21; cursor: default; }
.pw.empty { filter: grayscale(1) brightness(.6); opacity: .65; }
.pw.disabled { opacity: .55; }
.pw.active { animation: glow 1s ease-in-out infinite; }
.pw.flash { animation: flash .6s ease-out 2; }
@keyframes glow { 0%,100% { box-shadow: 0 5px 0 #0c3a21, 0 0 0 rgba(255,210,63,0); } 50% { box-shadow: 0 5px 0 #0c3a21, 0 0 24px rgba(255,210,63,.9); } }
@keyframes flash { 0% { transform: scale(1.25); filter: brightness(1.8); } 100% { transform: scale(1); } }

#countdown {
  position: absolute; left: 0; right: 0; top: 520px; z-index: 15; pointer-events: none;
  text-align: center; font-family: 'Luckiest Guy', sans-serif; font-size: 170px; color: #ffd23f;
  -webkit-text-stroke: 10px #3a0710; paint-order: stroke fill; text-shadow: 0 10px 0 #3a0710;
}
#countdown.tick { animation: cd .6s ease-out; }
@keyframes cd { 0% { transform: scale(1.8); opacity: 0; } 30% { transform: scale(1); opacity: 1; } 100% { transform: scale(.9); opacity: .9; } }

/* ---------- Result ---------- */
.banner { font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 72px; 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); } }
.result-row { display: flex; gap: 22px; align-items: center; width: 100%; }
#snapshot { width: 200px; height: 266px; border-radius: 18px; border: 3px solid rgba(255,255,255,.4); background: #0b1336; flex: 0 0 auto; }
.result-main { flex: 1; display: flex; flex-direction: column; align-items: center; }
.label { font-size: 22px; font-weight: 700; letter-spacing: 3px; color: #bfe6ff; }
.score-big { font-family: 'Luckiest Guy', sans-serif; font-size: 108px; 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(4, 1fr); gap: 10px; width: 100%; margin: 22px 0 10px; }
.stats div { background: rgba(255,255,255,.08); border-radius: 16px; padding: 12px 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 ---------- */
.permit { 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); }
.permit::before { display: none; }
.permit-head { font-weight: 700; letter-spacing: 3px; font-size: 20px; color: #fff; background: #1c6b3f; padding: 6px 18px; border-radius: 10px; }
.permit .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; }
.permit .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 110px 130px; 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; }
#boardList li .fl, #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; }
