* { 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: festive side panels */
  background:
    radial-gradient(circle at 12px 12px, rgba(255,255,255,.10) 2px, transparent 3px) 0 0 / 64px 64px,
    radial-gradient(circle at 44px 40px, rgba(255,255,255,.06) 1.5px, transparent 2.5px) 0 0 / 64px 64px,
    radial-gradient(ellipse at 50% 50%, #17324a 0%, #0a1826 55%, #050b14 100%);
  background-color: #050b14;
}

#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: #0b1330;
  box-shadow: 0 0 0 4px #d4a53a, 0 0 0 10px #7a0f1f, 0 0 80px rgba(0,0,0,.8);
}
#game { position: absolute; left: 0; top: 0; width: 720px; height: 1280px; display: block; touch-action: none; }

.hidden { display: none !important; }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px; text-align: center;
}
.screen.dim { background: rgba(5, 10, 30, .55); }

.brand-tag {
  font-family: 'Luckiest Guy', 'Fredoka', sans-serif;
  font-size: 44px; letter-spacing: 6px;
  background: #e8212e; color: #fff; padding: 10px 28px 4px; border-radius: 14px;
  border: 4px solid #fff; box-shadow: 0 6px 0 #7a0f1f, 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: .92; margin-top: 18px;
}
.title span { font-size: 124px; letter-spacing: 2px; paint-order: stroke fill; -webkit-text-stroke: 10px #3a0710; }
.title .t1 { color: #fff; text-shadow: 0 8px 0 #3a0710, 0 0 30px rgba(120,200,255,.5); }
.title .t2 { color: #ffd23f; text-shadow: 0 8px 0 #3a0710, 0 0 30px rgba(255,210,63,.5); }
.subtitle { font-size: 34px; font-weight: 600; color: #bfe6ff; margin-top: 14px; letter-spacing: 2px; text-shadow: 0 3px 0 rgba(0,0,0,.4); }
.menu-spacer { height: 250px; }

.btn {
  font-family: 'Fredoka', sans-serif; font-weight: 700; color: #fff;
  border: none; cursor: pointer; border-radius: 22px;
  font-size: 36px; padding: 18px 40px; min-width: 340px; margin: 10px 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(#ff4a55, #c4101d); border: 4px solid #ffd23f;
  box-shadow: 0 8px 0 #6b0913, 0 14px 26px rgba(0,0,0,.45);
  text-shadow: 0 3px 0 rgba(0,0,0,.35);
}
.btn.primary:active { box-shadow: 0 4px 0 #6b0913, 0 8px 16px rgba(0,0,0,.4); }
.btn.big { font-size: 56px; padding: 22px 70px; min-width: 420px; animation: pulse 1.6s ease-in-out infinite; }
.btn.ghost { background: rgba(255,255,255,.12); border: 3px solid rgba(255,255,255,.55); }
.btn.small { font-size: 28px; min-width: 260px; padding: 12px 28px; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.hint { font-size: 30px; margin: 16px 0 22px; color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.toggles { display: flex; gap: 20px; margin-bottom: 10px; }
.toggle {
  font-family: 'Fredoka', sans-serif; font-size: 28px; font-weight: 600; color: #fff; cursor: pointer;
  background: rgba(0,0,0,.35); border: 3px solid #5fd68b; border-radius: 18px; padding: 12px 24px; min-width: 210px;
}
.toggle b { color: #5fd68b; }
.toggle:not(.on) { border-color: #ff6b7a; }
.toggle:not(.on) b { color: #ff6b7a; }
.campaign {
  position: absolute; bottom: 36px; left: 40px; right: 40px;
  font-size: 24px; color: #fff; background: rgba(122,15,31,.75);
  border: 3px dashed rgba(255,210,63,.8); border-radius: 18px; padding: 14px 18px;
}
.campaign-tag { font-family: 'Luckiest Guy', sans-serif; background: #fff; color: #e8212e; padding: 2px 10px 0; border-radius: 8px; margin-right: 8px; }

/* ---------- Cards ---------- */
.card {
  width: 600px; padding: 36px 40px 30px;
  background: linear-gradient(#fdfbf5, #e9f3fb);
  color: #26143a; border-radius: 34px;
  border: 6px solid #ffd23f;
  box-shadow: 0 0 0 8px #c4101d, 0 24px 60px rgba(0,0,0,.55);
  display: flex; flex-direction: column; align-items: center; position: relative;
}
.card::before { /* snow cap */
  content: ''; position: absolute; left: 20px; right: 20px; top: -22px; height: 34px;
  background: radial-gradient(circle at 20px 26px, #fff 20px, transparent 21px) 0 0 / 48px 40px repeat-x;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.2));
}
.card .btn { width: 100%; }
.card .btn.ghost { color: #26143a; background: rgba(38,20,58,.06); border-color: rgba(38,20,58,.35); }
.card-title { font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 58px; color: #c4101d; margin-bottom: 14px; }
.banner {
  font-family: 'Luckiest Guy', sans-serif; font-weight: normal; font-size: 84px; color: #ffd23f;
  -webkit-text-stroke: 8px #3a0710; paint-order: stroke fill; text-shadow: 0 7px 0 #3a0710; margin-bottom: 40px;
  animation: drop .6s cubic-bezier(.2,1.6,.4,1) both;
}
@keyframes drop { from { transform: translateY(-80px) scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
.label { font-size: 30px; font-weight: 700; letter-spacing: 4px; color: #7a5a9a; }
.score-big { font-family: 'Luckiest Guy', sans-serif; font-size: 130px; color: #c4101d; line-height: 1.05; margin: 4px 0 10px; }
.breakdown { width: 100%; font-size: 28px; border-top: 3px dashed #d8c9e8; border-bottom: 3px dashed #d8c9e8; padding: 10px 6px; margin-bottom: 14px; }
.breakdown div { display: flex; justify-content: space-between; padding: 4px 0; }
.breakdown b { color: #1f7a45; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; width: 100%; margin-bottom: 18px; }
.stats div { display: flex; flex-direction: column; background: #efe6f7; border-radius: 16px; padding: 10px 4px; }
.stats b { font-size: 38px; color: #26143a; }
.stats span { font-size: 18px; color: #7a5a9a; }

/* ---------- Form ---------- */
.ticket { background: repeating-linear-gradient(45deg, #fffdf6 0 22px, #fff4f4 22px 44px); }
.form-score { font-size: 32px; margin-bottom: 18px; }
.form-score b { color: #c4101d; font-size: 40px; }
#playerForm { width: 100%; display: flex; flex-direction: column; }
#playerForm label { text-align: left; font-size: 26px; font-weight: 600; color: #5a3a7a; margin-bottom: 14px; display: flex; flex-direction: column; }
#playerForm input {
  font-family: 'Fredoka', sans-serif; font-size: 32px; padding: 14px 18px; margin-top: 6px;
  border: 3px solid #cdb8e2; border-radius: 16px; outline: none; color: #26143a; background: #fff;
  user-select: text; -webkit-user-select: text;
}
#playerForm input:focus { border-color: #c4101d; }
.err { color: #c4101d; font-size: 24px; min-height: 32px; font-weight: 600; }
.privacy { font-size: 20px; color: #8a7a9a; margin-top: 6px; }

/* ---------- Leaderboard ---------- */
.board-card { padding-bottom: 26px; }
#boardList { list-style: none; width: 100%; margin-bottom: 10px; counter-reset: rank; }
#boardList li {
  display: grid; grid-template-columns: 70px 1fr auto; align-items: center;
  font-size: 30px; padding: 9px 16px; margin: 6px 0; border-radius: 14px; background: #efe6f7;
}
#boardList li .rk { font-weight: 700; color: #7a5a9a; }
#boardList li .nm { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#boardList li .sc { font-weight: 700; color: #c4101d; }
#boardList li:nth-child(1) { background: #fff1bf; }
#boardList li:nth-child(2) { background: #eef1f5; }
#boardList li:nth-child(3) { background: #f7e1cf; }
#boardList li.me { background: #c4101d !important; color: #fff; box-shadow: 0 0 0 4px #ffd23f; }
#boardList li.me .rk, #boardList li.me .sc { color: #ffd23f; }
#boardList .empty { display: block; text-align: center; background: none; color: #7a5a9a; }
#boardYou { font-size: 26px; color: #5a3a7a; margin-bottom: 12px; min-height: 10px; }

/* ---------- Corner buttons ---------- */
#corner { position: absolute; inset: 0; pointer-events: none; }
.corner-btn {
  position: absolute; top: 1200px; width: 66px; height: 66px; border-radius: 20px;
  pointer-events: auto; cursor: pointer;
  background: rgba(255,255,255,.12); border: 3px solid rgba(255,255,255,.45);
  display: flex; align-items: center; justify-content: center;
}
.corner-btn.left { left: 22px; }
.corner-btn.right { right: 22px; }
.corner-btn svg { width: 36px; height: 36px; fill: #fff; stroke: #fff; }
.corner-btn .slash { display: none; stroke: #ff6b7a; }
.corner-btn.muted .slash { display: block; }
.corner-btn.muted .wave { display: none; }
