:root {
  color-scheme: dark;
  --space: #05060f;
  --surface: #1a1a19;
  --surface-2: #232321;
  --text: #ffffff;
  --text-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.1);
  --accent: #3987e5;
  --accent-track: #0d366b;
  --good: #0ca30c;
  --critical: #e66767;
  --gold: #fab219;
  --radius: 14px;
  --gutter: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--space);
  color: var(--text);
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

#space {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
}

h1, h2, h3 { line-height: 1.2; margin: 0; text-wrap: balance; }
h2 { font-size: 1.6rem; }
h3 { font-size: 1.05rem; }
p { margin: 0; }
a { color: inherit; }
button, input { font: inherit; color: inherit; }

/* --- top bar ---------------------------------------------------------------- */

.top {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(5, 6, 15, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: none;
}

.hero-logo {
  display: block;
  width: clamp(150px, 30vh, 280px);
  height: auto;
  margin: 0 auto 4px;
  filter: drop-shadow(0 10px 40px rgba(138, 201, 54, 0.22));
}
/* On narrow screens the round mark stands for the name, which the big logo shows anyway. */
@media (max-width: 480px) { .brand-name { display: none; } }
.stage-hint .slogan {
  max-width: 40rem;
  margin: 0 auto 6px;
  color: #8ac936;
  text-wrap: balance;
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.6);
}
.not-found { justify-items: center; text-align: center; padding-top: 48px; }
.not-found .hero-logo { width: 200px; }

.nav { display: flex; gap: 4px; margin-right: auto; }
.nav a {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.95rem;
}
.nav a:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.account { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 9px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.12); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: rgba(255, 255, 255, 0.1); }
.btn.small { padding: 6px 12px; font-size: 0.85rem; font-weight: 500; }
.btn.wide { width: 100%; }

