:root {
  --bg: #0a0a0a;
  --surface: #111111;
  --surface-2: #161616;
  --line: rgba(255,255,255,0.08);
  --line-strong: rgba(255,255,255,0.16);
  --text: #e8e4dc;
  --muted: #8a8780;
  --dim: #5a5852;
  --gold: #d8b56a;
  --gold-dim: rgba(216,181,106,0.14);
  --danger: #c96b5c;
  --serif: 'Instrument Serif', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'General Sans', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  --radius: 18px;
  --nav-h: 84px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select { font: inherit; color: inherit; }

.grain { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .35; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E"); }

.app { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top)) 20px calc(var(--nav-h) + 32px); min-height: 100dvh; }

/* type */
.eyebrow { font-family: var(--mono); font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
h1.title { font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1; margin: 6px 0 0; letter-spacing: -.01em; }
h2.serif { font-family: var(--serif); font-weight: 400; font-size: 34px; line-height: 1.05; margin: 0; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: .18em; text-transform: uppercase; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
p { line-height: 1.5; }

/* header */
.header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 22px; }
.logo { width: 54px; height: 54px; border-radius: 14px; background: linear-gradient(160deg, #1b1b1b, #0d0d0d); border: 1px solid var(--line); display: grid; place-items: center; font-family: var(--serif); font-size: 26px; box-shadow: 0 10px 30px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06); margin-bottom: 16px; }
.icon-row { display: flex; gap: 8px; }
.icon-btn { width: 50px; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--muted); box-shadow: 0 8px 24px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.05); }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); }

/* pills & tabs */
.pill { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-family: var(--mono); font-size: 13px; letter-spacing: .06em; color: var(--muted); box-shadow: 0 6px 18px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.05); }
.pill b { color: var(--text); font-weight: 500; }
.tabs { display: flex; gap: 4px; margin: 18px 0 8px; overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 12px 18px; border-radius: 14px; font-family: var(--mono); font-size: 12px; letter-spacing: .24em; text-transform: uppercase; color: var(--dim); border: 1px solid transparent; }
.tab.active { color: var(--text); background: var(--surface); border-color: var(--line); box-shadow: 0 6px 18px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.05); }
.select-wrap { position: relative; }
.select-wrap select { appearance: none; -webkit-appearance: none; width: 100%; padding: 12px 40px 12px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); font-family: var(--mono); font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--text); }
.select-wrap::after { content: ""; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; border-right: 1px solid var(--muted); border-bottom: 1px solid var(--muted); transform: translateY(-70%) rotate(45deg); pointer-events: none; }

/* buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; padding: 20px 24px; border-radius: 22px; border: 1px solid var(--line-strong); background: linear-gradient(180deg, #1a1a1a, #101010); font-family: var(--mono); font-size: 15px; letter-spacing: .22em; text-transform: uppercase; color: var(--text); box-shadow: 0 14px 40px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08); transition: transform .15s ease, border-color .15s ease; }
.btn:hover { border-color: rgba(255,255,255,.26); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-ghost { display: flex; justify-content: center; width: auto; margin: 14px auto 0; padding: 16px 28px; border-radius: 18px; border: 1px solid var(--line); background: transparent; font-family: var(--mono); font-size: 13px; letter-spacing: .24em; text-transform: uppercase; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line-strong); }
.btn-gold { border-color: rgba(216,181,106,.45); background: linear-gradient(180deg, #2a2212, #15120a); color: var(--gold); }
.btn-sm { width: auto; padding: 10px 14px; border-radius: 12px; font-size: 11px; letter-spacing: .16em; }
.btn-danger { color: var(--danger); border-color: rgba(201,107,92,.4); }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: 0 10px 30px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04); }
.card + .card { margin-top: 12px; }
.card.gold { border-color: rgba(216,181,106,.35); background: linear-gradient(180deg, rgba(216,181,106,.08), rgba(216,181,106,.02)); }

/* board */
.board { margin-top: 10px; }
.row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 14px; padding: 16px 6px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .rank { font-family: var(--mono); font-size: 13px; color: var(--dim); }
.row.top .rank { color: var(--text); }
.row .name { font-size: 16px; font-weight: 500; letter-spacing: -.005em; display: flex; align-items: center; gap: 8px; min-width: 0; }
.row .name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .sub { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--dim); margin-top: 4px; text-transform: uppercase; }
.row .pts { font-family: var(--serif); font-size: 30px; line-height: 1; text-align: right; }
.row .pts small { font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--dim); display: block; margin-top: 4px; }
.row.me { background: linear-gradient(90deg, rgba(255,255,255,.04), transparent); margin: 0 -8px; padding-left: 14px; padding-right: 14px; border-radius: 12px; }
.crown { color: var(--gold); display: inline-flex; }
.you { font-family: var(--mono); font-size: 9px; letter-spacing: .2em; padding: 3px 7px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--muted); }

.podium { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 6px; }
.podium .p { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 10px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.04); }
.podium .p:first-child { border-color: rgba(216,181,106,.3); }
.podium .p .n { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 8px 0 2px; }
.podium .p .v { font-family: var(--serif); font-size: 32px; line-height: 1; }
.podium .p .r { font-family: var(--mono); font-size: 10px; letter-spacing: .3em; color: var(--dim); }

