:root {
  --sky: #8fc4ee;
  --sky-light: #c9e4f8;
  --sky-pale: #eaf4fc;
  --blue: #2f80c8;
  --blue-dark: #1f5f99;
  --navy: #14324f;
  --ink: #111820;
  --ink-soft: #4a5b6b;
  --white: #ffffff;
  --good: #1f9a57;
  --bad: #e0403a;
  --hard: 4px 4px 0 var(--ink);
  --radius: 16px;
  --stencil: "Big Shoulders Stencil Display", "Arial Black", sans-serif;
  --round: "Baloo 2", "Nunito", sans-serif;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(rgba(255,255,255,.35) 1.5px, transparent 1.6px) 0 0 / 22px 22px,
    linear-gradient(180deg, var(--sky-light) 0%, var(--sky) 70%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  font-weight: 700;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ───────── decorative sky ───────── */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.waves { position: absolute; left: 0; bottom: 0; width: 200%; height: 90px; animation: drift 18s linear infinite; }
.waves .w1 { fill: rgba(255,255,255,.55); }
.waves .w2 { fill: #ffffff; }
@keyframes drift { to { transform: translateX(-50%); } }
.gulls { position: absolute; top: 34px; right: 6%; width: 120px; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; opacity: .55; animation: bob 6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translate(-10px, 6px); } }
@media (prefers-reduced-motion: reduce) { .waves, .gulls { animation: none; } }

/* ───────── layout ───────── */
.layout { position: relative; z-index: 1; }
#app { max-width: 480px; margin: 0 auto; padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); }
.side { display: none; }

@media (min-width: 1000px) {
  .layout { display: grid; grid-template-columns: minmax(0, 660px) 330px; gap: 32px; justify-content: center; align-items: start; padding: 24px 24px 100px; }
  #app { margin: 0; max-width: none; padding: 0; }
  .screen:not(.game) { max-width: 480px; margin: 0 auto; }
  .side { display: block; position: sticky; top: 24px; }
  body[data-view="board"] .layout { grid-template-columns: minmax(0, 520px); }
  body[data-view="board"] .side { display: none; }
}

.screen { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; animation: in .35s ease; }
.screen[hidden] { display: none; }
@keyframes in { from { opacity: 0; transform: translateY(8px); } }

/* ───────── type ───────── */
.logo { width: min(300px, 78vw); height: auto; filter: drop-shadow(4px 4px 0 rgba(17,24,32,.9)); margin-top: 4px; }
.logo.small { width: 190px; }
.title { font-family: var(--stencil); font-weight: 900; font-size: 54px; line-height: .95; margin: 2px 0 0; text-transform: uppercase; letter-spacing: 1px; }
.title span {
  display: inline-block; background: var(--blue); color: #fff; padding: 2px 12px 0; border: 3px solid var(--ink);
  border-radius: 10px; box-shadow: var(--hard); transform: rotate(-3deg); margin-left: 4px;
}
.title.small { font-size: 44px; }
.tagline { margin: 4px 0 0; font-family: var(--round); font-size: 17px; color: var(--navy); }
.eyebrow { margin: 4px 0 0; color: var(--navy); font-family: var(--stencil); font-size: 20px; text-transform: uppercase; letter-spacing: 2px; }
.sub { margin: 0; color: var(--navy); }
.fine { font-size: 13px; color: var(--navy); font-weight: 600; max-width: 360px; margin: 0; line-height: 1.45; }
.prize {
  position: relative; overflow: hidden; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 18px 12px; border-radius: 18px; border: 3px solid var(--ink);
  background: linear-gradient(135deg, #fff3b0 0%, #ffd23f 30%, #f5b301 55%, #ffe680 75%, #f2a900 100%);
  background-size: 220% 220%;
  box-shadow: 5px 5px 0 var(--ink), 0 0 22px 6px rgba(255, 200, 40, .75);
  transform: rotate(-1.5deg);
  animation: gold-shift 5s ease-in-out infinite, gold-glow 2.2s ease-in-out infinite;
}
.prize::after { /* shine sweep */
  content: ""; position: absolute; top: -50%; bottom: -50%; width: 60px; left: -90px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.85), transparent);
  transform: rotate(20deg); animation: shine 3s ease-in-out infinite;
}
.prize-top { font-family: var(--round); font-size: 14px; font-weight: 700; color: #5a3d00; display: flex; align-items: center; gap: 6px; }
.prize-top .trophy { font-size: 20px; animation: wiggle 2.2s ease-in-out infinite; display: inline-block; }
.prize-main {
  font-family: var(--stencil); font-weight: 900; font-size: 28px; line-height: 1; letter-spacing: 1px;
  text-transform: uppercase; color: var(--ink); text-shadow: 0 1px 0 rgba(255,255,255,.6);
}
@keyframes gold-shift { 50% { background-position: 100% 100%; } }
@keyframes gold-glow { 50% { box-shadow: 5px 5px 0 var(--ink), 0 0 34px 12px rgba(255, 205, 50, .95); } }
@keyframes shine { 0% { left: -90px; } 55%, 100% { left: 115%; } }
@keyframes wiggle { 0%, 70%, 100% { transform: rotate(0); } 80% { transform: rotate(-14deg) scale(1.15); } 90% { transform: rotate(12deg) scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .prize, .prize::after, .prize-top .trophy { animation: none; } }
.prize:empty { display: none; }

/* ───────── cards & forms ───────── */
.card { width: 100%; background: var(--white); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: 5px 5px 0 var(--ink); }
.form { padding: 18px; display: flex; flex-direction: column; gap: 12px; text-align: left; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .8px; }
.form input[type=email], .form input[type=password] {
  font: inherit; font-size: 17px; font-weight: 700; color: var(--ink); text-transform: none; letter-spacing: 0;
  padding: 13px 14px; border-radius: 12px; border: 2.5px solid var(--ink); background: var(--sky-pale); outline: none;
}
.form input:focus { background: #fff; box-shadow: 0 0 0 4px rgba(47,128,200,.35); }
.form .check { flex-direction: row; align-items: center; gap: 10px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.form .check input { width: 20px; height: 20px; accent-color: var(--blue); }
.msg { min-height: 1.2em; margin: 0; font-size: 14px; color: var(--bad); text-align: center; }
.msg.ok { color: var(--good); }

.btn {
  font-family: var(--round); font-weight: 800; font-size: 19px; line-height: 1.1;
  border-radius: 14px; padding: 13px 20px; cursor: pointer; width: 100%; color: var(--ink);
  background: #fff; border: 3px solid var(--ink); box-shadow: var(--hard); transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--blue); color: #fff; }
.btn.primary:hover { background: #3a8dd6; }
.btn.big { font-size: 22px; padding: 14px 20px; }
.btn.ghost { background: rgba(255,255,255,.75); }
.btn[disabled] { opacity: .6; pointer-events: none; }
.link { background: none; border: 0; font: inherit; font-size: 14px; color: var(--navy); text-decoration: underline; cursor: pointer; }

.nametag {
  position: relative; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 10px 22px 8px 38px;
  font-family: var(--round); font-weight: 800; font-size: 30px; transform: rotate(-2deg); box-shadow: 5px 5px 0 var(--blue);
}
.nametag .pin { position: absolute; left: 13px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border-radius: 50%; background: var(--blue); border: 2px solid var(--ink); }
.stats { display: flex; gap: 10px; width: 100%; }
.stats > div { flex: 1; background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 8px 6px; display: flex; flex-direction: column; box-shadow: var(--hard); }
.stats b { font-family: var(--round); font-weight: 800; font-size: 28px; line-height: 1.1; }
.stats span { font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .8px; }

.how { padding: 14px 18px; text-align: left; }
.how h2 { font-family: var(--stencil); font-size: 24px; margin: 0 0 4px; text-transform: uppercase; letter-spacing: 1px; }
.how ol { margin: 0; padding-left: 20px; font-weight: 600; line-height: 1.5; }
.how .keys { font-size: 13px; color: var(--ink-soft); font-weight: 600; margin: 10px 0 0; }
kbd { font-family: inherit; font-weight: 800; background: var(--sky-pale); border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: 6px; padding: 0 6px; margin: 0 1px; }
@media (hover: none) { .how .keys { display: none; } }

/* ───────── game ───────── */
.screen.game { gap: 10px; width: 100%; margin: 0 auto; }
@media (min-width: 1000px) { .screen.game { max-width: min(660px, calc((100vh - 300px) * 1.333)); min-width: 460px; } }
.hud {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 4px 14px; box-shadow: var(--hard);
}
.hud > div { display: flex; flex-direction: column; align-items: center; min-width: 70px; }
.hud span { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-soft); }
.hud b { font-family: var(--round); font-weight: 800; font-size: 26px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.hud-lives { flex-direction: row !important; gap: 5px; }
.life { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--ink); background: radial-gradient(circle at 35% 35%, #f0b766, #b9732c); transition: transform .3s, opacity .3s; position: relative; }
.life::before { content: ""; position: absolute; left: 1px; right: 1px; top: 0; height: 8px; border-radius: 8px 8px 3px 3px; background: #f59cc2; }
.life.lost { opacity: .2; transform: scale(.7); filter: grayscale(1); }

.board-wrap { position: relative; width: 100%; }
#gameCanvas { width: 100%; height: auto; display: block; border-radius: var(--radius); background: #fff; border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); touch-action: manipulation; }
.countdown { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--stencil); font-weight: 900; font-size: 110px; color: var(--blue); -webkit-text-stroke: 3px var(--ink); pointer-events: none; }
.countdown[hidden] { display: none; }

.bins { width: 100%; display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.bin-row { display: grid; gap: 8px; }
.bin-row.frost { grid-template-columns: repeat(3, 1fr); }
.bin-row.tops { grid-template-columns: repeat(4, 1fr); }
.bin {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; padding: 5px 2px 6px;
  background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer; font-family: var(--round); font-weight: 700; font-size: 13px; color: var(--ink);
  user-select: none; -webkit-user-select: none; touch-action: manipulation; transition: transform .06s, box-shadow .06s;
}
.bin-row.frost .bin { background: var(--sky-pale); }
.bin canvas { width: 46px; height: 46px; pointer-events: none; }
.bin:hover { background: #f4f9fe; }
.bin:active, .bin.hit { transform: translate(3px, 3px); box-shadow: 0 0 0 var(--ink); }
.bin .key { position: absolute; top: 3px; right: 7px; font-style: normal; font-size: 11px; color: var(--ink-soft); }
@media (hover: none) { .bin .key { display: none; } }
.send-row { display: flex; gap: 8px; }
.btn.send { background: var(--good); color: #fff; font-size: 22px; padding: 12px; }
.mute { flex: 0 0 58px; background: #fff; border: 3px solid var(--ink); border-radius: 14px; font-size: 20px; cursor: pointer; padding: 0; box-shadow: var(--hard); }

@media (max-height: 720px) and (max-width: 999px) {
  #app { padding-top: 10px; }
  .bin canvas { width: 36px; height: 36px; }
  .btn.send { padding: 8px; font-size: 19px; }
  .hud b { font-size: 22px; }
}
@media (min-width: 1000px) {
  .bin canvas { width: 54px; height: 54px; }
  .bin { font-size: 14px; }
}

/* ───────── game over / board ───────── */
.final { font-family: var(--round); font-weight: 800; font-size: 84px; line-height: .9; color: var(--blue); display: flex; flex-direction: column; -webkit-text-stroke: 2px var(--ink); text-shadow: 4px 4px 0 var(--ink); }
.final small { font-size: 16px; color: var(--navy); font-family: var(--stencil); -webkit-text-stroke: 0; text-shadow: none; text-transform: uppercase; letter-spacing: 3px; margin-top: 8px; }
.badge { background: var(--good); color: #fff; padding: 6px 14px; border-radius: 999px; border: 3px solid var(--ink); margin: 0; animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.12); } }

.board { list-style: none; margin: 0; padding: 6px; text-align: left; }
.board li { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; }
.board li + li { border-top: 2px dashed var(--sky-light); }
.board .r { width: 30px; font-family: var(--round); font-weight: 800; font-size: 18px; color: var(--ink-soft); text-align: center; }
.board .n { flex: 1; }
.board .s { font-family: var(--round); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums; }
.board li:nth-child(1) { background: var(--sky-pale); }
.board li:nth-child(1) .r { font-size: 22px; }
.board li.me { background: var(--blue); color: #fff; }
.board li.me .r { color: #fff; }
.board .empty { justify-content: center; color: var(--ink-soft); font-weight: 600; }
.me-row { width: 100%; background: var(--blue); color: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 9px 14px; display: flex; justify-content: space-between; }
.me-row[hidden] { display: none; }

/* desktop side leaderboard */
.side-card { background: #fff; border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: 5px 5px 0 var(--ink); overflow: hidden; }
.side-head { background: var(--navy); color: #fff; font-family: var(--stencil); font-size: 24px; text-transform: uppercase; letter-spacing: 1.5px; padding: 12px 16px 10px; display: flex; align-items: center; gap: 10px; }
.live-dot { width: 10px; height: 10px; border-radius: 50%; background: #ff5a4f; box-shadow: 0 0 0 0 rgba(255,90,79,.7); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(255,90,79,0); } 100% { box-shadow: 0 0 0 0 rgba(255,90,79,0); } }
.side-sub { margin: 0; padding: 10px 16px 0; font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.side .board { padding: 6px 8px 10px; }
.side .board li { padding: 7px 10px; }
.side .board .s { font-size: 18px; }
.side .me-row { width: auto; margin: 0 10px 12px; }

/* ───────── product carousel ───────── */
.shop { width: 100%; text-align: left; margin-top: 6px; }
.shop[hidden] { display: none; }
.shop-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 8px; }
.shop-head h2 { font-family: var(--stencil); font-size: 24px; text-transform: uppercase; letter-spacing: 1px; margin: 0; }
.shop-head a { color: var(--navy); font-size: 14px; font-weight: 800; white-space: nowrap; }
.shop-track {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-behavior: smooth;
  padding: 2px 6px 10px 2px; scrollbar-width: none; outline: none;
}
.shop-track::-webkit-scrollbar { display: none; }
.shop-card {
  flex: 0 0 72%; max-width: 260px; scroll-snap-align: start; text-decoration: none; color: var(--ink);
  background: #fff; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 4px 4px 0 var(--ink); overflow: hidden;
  transition: transform .15s;
}
.shop-card:hover { transform: translateY(-3px) rotate(-.5deg); }
.shop-img { position: relative; aspect-ratio: 4 / 3; background: var(--sky-pale); border-bottom: 3px solid var(--ink); }
.shop-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shop-badge { position: absolute; top: 8px; left: 8px; font-style: normal; background: #ffd23f; border: 2px solid var(--ink); border-radius: 999px; padding: 1px 9px; font-size: 12px; font-weight: 800; }
.shop-info { padding: 9px 12px 11px; display: flex; flex-direction: column; gap: 2px; }
.shop-info b { font-family: var(--round); font-size: 16px; line-height: 1.15; }
.shop-info span { color: var(--blue); font-weight: 800; font-size: 15px; }
.shop-dots { display: flex; justify-content: center; gap: 6px; }
.shop-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(17,24,32,.25); transition: all .2s; }
.shop-dots i.on { background: var(--ink); width: 20px; border-radius: 6px; }
@media (min-width: 1000px) { .shop-card { flex-basis: 46%; } }

/* tiny admin lock, bottom-left */
.admin-lock {
  position: fixed; left: 10px; bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 3;
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%;
  background: rgba(255,255,255,.7); border: 2px solid rgba(17,24,32,.35); opacity: .55; transition: opacity .2s;
}
.admin-lock:hover, .admin-lock:focus-visible { opacity: 1; }
.admin-lock svg { width: 13px; height: 14px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; }
body[data-view="game"] .admin-lock { display: none; }

/* carousel under the game: compact */
.shop-game { margin-top: 14px; }
.shop-game .shop-head h2 { font-size: 20px; }
.shop-game .shop-card { flex-basis: 44%; }
.shop-game .shop-img { aspect-ratio: 1 / 1; }
.shop-game .shop-info b { font-size: 14px; overflow-wrap: anywhere; }
.shop-game .shop-info span { font-size: 13px; }
@media (min-width: 1000px) { .shop-game .shop-card { flex-basis: 30%; } }
