:root {
  --bg: #07050f;
  --ink: #fff4dc;
  --muted: #d4bfa3;
  --marigold: #ffb627;
  --sindoor: #e63946;
  --panel: rgba(20, 11, 26, 0.66);
  --line: rgba(255, 196, 120, 0.22);
  --shopH: 170px;
  --font: 'Baloo 2', system-ui, sans-serif;
  --display: 'Rozha One', 'Baloo 2', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; background: var(--bg); color: var(--ink); font-family: var(--font); -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

#scene { position: fixed; inset: 0; display: block; cursor: none; touch-action: none; z-index: 0; }

.vignette { position: fixed; inset: 0; pointer-events: none; z-index: 3; background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.55) 100%); }
.grain { position: fixed; inset: -50%; pointer-events: none; z-index: 4; opacity: 0.08; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 0.6s steps(4) infinite; }
@keyframes grain { 0% { transform: translate(0, 0); } 25% { transform: translate(-3%, 2%); } 50% { transform: translate(2%, -3%); } 75% { transform: translate(-2%, -1%); } 100% { transform: translate(0, 0); } }

/* ───── HUD ───── */
#hud { position: fixed; top: 14px; left: 16px; z-index: 10; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.brand .dev { display: block; font-family: var(--display); font-size: 30px; line-height: 1; color: var(--marigold); text-shadow: 0 0 18px rgba(255, 160, 40, 0.55), 0 2px 0 #5a1500; }
.brand small { font-size: 12px; letter-spacing: 0.28em; text-transform: uppercase; color: var(--muted); }
.stats, .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.chip span { font-size: 12px; color: var(--muted); }
.chip b { font-size: 16px; font-variant-numeric: tabular-nums; }
.chip i { font-style: normal; font-size: 12px; }
#walletChip { cursor: pointer; }
.chip.bump { animation: bump 0.4s; }
@keyframes bump { 30% { transform: scale(1.15) rotate(-3deg); background: rgba(230, 57, 70, 0.6); } }
.aqi[data-lvl="0"] b { color: #6ee7a0; } .aqi[data-lvl="1"] b { color: #d9f06b; } .aqi[data-lvl="2"] b { color: #ffc24b; }
.aqi[data-lvl="3"] b { color: #ff8a3d; } .aqi[data-lvl="4"] b { color: #ff4d4d; } .aqi[data-lvl="5"] b { color: #c77dff; }
.btn { padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); transition: transform 0.15s, background 0.15s; }
.btn:hover { transform: translateY(-1px); background: rgba(60, 25, 50, 0.8); }
.btn:active { transform: scale(0.96); }
.btn.on { border-color: rgba(255, 182, 39, 0.6); }
.btn:not(.on)#btnPados, .btn:not(.on)#btnSfx, .btn:not(.on)#btnKid, .btn:not(.on)#btnVoice { opacity: 0.5; }
.btn.money { background: linear-gradient(#ffd54a, #ff9a1f); color: #3a1200; border: 0; }
.btn.money.low { animation: pulse 1.4s infinite; }
.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(5, 3, 10, 0.62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.modal[hidden] { display: none; }
.sheet { position: relative; width: min(600px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px; border-radius: 18px; background: linear-gradient(#2c1524, #170b15); border: 1px solid rgba(255, 182, 39, 0.4); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6); animation: toastIn 0.3s cubic-bezier(.3, 1.4, .5, 1); }
.sheet h3 { font-family: var(--display); font-weight: 400; font-size: 26px; color: var(--marigold); padding-right: 36px; }
.sheet .sub { margin: 2px 0 14px; font-size: 14px; color: var(--muted); }
.sheet .x { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255, 255, 255, 0.08); }
.rel-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.rel { display: grid; justify-items: center; gap: 2px; padding: 12px 6px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); transition: transform 0.15s, background 0.15s; }
.rel:hover:not(:disabled) { transform: translateY(-3px); background: rgba(255, 182, 39, 0.12); }
.rel canvas { width: 72px; height: 72px; border-radius: 50%; margin-bottom: 4px; background: radial-gradient(circle at 50% 30%, #6a4632, #24121a); border: 2px solid rgba(255, 182, 39, 0.55); }
.rel b { font-size: 16px; }
.rel span { font-size: 12px; color: var(--muted); }
.rel i { font-style: normal; font-size: 12px; font-weight: 800; color: #ffe14d; }
.rel:disabled { opacity: 0.45; cursor: not-allowed; }

/* ───── Hint / toasts ───── */
#hint { position: fixed; left: 50%; bottom: calc(var(--shopH) + 10px); transform: translateX(-50%); z-index: 9; max-width: calc(100vw - 32px); padding: 5px 14px; border-radius: 999px; font-size: 13px; text-align: center; color: var(--muted); background: rgba(10, 6, 14, 0.6); border: 1px solid var(--line); pointer-events: none; transition: opacity 0.3s; }
#hint:empty { opacity: 0; }
#hint b { color: var(--marigold); }
#toasts { position: fixed; top: 168px; left: 50%; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; width: max-content; max-width: calc(100vw - 32px); }
.toast { padding: 8px 16px; border-radius: 14px; font-weight: 700; font-size: 15px; text-align: center; background: rgba(30, 12, 26, 0.9); border: 1px solid rgba(255, 182, 39, 0.55); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45); animation: toastIn 0.35s cubic-bezier(.3, 1.6, .5, 1); transition: opacity 0.45s, transform 0.45s; }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.9); } }

/* ───── Shop ───── */
#shop { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 6px 0 calc(10px + env(safe-area-inset-bottom));
  background:
    linear-gradient(rgba(255, 220, 160, 0.18), transparent 3px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.1) 0 1px, transparent 1px 90px),
    linear-gradient(#5a3519, #3b2210 70%, #2a170a);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5); }
.shop-head { display: flex; align-items: baseline; gap: 10px; padding: 0 16px 4px; }
.shop-head b { font-family: var(--display); font-size: 20px; color: #ffdd7a; text-shadow: 0 2px 0 #6a1d00; }
.shop-head span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.shelf { display: flex; gap: 10px; overflow-x: auto; padding: 8px 16px 4px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: #a0703f transparent; touch-action: pan-x; }
.card { position: relative; flex: none; width: 96px; padding: 6px 4px 6px; border-radius: 12px; scroll-snap-align: start; display: grid; justify-items: center; gap: 1px; color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--c) 70%, white), var(--c) 45%, color-mix(in srgb, var(--c) 55%, black));
  border: 2px solid rgba(255, 255, 255, 0.28); box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4); transition: transform 0.18s, box-shadow 0.18s; }
.card:hover { transform: translateY(-4px) rotate(-1.5deg); }
.card:active { transform: scale(0.95); }
.card.sel { transform: translateY(-6px); outline: 3px solid var(--marigold); box-shadow: 0 0 26px rgba(255, 182, 39, 0.85), 0 6px 14px rgba(0, 0, 0, 0.45); }
.card canvas { width: 72px; height: 56px; border-radius: 8px; background: radial-gradient(ellipse at 50% 80%, rgba(255, 220, 160, 0.25), rgba(0, 0, 0, 0.35)); }
.card .hi { font-size: 14px; font-weight: 800; line-height: 1.15; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.card .nm { font-size: 11px; line-height: 1.1; opacity: 0.92; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); white-space: nowrap; }
.card .pr { position: absolute; top: -7px; right: -6px; padding: 0 7px; border-radius: 999px; font-size: 12px; font-weight: 800; color: #3a1500; background: #ffe14d; transform: rotate(9deg); box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4); }
.card .ct { position: absolute; top: -7px; left: -6px; padding: 0 6px; border-radius: 999px; font-size: 11px; font-weight: 800; background: var(--sindoor); }

/* ───── Intro ───── */
#intro { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 50% 35%, rgba(70, 22, 40, 0.72), rgba(5, 3, 10, 0.94) 70%); transition: opacity 0.9s; }
#intro.hide { opacity: 0; pointer-events: none; }
.intro-card { max-width: 600px; text-align: center; }
.intro-card h1 { font-family: var(--display); font-weight: 400; font-size: clamp(46px, 10vw, 92px); line-height: 1.05; color: var(--marigold); text-shadow: 0 0 34px rgba(255, 160, 40, 0.65), 0 4px 0 #6a1d00; }
.intro-card .en { margin-top: 2px; font-size: 13px; letter-spacing: 0.4em; text-transform: uppercase; color: var(--muted); }
.intro-card .tag { margin: 18px auto 0; max-width: 540px; font-size: 17px; line-height: 1.5; color: #f1dcc0; }
.how { list-style: none; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 20px 0 24px; }
.how li { padding: 5px 14px 5px 6px; border-radius: 999px; font-weight: 700; font-size: 14px; background: rgba(255, 255, 255, 0.07); border: 1px solid var(--line); }
.how b { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 6px; border-radius: 50%; font-size: 12px; color: #3a1200; background: var(--marigold); }
#start { padding: 14px 30px; border-radius: 999px; font-size: 20px; font-weight: 800; color: #3a1200; background: linear-gradient(#ffd54a, #ff8a1f); box-shadow: 0 0 0 5px rgba(255, 182, 39, 0.2), 0 12px 40px rgba(255, 140, 30, 0.55); animation: pulse 1.8s infinite; }
#start:hover { filter: brightness(1.08); }
.fine { margin-top: 14px; font-size: 13px; color: var(--muted); }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(255, 182, 39, 0.08), 0 12px 40px rgba(255, 140, 30, 0.7); } }
.diyas { display: flex; justify-content: center; gap: 16px; margin-bottom: 14px; }
.diyas i { position: relative; width: 26px; height: 11px; border-radius: 0 0 26px 26px; background: linear-gradient(#c8682a, #7a3412); }
.diyas i::before { content: ''; position: absolute; left: 50%; bottom: 9px; width: 8px; height: 15px; margin-left: -4px; border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%; background: radial-gradient(circle at 50% 70%, #fff7d0, #ffb43a 60%, rgba(255, 120, 20, 0)); box-shadow: 0 0 16px 6px rgba(255, 160, 50, 0.45); animation: flick 0.18s infinite alternate; }
.diyas i:nth-child(2)::before { animation-delay: -0.07s; } .diyas i:nth-child(4)::before { animation-delay: -0.11s; }
@keyframes flick { to { transform: scale(0.92, 1.08) skewX(3deg); } }


@media (max-width: 760px) {
  #hud { max-width: calc(100vw - 24px); top: 10px; left: 12px; gap: 6px; }
  .brand .dev { font-size: 22px; }
  .brand small { display: none; }
  .actions { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .btn { flex: none; font-size: 12px; padding: 3px 10px; }
  .btn.money { order: -1; }
  .card { width: 84px; }
  .card canvas { width: 64px; height: 50px; }
  #toasts { top: 132px; }
  #hint { font-size: 12px; padding: 4px 12px; white-space: nowrap; }
  #hint .x { display: none; }
}
