:root {
  --sky-1: #ff8a5b;     /* coral sunset */
  --sky-2: #ffc06a;     /* peach */
  --sky-3: #ffe3a3;     /* horizon haze */
  --sea-1: #27c4d6;     /* turquoise */
  --sea-2: #0b7a8f;     /* deep teal */
  --sea-3: #06485a;     /* abyss */
  --navy: #0e2a47;
  --navy-dim: rgba(14, 42, 71, 0.64);
  --white: #ffffff;
  --cream: #fff6e0;
  --sun: #ffb52e;
  --sun-2: #ffd36b;
  --coral: #ff6b4a;
  --coral-2: #ff8f6b;
  --ok: #2ec487;
  --danger: #e8453c;
  --card-bg: rgba(255, 255, 255, 0.93);
  --card-line: rgba(255, 255, 255, 0.7);
  --radius: 22px;
  --display: 'Unbounded', 'Arial Black', system-ui, sans-serif;
  --sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--navy);
  background: var(--sea-2);
  padding: max(12px, env(safe-area-inset-top)) 16px calc(28px + env(safe-area-inset-bottom));
  line-height: 1.4;
  overflow-x: hidden;
}

/* ---------- scenery ---------- */
.sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background: linear-gradient(180deg, var(--sky-1) 0%, var(--sky-2) 26%, var(--sky-3) 42%, var(--sea-1) 50%, var(--sea-2) 78%, var(--sea-3) 100%);
}
.sun {
  position: fixed; left: 50%; top: 38vh; width: 46vmin; height: 46vmin; margin-left: -23vmin; z-index: 0; pointer-events: none;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,246,224,0.95) 0%, rgba(255,211,107,0.7) 30%, rgba(255,181,46,0.25) 55%, transparent 70%);
  filter: blur(2px);
  animation: sunglow 6s ease-in-out infinite;
}
@keyframes sunglow { 0%,100% { transform: scale(1); opacity: .9 } 50% { transform: scale(1.06); opacity: 1 } }
.sea { position: fixed; left: 0; right: 0; bottom: 0; height: 26vh; z-index: 0; pointer-events: none; overflow: hidden; }
.wave { position: absolute; left: 0; bottom: 0; width: 200%; height: 100%; fill: rgba(255,255,255,0.08); animation: drift 14s linear infinite; }
.wave.w2 { fill: rgba(255,255,255,0.06); animation-duration: 22s; animation-direction: reverse; bottom: -8%; }
@keyframes drift { from { transform: translateX(0) } to { transform: translateX(-50%) } }

