:root {
  --bg: #090a0c;
  --bg-surface: #14171d;
  --bg-surface-hover: #1a1e26;
  --text: #f0f3f6;
  --text-muted: #959da6;
  --text-dim: #606873;
  --text-inverse: #090a0c;
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.16);
  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.1);
  --accent-border: rgba(56, 189, 248, 0.24);
  --emerald: #10b981;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Segoe UI Mono", Menlo, Consolas, monospace;
  --radius-md: 0.625rem;
  --radius-lg: 0.875rem;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 160ms var(--ease);
  --slow: 700ms var(--ease);
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-sans);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(1200px, 100vw);
  height: 450px;
  background: radial-gradient(ellipse at 50% 0%, rgba(56, 189, 248, 0.07) 0%, rgba(16, 185, 129, 0.03) 40%, transparent 70%);
  pointer-events: none;
}

a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

/* Buttons (same as main site) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.65rem 1.35rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: transform var(--fast), background-color var(--fast), border-color var(--fast), color var(--fast), box-shadow var(--fast);
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--text); color: var(--text-inverse); border-color: var(--text); }
.btn-primary:hover { background: #fff; color: var(--text-inverse); box-shadow: 0 4px 18px rgba(255, 255, 255, 0.15); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border-hover); }
.btn-outline:hover { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent); }

/* Hero: centered, moves to the top when playing */
.hero {
  position: fixed;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  width: min(92vw, 640px);
  text-align: center;
  z-index: 2;
  transition: top var(--slow), transform var(--slow);
}

.name {
  font-size: clamp(2.35rem, 9vw, 3.85rem);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 1.05;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
  transition: font-size var(--slow), letter-spacing var(--slow), margin var(--slow);
}

.title {
  font-size: clamp(1.2rem, 4vw, 1.625rem);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.02em;
  max-height: 3rem;
  transition: opacity 300ms, max-height var(--slow), margin var(--slow);
}

.extra {
  max-height: 14rem;
  overflow: hidden;
  padding-top: 1.25rem;
  transition: opacity 300ms, max-height var(--slow), padding var(--slow);
}
.desc { color: var(--text-muted); font-size: 1.05rem; line-height: 1.65; max-width: 40ch; }
.extra { display: flex; flex-direction: column; align-items: center; gap: 1rem; }

.start {
  margin-top: 1.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-dim);
  transition: color var(--fast);
}
.start:hover { color: var(--accent); }
.start svg, .cv-link svg, .close svg, .retry svg {
  width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0;
}
.start svg { width: 0.95rem; height: 0.95rem; }
.on-mouse { display: none; }
svg.on-mouse { display: none; }
@media (hover: hover) and (pointer: fine) {
  .on-touch, svg.on-touch { display: none; }
  .on-mouse { display: inline; }
  svg.on-mouse { display: block; }
}

.cv-link {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.75rem;
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.03);
  transition: border-color var(--fast), background-color var(--fast), color var(--fast);
}
.cv-link svg { width: 1.15rem; height: 1.15rem; animation: nudge 2.4s var(--ease) infinite; }
.cv-link:hover { border-color: var(--accent-border); background: var(--accent-soft); color: var(--accent); }
@keyframes nudge { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-3px); } 90% { transform: translateY(1px); } }

/* HUD */
.hud {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: opacity 400ms 250ms, max-height var(--slow);
}
.score {
  font-family: var(--font-mono);
  font-size: clamp(3rem, 14vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin-top: 0.5rem;
}
.hint { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-dim); }

/* Playing state */
body.playing .hero { top: calc(env(safe-area-inset-top, 0px) + 1.25rem); transform: translate(-50%, 0); pointer-events: none; }
body.playing .name { font-size: 1.05rem; letter-spacing: 0.08em; margin-bottom: 0; color: var(--text-muted); }
body.playing .title { opacity: 0; max-height: 0; }
body.playing .extra { opacity: 0; max-height: 0; padding-top: 0; pointer-events: none; }
body.playing .hud { max-height: 8rem; opacity: 1; }
body.ended .hint { opacity: 0; }

/* Close button */
.close {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 1rem);
  right: 1rem;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms, color var(--fast), border-color var(--fast);
}
.close:hover { color: var(--text); border-color: var(--border-hover); }
body.playing .close { opacity: 1; pointer-events: auto; transition-delay: 300ms; }

/* Game over card */
.over {
  position: fixed;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  z-index: 4;
  width: min(88vw, 340px);
  text-align: center;
  padding: 1.5rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: 0.375rem;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.6);
  animation: pop 400ms var(--ease);
}
.over[hidden] { display: none; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -46%) scale(0.96); } }
.over-label { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim); }
.over-score { font-size: 1.75rem; font-weight: 700; color: var(--text); letter-spacing: -0.03em; margin: 0.25rem 0; }
.over-best { font-family: var(--font-mono); font-size: 0.78rem; color: var(--accent); margin-bottom: 1.25rem; }
.retry {
  display: inline-grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  background: var(--text);
  color: var(--text-inverse);
  border-radius: 0.5rem;
  transition: transform var(--fast), box-shadow var(--fast);
}
.retry:hover { box-shadow: 0 4px 18px rgba(255, 255, 255, 0.15); }
.retry:hover svg { transform: rotate(-90deg); }
.retry svg { transition: transform 300ms var(--ease); }
.retry:active { transform: scale(0.96); }

.footer {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  z-index: 1;
  transition: opacity 300ms;
}
body.playing .footer { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
