:root {
  --bg: #0a0b14;
  --surface: #12131f;
  --surface-2: #1a1c2b;
  --border: #2a3148;
  --border-strong: #3a4163;
  --text: #eef0fa;
  --text-2: #c5cae0;
  --muted: #7a82a8;
  --accent: #7c5cff;
  --accent-2: #6248d6;
  --gold: #f5c518;
  --green: #4ade80;
  --red: #ff5470;
  --radius: 14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #161a2e 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), #c9990a);
  color: #2a2206;
  font-weight: 800;
  font-size: 1.2rem;
}
.brand-name { font-weight: 700; font-size: 1.1rem; }
.brand-tagline { font-size: 0.8rem; color: var(--muted); }
.topbar-link { font-size: 0.85rem; color: var(--muted); }
.topbar-link:hover { color: var(--text-2); }
.sound-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 8px;
  font-size: 1.1rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.7;
}
.sound-toggle:hover { opacity: 1; border-color: var(--border-strong); }
.sound-toggle.muted { opacity: 0.35; }

.wrap {
  max-width: 980px;
  margin: 28px auto;
  padding: 0 20px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 20px;
}
@media (max-width: 820px) { .wrap { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: 1.1rem; }

.hud { display: flex; align-items: center; gap: 18px; margin-bottom: 12px; font-size: 0.85rem; color: var(--muted); }
.hud-spacer { flex: 1; }
.hud-stat b { color: var(--text); font-size: 1.05rem; margin-left: 4px; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 520 / 560;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #0d0f1c;
}
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: none; }

.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 9, 18, 0.8);
  backdrop-filter: blur(3px);
  text-align: center; padding: 24px;
}
.overlay.hidden { display: none; }
.overlay-card { max-width: 340px; }
.overlay-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 10px; }
.overlay-sub { color: var(--text-2); font-size: 0.9rem; line-height: 1.55; margin-bottom: 18px; }

.lives { margin-top: 10px; font-size: 1.1rem; color: var(--red); letter-spacing: 3px; min-height: 1.3em; }

.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.faucet-balance { font-size: 1.05rem; }
.faucet-balance b { color: var(--gold); }
.schedule { font-size: 0.85rem; color: var(--muted); line-height: 1.5; margin: 8px 0 18px; }

label { display: block; font-size: 0.82rem; color: var(--text-2); margin-bottom: 6px; }
input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.82rem;
}
input:focus { outline: none; border-color: var(--accent); }
.addr-hint { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }

.est { margin: 16px 0; font-size: 0.9rem; color: var(--text-2); }
.est b { color: var(--green); margin-left: 4px; }

.claim-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.msg { font-size: 0.85rem; color: var(--muted); }
.msg.green { color: var(--green); }
.msg.red { color: var(--red); }
.amber { color: var(--gold); }

.reset-timer { font-size: 0.82rem; color: var(--muted); margin-top: 12px; }
.reset-timer b { color: var(--text-2); }

.how { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 12px; }
.how h3 { font-size: 0.9rem; margin: 0 0 8px; color: var(--text-2); }
.how p { font-size: 0.82rem; color: var(--muted); line-height: 1.55; margin: 6px 0; }
.faucet-addr code { font-family: var(--mono); font-size: 0.72rem; color: var(--text-2); word-break: break-all; }
.donate { color: var(--green) !important; font-style: italic; }

.leaderboard-panel { grid-column: 1 / -1; }
.lb-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.lb-head h2 { margin: 0; }
.lb-tabs { display: flex; gap: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px; }
.lb-tab {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
}
.lb-tab:hover { color: var(--text-2); }
.lb-tab.active { background: var(--accent); color: #fff; }

.lb-info { font-size: 0.78rem; color: var(--muted); margin-bottom: 10px; }
.lb-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; table-layout: fixed; }
.lb-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.lb-table th.lb-score { text-align: right; }
.lb-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); height: 44px; }
.lb-table tr:last-child td { border-bottom: none; }
.lb-table th.lb-rank { text-align: center; }
.lb-rank { width: 52px; min-width: 52px; color: var(--muted); text-align: center; }
.lb-score { text-align: right; width: 92px; color: var(--gold); font-weight: 700; }
.lb-medal, .lb-medal-spacer { display: inline-block; width: 1.4em; text-align: center; }
.lb-medal { font-size: 1.1rem; vertical-align: -1px; }
.lb-medal-spacer { font-size: inherit; color: var(--muted); }
.lb-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-name code { font-size: 0.72rem; }
.lb-name.me { color: var(--accent); }
.lb-empty { color: var(--muted); font-size: 0.86rem; padding: 18px 4px; text-align: center; }

.lb-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.lb-pager:empty { display: none; }
.lb-page-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 32px;
  text-align: center;
}
.lb-page-btn:hover { color: var(--text-2); border-color: var(--border-strong); }
.lb-page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.history-panel { grid-column: 1 / -1; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; table-layout: fixed; }
.history-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
.history-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-table tr:last-child td { border-bottom: none; }
.history-table td code { font-size: 0.72rem; }
.hist-score { text-align: right; color: var(--gold); font-weight: 700; }
.hist-amount { text-align: right; color: var(--green); font-weight: 600; }
.hist-time { text-align: right; color: var(--muted); font-size: 0.78rem; }
.history-table th.hist-score { text-align: right; }
.history-table th.hist-amount { text-align: right; }
.history-table th.hist-time { text-align: right; }
.hist-empty { color: var(--muted); font-size: 0.86rem; padding: 18px 4px; text-align: center; }

.hist-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.hist-pager:empty { display: none; }
.hist-page-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 32px;
  text-align: center;
}
.hist-page-btn:hover { color: var(--text-2); border-color: var(--border-strong); }
.hist-page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.sitefoot {
  text-align: center;
  padding: 24px;
  font-size: 0.82rem;
  color: var(--muted);
}
