:root {
  --bg: #f6f3fb; --surface: #ffffff; --text: #1d1630; --muted: #6b6380; --line: #e4def0;
  --gold: #e8b931; --gold-dark: #b8861b; --gold-ink: #4a3200;
  --accent: #5b3fd1; --accent-ink: #ffffff; --pos: #13824a; --neg: #b3261e; --warn-bg: #fff4d6;
  --radius: 16px; --shadow: 0 2px 10px rgba(29, 22, 48, .08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14101f; --surface: #1f1931; --text: #f1edf9; --muted: #a59dbb; --line: #322a4a;
    --accent: #8f78ff; --accent-ink: #14101f; --pos: #4cd28b; --neg: #ff8a80; --warn-bg: #3a2f12;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
main { max-width: 560px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; margin: .4em 0 .5em; }
h2 { font-size: 1.1rem; margin: 1.4em 0 .5em; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: .85rem; } .center { text-align: center; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 10px; } .row > * { flex: 1; }
.err { color: var(--neg); min-height: 1.2em; margin: 0; }
.back { display: inline-block; margin-bottom: 4px; text-decoration: none; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.net { font-size: .75rem; padding: 2px 8px; border-radius: 99px; }
.net.on { background: color-mix(in srgb, var(--pos) 18%, transparent); color: var(--pos); }
.net.off { background: color-mix(in srgb, var(--neg) 18%, transparent); color: var(--neg); }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 5; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 10px; font-size: .75rem; color: var(--muted); text-decoration: none; }
.tabs a span { font-size: 1.3rem; } .tabs a.active { color: var(--accent); font-weight: 700; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 12px;
  padding: 11px 16px; font: inherit; font-weight: 600; text-align: center; text-decoration: none; cursor: pointer; display: inline-block; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, transparent); }
.btn.big { padding: 15px 18px; font-size: 1.05rem; }
.btn.small { padding: 5px 10px; font-size: .85rem; border-radius: 8px; }
input, select, textarea { width: 100%; font: inherit; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--text); margin-top: 4px; }
input.pin { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
label { font-weight: 600; font-size: .95rem; }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin: 14px 0; }
label.check input { width: 22px; height: 22px; margin: 0; flex: none; }

.coin { display: inline-grid; place-items: center; width: 1.1em; height: 1.1em; border-radius: 50%; background: var(--gold);
  color: var(--gold-ink); font-family: Georgia, serif; font-weight: 700; font-size: .8em; box-shadow: inset 0 0 0 .08em var(--gold-dark); }
.coin.sm { font-size: 1.4rem; } .coin.xl { width: 120px; height: 120px; font-size: 72px; box-shadow: inset 0 0 0 8px var(--gold-dark), 0 8px 30px rgba(232, 185, 49, .35); }
.hero { text-align: center; padding-top: 24px; } .hero h1 { font-size: 2.2rem; margin-bottom: 0; } .hero .stack { margin-top: 28px; }

.balance-card, .card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 18px; margin-bottom: 14px; }
.balance-card { text-align: center; }
.balance-card p { margin: 0; }
.balance { font-size: 2.8rem; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 0; font-variant-numeric: tabular-nums; }
.addr { margin: 0 0 16px !important; font-size: .8rem; color: var(--muted); }
.addr-full { word-break: break-all; font-size: .9rem; background: var(--surface); border: 1px dashed var(--line); padding: 10px; border-radius: 10px; }

.list, .board { list-style: none; padding: 0; margin: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.list li, .board li > a { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.list li:first-child, .board li:first-child > a { border-top: 0; }
.board li.muted { padding: 14px; }
.board li.me > a { background: color-mix(in srgb, var(--gold) 16%, transparent); }
.rank { width: 2em; text-align: center; font-size: 1.2rem; font-weight: 700; color: var(--muted); }
.avatar { font-size: 1.2rem; }
.amt { font-weight: 700; font-variant-numeric: tabular-nums; } .pos { color: var(--pos); } .neg { color: var(--neg); }

.words { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 0; margin: 12px 0; list-style: none; counter-reset: w; }
.words li { counter-increment: w; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-weight: 700; }
.words li::before { content: counter(w) ". "; color: var(--muted); font-weight: 400; }

.notice { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; color: inherit; text-decoration: none; }
.notice.warn { background: var(--warn-bg); border-color: transparent; }
.notice .btn { margin-left: 6px; }

.qr { border-radius: 12px; max-width: 100%; height: auto; }
.modal-wrap { position: fixed; inset: 0; background: rgba(10, 6, 20, .55); display: grid; place-items: end center; z-index: 20; padding: 12px; }
@media (min-width: 600px) { .modal-wrap { place-items: center; } }
.modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: 20px; padding: 20px; max-height: 90dvh; overflow: auto; }
.modal h2 { margin-top: 0; } .modal video { width: 100%; border-radius: 12px; background: #000; margin-bottom: 10px; }
.big-text { font-size: 1.2rem; text-align: center; }
.spinner { width: 42px; height: 42px; margin: 10px auto; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 12px; z-index: 30; max-width: calc(100% - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25); }
.toast.bad { background: var(--neg); color: #fff; } .toast.ok { background: var(--pos); color: #fff; }
.celebrate { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; z-index: 40; background: color-mix(in srgb, var(--bg) 85%, transparent); font-size: 1.3rem; font-weight: 700; }
.coin.spin { animation: flip 1.1s ease-in-out 2; margin: 0 auto 12px; }
@keyframes flip { 50% { transform: rotateY(180deg) scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .coin.spin, .spinner { animation: none; } }
