:root {
  --bg: #07070c;
  --fg: #f3f0ea;
  --muted: #9a96a6;
  --line: rgba(255, 255, 255, 0.1);
  --card: rgba(255, 255, 255, 0.04);
  --accent: #ffd36b;
  --accent-ink: #1a1405;
  --you: #ff6b8b;
  --display: 'Syne', system-ui, sans-serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--body);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  display: block;
  touch-action: none;
}

.screen {
  position: fixed;
  inset: 0;
  height: 100dvh;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.screen[hidden] {
  display: none;
}

.column {
  width: 100%;
  max-width: 420px;
  margin: auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.logo {
  margin: 4px 0 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(34px, 10vw, 80px);
  letter-spacing: -0.03em;
  line-height: 1;
  white-space: nowrap;
}

.logo span {
  display: inline-block;
  animation: flicker 7s ease-in-out infinite;
}

@keyframes flicker {
  0%, 100% { opacity: 1; filter: blur(0); transform: translateY(0); }
  45% { opacity: 1; filter: blur(0); transform: translateY(0); }
  55% { opacity: 0.12; filter: blur(6px); transform: translateY(-6px); }
  65% { opacity: 1; filter: blur(0); transform: translateY(0); }
}

.lede {
  margin: 0;
  font-size: 17px;
  line-height: 1.5;
  color: var(--fg);
  opacity: 0.85;
}

.fine {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
}

.btn {
  font: 600 16px var(--body);
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 14px 28px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
  font-weight: 700;
  font-size: 18px;
  padding: 16px 36px;
  box-shadow: 0 0 40px rgba(255, 211, 107, 0.25);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 16px;
}

#home-fresh,
#home-played {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
}

#home-fresh[hidden],
#home-played[hidden] {
  display: none;
}

.card {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: blur(6px);
}

.played-card {
  align-items: center;
}

.played-score {
  margin: 0;
  font-family: var(--body);
  font-size: 40px;
  font-weight: 800;
}

.countdown {
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.dev {
  margin-top: 24px;
  padding: 12px 16px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.dev[hidden] {
  display: none;
}

.dev select {
  margin-left: 8px;
  font: inherit;
  background: #15151d;
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
}

/* Intro */

.overlay {
  pointer-events: none;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding-top: max(18vh, env(safe-area-inset-top));
  padding-bottom: max(16vh, env(safe-area-inset-bottom));
}

.intro-label,
.intro-tagline {
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
  transform: translateY(8px);
}

.intro-label.show,
.intro-tagline.show {
  opacity: 1;
  transform: none;
}

.intro-tagline {
  max-width: 360px;
  margin: 0;
  font-size: 18px;
  line-height: 1.5;
  text-align: center;
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
}

/* Results */

.big-score {
  margin: 0;
  font-family: var(--body);
  letter-spacing: -0.03em;
  font-weight: 800;
  font-size: 76px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.big-score small {
  font-family: var(--body);
  font-size: 20px;
  color: var(--muted);
  margin-left: 6px;
  font-weight: 600;
}

.res-reason {
  margin: 0;
  color: var(--fg);
  opacity: 0.85;
}

.res-squares {
  margin: 0;
  font-size: 20px;
  letter-spacing: 2px;
}

.histogram {
  height: 120px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
}

.histogram .bar {
  flex: 1;
  min-height: 3px;
  border-radius: 4px 4px 2px 2px;
  background: rgba(255, 255, 255, 0.18);
  transition: height 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.histogram .bar.you {
  background: var(--you);
  box-shadow: 0 0 16px rgba(255, 107, 139, 0.5);
}

.histogram .bar.finish {
  background: rgba(255, 211, 107, 0.45);
}

.histogram .bar.finish.you {
  background: var(--accent);
}

.hist-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-top: -4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(32px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--fg);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}

.toast[hidden] {
  display: none;
}