.lang-switch {
  padding: 6px 8px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lang-switch:hover { color: var(--text); background: rgba(255, 255, 255, 0.08); }

.chip {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 14px 7px 10px;
  background: rgba(26, 26, 25, 0.8);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.coin {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffe28a, var(--gold) 60%, #b97a00);
  flex: none;
}

.notice {
  position: fixed;
  inset: 60px var(--gutter) auto var(--gutter);
  z-index: 9;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 14px;
  border: 1px solid #6b4f00;
  border-radius: 12px;
  background: rgba(59, 42, 0, 0.92);
  color: #ffe9b0;
  font-size: 0.9rem;
  text-align: center;
}
.notice strong { overflow-wrap: anywhere; }

.banner {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 9;
  padding: 8px var(--gutter);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: #3b2a00;
  color: #ffe9b0;
  font-size: 0.85rem;
  text-align: center;
}

:focus-visible { outline: 2px solid #9ec5f4; outline-offset: 2px; }

/* --- the game ----------------------------------------------------------------- */

.stage {
  position: relative;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  /* No callout menu on a long press in iOS Safari. */
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

.stage-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 0 24px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.6s;
}
.stage-hint h1 { font-size: clamp(2rem, 8vw, 4rem); }
.stage-hint p { color: var(--text-2); max-width: 30rem; margin: 0 auto; }
.stage.playing .stage-hint { opacity: 0; }
.stage-hint .guest-hint { color: var(--text); font-weight: 600; }

.ladder {
  position: absolute;
  right: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column-reverse;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}
.ladder li {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--c);
  opacity: 0.3;
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
}
.ladder li.on {
  opacity: 1;
  transform: scale(1.6);
  box-shadow: 0 0 16px 4px var(--c);
}

.burst {
  position: absolute;
  width: min(62vw, 300px);
  aspect-ratio: 1;
  margin: calc(min(62vw, 300px) / -2) 0 0 calc(min(62vw, 300px) / -2);
  pointer-events: none;
  animation: burst 1s ease-out forwards;
  filter: drop-shadow(0 0 28px var(--c));
}
.burst svg { width: 100%; height: 100%; display: block; }

@keyframes burst {
  0% { transform: scale(0.3) rotate(-20deg); opacity: 0; }
  12% { transform: scale(1.06) rotate(0deg); opacity: 1; }
  30% { opacity: 0.55; }
  45% { opacity: 1; }
  100% { transform: scale(1.35) rotate(14deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .burst { animation-name: burst-calm; }
  @keyframes burst-calm {
    0% { opacity: 0; }
    15% { opacity: 1; }
    100% { opacity: 0; }
  }
}

/* --- panels ------------------------------------------------------------------- */

.panel {
  max-width: 1080px;
  margin: 0 auto;
  padding: 72px var(--gutter) 24px;
  display: grid;
  gap: 16px;
}
.panel > * { min-width: 0; }
.lead { color: var(--text-2); }
/* On wide screens the account is in the menu; the button stands in for it on phones. */
@media (min-width: 641px) { .account .account-btn { display: none; } }
.admin-panel { display: grid; gap: 16px; margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--grid); }
.search-row { display: flex; gap: 8px; margin-bottom: 8px; }
.search-row input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--axis);
  border-radius: 10px;
  background: #111110;
  color: var(--text);
}
.pager { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.users td { vertical-align: top; }
.users .who { display: grid; gap: 2px; }
.users .who small { color: var(--muted); font-variant-numeric: tabular-nums; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-2);
  font-size: 0.75rem;
  white-space: nowrap;
}
.badge.admin { background: rgba(57, 135, 229, 0.18); color: #9ec5f4; }
.badge.bad { background: rgba(230, 103, 103, 0.18); color: #f2a6a6; }
.actions { display: flex; flex-wrap: wrap; gap: 4px; max-width: 360px; }
.actions .btn { padding: 4px 10px; font-size: 0.8rem; font-weight: 500; }
.console-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
a.btn { text-decoration: none; display: inline-block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin: 0;
  min-width: 0;
  scroll-margin-top: 72px;
}
.card h3 { margin-bottom: 12px; }

.label { color: var(--text-2); font-size: 0.9rem; }
.label.spaced { margin-top: 18px; margin-bottom: 6px; }
.sub { color: var(--muted); font-size: 0.85rem; }

.hero-row { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.hero-value { font-size: 4rem; font-weight: 700; line-height: 1.1; }

.tiles {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-width: 0;
}
.card .tile { background: var(--surface-2); }
.tile .value { font-size: 1.6rem; font-weight: 600; overflow-wrap: anywhere; }

.meter {
  height: 10px;
  border-radius: 5px;
  background: var(--accent-track);
  overflow: hidden;
  margin: 10px 0 6px;
}
.meter span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 0 5px 5px 0;
  background: var(--accent);
  transition: width 0.4s;
}

.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 860px) {
  .hero-row { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
  .grid { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
}

.chart figcaption p { color: var(--muted); font-size: 0.85rem; margin-top: -8px; }
.plot { margin-top: 14px; }
.plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.plot text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.plot text.value { fill: var(--text-2); }
.plot text.name { fill: var(--text-2); font-size: 12px; }
.plot .gridline { stroke: var(--grid); stroke-width: 1; }
.plot .baseline { stroke: var(--axis); stroke-width: 1; }
.plot .bar { fill: var(--accent); }
.plot .band { fill: transparent; outline: none; }
.plot .band:hover + .bar, .plot .band:focus-visible + .bar { fill: #6da7ec; }
.plot .empty { fill: var(--muted); font-size: 13px; }

.table-view { margin-top: 12px; }
.table-view summary { cursor: pointer; color: var(--text-2); font-size: 0.85rem; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.empty { color: var(--muted); border: 0; white-space: normal; }

.status { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.status::before { content: "…"; width: 1em; text-align: center; color: var(--muted); }
.status.good::before { content: "✓"; color: var(--good); }
.status.bad::before { content: "✕"; color: var(--critical); }
.status.win::before { content: "★"; color: var(--gold); }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
  color: var(--text-2);
}
.key {
  display: block;
  padding: 12px;
  border: 1px dashed var(--axis);
  border-radius: 10px;
  color: var(--text);
  font-size: 1rem;
  text-align: center;
  user-select: all;
}

.chain-line { color: var(--muted); font-size: 0.85rem; overflow-wrap: anywhere; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.dot.good { background: var(--good); }
.dot.bad { background: var(--critical); }

/* --- FAQ ---------------------------------------------------------------------- */

.faq { display: grid; gap: 8px; }
.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 18px;
}
.faq summary { cursor: pointer; padding: 14px 0; font-weight: 600; }
.faq .answer { padding-bottom: 16px; color: var(--text-2); display: grid; gap: 10px; max-width: 70ch; }
.faq .answer ul { margin: 0; padding-left: 20px; }
.faq .answer li span.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; background: var(--c); }

.foot {
  display: flex;
  justify-content: space-between;
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px var(--gutter) 72px;
  color: var(--muted);
  font-size: 0.85rem;
}

/* --- dialogs ------------------------------------------------------------------ */

dialog {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
}
dialog::backdrop { background: rgba(3, 4, 10, 0.72); backdrop-filter: blur(4px); }
dialog h2 { margin-bottom: 16px; }
dialog h3 { margin: 8px 0 0; }

.close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-2);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.close:hover { background: rgba(255, 255, 255, 0.1); }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button {
  border: 0;
  border-radius: 999px;
  padding: 6px 12px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
}
.tabs button[aria-selected="true"] { background: rgba(255, 255, 255, 0.12); color: var(--text); }

.form { display: grid; gap: 14px; }
#wallet-dialog .form + .form { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--grid); }
.form label { display: grid; gap: 6px; color: var(--text-2); font-size: 0.9rem; }
.form input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--axis);
  border-radius: 10px;
  background: #111110;
  color: var(--text);
  font-size: 1rem;
}
.form small { color: var(--muted); }
.form label.check, .radios label { display: flex; align-items: center; gap: 8px; color: var(--text); }
.radios { display: flex; gap: 16px; flex-wrap: wrap; }
.error { color: var(--critical); font-size: 0.9rem; }
.error:empty { display: none; }
[hidden] { display: none !important; }

.qr { display: grid; place-items: center; }
.qr svg { width: 200px; height: 200px; border-radius: 10px; }

.wallet-balance { display: flex; align-items: center; gap: 8px; font-size: 1.3rem; margin-bottom: 16px; flex-wrap: wrap; }
#withdrawals { margin-top: 16px; }

/* --- win, toasts, tooltip ----------------------------------------------------- */

.win {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 4, 10, 0.8);
  animation: fade 0.3s;
}
.win-box {
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
  max-width: 420px;
  padding: 28px;
  border-radius: 22px;
  background: var(--surface);
  border: 1px solid var(--gold);
  box-shadow: 0 0 80px rgba(250, 178, 25, 0.35);
}
.win-box h2 { font-size: 2.2rem; }
.win-box p { color: var(--text-2); }
.win-chakras { display: flex; gap: 8px; }
.win-chakras span { width: 16px; height: 16px; border-radius: 50%; background: var(--c); box-shadow: 0 0 12px var(--c); }
@keyframes fade { from { opacity: 0; } }

.toasts {
  position: fixed;
  inset: auto 0 64px 0;
  z-index: 40;
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0 var(--gutter);
  pointer-events: none;
}
.toast {
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 12px;
  background: #2c2c2a;
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5);
  animation: fade 0.2s;
}

.tooltip {
  position: fixed;
  z-index: 50;
  padding: 8px 10px;
  border-radius: 8px;
  background: #2c2c2a;
  border: 1px solid var(--border);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  font-size: 0.85rem;
  pointer-events: none;
  white-space: nowrap;
}
.tooltip strong { display: block; font-size: 1rem; }
.tooltip span { color: var(--text-2); }

@media (max-width: 640px) {
  .nav { display: none; }
  .top { gap: 8px; }
  .btn { padding: 8px 12px; font-size: 0.9rem; }
  .hero-value { font-size: 3.2rem; }
}
