/* ===== Connect the Brand Pipeline — UI styles =====
   The #stage is a fixed 720x1280 logical portrait box that game.js scales
   to fit the window; everything inside uses logical pixels. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #081128;
  font-family: 'Fredoka', 'Trebuchet MS', system-ui, sans-serif;
  color: #fff; user-select: none; -webkit-user-select: none; touch-action: none;
}
/* Letterbox background (PC sides / mobile bars) */
body {
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.18) 0 2px, transparent 3px) 0 0 / 90px 90px,
    radial-gradient(circle at 70% 60%, rgba(255,255,255,.12) 0 1.5px, transparent 2.5px) 0 0 / 60px 60px,
    radial-gradient(ellipse at 50% 120%, #1f4b7a 0%, #0f2350 45%, #081128 100%);
}

.hidden { display: none !important; }

#stage {
  position: absolute; left: 0; top: 0;
  width: 720px; height: 1280px;
  transform-origin: 0 0;
  overflow: hidden;
  border-radius: 6px;
  box-shadow: 0 0 0 6px #f2c14e, 0 0 0 12px #c8282f, 0 20px 80px rgba(0,0,0,.6);
}
#game { position: absolute; left: 0; top: 0; width: 720px; height: 1280px; display: block; }

/* ---------- side panels ---------- */
.side {
  position: absolute; top: 50%; transform: translateY(-50%);
  pointer-events: none;
  display: flex; justify-content: center;
}
.side-inner {
  width: 100%;
  background: linear-gradient(180deg, rgba(200,40,47,.92), rgba(140,22,34,.92));
  border: 5px solid #f2c14e; border-radius: 28px;
  padding: 28px 22px; text-align: center;
  box-shadow: 0 14px 40px rgba(0,0,0,.45), inset 0 0 0 4px rgba(255,255,255,.15);
  position: relative;
}
.side-inner::before { /* snow cap */
  content: ""; position: absolute; left: -6px; right: -6px; top: -14px; height: 26px;
  background: radial-gradient(circle at 12px 14px, #fff 11px, transparent 12px) 0 0 / 24px 26px repeat-x;
}
.side-tag { display: inline-block; background: #fff; color: #c8282f; font-family: 'Luckiest Guy', sans-serif; padding: 6px 16px; border-radius: 99px; letter-spacing: 1px; }
.side h3 { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; font-size: 30px; line-height: 1.1; margin: 16px 0; letter-spacing: 1px; }
.side h3 span { color: #ffd166; }
.side p { font-size: 16px; line-height: 1.4; margin: 10px 0 0; opacity: .95; }
.side-art { font-size: 46px; }
.side-art i { font-style: normal; color: #ffd166; font-size: 30px; vertical-align: middle; margin: 0 6px; }
.side ul { list-style: none; padding: 0; margin: 0; text-align: left; font-size: 16px; }
.side li { background: rgba(255,255,255,.12); border-radius: 12px; padding: 8px 12px; margin: 7px 0; }
.side li b { color: #ffd166; }
.side-gifts { font-size: 30px; margin: 12px 0; }
.side-cta { border: 3px dashed rgba(255,255,255,.6); border-radius: 16px; padding: 18px 8px; font-weight: 700; opacity: .9; }

/* ---------- generic screen / card / buttons ---------- */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; z-index: 5;
}
.screen.dim { background: rgba(6,14,36,.72); }

.card {
  position: relative;
  width: 600px; max-width: 92%;
  background: linear-gradient(180deg, #fffaf0, #fdf0d8);
  color: #2b2140;
  border: 7px solid #f2c14e; border-radius: 40px;
  padding: 46px 44px 38px;
  box-shadow: 0 14px 0 #b3851f, 0 26px 60px rgba(0,0,0,.5);
  display: flex; flex-direction: column; align-items: center;
  animation: pop .35s cubic-bezier(.2,1.6,.4,1);
}
.card::before {
  content: ""; position: absolute; left: -10px; right: -10px; top: -20px; height: 34px;
  background: radial-gradient(circle at 17px 20px, #fff 16px, transparent 17px) 0 0 / 34px 34px repeat-x;
  filter: drop-shadow(0 3px 0 #d8e6f5);
}
.card h2 { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; color: #c8282f; font-size: 56px; margin: 0 0 22px; letter-spacing: 2px; line-height: 1.05; text-shadow: 0 4px 0 #f6c9a0; }

@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.btn {
  font-family: 'Luckiest Guy', sans-serif; letter-spacing: 2px;
  font-size: 40px; line-height: 1;
  border: none; border-radius: 999px; cursor: pointer;
  padding: 24px 56px 20px; margin: 10px 0;
  min-width: 380px;
  transition: transform .08s;
  color: #fff;
}
.btn:active { transform: translateY(6px) scale(.98); }
.btn.primary { background: linear-gradient(180deg, #ff5a5f, #d62839); box-shadow: 0 9px 0 #8d1424, 0 14px 24px rgba(0,0,0,.35); text-shadow: 0 3px 0 rgba(0,0,0,.25); }
.btn.primary:active { box-shadow: 0 3px 0 #8d1424; }
.btn.ghost { background: #fff; color: #23345e; box-shadow: 0 9px 0 #9fb2cf, 0 14px 24px rgba(0,0,0,.25); }
.btn.ghost:active { box-shadow: 0 3px 0 #9fb2cf; }
.btn.big { font-size: 62px; padding: 30px 90px 24px; }
.btn.small { min-width: 220px; font-size: 34px; padding: 20px 30px 16px; }
.btn.tiny { min-width: 0; font-size: 22px; padding: 12px 24px 9px; }
.btn.link { background: none; color: #23345e; font-family: 'Fredoka', sans-serif; font-weight: 700; font-size: 24px; letter-spacing: 0; min-width: 0; padding: 10px; margin: 8px 0 0; text-decoration: underline; }
.btn.music { display: flex; align-items: center; justify-content: center; gap: 16px; background: linear-gradient(180deg, #4cc38a, #23955f); box-shadow: 0 9px 0 #12603b, 0 14px 24px rgba(0,0,0,.3); font-size: 34px; }
.btn.music:not(.on) { background: linear-gradient(180deg, #9aa6bb, #6b778e); box-shadow: 0 9px 0 #454e60; }
.btn.music .ico { font-size: 40px; }
.btn.music.on .off, .btn.music:not(.on) .on { display: none; }
.row { display: flex; gap: 22px; }

/* ---------- menu ---------- */
#menu { justify-content: flex-start; padding-top: 150px; }
.logo { margin-bottom: 70px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.logo-tag { display: inline-block; background: #fff; color: #c8282f; font-family: 'Luckiest Guy', sans-serif; font-size: 24px; letter-spacing: 3px; padding: 10px 24px 6px; border-radius: 99px; box-shadow: 0 5px 0 #c9d6ea; }
.logo h1 { margin: 22px 0 6px; font-family: 'Luckiest Guy', sans-serif; font-weight: 400; line-height: .92; display: flex; flex-direction: column; }
.logo h1 span { display: block; -webkit-text-stroke: 4px #1b1036; paint-order: stroke fill; text-shadow: 0 9px 0 #1b1036; }
.logo .l1 { font-size: 104px; color: #fff; }
.logo .l2 { font-size: 76px; color: #ffd166; }
.logo .l3 { font-size: 118px; color: #ff4d5e; }
.logo-sub { font-weight: 700; font-size: 28px; letter-spacing: 6px; color: #cfe3ff; text-transform: uppercase; margin-top: 14px; }
.menu-btns { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.menu-best { margin-top: 36px; font-size: 26px; font-weight: 700; color: #cfe3ff; background: rgba(6,14,36,.55); padding: 10px 28px; border-radius: 99px; }
.menu-best b { color: #ffd166; }

/* ---------- HUD ---------- */
#hud { position: absolute; left: 0; top: 0; width: 720px; height: 150px; z-index: 3; pointer-events: none; }
.hud-top { display: flex; align-items: center; justify-content: space-between; padding: 22px 22px 0; gap: 10px; }
.icon-btn {
  pointer-events: auto; width: 82px; height: 82px; border-radius: 50%; border: 5px solid #f2c14e;
  background: linear-gradient(180deg, #ff5a5f, #c8282f); box-shadow: 0 6px 0 #7d1220;
  display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
}
.icon-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #7d1220; }
.icon-btn svg { width: 42px; height: 42px; fill: #fff; stroke: #fff; }
.icon-btn.sound .off { display: none; }
.icon-btn.sound.muted .on { display: none; }
.icon-btn.sound.muted .off { display: block; }
.hud-stat, .hud-score {
  background: rgba(8,18,46,.82); border: 4px solid rgba(242,193,78,.85); border-radius: 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 6px 10px 4px; min-width: 128px;
}
.hud-stat span, .hud-score span { font-size: 17px; font-weight: 700; letter-spacing: 2px; color: #a9c6f0; }
.hud-stat b, .hud-score b { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; font-size: 44px; line-height: 1; letter-spacing: 1px; }
.hud-score { min-width: 186px; background: linear-gradient(180deg, #fff6dc, #ffe6a8); border-color: #fff; }
.hud-score span { color: #a0651a; }
.hud-score b { color: #c8282f; font-size: 52px; }
#hud.urgent #hudTime { color: #ff5a5f; animation: beat 1s infinite; }
@keyframes beat { 0%,100% { transform: scale(1); } 15% { transform: scale(1.25); } }
.timebar { position: absolute; left: 24px; right: 24px; top: 122px; height: 16px; background: rgba(8,18,46,.8); border-radius: 99px; border: 3px solid rgba(255,255,255,.55); overflow: hidden; }
#timeFill { height: 100%; width: 100%; background: linear-gradient(90deg, #4cc38a, #b8e04a); border-radius: 99px; transform-origin: 0 50%; }
#hud.warn #timeFill { background: linear-gradient(90deg, #ffb703, #ffd166); }
#hud.urgent #timeFill { background: linear-gradient(90deg, #ff4d5e, #ff8a5b); }

/* ---------- countdown ---------- */
#countdown {
  position: absolute; inset: 0; z-index: 6; display: flex; align-items: center; justify-content: center;
  font-family: 'Luckiest Guy', sans-serif; font-size: 260px; color: #ffd166; pointer-events: none;
  -webkit-text-stroke: 10px #1b1036; paint-order: stroke fill; text-shadow: 0 14px 0 #1b1036;
  background: rgba(6,14,36,.35);
}
#countdown.go { color: #4cc38a; font-size: 220px; }
#countdown span { animation: cd .9s ease-out both; display: block; }
@keyframes cd { 0% { transform: scale(2.2); opacity: 0; } 25% { transform: scale(1); opacity: 1; } 80% { opacity: 1; } 100% { transform: scale(.8); opacity: 0; } }

/* ---------- instructions ---------- */
.howto-card { padding-bottom: 26px; }
.panels { position: relative; width: 100%; height: 520px; }
.panel { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; }
.panel.active { display: flex; animation: slide .3s ease-out; }
@keyframes slide { from { transform: translateX(50px); opacity: 0; } to { transform: none; opacity: 1; } }
.illus { width: 420px; height: 260px; border-radius: 26px; background: #132449; border: 5px solid #23345e; }
.panel h4 { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; font-size: 40px; color: #23345e; margin: 26px 0 10px; letter-spacing: 1px; }
.panel p { font-size: 26px; line-height: 1.35; margin: 0; color: #4a3f60; }
.panel p b { color: #c8282f; }
.chips { width: 440px; display: flex; flex-direction: column; gap: 14px; }
.chip { display: flex; align-items: center; gap: 18px; background: #ffe3e3; border: 4px solid #ff5a5f; border-radius: 20px; padding: 10px 18px; text-align: left; }
.chip b { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; font-size: 42px; color: #c8282f; min-width: 104px; }
.chip span { font-size: 21px; font-weight: 600; color: #4a3f60; }
.chip.blue { background: #e1efff; border-color: #4c8dff; } .chip.blue b { color: #2563d9; }
.chip.gold { background: #fff3cf; border-color: #f2b01e; } .chip.gold b { color: #c98a00; }
.dots { display: flex; gap: 14px; margin: 18px 0 8px; }
.dots i { width: 18px; height: 18px; border-radius: 50%; background: #d8cbb4; }
.dots i.on { background: #c8282f; transform: scale(1.2); }

/* ---------- tutorial ---------- */
#tut { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.tut-bubble {
  position: absolute; left: 30px; right: 30px; top: 26px;
  background: #fffaf0; color: #2b2140; border: 6px solid #f2c14e; border-radius: 30px;
  padding: 16px 26px 18px; box-shadow: 0 8px 0 #b3851f, 0 14px 30px rgba(0,0,0,.4);
  text-align: center; animation: pop .3s ease-out;
}
.tut-bubble::after { content: ""; position: absolute; left: 50%; bottom: -26px; margin-left: -18px; border: 18px solid transparent; border-top-color: #f2c14e; border-bottom: 0; }
.tut-step { font-family: 'Luckiest Guy', sans-serif; color: #c8282f; font-size: 24px; letter-spacing: 2px; }
#tutText { margin: 4px 0 0; font-size: 30px; font-weight: 700; line-height: 1.25; }
#btnTutSkip { position: absolute; right: 30px; bottom: 26px; pointer-events: auto; }
.ready { list-style: none; padding: 0; margin: 0 0 24px; width: 100%; text-align: left; }
.ready li { display: flex; align-items: center; gap: 18px; font-size: 27px; margin: 12px 0; background: #fff; border-radius: 18px; padding: 12px 18px; border: 3px solid #f0dfbd; }
.ready i { font-style: normal; font-size: 40px; }
.ready b { color: #c8282f; }

/* ---------- result ---------- */
.banner {
  font-family: 'Luckiest Guy', sans-serif; font-weight: 400; font-size: 92px; margin: 0 0 40px; color: #ffd166;
  -webkit-text-stroke: 6px #1b1036; paint-order: stroke fill; text-shadow: 0 9px 0 #1b1036; letter-spacing: 3px;
  animation: pop .45s cubic-bezier(.2,1.6,.4,1);
}
.score-label { font-weight: 700; font-size: 24px; letter-spacing: 4px; color: #8a7a62; }
.score-big { font-family: 'Luckiest Guy', sans-serif; font-size: 130px; line-height: 1; color: #c8282f; text-shadow: 0 6px 0 #f6c9a0; margin: 6px 0; }
.best { font-size: 28px; font-weight: 700; color: #4a3f60; }
.best b { color: #23345e; }
.newbest { display: inline-block; background: #ffd166; color: #8d1424; font-family: 'Luckiest Guy', sans-serif; padding: 6px 14px 2px; border-radius: 12px; margin-left: 8px; animation: beat 1.2s infinite; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: 100%; margin: 24px 0 16px; }
.stats div { background: #fff; border: 3px solid #f0dfbd; border-radius: 18px; padding: 10px 4px; display: flex; flex-direction: column; }
.stats b { font-family: 'Luckiest Guy', sans-serif; font-weight: 400; font-size: 40px; color: #23345e; }
.stats span { font-size: 17px; font-weight: 600; color: #7a6c86; }
.achv-title { font-weight: 700; letter-spacing: 3px; color: #8a7a62; font-size: 20px; margin-bottom: 8px; }
.achv { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 18px; }
.achv span { font-size: 19px; font-weight: 700; padding: 8px 14px; border-radius: 99px; background: #ece6dc; color: #a99d8c; }
.achv span.got { background: linear-gradient(180deg, #ffd166, #f2a81e); color: #6b3b00; box-shadow: 0 3px 0 #b3761a; }

/* ---------- form ---------- */
.form-score { font-size: 26px; font-weight: 600; color: #4a3f60; margin-bottom: 16px; }
.form-score b { color: #c8282f; }
#playerForm { width: 100%; display: flex; flex-direction: column; align-items: center; }
#playerForm label { width: 100%; text-align: left; font-weight: 700; font-size: 24px; color: #23345e; margin-bottom: 14px; }
#playerForm label em { font-weight: 500; color: #8a7a62; font-style: normal; }
#playerForm input:not([type=checkbox]) {
  display: block; width: 100%; margin-top: 6px; font: 600 30px 'Fredoka', sans-serif; color: #2b2140;
  padding: 14px 20px; border-radius: 18px; border: 4px solid #e2d3b6; background: #fff; outline: none;
  user-select: text; -webkit-user-select: text;
}
#playerForm input:focus { border-color: #f2c14e; }
#playerForm .consent { display: flex; gap: 14px; align-items: flex-start; font-size: 21px; font-weight: 600; color: #4a3f60; }
#playerForm .consent input { width: 34px; height: 34px; flex: none; accent-color: #c8282f; margin: 0; }
.err { color: #c8282f; font-weight: 700; font-size: 22px; min-height: 30px; }

/* ---------- leaderboard ---------- */
#boardList { list-style: none; padding: 0; margin: 0 0 10px; width: 100%; counter-reset: r; }
#boardList li { display: flex; align-items: center; gap: 14px; background: #fff; border: 3px solid #f0dfbd; border-radius: 18px; padding: 10px 18px; margin: 8px 0; font-size: 27px; font-weight: 600; }
#boardList li .rk { font-family: 'Luckiest Guy', sans-serif; color: #c8282f; width: 46px; text-align: left; font-size: 30px; }
#boardList li .nm { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#boardList li .sc { font-family: 'Luckiest Guy', sans-serif; color: #23345e; font-size: 30px; }
#boardList li.me { background: #fff3cf; border-color: #f2b01e; transform: scale(1.03); }
.board-msg { font-size: 22px; font-weight: 600; color: #7a6c86; min-height: 30px; margin-bottom: 8px; }
.nogl-p { font-size: 28px; line-height: 1.4; }
