:root {
  --bg: #0f1218;
  --surface: #171c26;
  --surface-2: #1f2633;
  --line: #2b3445;
  --text: #e9edf5;
  --muted: #98a3b8;
  --accent: #f5b83d;
  --accent-ink: #1a1304;
  --ok: #4cc38a;
  --bad: #ff6b6b;
  --r-common: #7b8aa3;
  --r-uncommon: #4c9bf5;
  --r-rare: #a56bff;
  --r-legend: #f5b83d;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f4f6fa; --surface: #ffffff; --surface-2: #eef1f7; --line: #d9dfeb;
    --text: #1b2230; --muted: #5b667d; --accent: #e5a21c; --accent-ink: #1a1304;
    --ok: #17915f; --bad: #d63b3b; --shadow: 0 10px 30px rgba(20, 30, 60, .12);
    --r-common: #6b7a94; --r-uncommon: #2a7de1; --r-rare: #8b4fe8; --r-legend: #c98600;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: clamp(1.5rem, 4vw, 2rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
a { color: inherit; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85em; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; text-decoration: none; letter-spacing: .2px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; display: inline-block;
  background: linear-gradient(var(--accent) 0 35%, #c98a1c 35%);
  box-shadow: inset 0 0 0 2px rgba(0,0,0,.15);
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a { text-decoration: none; padding: 8px 12px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.account { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.balance { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; padding-right: 6px; }
.balance .label { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.balance strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.banner { text-align: center; font-size: .85rem; color: var(--muted); padding: 8px 16px; background: var(--surface-2); border-bottom: 1px solid var(--line); }

main { max-width: 1040px; margin: 0 auto; padding: 24px 16px 64px; outline: none; }
.page-head { display: flex; flex-direction: column; gap: 4px; margin-bottom: 20px; }

/* ---------- controls ---------- */
.btn {
  appearance: none; border: 1px solid transparent; cursor: pointer; font: inherit; font-weight: 600;
  display: inline-block; text-decoration: none; text-align: center;
  background: var(--accent); color: var(--accent-ink); padding: 11px 18px; border-radius: 12px;
  transition: transform .08s ease, filter .15s ease, background .15s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-2); filter: none; }
.btn.small { padding: 7px 12px; font-size: .875rem; border-radius: 10px; }
.btn.block { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .85rem; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"] {
  font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 11px 12px; width: 100%;
}
input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.error { color: var(--bad); font-size: .9rem; min-height: 1.3em; }

/* ---------- auth ---------- */
.auth { max-width: 380px; margin: 32px auto 0; }
.auth h1 { margin-bottom: 6px; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 4px; border-radius: 12px; margin: 16px 0; }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: 8px; border-radius: 9px; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 0 var(--line); }

/* ---------- boxes ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.box-card {
  display: flex; flex-direction: column; gap: 14px; text-align: left; cursor: pointer; color: inherit; font: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}
.box-card:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: var(--shadow); }
.crate { height: 96px; border-radius: 12px; position: relative; overflow: hidden; background: linear-gradient(160deg, var(--surface-2), var(--bg)); }
.crate::before { content: ""; position: absolute; inset: 22px 34px 14px; border-radius: 10px; background: linear-gradient(var(--accent) 0 34%, #c98a1c 34%); box-shadow: 0 8px 18px rgba(0,0,0,.35); }
.crate::after { content: ""; position: absolute; left: 50%; top: 22px; bottom: 14px; width: 14px; margin-left: -7px; background: #fff3d1; opacity: .9; }
.price { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.odds-mini { display: flex; gap: 6px; flex-wrap: wrap; }

.pill { font-size: .75rem; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-variant-numeric: tabular-nums; }
.pill i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--rc, var(--r-common)); }

.rar-common { --rc: var(--r-common); }
.rar-uncommon { --rc: var(--r-uncommon); }
.rar-rare { --rc: var(--r-rare); }
.rar-legend { --rc: var(--r-legend); }

/* ---------- dialog ---------- */
dialog {
  width: min(680px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(5, 8, 14, .65); backdrop-filter: blur(3px); }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }
.prize-list { display: grid; gap: 8px; margin: 14px 0 18px; padding: 0; list-style: none; }
.prize-list li { display: flex; justify-content: space-between; gap: 12px; align-items: center; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; }
.prize-list li span:first-child::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 10px; border-radius: 50%; background: var(--rc); }

/* ---------- roulette ---------- */
.roulette { position: relative; overflow: hidden; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); margin: 6px 0 16px; height: 150px; }
.roulette::before, .roulette::after { content: ""; position: absolute; top: 0; bottom: 0; width: 70px; z-index: 2; pointer-events: none; }
.roulette::before { left: 0; background: linear-gradient(90deg, var(--bg), transparent); }
.roulette::after { right: 0; background: linear-gradient(270deg, var(--bg), transparent); }
.marker { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--accent); z-index: 3; box-shadow: 0 0 12px var(--accent); }
.track { display: flex; gap: 8px; padding: 12px 0; will-change: transform; height: 100%; }
.rcard {
  flex: 0 0 120px; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 10px;
  border-radius: 10px; background: var(--surface-2); font-size: .8rem; line-height: 1.25;
  background-image: linear-gradient(180deg, transparent 30%, color-mix(in srgb, var(--rc) 32%, transparent));
}
.rcard b { font-size: .85rem; }

.result { text-align: center; padding: 18px 12px 6px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--rc); animation: pop .35s ease; }
.result .big { font-size: 1.4rem; font-weight: 700; margin: 4px 0 8px; }
.codebox { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.codebox code { padding: 8px 12px; border-radius: 8px; background: var(--bg); border: 1px dashed var(--line); font-size: .95rem; word-break: break-all; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- lists / tables ---------- */
.list { display: grid; gap: 10px; }
.item { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.badge { font-size: .75rem; padding: 3px 9px; border-radius: 999px; font-weight: 600; background: var(--surface-2); color: var(--muted); }
.badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, transparent); }
.badge.bad { color: var(--bad); background: color-mix(in srgb, var(--bad) 14%, transparent); }
.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; word-break: break-all; }
.verify-out { margin-top: 8px; font-size: .85rem; }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .nav { order: 3; flex-basis: 100%; overflow-x: auto; }
  .rcard { flex-basis: 104px; }
  .kv { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
[hidden] { display: none !important; }

/* ---------- admin ---------- */
.sumbar { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; padding: 12px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.sumbar b { font-weight: 700; }
.sumbar.loss { border-color: var(--bad); }
.pform { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px 12px; align-items: end; }
.pform .wide { grid-column: span 2; }
.pform select, .pform input[type="number"], .pform input[type="text"] { width: 100%; }
select, input[type="number"] { font: inherit; color: var(--text); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
select:focus-visible, input[type="number"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 42px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.pcard { display: flex; flex-direction: column; gap: 12px; }
.pcard.off { opacity: .6; }
.pcard .chance { font-weight: 700; font-variant-numeric: tabular-nums; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: 14px; }
.diff { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .8rem; color: var(--muted); white-space: pre-wrap; word-break: break-all; margin-top: 6px; }
@media (max-width: 640px) { .pform .wide { grid-column: span 1; } }