/* empty state / hero */
.hero { text-align: center; padding: 56px 8px 36px; }
.hero p { color: var(--muted); font-size: 17px; max-width: 34ch; margin: 14px auto 32px; }

/* forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .28em; text-transform: uppercase; color: var(--dim); margin: 0 0 8px 4px; }
.field input { width: 100%; padding: 16px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; outline: none; }
.field input:focus { border-color: var(--line-strong); }
.form-links { display: flex; justify-content: space-between; margin-top: 14px; }
.form-links button { font-family: var(--mono); font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); padding: 6px 2px; }
.form-links button:hover { color: var(--text); }
.error { color: var(--danger); font-size: 13px; margin: 10px 4px 0; }
.ok { color: var(--gold); font-size: 13px; margin: 10px 4px 0; }

/* result screen */
.result { text-align: center; padding: 40px 8px 20px; }
.result .big { font-family: var(--serif); font-size: 96px; line-height: .9; margin: 18px 0 6px; }
.result .big small { font-size: 28px; color: var(--muted); }
.result .tier { display: inline-block; margin-top: 18px; }
.upgrade { animation: pulse 2.4s ease-in-out infinite; }
.upgrade h2.serif { font-size: 46px; color: var(--gold); text-shadow: 0 0 40px rgba(216,181,106,.35); }
.code { font-family: var(--mono); font-size: 28px; letter-spacing: .32em; padding: 16px 20px; border: 1px dashed rgba(216,181,106,.5); border-radius: 14px; display: inline-block; margin: 18px 0 8px; color: var(--gold); }
@keyframes pulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.18); } }
.glow { position: fixed; inset: 0; z-index: 0; pointer-events: none; background: radial-gradient(60% 40% at 50% 30%, rgba(216,181,106,.18), transparent 70%); }

/* vault list */
.badges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.badge { aspect-ratio: 3/4; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; font-family: var(--mono); font-size: 10px; letter-spacing: .2em; color: var(--dim); position: relative; }
.badge.filled { color: var(--text); border-color: var(--line-strong); background: linear-gradient(170deg, #1a1a1a, #0f0f0f); }
.badge.filled .t { font-family: var(--serif); font-size: 22px; letter-spacing: 0; }
.badge.gold { color: var(--gold); border-color: rgba(216,181,106,.45); background: linear-gradient(170deg, #2a2212, #15120a); }
.show-block { display: grid; grid-template-columns: 96px 1fr; gap: 14px; align-items: center; padding: 18px 0; border-bottom: 1px solid var(--line); }
.show-block .idx { font-family: var(--mono); font-size: 11px; letter-spacing: .2em; color: var(--dim); }
.show-block .nm { font-size: 20px; font-weight: 500; margin: 4px 0; }
.show-block .ct { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; color: var(--dim); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { width: 54px; height: 70px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; font-family: var(--mono); font-size: 9px; letter-spacing: .14em; color: var(--dim); }
.chip.on { color: var(--text); border-color: var(--line-strong); background: linear-gradient(170deg, #1c1c1c, #0f0f0f); }
.chip.gold { color: var(--gold); border-color: rgba(216,181,106,.5); background: linear-gradient(170deg, #2a2212, #15120a); }

/* stats */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px 12px; text-align: center; }
.stat .v { font-family: var(--serif); font-size: 34px; line-height: 1; }
.stat .k { font-family: var(--mono); font-size: 9px; letter-spacing: .28em; color: var(--dim); margin-top: 6px; text-transform: uppercase; }

/* admin */
table.admin { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin th { font-family: var(--mono); font-size: 9px; letter-spacing: .24em; text-transform: uppercase; color: var(--dim); text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-weight: 400; }
table.admin td { padding: 10px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.admin td code { font-family: var(--mono); font-size: 11px; color: var(--gold); letter-spacing: .1em; }
table.admin td.muted, table.admin .small { font-size: 11px; }

/* nav */
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; height: var(--nav-h); padding-bottom: env(safe-area-inset-bottom); display: flex; align-items: center; justify-content: center; gap: 28px; background: linear-gradient(180deg, rgba(10,10,10,0), rgba(10,10,10,.92) 40%, var(--bg)); }
.nav-pill { padding: 16px 28px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); font-family: var(--mono); font-size: 12px; letter-spacing: .28em; text-transform: uppercase; color: var(--dim); box-shadow: 0 8px 24px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.04); }
.nav-pill.active { color: var(--text); border-color: var(--line-strong); }
.nav-scan { width: 64px; height: 64px; border-radius: 20px; border: 1px solid var(--line-strong); background: linear-gradient(180deg, #1d1d1d, #0f0f0f); display: grid; place-items: center; color: var(--muted); box-shadow: 0 14px 40px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.08); }
.nav-scan.active { color: var(--text); }

.center { text-align: center; }
.spacer { height: 18px; }
.loading { text-align: center; color: var(--dim); padding: 50px 0; font-family: var(--mono); font-size: 11px; letter-spacing: .3em; text-transform: uppercase; }
.fade { animation: fade .35s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px);} to { opacity: 1; transform: none; } }
@media (max-width: 380px) { h1.title { font-size: 38px; } .nav { gap: 16px; } .nav-pill { padding: 14px 20px; } }
