:root {
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff;
  background: #100728;
  font-synthesis: none;
  --gold: #ffd34f;
  --pink: #ff5b9d;
  --mint: #29e0c1;
  --purple: #7f5af0;
  --panel: rgba(255, 255, 255, 0.09);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.12);
}

* { box-sizing: border-box; }
html, body, #app { margin: 0; width: 100%; min-height: 100%; }
body { min-height: 100vh; min-height: 100dvh; overflow: hidden; background: #100728; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
button, canvas { touch-action: manipulation; }
button:focus-visible { outline: 3px solid rgba(41, 224, 193, 0.6); outline-offset: 2px; }

#app { display: flex; justify-content: center; background: radial-gradient(circle at 50% -10%, #4d218d 0, #1b0c43 40%, #100728 90%); }

.app-shell {
  position: relative;
  width: min(100%, 430px);
  height: 100vh;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
  background:
    radial-gradient(circle at 95% 18%, rgba(255, 91, 157, .18), transparent 29%),
    radial-gradient(circle at 8% 65%, rgba(41, 224, 193, .12), transparent 32%),
    linear-gradient(165deg, #25104f, #36166c 56%, #421a77);
  box-shadow: 0 0 50px rgba(0, 0, 0, .35);
}

.app-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .24;
  background-image: radial-gradient(rgba(255,255,255,.25) .7px, transparent .7px);
  background-size: 18px 18px;
  mask-image: linear-gradient(to bottom, #000, transparent 55%);
}

.topbar {
  position: relative;
  z-index: 4;
  height: calc(54px + env(safe-area-inset-top));
  padding: calc(15px + env(safe-area-inset-top)) 18px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo { text-align: center; font-size: 15px; font-weight: 950; letter-spacing: -.035em; color: var(--pink); text-shadow: 0 2px 8px rgba(0,0,0,.3); }
.logo span { color: var(--gold); }
.logo b { margin-left: 5px; padding: 3px 5px; border-radius: 5px; color: #160b35; background: var(--mint); font-size: 8px; letter-spacing: .1em; vertical-align: 2px; }

.app-content { position: absolute; z-index: 2; inset: calc(54px + env(safe-area-inset-top)) 0 calc(76px + env(safe-area-inset-bottom)); overflow: hidden; }
.play-screen { height: 100%; display: flex; flex-direction: column; padding: 8px 16px 10px; }

.hero-stats {
  flex: none;
  padding: 13px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,.15), rgba(255,255,255,.055));
  box-shadow: 0 10px 24px rgba(0,0,0,.2);
  backdrop-filter: blur(12px);
}
.wallet { display: grid; grid-template-columns: 30px auto; gap: 8px; align-items: baseline; }
.wallet .stat-icon { align-self: center; display: grid; place-items: center; width: 28px; height: 28px; color: #a86c00; background: radial-gradient(circle at 35% 28%, #fff3be, #f1b82e 64%, #b86e08); border: 2px solid #f4cb5b; border-radius: 50%; box-shadow: inset 0 -2px 4px rgba(108,55,0,.55); }
.wallet strong { font-size: clamp(28px, 8vw, 38px); line-height: 1; letter-spacing: -.04em; }
.mini-stats { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
.mini-stats div { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding: 8px 10px; border-radius: 11px; background: rgba(8,3,28,.22); }
.mini-stats strong { font-size: 15px; }
.mini-stats small { color: rgba(255,255,255,.5); font-size: 9px; font-weight: 750; }
.goal-line { display: flex; justify-content: space-between; margin: 10px 2px 5px; color: rgba(255,255,255,.55); font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.goal-line b { color: var(--mint); }
.progress-track { height: 7px; overflow: hidden; border-radius: 6px; background: rgba(5,2,20,.35); }
.progress-track i { display: block; height: 100%; min-width: 2px; border-radius: inherit; background: linear-gradient(90deg, var(--mint), var(--gold)); box-shadow: 0 0 8px rgba(41,224,193,.45); transition: width .25s; }

.ticket-stage { position: relative; flex: 1; min-height: 285px; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 7px; }
.ticket-frame { width: min(100%, 354px); padding: 12px; border-radius: 24px; background: linear-gradient(160deg, #fffdf7, #f6e9ca); box-shadow: 0 18px 30px rgba(4,0,20,.38), inset 0 0 0 1px rgba(255,255,255,.7); transform: rotate(-.4deg); }
.silver-era .ticket-frame { background: linear-gradient(145deg, #f8fbff, #c6d1e0 46%, #f3f8ff); box-shadow: 0 18px 34px rgba(4,0,20,.42), 0 0 22px rgba(210,229,255,.16), inset 0 0 0 1px #fff; }
.scratch-card { position: relative; width: 100%; min-height: 172px; overflow: hidden; border-radius: 15px; background: #fff; box-shadow: inset 0 0 0 1px rgba(88,50,25,.2); }
.scratch-card canvas { position: absolute; inset: 0; cursor: crosshair; touch-action: none; }
.scratch-card .sc__inner { position: absolute; inset: 0; width: 100%; height: 100%; }
.prize-background { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #6a472f; background: radial-gradient(circle at 50% 36%, #fffef8, #f8ead1 70%); font-family: inherit; }
.prize-background.silver { color: #47566a; background: radial-gradient(circle at 50% 36%, #fff, #dfe9f5 72%); }
.prize-background span { font-size: clamp(10px, 3vw, 13px); font-weight: 900; letter-spacing: .14em; }
.prize-background strong { font-size: clamp(42px, 14vw, 62px); line-height: 1; letter-spacing: -.04em; }
.prize-background i { display: grid; place-items: center; width: 25px; height: 25px; color: #a86c00; border-radius: 50%; background: var(--gold); font-style: normal; }
.scratch-caption { margin: 12px 0 0; color: rgba(255,255,255,.58); font-size: 11px; font-weight: 800; letter-spacing: .04em; }
.era-badge { margin-bottom: 8px; padding: 5px 10px; border: 1px solid rgba(224,237,255,.3); border-radius: 999px; color: #e8f3ff; background: rgba(212,228,248,.13); font-size: 9px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }

.bottom-nav { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; height: calc(76px + env(safe-area-inset-bottom)); padding: 7px 9px calc(9px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid rgba(255,255,255,.09); background: rgba(13,5,34,.9); backdrop-filter: blur(18px); }
.bottom-nav.four-tabs { grid-template-columns: repeat(4, 1fr); }
.bottom-nav button { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; color: rgba(255,255,255,.42); background: transparent; font-size: 9px; font-weight: 800; cursor: pointer; }
.bottom-nav i { display: grid; place-items: center; width: 34px; height: 29px; border-radius: 10px; font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif; font-size: 20px; font-style: normal; line-height: 1; }
.bottom-nav button.active { color: var(--gold); }
.bottom-nav button.active i { color: #25104f; background: var(--gold); box-shadow: 0 4px 12px rgba(255,211,79,.26); }
.nav-badge { position: absolute; z-index: 2; top: 1px; left: calc(50% + 8px); min-width: 18px; height: 18px; display: grid; place-items: center; padding: 0 5px; border: 2px solid #13082e; border-radius: 999px; color: #fff; background: #ff3b57; box-shadow: 0 3px 8px rgba(0,0,0,.35); font-size: 9px; font-style: normal; font-weight: 950; line-height: 1; }
.nav-badge.hidden { display: none; }

.scroll-screen { height: 100%; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding: 6px 14px 22px; }
.scroll-screen::-webkit-scrollbar { display: none; }
.screen-heading { display: flex; align-items: center; justify-content: space-between; padding: 7px 5px 12px; }
.screen-heading p { margin: 0 0 2px; color: rgba(255,255,255,.45); font-size: 9px; font-weight: 900; letter-spacing: .14em; }
.screen-heading h1 { margin: 0; font-size: 24px; letter-spacing: -.035em; }
.screen-heading h1 small { color: rgba(255,255,255,.38); font-size: 12px; }
.screen-heading > span { font-size: 27px; }
.upgrade-balances { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 5px 0 13px; }
.upgrade-balance { min-width: 0; display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 7px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.055)); }
.upgrade-balance strong { overflow: hidden; color: #fff; font-size: 19px; line-height: 1; text-overflow: ellipsis; }
.upgrade-balance small { grid-column: 1 / -1; color: rgba(255,255,255,.46); font-size: 8px; font-weight: 850; letter-spacing: .04em; text-transform: uppercase; }
.upgrade-balance.progress strong { grid-column: 1 / -1; color: var(--mint); }
.balance-symbol { display: grid; place-items: center; width: 22px; height: 22px; border: 2px solid #f4cb5b; border-radius: 50%; color: #a86c00; background: radial-gradient(circle at 35% 28%, #fff3be, #f1b82e 64%, #b86e08); box-shadow: inset 0 -2px 3px rgba(108,55,0,.45); font-size: 9px; }
.upgrades-screen section > h2 { margin: 11px 3px 6px; color: rgba(255,255,255,.42); font-size: 9px; letter-spacing: .13em; }
.automation-note { margin: 0 2px 8px; padding: 9px 10px; border: 1px solid rgba(41,224,193,.17); border-radius: 11px; color: rgba(226,255,249,.68); background: rgba(41,224,193,.07); font-size: 9px; line-height: 1.35; }
.upgrade-row { position: relative; display: grid; grid-template-columns: 43px minmax(0, 1fr) auto; align-items: center; gap: 10px; margin-bottom: 7px; padding: 10px; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.055)); }
.upgrade-row.featured { border-color: rgba(218,234,255,.3); background: linear-gradient(145deg, rgba(212,228,248,.16), rgba(127,90,240,.12)); }
.upgrade-icon { display: grid; place-items: center; width: 43px; height: 43px; border-radius: 12px; background: rgba(3,0,18,.22); font-size: 22px; }
.upgrade-copy { min-width: 0; }
.upgrade-copy h3 { margin: 0; color: #fff; font-size: 13px; line-height: 1.2; }
.upgrade-copy h3 b { margin-left: 3px; color: var(--gold); font-size: 10px; }
.upgrade-copy p { margin: 3px 0 0; color: rgba(255,255,255,.56); font-size: 10px; line-height: 1.25; }
.buy-button { min-width: 68px; padding: 7px 9px; border: 0; border-radius: 11px; color: #533607; background: linear-gradient(#ffe078, #f3b52c); box-shadow: 0 3px 0 #b87811; font-weight: 900; font-size: 11px; cursor: pointer; }
.buy-button small { display: block; margin-bottom: 1px; font-size: 7px; letter-spacing: .07em; text-transform: uppercase; opacity: .7; }
.buy-button:disabled { color: rgba(255,255,255,.38); background: rgba(255,255,255,.1); box-shadow: none; cursor: not-allowed; }
.owned-pill { padding: 7px 8px; border-radius: 9px; color: var(--mint); background: rgba(41,224,193,.13); font-size: 9px; font-weight: 900; white-space: nowrap; }
.lock-pill { max-width: 90px; display: flex; align-items: center; gap: 4px; color: rgba(255,255,255,.5); font-size: 11px; }
.lock-pill small { color: rgba(255,255,255,.43); font-size: 7px; line-height: 1.2; }

.profile-card { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 11px; padding: 14px; border: 1px solid rgba(255,255,255,.14); border-radius: 18px; background: linear-gradient(145deg, rgba(127,90,240,.28), rgba(255,91,157,.16)); }
.avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; color: #4a3108; background: linear-gradient(145deg, #ffe37d, #efa51d); font-size: 19px; font-weight: 950; }
.profile-card h2 { margin: 0; font-size: 15px; }
.profile-card p { margin: 3px 0 0; color: rgba(255,255,255,.55); font-size: 9px; }
.sync-pill { padding: 5px 7px; border-radius: 7px; color: var(--mint); background: rgba(41,224,193,.12); font-size: 7px; font-weight: 900; text-transform: uppercase; }
.sync-pill.saving { color: var(--gold); background: rgba(255,211,79,.12); }
.sync-pill.error { color: var(--pink); background: rgba(255,91,157,.12); }
.settings-card { margin-top: 13px; overflow: hidden; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.07); }
.setting-row { min-height: 56px; display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,.07); font-size: 12px; font-weight: 800; }
.setting-row:last-child { border-bottom: 0; }
.segmented { display: flex; padding: 3px; border-radius: 9px; background: rgba(0,0,0,.25); }
.segmented button { padding: 5px 12px; border: 0; border-radius: 7px; color: rgba(255,255,255,.5); background: transparent; font-size: 10px; font-weight: 900; cursor: pointer; }
.segmented button.active { color: #4a3108; background: var(--gold); }
.toggle { position: relative; width: 43px; height: 25px; padding: 0; border: 0; border-radius: 20px; background: rgba(255,255,255,.18); cursor: pointer; }
.toggle i { position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: #fff; transition: transform .18s; }
.toggle.active { background: var(--mint); }
.toggle.active i { transform: translateX(18px); }
.danger-button { width: 100%; margin-top: 14px; padding: 12px; border: 1px solid rgba(255,91,157,.45); border-radius: 14px; color: #ff9abd; background: rgba(255,91,157,.1); font-weight: 850; cursor: pointer; }
.version { text-align: center; color: rgba(255,255,255,.28); font-size: 9px; }

.modal-backdrop { position: absolute; z-index: 20; inset: 0; display: grid; place-items: center; padding: 22px; background: rgba(5,1,18,.72); backdrop-filter: blur(10px); }
.modal-card { width: min(100%, 330px); padding: 24px 20px 19px; border: 1px solid rgba(255,255,255,.16); border-radius: 24px; text-align: center; background: linear-gradient(160deg, #321566, #1b0d43); box-shadow: 0 26px 50px rgba(0,0,0,.45); }
.modal-icon { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%; color: #39220a; background: var(--gold); font-size: 25px; }
.modal-icon.danger { color: #fff; background: var(--pink); }
.modal-card h2 { margin: 0 0 8px; font-size: 21px; }
.modal-card > p { margin: 0 0 18px; color: rgba(255,255,255,.58); font-size: 12px; line-height: 1.45; }
.offline-gain { display: inline-flex; flex-direction: column; min-width: 110px; padding: 11px; margin: 6px 3px 17px; border-radius: 13px; background: rgba(41,224,193,.11); }
.offline-gain.coins { background: rgba(255,211,79,.11); }
.offline-gain b { color: var(--mint); font-size: 20px; }
.offline-gain.coins b { color: var(--gold); }
.offline-gain span { margin-top: 2px; color: rgba(255,255,255,.48); font-size: 8px; font-weight: 800; text-transform: uppercase; }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.modal-actions button { padding: 11px; border: 0; border-radius: 11px; color: #fff; background: rgba(255,255,255,.1); font-weight: 800; cursor: pointer; }
.modal-actions button.danger { background: var(--pink); }
.primary-button { width: 100%; padding: 12px 16px; border: 0; border-radius: 13px; color: #442c07; background: linear-gradient(#ffe37d, #efae22); box-shadow: 0 4px 0 #aa6d0c; font-weight: 900; cursor: pointer; }

.victory-screen { height: 100%; overflow-y: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 24px calc(24px + env(safe-area-inset-bottom)); text-align: center; }
.victory-ticket { display: grid; place-items: center; width: 84px; height: 84px; border: 3px solid #fff1b4; border-radius: 24px; color: #875408; background: linear-gradient(145deg, #fff0a7, #f3b72e); box-shadow: 0 18px 38px rgba(0,0,0,.28); font-size: 44px; transform: rotate(-5deg); }
.victory-screen .eyebrow { margin: 22px 0 4px; color: var(--mint); font-size: 9px; font-weight: 950; letter-spacing: .17em; }
.victory-screen h1 { margin: 0; font-size: 34px; letter-spacing: -.05em; }
.victory-stats { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 20px 0; }
.victory-stats div { display: flex; flex-direction: column; padding: 13px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); }
.victory-stats span { color: rgba(255,255,255,.48); font-size: 8px; font-weight: 850; text-transform: uppercase; }
.victory-stats b { margin-top: 4px; font-size: 16px; }

.toast-region { position: absolute; z-index: 30; top: calc(66px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); pointer-events: none; }
.toast { padding: 10px 16px; border: 1px solid rgba(255,211,79,.45); border-radius: 999px; color: #3e2706; background: var(--gold); box-shadow: 0 12px 26px rgba(0,0,0,.35); font-size: 11px; font-weight: 950; white-space: nowrap; animation: toast-pop .35s ease-out; }
.toast.mega { color: #fff; border-color: rgba(255,255,255,.4); background: linear-gradient(90deg, var(--pink), var(--purple)); }
.confetti { position: absolute; left: 50%; top: 20px; width: 1px; height: 1px; }
.confetti i { --angle: calc(var(--i) * 22.5deg); position: absolute; width: 7px; height: 12px; border-radius: 2px; background: hsl(calc(var(--i) * 43deg) 90% 62%); animation: confetti-burst 1.25s ease-out forwards; transform: rotate(var(--angle)) translateY(-10px); }
@keyframes toast-pop { from { opacity: 0; transform: translateY(-8px) scale(.85); } to { opacity: 1; transform: none; } }
@keyframes confetti-burst { to { opacity: 0; transform: rotate(calc(var(--angle) + 180deg)) translateY(calc(88px + var(--i) * 2px)); } }

.system-screen { width: min(100%, 430px); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px; text-align: center; background: radial-gradient(circle at 50% 20%, #4b208b, #160b35 58%, #0e0624); }
.system-screen .brand-mark { display: grid; place-items: center; width: 70px; height: 70px; border-radius: 20px; color: #543609; background: var(--gold); font-size: 35px; font-weight: 950; box-shadow: 0 16px 34px rgba(0,0,0,.3); }
.system-screen .eyebrow { margin: 18px 0 3px; color: var(--mint); font-size: 9px; font-weight: 950; letter-spacing: .18em; }
.system-screen h1 { max-width: 330px; margin: 0; font-size: 30px; }
.system-screen p:not(.eyebrow) { max-width: 320px; color: rgba(255,255,255,.6); font-size: 13px; line-height: 1.5; }
.system-screen .primary-button { width: min(100%, 260px); margin-top: 10px; }
.error-screen .brand-mark { color: #fff; background: var(--pink); }
.loader { width: 25px; height: 25px; margin-top: 22px; border: 3px solid rgba(255,255,255,.18); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-height: 690px) {
  .hero-stats { padding: 10px; }
  .mini-stats { margin-top: 7px; }
  .ticket-stage { min-height: 240px; }
  .ticket-frame { width: min(88%, 320px); padding: 9px; }
  .scratch-caption { margin-top: 7px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
