:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel-2: #1e2430;
  --line: #2a3140;
  --text: #e9edf3;
  --muted: #8b95a7;
  --gold: #f5c542;
  --gold-2: #d99b1c;
  --red: #e5484d;
  --green: #30a46c;
  --blue: #3e8ef7;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--gold); }
code, pre { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
pre {
  background: #0a0c10;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  overflow: auto;
}
.muted { color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 24px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
[hidden] { display: none !important; }

/* ---------- buttons & forms ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform .06s ease, background .15s ease;
}
.btn:hover:not(:disabled) { background: #283041; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: linear-gradient(180deg, var(--gold), var(--gold-2)); color: #1a1300; border-color: transparent; }
.btn.danger { background: transparent; color: var(--red); border-color: #5a2327; }
.btn.small { padding: 5px 10px; font-size: 13px; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: #0f1218;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { width: 100%; min-height: 70px; }
label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

/* ---------- panels / tables ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--panel-2); }
.badge.ok { background: #13351f; color: #6fe3a1; }
.badge.bad { background: #3b1518; color: #ff9592; }
.badge.warn { background: #3a2c0b; color: var(--gold); }

/* ---------- marketplace ---------- */
.hero { padding: 48px 0 24px; }
.hero h1 { font-size: 40px; margin: 0 0 8px; }
.hero h1 span { color: var(--gold); }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px; }
.game-card { background: linear-gradient(160deg, #1f2533, #12151c); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.game-card h2 { margin: 0 0 6px; }
.game-card .price { font-size: 22px; font-weight: 700; color: var(--gold); }
.top-prize { font-size: 42px; }
.nav { display: flex; gap: 18px; align-items: center; padding: 16px 0; border-bottom: 1px solid var(--line); }
.nav .brand { font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; }
.nav .brand b { color: var(--gold); }


/* ---------- status line (admin, demos) ---------- */
.status { min-height: 1.5em; margin: 0; color: var(--muted); font-size: 14px; }
.status.error { color: #ff9592; }

/* ---------- admin ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin: 18px 0; }
.tabs button { background: none; border: none; color: var(--muted); font: inherit; font-weight: 600; padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--text); border-bottom-color: var(--gold); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.secret-box { background: #231c05; border: 1px solid var(--gold-2); border-radius: 12px; padding: 14px; margin-top: 14px; }
.secret-box code { display: block; word-break: break-all; background: #0a0c10; padding: 8px; border-radius: 6px; margin: 4px 0 10px; font-size: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel-2); border-radius: 12px; padding: 14px; }
.kpi .v { font-size: 22px; font-weight: 700; }
.kpi .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; max-width: 420px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); }
.toast.error { border-color: var(--red); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }


/* ---------- demo parent (seamless + transfer) ---------- */
/* The iframe is the hero; operator wallet + logs live in a bottom drawer. */
body.demo {
  --drawer-bar-h: 64px;
  min-height: 100vh;
  padding-bottom: calc(var(--drawer-bar-h) + 24px);
  background: radial-gradient(90% 50% at 50% -10%, rgba(92, 70, 180, .16), transparent 60%), var(--bg);
}
.demo-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 15, 20, .85);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.demo-top .brand { font-weight: 800; font-size: 18px; color: var(--text); text-decoration: none; }
.demo-top .brand b { color: var(--gold); }
.demo-top a:not(.brand) { font-size: 14px; }
.demo-main { max-width: 1320px; margin: 0 auto; padding: 16px 24px; display: grid; gap: 16px; }
.demo-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 12px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.demo-toolbar label { min-width: 140px; }
.demo-toolbar label.grow { flex: 1; min-width: 220px; }
.demo-note { margin: 0; font-size: 13px; }
.demo-note summary { cursor: pointer; }
.demo-note p { margin: 8px 0 0; }

.seg { display: inline-flex; padding: 3px; border-radius: 10px; background: #0f1218; border: 1px solid var(--line); }
.seg button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 7px; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.seg-wrap { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }

.demo-stage { display: grid; justify-items: center; }
.device {
  width: 100%;
  transition: max-width .25s cubic-bezier(.2, .8, .2, 1);
}
.demo-stage[data-viewport="mobile"] .device {
  max-width: 414px;
  padding: 12px;
  border-radius: 40px;
  background: linear-gradient(180deg, #1c2030, #0c0e14);
  box-shadow: 0 0 0 1px #2a3140, 0 30px 80px rgba(0, 0, 0, .55);
}
.demo-stage[data-viewport="mobile"] .demo-frame { border-radius: 28px; }
.demo-stage[data-viewport="desktop"] .device { max-width: 1280px; }
.demo-frame {
  display: block;
  width: 100%;
  height: 860px;
  border: 0;
  border-radius: var(--radius);
  background: #06070b;
  box-shadow: 0 0 0 1px var(--line), 0 16px 48px rgba(0, 0, 0, .4);
  transition: height .2s ease;
}
.demo-stage[data-viewport="desktop"] .demo-frame { height: 760px; }
.demo-empty {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}

/* bottom drawer */
.drawer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: rgba(16, 19, 27, .96);
  border-top: 1px solid var(--line);
  box-shadow: 0 -12px 40px rgba(0, 0, 0, .45);
  backdrop-filter: blur(12px);
}
.drawer-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  min-height: var(--drawer-bar-h);
  max-width: 1320px;
  margin: 0 auto;
  padding: 10px 24px;
}
.drawer-stat { display: grid; line-height: 1.2; }
.drawer-stat span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.drawer-stat strong { font-size: 20px; color: var(--gold); font-variant-numeric: tabular-nums; }
.drawer-bar .arrow { color: var(--muted); font-size: 18px; }
.drawer-bar label.inline { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.drawer-bar input[type="number"] { width: 110px; padding: 6px 8px; }
.drawer-toggle { display: inline-flex; align-items: center; gap: 8px; }
.drawer-toggle .count {
  min-width: 20px; padding: 0 6px; border-radius: 99px; font-size: 11px; line-height: 18px; text-align: center;
  background: var(--gold); color: #1a1300; font-variant-numeric: tabular-nums;
}
.drawer-toggle .chev { display: inline-block; transition: transform .2s ease; }
.drawer-toggle[aria-expanded="true"] .chev { transform: rotate(180deg); }
.drawer-body {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px 16px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  max-height: 44vh;
  overflow: auto;
}
.drawer-body h3 { margin: 0 0 8px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.drawer-body .status { text-align: left; font-size: 13px; }

.log {
  height: 240px;
  overflow: auto;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
  background: #0a0c10;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.log div { border-bottom: 1px dashed #1f2530; padding: 4px 0; word-break: break-all; color: var(--muted); }
.log div b { font-weight: 700; margin-right: 6px; }
.log .in b { color: #6fb3ff; }
.log .out b { color: #6fe3a1; }
.log time { color: #5b6477; margin-right: 6px; }
.log:empty::before { content: "No messages yet."; color: #5b6477; }

.wallet { font-size: 28px; font-weight: 800; color: var(--gold); }
.banner {
  background: linear-gradient(90deg, var(--gold-2), var(--gold));
  color: #1a1300;
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
}
.warn-banner {
  background: #231c05;
  color: var(--text);
  border: 1px solid var(--gold-2);
  font-weight: 500;
  margin: 0;
}
.balances {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
}
.balances .arrow { font-size: 26px; color: var(--muted); }
@media (max-width: 640px) {
  .demo-main, .drawer-bar, .drawer-body { padding-left: 12px; padding-right: 12px; }
  .demo-top { padding: 12px; flex-wrap: wrap; }
  .drawer-body { grid-template-columns: 1fr; }
}

/* ---------- admin charts ---------- */
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; margin-bottom: 16px; }
@media (max-width: 520px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-panel { min-width: 0; }
.chart-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.chart-head h3 { margin: 0; font-size: 15px; }
.chart-head .muted { font-size: 12px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-left: auto; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart-empty { margin: 30px 0; text-align: center; }
svg.viz { width: 100%; height: auto; display: block; overflow: visible; }
svg.viz .grid { stroke: var(--line); stroke-width: 1; opacity: .6; }
svg.viz .baseline { stroke: #4a5366; stroke-width: 1; }
svg.viz .axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
svg.viz .hit { fill: transparent; cursor: default; }
svg.viz .hit:hover { fill: rgba(255, 255, 255, .04); }
.hbar { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; padding: 5px 0; font-size: 13px; }
.hbar:hover { background: rgba(255, 255, 255, .03); }
.hbar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 12px; }
.hbar-track span { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.hbar-value { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.viz-tip {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none;
  background: #0a0c10; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  font-size: 12px; line-height: 1.5; white-space: pre-line; font-variant-numeric: tabular-nums;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
}

/* ---------- symbols (local SVGs) ---------- */
img.sym { width: 1.35em; height: 1.35em; vertical-align: -0.35em; object-fit: contain; }
img.sym.big { width: 68%; height: 68%; vertical-align: 0; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0, 0, 0, .25)); pointer-events: none; }
img.sym.sym-hero { width: 64px; height: 64px; object-fit: contain; }
td.syms { white-space: nowrap; }


/* ---------- marketplace: browse & pick ---------- */
.toolbar { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.active { color: #1a1300; background: var(--gold); border-color: transparent; }
.game-card { display: flex; flex-direction: column; gap: 2px; }
.game-card.selected { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.game-card .facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.game-card .facts div { background: rgba(255, 255, 255, .04); border-radius: 10px; padding: 8px; }
.game-card .facts span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.game-card .facts strong { font-variant-numeric: tabular-nums; }
.game-card .actions { display: flex; gap: 8px; margin-top: auto; padding-top: 12px; }
.tier-badge { font-size: 11px; }

/* ---------- admin: house & game editor ---------- */
.section-title { margin: 20px 0 10px; font-size: 15px; }
.section-title .muted { font-weight: 500; font-size: 13px; }
.tier-table input, .tier-table select { padding: 5px 7px; font-size: 13px; }
.tier-table input:disabled { opacity: .35; }
.tier-table td { vertical-align: middle; }
/* ---------------------------------------------------------------- admin case builder */
.cb-template { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-items: start; }
.cb-color { display: flex; gap: 6px; align-items: center; }
.cb-color input[type="color"] { width: 54px; height: 34px; padding: 2px; border-radius: 8px; }
.cb-color input[data-custom="0"] { opacity: .55; }
.cb-art { display: grid; gap: 6px; }
.cb-art > span { font-size: 13px; color: var(--muted); }
.cb-slot { position: relative; width: 96px; height: 96px; border-radius: 10px; border: 1px dashed var(--line);
  background: repeating-conic-gradient(#1b2130 0 25%, #222a3b 0 50%) 0 0 / 16px 16px; display: grid; place-items: center; overflow: hidden; }
.cb-slot.wide { width: 170px; }
.cb-slot img { width: 100%; height: 100%; object-fit: contain; }
.cb-slot.wide img { object-fit: cover; }
.cb-slot em { position: absolute; font-size: 11px; color: var(--muted); font-style: normal; }
.cb-slot.has em { display: none; }
.cb-slot:not(.has) img { display: none; }
.cb-slot.busy::after { content: "…"; position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .55); font-size: 22px; }
#case-items .cb-slot { width: 56px; height: 56px; cursor: pointer; }
.cb-rarity { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: #0b0d12; }
.cb-rarity.common { background: #8fa3c2; } .cb-rarity.uncommon { background: #4aa8ff; } .cb-rarity.rare { background: #9b5cff; color: #fff; }
.cb-rarity.epic { background: #ff4fd8; } .cb-rarity.legendary { background: #ffb52e; } .cb-rarity.mythic { background: #ff4040; color: #fff; }
