:root {
  --bg: #0b0704;
  --orange: #F39320;
  --orange-d: #c96d07;
  --gold: #FFD24A;
  --gold-l: #FFF0B3;
  --text: #fbefe0;
  --muted: #c4b098;
  --card: rgba(20, 11, 4, .78);
  --line: rgba(243, 147, 32, .45);
  --horizon: 54vh;
  /* egg cell size: 3 rows always fit on screen without scrolling */
  --cell: min(calc((100vw - 40px) / 3), calc((100vh - 330px) / 3.2), 150px);
}
@supports (height: 100dvh) {
  :root { --cell: min(calc((100vw - 40px) / 3), calc((100dvh - 330px) / 3.2), 150px); }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
@supports (overflow-x: clip) { html, body { overflow-x: clip; } }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Poppins, system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- background scene ---------- */
.scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.sky { position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 70% 22% at 50% var(--horizon), rgba(255,140,30,.55), rgba(255,110,20,0) 70%),
    linear-gradient(180deg, #060302 0%, #140904 22%, #3a1605 40%, #8a3509 50%, #d4600f var(--horizon), #2a1408 calc(var(--horizon) + 1px), #120904 100%); }
.city { position: absolute; left: 0; width: 100%; bottom: calc(100% - var(--horizon)); height: 30vh; }
.floor { position: absolute; left: -50%; right: -50%; top: var(--horizon); bottom: -10vh; transform-origin: 50% 0;
  transform: perspective(300px) rotateX(58deg);
  background:
    linear-gradient(rgba(243,120,30,.0), rgba(0,0,0,.0)),
    repeating-linear-gradient(90deg, rgba(0,0,0,.55) 0 2px, transparent 2px 64px),
    repeating-linear-gradient(0deg, rgba(0,0,0,.55) 0 2px, transparent 2px 48px),
    linear-gradient(#6b4a33, #3a271a 40%, #1e140c);
  -webkit-mask: linear-gradient(#000 40%, rgba(0,0,0,.6)); mask: linear-gradient(#000 40%, rgba(0,0,0,.6)); }
.floor::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse 50% 30% at 50% 0%, rgba(255,140,40,.45), transparent 70%); }
#embers i { position: absolute; bottom: -10px; width: 3px; height: 3px; border-radius: 50%; background: #ffb24a;
  box-shadow: 0 0 6px 2px rgba(255,150,40,.7); animation: rise linear infinite; opacity: 0; }
@keyframes rise { 0% { transform: translate(0, 0); opacity: 0; } 15% { opacity: .9; } 100% { transform: translate(var(--dx, 20px), -90vh); opacity: 0; } }

/* money trees + dragons flank the eggs (behind content) */
.tree, .dragon { position: absolute; }
.tree svg, .dragon svg { display: block; width: 100%; height: 100%; overflow: visible; }
.tree { top: 3vh; height: 74vh; aspect-ratio: 400 / 640; filter: drop-shadow(0 8px 16px rgba(0,0,0,.6)); }
.tree-l { right: calc(50% + min(250px, 33vw)); }
.tree-r { left: calc(50% + min(250px, 33vw)); transform: scaleX(-1); }
.dragon { bottom: 0; height: min(52vh, 460px); aspect-ratio: 320 / 440; filter: drop-shadow(0 8px 14px rgba(0,0,0,.7)); }
.dragon-l { right: calc(50% + min(200px, 30vw)); }
.dragon-r { left: calc(50% + min(200px, 30vw)); transform: scaleX(-1); }
@media (max-width: 560px) {
  .tree { height: 56vh; top: 10vh; }
  .dragon { height: 30vh; bottom: 118px; }
  .dragon-l { right: calc(50% + 22vw); }
  .dragon-r { left: calc(50% + 22vw); }
}

/* ---------- shared ---------- */
.view { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; max-width: 560px; margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 16px max(10px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; }
/* title plaque with gold frame + hanging tassels */
.plaque { position: relative; margin: 0; display: inline-block; padding: 7px 26px 8px; border-radius: 10px;
  background: linear-gradient(180deg, #ffad42 0%, #F39320 45%, #b85a00 100%);
  border: 3px solid #FFD966; box-shadow: 0 0 0 2px #7a3c00, 0 0 0 5px #e8b23a, 0 8px 20px rgba(0,0,0,.6), 0 0 24px rgba(243,147,32,.55), inset 0 2px 0 rgba(255,255,255,.45), inset 0 -3px 0 rgba(90,40,0,.35); }
.plaque span { display: block; font-family: "Lilita One", Poppins, sans-serif; font-weight: 400; letter-spacing: 1.2px; color: #fff;
  text-shadow: 0 2px 0 #7a3000, 0 0 10px rgba(122,48,0,.6); white-space: nowrap; }
.plaque::before, .plaque::after { content: ""; position: absolute; top: calc(100% + 4px); width: 6px; height: 22px; border-radius: 0 0 3px 3px;
  background: linear-gradient(#FFD966 0 5px, #e2421f 5px); }
.plaque::before { left: 14px; }
.plaque::after { right: 14px; }
.btn-primary { border: 0; border-radius: 999px; padding: 12px 26px; min-height: 46px; font-weight: 700; letter-spacing: 1px; color: #2a1200;
  background: linear-gradient(180deg, #FFC46B 0%, var(--orange) 50%, var(--orange-d) 100%);
  box-shadow: 0 4px 0 #7a3c00, 0 6px 18px rgba(243, 147, 32, .35), inset 0 1px 0 rgba(255,255,255,.6); transition: transform .08s, box-shadow .08s; }
.btn-primary:active { transform: translateY(3px); box-shadow: 0 1px 0 #7a3c00, 0 2px 8px rgba(243, 147, 32, .3); }
.btn-primary:disabled { filter: grayscale(.6) brightness(.8); }
.btn-ghost { background: rgba(20,11,4,.7); color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 10px 20px; min-height: 44px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- login ---------- */
#vLogin { justify-content: center; }
.login-card { width: 100%; max-width: 380px; text-align: center; padding: 26px 22px 24px; border-radius: 22px;
  background: rgba(18, 10, 4, .86); border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0,0,0,.6), inset 0 0 40px rgba(243,147,32,.08);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.login-logo { width: 200px; max-width: 72%; height: auto; }
.login-card .plaque { margin: 16px 0 14px; }
.login-card .plaque span { font-size: 26px; }
.login-eggs { display: flex; justify-content: center; align-items: end; gap: 4px; margin: 14px 0 16px; }
.login-eggs .egg { width: 76px; height: 76px; pointer-events: none; }
.login-eggs .egg:nth-child(2) { width: 92px; height: 92px; }
#loginForm { text-align: left; display: grid; gap: 8px; }
#loginForm label { font-weight: 600; color: var(--gold-l); font-size: 13px; }
#loginForm input { width: 100%; padding: 13px 16px; border-radius: 12px; border: 1px solid var(--line); background: #0d0804; color: var(--text); font: inherit; font-size: 16px; }
#loginForm input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(243,147,32,.25); }
.form-err { color: #ff7a6b; min-height: 20px; margin: 0; font-size: 13px; }

/* ---------- game ---------- */
.top { width: 100%; display: flex; align-items: center; justify-content: space-between; height: 44px; }
.logo { height: 28px; width: auto; filter: drop-shadow(0 2px 4px rgba(0,0,0,.7)); }
.top-btns { display: flex; gap: 8px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #2a1200; text-decoration: none;
  background: linear-gradient(180deg, #FFC46B, var(--orange) 55%, var(--orange-d)); border: 0; box-shadow: 0 2px 0 #7a3c00, 0 0 10px rgba(243,147,32,.35); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn .bang { font-family: "Lilita One", sans-serif; font-size: 21px; line-height: 1; }
.game-plaque { margin: 4px 0 20px; }
.game-plaque span { font-size: clamp(22px, 7vw, 32px); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; max-width: 440px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 10px; text-align: center;
  box-shadow: inset 0 0 18px rgba(243,147,32,.1); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.stat span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .6px; }
.stat b { display: block; font-size: 20px; color: var(--gold); line-height: 1.25; font-variant-numeric: tabular-nums; }

.stage { width: 100%; flex: 1; display: flex; align-items: center; justify-content: center; margin: 4px 0 0; }
.grid { display: grid; grid-template-columns: repeat(3, var(--cell)); grid-auto-rows: var(--cell); gap: 0 2px; }

/* one egg sitting in its own nest */
.egg { position: relative; border: 0; padding: 0; background: none; }
.egg .nest-back, .egg .nest-front { position: absolute; left: 4%; width: 92%; bottom: 3%; height: auto; }
.egg .nest-back { z-index: 0; }
.egg .nest-front { z-index: 2; filter: drop-shadow(0 6px 6px rgba(0,0,0,.6)); }
.egg .shell { position: absolute; z-index: 1; left: 18%; width: 64%; bottom: 13%; height: auto; overflow: visible;
  filter: drop-shadow(0 4px 4px rgba(0,0,0,.45)); transform-origin: 50% 92%; transition: filter .2s; }
.egg.ready .shell { animation: idle 3.2s ease-in-out infinite; }
.egg.ready:nth-child(3n+2) .shell { animation-delay: .5s; }
.egg.ready:nth-child(3n) .shell { animation-delay: 1s; }
.egg.ready:hover .shell { filter: drop-shadow(0 4px 4px rgba(0,0,0,.45)) drop-shadow(0 0 14px rgba(255,210,74,.8)); }
@keyframes idle { 0%, 82%, 100% { transform: rotate(0); } 86% { transform: rotate(-4deg); } 90% { transform: rotate(4deg); } 94% { transform: rotate(-2deg); } }
.egg.locked .shell { filter: grayscale(1) brightness(.55) drop-shadow(0 4px 4px rgba(0,0,0,.6)); }
.egg .lock { position: absolute; z-index: 3; left: 50%; top: 46%; transform: translate(-50%, -50%); width: 24%; color: #e3d4bf; opacity: .9; }
.egg.shaking .shell { animation: shake .45s ease-in-out infinite; }
@keyframes shake { 0%, 100% { transform: rotate(0) } 20% { transform: rotate(-13deg) } 40% { transform: rotate(11deg) } 60% { transform: rotate(-8deg) } 80% { transform: rotate(6deg) } }
.egg .top-shell { transition: transform .6s cubic-bezier(.2, .9, .3, 1.3), opacity .6s .25s; transform-origin: 30% 60%; transform-box: view-box; }
.egg.cracked .top-shell { transform: translate(-8px, -40px) rotate(-38deg); opacity: 0; }
.egg.opened .top-shell { display: none; }
.egg .inside { opacity: 0; transition: opacity .2s .1s; }
.egg.cracked .inside, .egg.opened .inside { opacity: 1; }
.egg .light { position: absolute; z-index: 3; left: 50%; top: 50%; width: 0; height: 0; border-radius: 50%; transform: translate(-50%, -50%);
  background: radial-gradient(#fff 0%, rgba(255,230,140,.9) 25%, rgba(243,147,32,0) 70%); pointer-events: none; }
.egg.cracked .light { animation: flash .9s ease-out forwards; }
@keyframes flash { 0% { width: 0; height: 0; opacity: 1; } 60% { width: 240%; height: 240%; opacity: .9; } 100% { width: 280%; height: 280%; opacity: 0; } }
.egg .tag { position: absolute; z-index: 4; left: 50%; top: 30%; transform: translateX(-50%); white-space: nowrap; max-width: 104%; overflow: hidden; text-overflow: ellipsis;
  font-size: calc(var(--cell) * .1); font-weight: 700; color: #2a1200; background: linear-gradient(#FFE58A, var(--orange));
  padding: 1px 8px; border-radius: 999px; box-shadow: 0 2px 0 #7a3c00, 0 0 12px rgba(255,210,74,.6); }
.coin { position: fixed; width: 18px; height: 18px; border-radius: 50%; pointer-events: none; z-index: 40;
  background: radial-gradient(circle at 35% 35%, #fff6c9, #FFD24A 40%, #c98400 80%); box-shadow: inset 0 0 0 2px #b07000; }
.coin::after { content: ""; position: absolute; inset: 6px; border: 1.5px solid #9a6200; border-radius: 2px; }

.hint { margin: 4px 0 8px; min-height: 20px; font-size: 13px; color: var(--gold-l); text-align: center; text-shadow: 0 1px 3px #000, 0 0 8px #000; }
.hint.warn { color: #ffc48f; }
.bottom { display: flex; gap: 10px; width: 100%; justify-content: center; }
.bottom .btn-primary { flex: 1; max-width: 240px; }
.foot { margin: 6px 0 0; font-size: 11px; color: var(--muted); text-align: center; text-shadow: 0 1px 3px #000; }
.foot b { color: var(--text); font-weight: 600; }

/* ---------- modals ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px;
  background: rgba(0,0,0,.72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; width: 100%; max-width: 400px; max-height: 86vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #2a1708, #140b04); border: 1.5px solid var(--orange); border-radius: 20px; padding: 22px 18px 18px;
  box-shadow: 0 0 0 4px rgba(243,147,32,.15), 0 24px 70px rgba(0,0,0,.8); animation: pop .35s cubic-bezier(.2,.9,.3,1.3); text-align: center; }
.sheet.tall { height: 80vh; }
@keyframes pop { from { transform: scale(.7); opacity: 0; } }
.sheet h2 { margin: 0 0 12px; font-family: "Lilita One", sans-serif; font-weight: 400; letter-spacing: 1px; font-size: 26px; color: var(--gold); }
.x { position: absolute; right: 8px; top: 6px; width: 40px; height: 40px; border: 0; background: none; color: var(--muted); font-size: 28px; line-height: 1; }
.rules { text-align: left; white-space: pre-wrap; overflow: auto; flex: 1; margin-bottom: 14px; color: var(--text); font-size: 13.5px; }
.prize-sheet { overflow: hidden; padding-top: 30px; }
.prize-sheet h2 { font-size: 32px; position: relative; }
.prize-sheet .won { margin: 0; color: var(--muted); position: relative; }
.prize-name { position: relative; margin: 4px 0 10px; font-family: "Lilita One", sans-serif; font-size: 40px; line-height: 1.1;
  background: linear-gradient(180deg, #FFF3C4, #FFD24A 45%, #F39320); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #5a2a00); }
.credit-note { position: relative; margin: 0 0 18px; color: var(--gold-l); font-size: 13px; }
.burst { position: absolute; left: 50%; top: 40%; width: 520px; height: 520px; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(rgba(255,210,74,.16) 0 10deg, transparent 10deg 20deg);
  mask: radial-gradient(circle, #000 10%, transparent 60%); -webkit-mask: radial-gradient(circle, #000 10%, transparent 60%);
  animation: spin2 12s linear infinite; }
@keyframes spin2 { to { transform: translate(-50%, -50%) rotate(360deg); } }
.rw-list { overflow: auto; flex: 1; text-align: left; }
.rw-item { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 11px 4px; border-bottom: 1px solid rgba(243,147,32,.18); }
.rw-item .p { font-weight: 700; color: var(--gold); }
.rw-item .d { font-size: 12px; color: var(--muted); }
.badge { align-self: center; grid-row: span 2; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.badge.pending { background: rgba(243,147,32,.15); color: var(--orange); border: 1px solid rgba(243,147,32,.5); }
.badge.credited { background: rgba(80,200,120,.15); color: #6ee59a; border: 1px solid rgba(80,200,120,.5); }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); z-index: 60;
  background: #2a1708; color: var(--gold-l); border: 1px solid var(--orange); border-radius: 999px; padding: 10px 18px;
  font-size: 13px; text-align: center; width: max-content; max-width: calc(100vw - 32px);
  opacity: 0; transition: .25s; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.6); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  .burst, .egg.ready .shell, #embers i { animation: none !important; }
}
