:root {
  --gold: #f6c557;
  --gold-lt: #ffe08a;
  --gold-deep: #d89b2e;
  --red: #e8313a;
  --red-deep: #b70f16;
  --bg: #06101f;
  --card: rgba(10, 22, 42, 0.72);
  --card-line: rgba(120, 160, 220, 0.18);
  --text: #f6f8ff;
  --muted: #9fb0c8;
  --line: #283b5a;
  --green: #34d36a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Baloo 2", "Segoe UI", Arial, Helvetica, sans-serif;
  background: #03060f;
  color: var(--text);
  overflow: hidden;
  user-select: none;
}

/* Background — night scene + moon glow */
.bg {
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(60,110,190,.28) 0, transparent 60%),
    url("../assets/bg-night.png") center/cover no-repeat,
    linear-gradient(180deg, #123059 0, #071224 55%, #030913 100%);
}

/* Dev banner */
.dev-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: repeating-linear-gradient(45deg, #2a1b00, #2a1b00 10px, #3a2600 10px, #3a2600 20px);
  color: #ffd24d; font-size: 11px; font-weight: 700; text-align: center;
  padding: 4px; letter-spacing: .3px;
}

/* App shell — phone-sized centered column */
.app {
  position: relative; z-index: 1;
  width: 100%; max-width: 430px; height: 100dvh; margin: 0 auto;
  padding: 30px 22px 26px;
  display: flex; flex-direction: column;
}

