:root {
  --bg: #09090b;
  --bg-elevated: #0c0c0f;
  --surface: #141417;
  --text: #fafafa;
  --muted: #a1a1aa;
  --muted2: #71717a;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --accent: #e4e4e7;
  --green: #86efac;
  --green-dim: rgba(134, 239, 172, 0.12);
  --red: #fca5a5;
  --font: "Inter", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 6px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  position: relative;
}

.grid-bg {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black 20%, transparent 70%);
  z-index: 0;
}

.site-header {
  position: relative;
  z-index: 1;
  max-width: 56rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.25rem;
}

.logo {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted2);
}

.header-x {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.7rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.header-x:hover {
  border-color: var(--border-strong);
  color: var(--text);
  background: var(--surface);
}

.header-x-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

.shell {
  position: relative;
  z-index: 1;
  max-width: 42rem;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.hero {
  margin-bottom: 3rem;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted2);
  margin: 0 0 1rem;
}

.hero h1 {
  font-size: clamp(2.25rem, 6vw, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.08;
  margin: 0 0 1.25rem;
  color: var(--text);
}

.hero-lede {
  margin: 0;
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 38ch;
}

.hero-lede strong {
  color: var(--accent);
  font-weight: 500;
}

.block {
  margin-bottom: 3rem;
}

.block-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted2);
  margin: 0 0 1rem;
}

.manifest {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.manifest pre {
  margin: 0;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.55;
  color: #d4d4d8;
}

.manifest code {
  font-family: inherit;
}

.bullet-list {
  margin: 0 0 1.25rem;
  padding: 0;
  list-style: none;
}

.bullet-list li {
  position: relative;
  padding-left: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--muted);
  line-height: 1.5;
}

.bullet-k {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted2);
  margin-right: 0.35rem;
}

.row-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

@media (min-width: 480px) {
  .row-actions {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
  }
}

.placeholder {
  font-size: 0.82rem;
  color: var(--muted2);
  max-width: 18rem;
  line-height: 1.45;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--muted2);
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: not-allowed;
}

.fine-print {
  margin: 1rem 0 0;
  font-size: 0.72rem;
  color: var(--muted2);
  line-height: 1.45;
}

.block-play {
  padding-top: 0.5rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.hud-box {
  padding: 0.75rem 0.65rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  text-align: center;
}

.hud-k {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted2);
  margin-bottom: 0.25rem;
}

.hud-v {
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.canvas-wrap {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 1rem;
}

#chart {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: middle;
  touch-action: manipulation;
  cursor: pointer;
}

.toast {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 500;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s;
}

.toast.show {
  opacity: 1;
}

.toast.ok {
  color: var(--green);
}

.toast.bad {
  color: var(--red);
}

.play-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--text);
  color: var(--bg);
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:hover {
  opacity: 0.92;
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.75rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-secondary:hover {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:active {
  transform: scale(0.99);
}

.hint {
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: var(--muted2);
  line-height: 1.5;
}

.hint strong {
  color: var(--muted);
  font-weight: 500;
}

.leaderboard {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.lb-sub {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--muted2);
  line-height: 1.45;
}

.leaderboard-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  min-height: 3rem;
}

.lb-empty {
  margin: 0;
  padding: 1rem 1.1rem;
  font-size: 0.82rem;
  color: var(--muted2);
  line-height: 1.45;
}

.lb-empty strong {
  color: var(--muted);
  font-weight: 500;
}

.lb-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.lb-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

.lb-list li:last-child {
  border-bottom: none;
}

.lb-rank {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted2);
}

.lb-score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.lb-date {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted2);
  text-align: right;
}

.site-footer {
  position: relative;
  z-index: 1;
  max-width: 56rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 3rem;
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted2);
}

.site-footer-x {
  margin-top: 0.65rem;
}

.site-footer-x a {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
}

.site-footer-x a:hover {
  color: var(--text);
  text-decoration: underline;
}