/* ---------- header ---------- */
.top { position: relative; z-index: 1; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; max-width: 560px; margin: 0 auto 14px; }
.brand-title {
  font-family: var(--display); font-weight: 900; text-transform: uppercase; line-height: 0.98; letter-spacing: -0.01em;
  color: var(--cream); display: flex; flex-direction: column; transform: rotate(-2deg); transform-origin: left center;
  text-shadow: 2px 2px 0 var(--coral), 4px 4px 0 rgba(14,42,71,0.35);
}
.brand-title span:first-child { font-size: 24px; }
.brand-title span:last-child { font-size: 13px; letter-spacing: 0.02em; }
.top-right { text-align: right; font-size: 12px; color: var(--cream); padding-top: 4px; white-space: nowrap; text-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.top-right b { color: var(--sun-2); font-weight: 800; }
.top-right .crown { color: var(--sun-2); }

.screen { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }

/* ---------- cards ---------- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-line);
  border-radius: var(--radius);
  padding: 22px 18px;
  box-shadow: 0 18px 40px rgba(6, 72, 90, 0.35), inset 0 1px 0 rgba(255,255,255,0.9);
  position: relative;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card.gold { box-shadow: 0 0 0 3px rgba(255,181,46,0.55), 0 22px 50px rgba(6,72,90,0.4); }
.card.center { text-align: center; }
.card.admin-box { background: rgba(14,42,71,0.72); color: var(--cream); border-style: dashed; border-color: rgba(255,255,255,0.35); }
.card.admin-box .kicker { color: var(--sun-2); }

.kicker { font-size: 11px; letter-spacing: 0.24em; text-transform: uppercase; color: var(--coral); font-weight: 800; margin-bottom: 8px; }
h2 { font-family: var(--display); font-weight: 800; font-size: 26px; line-height: 1.1; margin: 0 0 10px; letter-spacing: -0.01em; }
h3 { font-family: var(--display); font-weight: 600; font-size: 18px; margin: 0 0 8px; }
p { margin: 6px 0; }
.muted { color: var(--navy-dim); font-size: 14px; }
.topic {
  font-family: var(--sans); font-weight: 800; font-size: 22px; line-height: 1.25; color: var(--navy);
  padding: 16px 14px; margin: 10px 0;
  background: linear-gradient(135deg, rgba(255,211,107,0.35), rgba(39,196,214,0.22));
  border: 2px dashed rgba(14,42,71,0.18); border-radius: 16px;
}
.topic.joke {
  font-weight: 600; font-size: 17px; text-align: left; line-height: 1.4;
  background: linear-gradient(135deg, rgba(255,107,74,0.18), rgba(255,211,107,0.35));
  border-color: rgba(255,107,74,0.45);
}

/* ---------- timer ---------- */
.timer { font-variant-numeric: tabular-nums; font-family: var(--display); font-weight: 900; font-size: 64px; line-height: 1; color: var(--sea-2); margin: 10px 0 4px; }
.timer.warn { color: var(--sun); }
.timer.over { color: var(--danger); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.timer-bar { height: 8px; border-radius: 8px; background: rgba(14,42,71,0.12); overflow: hidden; margin: 10px 0 2px; }
.timer-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--sea-1), var(--sun)); transition: width 1s linear; }
.timer-bar.over > i { background: var(--danger); }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; border: 0; cursor: pointer; font-family: var(--sans);
  font-weight: 800; font-size: 17px; padding: 16px 18px; border-radius: 16px;
  background: linear-gradient(180deg, var(--sun-2), var(--sun)); color: var(--navy);
  box-shadow: 0 8px 0 #d98f10, 0 14px 24px rgba(6,72,90,0.3);
  transition: transform .08s ease, box-shadow .08s ease, filter .15s ease;
  margin-top: 12px;
}
.btn:active { transform: translateY(5px); box-shadow: 0 3px 0 #d98f10, 0 8px 16px rgba(6,72,90,0.3); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.secondary { background: var(--white); color: var(--sea-2); border: 2px solid var(--sea-1); box-shadow: 0 6px 0 rgba(11,122,143,0.35); }
.btn.secondary:active { box-shadow: 0 2px 0 rgba(11,122,143,0.35); }
.btn.danger { background: var(--white); color: var(--danger); border: 2px solid rgba(232,69,60,0.5); box-shadow: 0 6px 0 rgba(232,69,60,0.25); }
.btn.danger:active { box-shadow: 0 2px 0 rgba(232,69,60,0.25); }
.btn.small { font-size: 14px; padding: 10px 14px; width: auto; display: inline-block; margin: 8px 8px 0 0; box-shadow: 0 4px 0 rgba(0,0,0,0.15); }
.btn.small:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
.admin-box .btn.secondary { background: rgba(255,255,255,0.1); color: var(--cream); border-color: rgba(255,255,255,0.5); }
.admin-box .btn.danger { background: rgba(255,255,255,0.08); color: #ffb3ad; border-color: rgba(255,179,173,0.5); }
.row { display: flex; gap: 10px; }

.input {
  width: 100%; font-family: var(--sans); font-size: 18px; font-weight: 600; padding: 15px 16px; border-radius: 16px;
  background: #fff; border: 2px solid rgba(14,42,71,0.15); color: var(--navy); outline: none;
}
.input:focus { border-color: var(--sea-1); box-shadow: 0 0 0 4px rgba(39,196,214,0.25); }
.input::placeholder { color: rgba(14,42,71,0.4); font-weight: 500; }

/* ---------- players ---------- */
.players { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px;
  background: rgba(39,196,214,0.1); border: 1px solid rgba(11,122,143,0.12);
}
.players li.me { border-color: var(--sun); background: rgba(255,211,107,0.25); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #b5c2cc; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 10px rgba(46,196,135,0.8); }
.pname { flex: 1; font-weight: 700; font-size: 16px; }
.crown { color: var(--sun); font-size: 14px; }
.tag { font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 800; color: #fff; background: var(--coral); border-radius: 999px; padding: 3px 9px; }
.tag.done { color: var(--navy-dim); background: rgba(14,42,71,0.08); }
.x { background: none; border: 0; color: var(--navy-dim); font-size: 22px; padding: 0 4px; cursor: pointer; }

/* ---------- stars ---------- */
.stars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin: 14px 0 4px; }
.star {
  border: 2px solid rgba(14,42,71,0.12); background: #fff; color: var(--navy); border-radius: 16px;
  font-size: 22px; font-weight: 800; padding: 13px 0; cursor: pointer; font-family: var(--sans);
  transition: transform .08s ease, background .15s ease; box-shadow: 0 4px 0 rgba(14,42,71,0.08);
}
.star small { display: block; font-size: 12px; color: var(--sun); font-weight: 700; }
.star.on { background: linear-gradient(180deg, var(--sun-2), var(--sun)); border-color: var(--sun); box-shadow: 0 4px 0 #d98f10; transform: translateY(-2px) scale(1.04); }
.star.on small { color: var(--navy); }
.star:active { transform: scale(0.94); }
.my-vote { font-size: 15px; margin-top: 10px; }
.my-vote b { color: var(--coral); font-size: 18px; }

.greet h2 { font-size: 22px; line-height: 1.25; margin: 6px 0 16px; }
.greet-emoji { font-size: 56px; line-height: 1; margin: 4px 0 10px; animation: bob 2.4s ease-in-out infinite; }
.prep { font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--sea-2); margin: 4px 0 8px; }
.sealed { font-size: 44px; line-height: 1; margin: 6px 0 4px; }
.big-score { font-family: var(--display); font-size: 72px; font-weight: 900; line-height: 1; color: var(--coral); margin: 6px 0; }
.big-score small { font-size: 20px; color: var(--navy-dim); font-family: var(--sans); font-weight: 600; margin-left: 4px; }
.votes { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.votes span { background: rgba(39,196,214,0.12); border: 1px solid rgba(11,122,143,0.15); border-radius: 999px; padding: 4px 11px; font-size: 13px; font-weight: 600; }
.votes span b { color: var(--coral); margin-left: 4px; }

/* ---------- leaderboard ---------- */
.lb { width: 100%; border-collapse: collapse; margin-top: 8px; }
.lb td { padding: 10px 6px; border-bottom: 1px solid rgba(14,42,71,0.08); vertical-align: middle; }
.lb tr:last-child td { border-bottom: 0; }
.lb .place { width: 36px; font-family: var(--display); font-weight: 800; font-size: 18px; color: var(--coral); text-align: center; }
.lb .total { text-align: right; font-weight: 800; font-size: 18px; color: var(--sea-2); white-space: nowrap; }
.lb .sub { display: block; font-size: 12px; color: var(--navy-dim); font-weight: 500; }
.lb tr.me td { background: rgba(255,211,107,0.2); }

.podium { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 8px; align-items: end; margin: 12px 0 6px; }
.podium .p { text-align: center; border-radius: 16px 16px 8px 8px; background: rgba(39,196,214,0.12); border: 1px solid rgba(11,122,143,0.15); padding: 12px 6px; }
.podium .p.first { border-color: var(--sun); background: linear-gradient(180deg, rgba(255,211,107,0.5), rgba(255,181,46,0.15)); padding-top: 22px; }
.podium .medal { font-size: 30px; }
.podium .nm { font-weight: 800; font-size: 14px; word-break: break-word; }
.podium .sc { color: var(--coral); font-family: var(--display); font-weight: 800; font-size: 20px; }

.pulse { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--coral); margin-right: 8px; animation: pulse 1.4s ease-in-out infinite; vertical-align: middle; }
@keyframes pulse { 0%,100% { transform: scale(0.8); opacity: .6 } 50% { transform: scale(1.2); opacity: 1 } }

/* ---------- login hero ---------- */
.hero-card { padding: 0; overflow: hidden; }
.hero-scene { width: 100%; aspect-ratio: 16 / 9; overflow: hidden; }
.hero-scene .scene { width: 100%; height: 100%; display: block; }
.hero-body { padding: 18px 18px 22px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 15px;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 50; max-width: 90vw; text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.fade { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- intro ---------- */
.intro { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; overflow: hidden; transition: opacity .6s ease, visibility .6s;
  background: linear-gradient(180deg, #1aa9bd 0%, var(--sea-2) 55%, var(--sea-3) 100%); }
.intro.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.intro-scene { position: absolute; left: 0; top: 0; width: 100%; height: min(62vh, 130vw); overflow: hidden; }
.intro-scene::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 28%; background: linear-gradient(180deg, rgba(11,122,143,0), var(--sea-2)); pointer-events: none; }
.intro-scene .scene { width: 100%; height: 100%; display: block; animation: kenburns 9s ease-out forwards; transform-origin: 50% 60%; }
@keyframes kenburns { from { transform: scale(1.1); } to { transform: scale(1); } }
.intro-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(6,72,90,0) 0%, rgba(6,72,90,0) 45%, rgba(6,72,90,0.45) 70%, rgba(6,40,56,0.9) 100%); }
.intro-content { position: relative; text-align: center; padding: 0 22px calc(40px + env(safe-area-inset-bottom)); max-width: 620px; width: 100%; }
.intro-kicker { color: var(--sun-2); font-weight: 800; letter-spacing: 0.26em; text-transform: uppercase; font-size: 12px; opacity: 0; animation: rise .7s ease .4s forwards; text-shadow: 0 2px 6px rgba(0,0,0,0.5); }
.intro-title { margin: 10px 0 8px; font-family: var(--display); font-weight: 900; text-transform: uppercase; color: var(--cream); line-height: 0.98; letter-spacing: -0.01em;
  text-shadow: 3px 3px 0 var(--coral), 6px 6px 0 rgba(14,42,71,0.45), 0 10px 30px rgba(0,0,0,0.4); transform: rotate(-2deg); }
.intro-title .line { display: block; opacity: 0; transform: translateY(30px) scale(0.9); }
.intro-title .l1 { font-size: clamp(30px, 9vw, 56px); animation: pop .8s cubic-bezier(.2,1.4,.3,1) .8s forwards; }
.intro-title .l2 { font-size: clamp(22px, 7vw, 44px); animation: pop .8s cubic-bezier(.2,1.4,.3,1) 1.15s forwards; }
.intro-sub { color: #fff; font-weight: 600; font-size: 16px; opacity: 0; animation: rise .7s ease 1.8s forwards; text-shadow: 0 2px 8px rgba(0,0,0,0.6); }
.intro .sun-btn { max-width: 320px; margin: 18px auto 0; opacity: 0; animation: rise .6s ease 2.3s forwards; font-size: 18px; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(30px) scale(0.9); } to { opacity: 1; transform: none; } }
@media (orientation: landscape) {
  .intro-scene { height: 100%; }
  .intro-scene::after { display: none; }
  .intro-shade { background: linear-gradient(180deg, rgba(6,72,90,0) 0%, rgba(6,72,90,0) 40%, rgba(6,72,90,0.5) 70%, rgba(6,40,56,0.92) 100%); }
}

@media (prefers-reduced-motion: reduce) {
  .intro-scene .scene, .sun, .wave, .sc-yacht, .sc-glints, .sc-wave, .sc-sun { animation: none; }
  .intro-kicker, .intro-title .line, .intro-sub, .intro .sun-btn { animation-duration: .01s; animation-delay: 0s; }
}
@media (min-width: 600px) {
  .brand-title span:first-child { font-size: 30px; }
  .brand-title span:last-child { font-size: 16px; }
  h2 { font-size: 32px; }
  .topic { font-size: 26px; }
  .timer { font-size: 88px; }
}

/* ---------- skyline on the page background ---------- */
.skyline { position: fixed; left: 0; right: 0; top: calc(50vh - 70px); height: 70px; z-index: 0; pointer-events: none; }
.skyline svg { width: 100%; height: 100%; display: block; }

/* ---------- scene animations ---------- */
.scene { overflow: hidden; }
.sc-yacht { animation: bob 4.5s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 100%; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(0deg); } 50% { transform: translateY(3px) rotate(-0.8deg); } }
.sc-glints { animation: glint 2.4s ease-in-out infinite; }
@keyframes glint { 0%,100% { opacity: .85 } 50% { opacity: .35 } }
.sc-sun { animation: sunpulse 5s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes sunpulse { 0%,100% { transform: scale(1) } 50% { transform: scale(1.06) } }
.sc-wave { animation: scdrift 9s linear infinite; }
.sc-w2 { animation-duration: 14s; animation-direction: reverse; }
@keyframes scdrift { from { transform: translateX(0) } to { transform: translateX(400px) } }

/* ---------- drum ---------- */
.drum { position: relative; margin: 14px auto 6px; max-width: 360px; }
.drum-win {
  height: 216px; overflow: hidden; border-radius: 18px; position: relative;
  background: linear-gradient(180deg, #e9f6f8 0%, #ffffff 35%, #ffffff 65%, #e9f6f8 100%);
  border: 2px solid rgba(11,122,143,0.2); box-shadow: inset 0 10px 24px rgba(14,42,71,0.12), inset 0 -10px 24px rgba(14,42,71,0.12);
}
.drum-win::before, .drum-win::after { content: ""; position: absolute; left: 0; right: 0; height: 72px; pointer-events: none; z-index: 2; }
.drum-win::before { top: 0; background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,255,255,0)); }
.drum-win::after { bottom: 0; background: linear-gradient(0deg, rgba(255,255,255,0.95), rgba(255,255,255,0)); }
.drum-win .reel { list-style: none; margin: 0; padding: 0; position: absolute; left: 0; right: 0; top: 72px; will-change: transform; }
.drum-win .reel li {
  height: 72px; display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 800; font-size: 24px; color: var(--navy); letter-spacing: -0.01em; padding: 0 16px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.drum-win .reel li.win { color: var(--coral); animation: winpop .5s cubic-bezier(.2,1.6,.3,1) both; }
@keyframes winpop { from { transform: scale(0.9); } to { transform: scale(1.12); } }
.drum-marker { position: absolute; top: 50%; width: 0; height: 0; margin-top: -10px; border-top: 10px solid transparent; border-bottom: 10px solid transparent; z-index: 3; }
.drum-marker.left { left: -4px; border-left: 14px solid var(--coral); }
.drum-marker.right { right: -4px; border-right: 14px solid var(--coral); }
.drum::after { content: ""; position: absolute; left: 10px; right: 10px; top: 50%; height: 72px; margin-top: -36px; border-radius: 12px; border: 2px solid var(--sun); pointer-events: none; z-index: 2; box-shadow: 0 0 0 4px rgba(255,181,46,0.18); }
.drum-card.landed .drum::after { border-color: var(--coral); box-shadow: 0 0 0 6px rgba(255,107,74,0.22); }
.win-text { color: var(--coral); font-size: 18px; }