.screen { display: none; flex: 1; flex-direction: column; align-items: center; text-align: center; animation: fade .4s ease; }
.screen.active { display: flex; }
@keyframes fade { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Brand + display type */
.brand-mini { font-size: 13px; letter-spacing: 5px; font-weight: 800; color: var(--gold); margin-top: 4px; text-shadow: 0 0 12px rgba(246,197,87,.4); }
.hero-tiger { width: 205px; max-width: 62%; margin: 10px 0 2px; filter: drop-shadow(0 14px 26px rgba(0,0,0,.55)); animation: bob 3s ease-in-out infinite; }
.hero-tiger.sm { width: 128px; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.title {
  font-size: 33px; font-weight: 800; line-height: 1.02; margin: 4px 0 6px; letter-spacing: .5px;
  color: #ffe9b0;
  text-shadow: 0 2px 0 #7a3b12, 0 0 18px rgba(255,170,40,.35);
}
.title .lg { display: block; font-size: 40px; color: #fff; -webkit-text-stroke: 1px rgba(122,59,18,.5); }
.title.sm { font-size: 24px; }
.subtitle { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0 6px 14px; }
.subtitle.big { font-size: 17px; color: var(--gold); font-weight: 800; margin-top: 22px; text-shadow: 0 0 14px rgba(255,150,0,.4); }

/* Card */
.card {
  width: 100%; background: var(--card); border: 1px solid var(--card-line);
  border-radius: 20px; padding: 16px; margin: 8px 0;
  backdrop-filter: blur(6px); box-shadow: 0 12px 30px rgba(0,0,0,.35);
}

/* Form fields */
.field { width: 100%; text-align: left; margin: 8px 0; }
.field label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 6px; letter-spacing: .5px; }
.field input {
  width: 100%; padding: 14px 16px; font-size: 16px; border-radius: 14px;
  background: #0d1b2f; border: 1px solid var(--line); color: var(--text); outline: none;
}
.field input:focus { border-color: var(--gold); }
.tac-input { text-align: center; letter-spacing: 12px; font-size: 26px; font-weight: 800; }

/* ALTCHA */
.altcha-wrap { width: 100%; display: flex; justify-content: center; margin: 12px 0 2px; }
.altcha-wrap altcha-widget {
  width: 100%; --altcha-max-width: 100%;
  --altcha-color-base: #0d1b2f; --altcha-color-border: #283b5a; --altcha-color-text: #f6f8ff;
  --altcha-color-border-focus: #f6c557; --altcha-color-error-text: #ff8088; --altcha-border-radius: 14px;
}

/* Buttons */
.btn {
  width: 100%; margin-top: 14px; padding: 16px; border: 0; border-radius: 18px; cursor: pointer;
  background: linear-gradient(180deg, var(--gold-lt), var(--gold-deep));
  color: #4a2a00; font-size: 17px; font-weight: 800; letter-spacing: .5px;
  box-shadow: 0 10px 26px rgba(216,155,46,.45), inset 0 1px 0 rgba(255,255,255,.5);
  transition: transform .08s ease, filter .15s ease;
}
.btn:active { transform: translateY(2px) scale(.99); }
.btn:disabled { filter: grayscale(.5) brightness(.85); cursor: default; box-shadow: none; }
.btn.link { background: none; box-shadow: none; color: var(--muted); font-weight: 600; font-size: 13px; margin-top: 8px; }
.btn.glow { animation: btnGlow 1.8s ease-in-out infinite; }
@keyframes btnGlow { 0%,100% { box-shadow: 0 10px 26px rgba(216,155,46,.45); } 50% { box-shadow: 0 10px 34px rgba(255,200,80,.75); } }
.form-msg { margin-top: 12px; font-size: 13px; min-height: 18px; }
.form-msg.err { color: #ff8088; }
.form-msg.ok { color: var(--green); }
.form-msg .devcode { color: var(--gold); font-weight: 800; }

/* Waiting — NEXT RAIN card + players joined */
.rain-card { width: 100%; margin-top: 6px; }
.rain-card .rc-label { font-size: 12px; letter-spacing: 4px; color: var(--muted); font-weight: 700; }
.next-rain { font-size: 46px; font-weight: 800; color: #fff; letter-spacing: 3px; margin: 4px 0 2px; font-variant-numeric: tabular-nums; text-shadow: 0 0 20px rgba(120,180,255,.35); }
.next-rain.live { color: var(--gold); text-shadow: 0 0 22px rgba(255,180,40,.6); }
.rc-sub { font-size: 13px; color: var(--gold); font-weight: 700; letter-spacing: 1px; }
.players { width: 100%; margin-top: auto; }
.players .p-label { font-size: 11px; letter-spacing: 3px; color: var(--muted); }
.players .p-count { font-size: 15px; }
.players .p-count b { color: var(--gold); font-size: 17px; }

/* Countdown ring */
[data-screen="countdown"] { justify-content: center; }
.ring-wrap { position: relative; margin: 0 0 8px; }
.ring { width: 210px; height: 210px; transform: rotate(-90deg); filter: drop-shadow(0 0 16px rgba(246,197,87,.4)); }
.ring-track { fill: none; stroke: #16263f; stroke-width: 9; }
.ring-fill { fill: none; stroke: var(--gold); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 0; transition: stroke-dashoffset 1s linear; }
.ring-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 64px; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }

/* Roar */
.roar-screen { justify-content: center; }
.roar-tiger { width: 84%; max-width: 340px; filter: drop-shadow(0 0 40px rgba(255,140,20,.6)); animation: roarPulse .5s ease-in-out infinite alternate; }
@keyframes roarPulse { from { transform: scale(1); } to { transform: scale(1.06); } }
.roar-text { font-size: 48px; font-weight: 800; color: #ffd24d; letter-spacing: 1px; text-shadow: 0 0 24px rgba(255,120,0,.9), 0 3px 0 #7a2b00; margin-top: 8px; }
.shake { animation: shake .5s linear infinite; }
@keyframes shake {
  0%,100% { transform: translate(0,0) rotate(0); }
  20% { transform: translate(-6px,4px) rotate(-1deg); }
  40% { transform: translate(6px,-4px) rotate(1deg); }
  60% { transform: translate(-5px,-3px) rotate(0); }
  80% { transform: translate(5px,3px) rotate(1deg); }
}

/* Rain + catch */
[data-screen="rain"] { padding: 0; }
.rain-storm { position: absolute; inset: 0; background: radial-gradient(120% 80% at 50% 0, rgba(255,120,0,.10) 0, transparent 55%), linear-gradient(180deg, rgba(3,8,20,.2), rgba(3,8,20,.55)); z-index: 1; pointer-events: none; }
.hud { position: absolute; top: 34px; left: 16px; right: 16px; display: flex; justify-content: space-between; z-index: 4; font-weight: 800; }
.hud-timer, .hud-score { background: rgba(6,16,31,.75); border: 1px solid var(--card-line); border-radius: 14px; padding: 7px 14px; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.hud-timer span { color: var(--gold); font-variant-numeric: tabular-nums; }
.hud-total { position: absolute; top: 78px; left: 0; right: 0; text-align: center; z-index: 4; font-size: 30px; font-weight: 800; color: var(--gold); text-shadow: 0 2px 10px rgba(0,0,0,.7), 0 0 20px rgba(255,180,40,.4); }
.hud-total span { font-variant-numeric: tabular-nums; }
.rain-field { position: absolute; inset: 0; overflow: hidden; z-index: 3; }
.catch-chest { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); width: 170px; z-index: 4; filter: drop-shadow(0 -4px 16px rgba(255,160,40,.4)); pointer-events: none; }
.catch-chest.pulse { animation: chestPulse .3s ease; }
@keyframes chestPulse { 50% { transform: translateX(-50%) scale(1.08); } }

.angpao, .drop-coin { position: absolute; top: -130px; animation: fall linear forwards; will-change: transform; }
.angpao { width: 62px; cursor: pointer; }
.angpao::after { content: ""; position: absolute; left: 50%; top: -34px; width: 8px; height: 40px; transform: translateX(-50%); background: linear-gradient(180deg, rgba(255,180,40,0), rgba(255,120,0,.6)); filter: blur(3px); border-radius: 50%; }
.angpao img { width: 100%; pointer-events: none; filter: drop-shadow(0 6px 10px rgba(0,0,0,.5)); }
.drop-coin { width: 34px; opacity: .9; }
.drop-coin img { width: 100%; }
@keyframes fall { to { transform: translateY(118dvh) rotate(var(--spin, 8deg)); } }

.pop { position: absolute; z-index: 6; transform: translate(-50%,-50%) scale(.6); text-align: center; pointer-events: none; animation: popUp .9s ease forwards; }
.pop .burst { font-size: 28px; font-weight: 800; color: #ffd24d; text-shadow: 0 0 12px rgba(255,150,0,.9); }
.pop .amt { display: inline-block; margin-top: 2px; background: var(--red); color: #fff; font-weight: 800; font-size: 15px; padding: 3px 11px; border-radius: 999px; box-shadow: 0 4px 10px rgba(0,0,0,.4); }
@keyframes popUp {
  0% { transform: translate(-50%,-50%) scale(.5); opacity: 0; }
  25% { transform: translate(-50%,-62%) scale(1.15); opacity: 1; }
  100% { transform: translate(-50%,-132%) scale(1); opacity: 0; }
}
.rain-title { position: absolute; bottom: 128px; left: 0; right: 0; text-align: center; font-size: 22px; font-weight: 800; color: #fff; opacity: .16; letter-spacing: 3px; z-index: 2; }

/* Summary */
[data-screen="summary"] { justify-content: center; }
.good-job { font-size: 38px; font-weight: 800; color: var(--gold); letter-spacing: 1px; text-shadow: 0 0 16px rgba(255,150,0,.55), 0 3px 0 #7a3b12; }
.collected-card { width: 100%; text-align: center; }
.collected-label { letter-spacing: 3px; color: var(--muted); font-size: 12px; }
.collected-amt { font-size: 52px; font-weight: 800; color: var(--gold); margin: 2px 0; text-shadow: 0 0 22px rgba(255,180,40,.5); }
.collected-amt span { font-variant-numeric: tabular-nums; }
.collected-sub { color: #fff; font-weight: 700; }
.collected-sub .all { color: var(--green); display: block; font-size: 13px; margin-top: 2px; }

/* Claim */
[data-screen="claim"] { justify-content: center; }
.claim-amt { font-size: 46px; font-weight: 800; color: var(--gold); text-shadow: 0 0 20px rgba(255,180,40,.5); margin: 2px 0; }
.claim-into { color: var(--muted); font-size: 14px; margin-bottom: 4px; }
.claim-into b { color: #fff; }
.creds { width: 100%; }
.creds .cred-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; border-bottom: 1px dashed var(--line); }
.creds .cred-row:last-child { border-bottom: 0; }
.creds .cred-k { font-size: 11px; letter-spacing: 2px; color: var(--muted); }
.creds .cred-v { font-size: 18px; font-weight: 800; color: #fff; letter-spacing: 1px; }
.claim-note { color: var(--muted); font-size: 11px; margin-top: 8px; }
.status-ok { color: var(--green); font-weight: 800; }
.status-pending { color: var(--gold); font-weight: 800; }
.claim-box { width: 100%; }
.claim-box .row { display: flex; justify-content: space-between; margin: 5px 0; font-size: 13px; color: var(--muted); }
.claim-box .row b { color: var(--text); }

/* Jumpa Lagi — winners */
[data-screen="bye"] { justify-content: flex-start; }
.winners { width: 100%; text-align: left; }
.winners .w-title { text-align: center; font-size: 13px; letter-spacing: 3px; color: var(--gold); font-weight: 800; margin-bottom: 8px; }
.w-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid rgba(120,160,220,.1); }
.w-row:last-child { border-bottom: 0; }
.w-rank { width: 26px; height: 26px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; color: #3a2600; background: var(--line); }
.w-row:nth-child(1) .w-rank { background: linear-gradient(180deg,#ffe08a,#d89b2e); }
.w-row:nth-child(2) .w-rank { background: linear-gradient(180deg,#e6e9f2,#a9b3c9); }
.w-row:nth-child(3) .w-rank { background: linear-gradient(180deg,#f0b47a,#b9722f); }
.w-name { flex: 1; font-weight: 700; color: #fff; }
.w-amt { font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

/* Spinner */
.spinner { width: 34px; height: 34px; border: 4px solid var(--line); border-top-color: var(--gold); border-radius: 50%; margin: 6px auto; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Confetti / coin burst (summary + claim) */
.burst-field { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.burst-field .cf { position: absolute; top: -20px; width: 12px; height: 12px; border-radius: 3px; opacity: .9; animation: cfFall linear forwards; }
@keyframes cfFall { to { transform: translateY(110dvh) rotate(540deg); } }
