:root {
  --bg: #170b03;
  --bg2: #2a1406;
  --panel: #2b1609;
  --line: #5a3510;
  --gold: #ffd56a;
  --gold2: #e8a93a;
  --text: #fff4dc;
  --muted: #c9a97a;
  --ok: #6fe39b;
  --err: #ff7a6b;
  --teal: #19a7a0;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; padding-bottom: calc(72px + env(safe-area-inset-bottom)); background: radial-gradient(120% 60% at 50% 0%, #4a2208 0%, var(--bg) 60%); }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.test-banner { background: repeating-linear-gradient(45deg, #6b1f8f, #6b1f8f 12px, #5a1878 12px, #5a1878 24px); text-align: center; font-size: 12px; font-weight: 700; letter-spacing: .08em; padding: 4px; }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: rgba(23, 11, 3, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { font-family: Georgia, serif; font-weight: 700; font-size: 20px; color: var(--gold); margin-right: auto; white-space: nowrap; }
.brand span { color: var(--text); }
.balance { display: flex; flex-direction: column; align-items: flex-end; background: none; border: 0; padding: 0; }
.balance-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.balance-value { font-weight: 800; font-size: 17px; }

.btn { border: 1px solid var(--line); background: var(--bg2); border-radius: 12px; padding: 12px 18px; font-weight: 700; }
.btn-gold { background: linear-gradient(180deg, #ffe08a, #e8a93a); color: #3b1d05; border: 0; box-shadow: 0 3px 0 #9a5d12, 0 6px 16px rgba(232, 169, 58, .35); }
.btn-gold:active { transform: translateY(2px); box-shadow: 0 1px 0 #9a5d12; }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn.wide { width: 100%; margin-top: 14px; }
.btn:disabled { opacity: .5; }

main { padding: 16px; max-width: 760px; margin: 0 auto; }
.section-title { font-family: Georgia, serif; color: var(--gold); font-size: 20px; margin: 22px 0 12px; }
.panel > .section-title:first-child { margin-top: 4px; }

.hero { position: relative; overflow: hidden; border-radius: 20px; min-height: 220px; background-size: cover; background-position: center 30%; border: 2px solid var(--gold2); box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.hero::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(23, 11, 3, .92) 0%, rgba(23, 11, 3, .6) 50%, rgba(23, 11, 3, 0) 80%); }
.hero-text { position: relative; padding: 22px; max-width: 62%; }
.hero h1 { font-family: Georgia, serif; color: var(--gold); margin: 6px 0 4px; font-size: 30px; text-shadow: 0 2px 0 #3b1d05; }
.hero p { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.hero-char { position: absolute; right: -6px; bottom: -8px; height: 92%; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, .5)); animation: float 2.8s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px); } }
.tag { display: inline-block; background: var(--teal); color: #fff; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 99px; letter-spacing: .06em; }

.cats { display: flex; gap: 8px; overflow-x: auto; margin: 22px 0 14px; padding-bottom: 4px; }
.cats .chip { white-space: nowrap; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 10px 14px; border-radius: 16px; border: 1px solid var(--line); background: linear-gradient(180deg, #3a1d0a, #22100500); text-align: center; transition: transform .15s; }
.tile:not(:disabled):hover, .tile:not(:disabled):active { transform: translateY(-3px); border-color: var(--gold2); }
.tile img { width: 100%; aspect-ratio: 1; object-fit: contain; margin-bottom: 6px; }
.tile-name { font-weight: 800; }
.tile-kind { font-size: 12px; color: var(--muted); }
.tile.soon { opacity: .6; cursor: default; }
.tile.soon img { filter: saturate(.6); }
.badge { position: absolute; top: 8px; right: 8px; font-size: 10px; font-weight: 800; letter-spacing: .06em; padding: 2px 7px; border-radius: 99px; background: #4a3420; color: var(--muted); }
.badge.hot { background: #e2412f; color: #fff; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 16px; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 700; color: var(--muted); }
.seg button.on { background: var(--bg2); color: var(--gold); box-shadow: inset 0 0 0 1px var(--line); }
.label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.input { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 17px; }
.input:focus { outline: 2px solid var(--gold2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.chip { border: 1px solid var(--line); background: var(--bg); padding: 8px 14px; border-radius: 99px; font-weight: 700; }
.chip.on { border-color: var(--gold); color: var(--gold); }
.note { background: rgba(25, 167, 160, .12); border: 1px solid rgba(25, 167, 160, .4); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin: 0 0 6px; }
.sub { margin: 22px 0 6px; font-size: 15px; color: var(--muted); }
.list .row, .panel > .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.right { text-align: right; }
.plus { color: var(--ok); }
.minus { color: var(--text); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.status { font-size: 12px; font-weight: 800; text-transform: uppercase; padding: 3px 9px; border-radius: 99px; background: #4a3420; }
.status.pending { color: #ffd56a; }
.status.approved { color: var(--ok); }
.status.rejected { color: var(--err); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: rgba(23, 11, 3, .96); border-top: 1px solid var(--line); }
.tabbar button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; color: var(--muted); padding: 6px; }
.tabbar .ico { font-size: 18px; line-height: 1; }
.tabbar button.active { color: var(--gold); }

.game-frame { position: fixed; inset: 0; z-index: 20; background: #000; }
.game-frame iframe { width: 100%; height: 100%; border: 0; }
.game-close { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 10px; z-index: 2; width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--gold); background: rgba(23, 11, 3, .8); color: var(--gold); font-weight: 800; }

.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; padding: 10px 16px; border-radius: 12px; background: #3a2412; border: 1px solid var(--line); font-weight: 600; max-width: calc(100% - 32px); }
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--err); }

@media (max-width: 400px) {
  .hero-text { max-width: 70%; }
  .hero h1 { font-size: 26px; }
  .grid { grid-template-columns: repeat(2, 1fr); }
}
