@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;700;800&family=IBM+Plex+Mono:wght@400;500;700&display=swap");
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.min.css");

/* =====================================================
   DESIGN SYSTEM — Cyber-Minimalism / Neo-Brutalist
   Pure black. Razor lines. Monochrome + controlled glitch.
   ===================================================== */

:root {
  color-scheme: dark;

  /* Pure Blacks */
  --void: #000000;
  --surface: #050505;
  --surface-raised: #0a0a0a;

  /* Ink */
  --ink: #ffffff;
  --ink-2: #888888;
  --ink-3: #444444;

  /* Wire (the only decorative lines) */
  --wire: rgba(255, 255, 255, 0.06);
  --wire-hover: rgba(255, 255, 255, 0.12);
  --wire-active: rgba(255, 255, 255, 0.25);

  /* Glitch Colors — ONLY for animations, never static UI */
  --glitch-cyan: rgba(0, 255, 255, 0.85);
  --glitch-magenta: rgba(255, 0, 255, 0.85);

  /* Typography */
  --font-display: "Space Grotesk", "Pretendard", "Inter", sans-serif;
  --font-body: "Pretendard", "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", "Menlo", monospace;
}

/* =====================================================
   RESET & BASE
   ===================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--void);
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  line-height: 1.5;
  background: var(--void);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Skip-link (a11y) */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--ink);
  color: var(--void);
  padding: 12px;
  z-index: 9999;
  font-weight: 700;
  transition: transform 0.2s;
}
.skip-link:focus {
  transform: translateY(40px);
}

/* =====================================================
   FLOATING ISLAND HEADER
   Capsule nav floating at top-center.
   ===================================================== */
.navbar,
.navbar-shell {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  padding: 0 6px;
  height: 48px;
  border: 1px solid var(--wire);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  width: auto;
}

.navbar-container {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0;
}

.navbar-brand {
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 100%;
}

.logo-text {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: var(--ink);
  text-transform: uppercase;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.nav-link {
  text-decoration: none;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border-radius: 999px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}
.nav-link--active {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
}

.nav-btn {
  appearance: none;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border-radius: 999px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}


/* =====================================================
   THEATER LAYOUT — Minimal overhead, game is king
   ===================================================== */
.theater-main {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 80px 24px 48px; /* 80px top accounts for floating nav */
  display: flex;
  flex-direction: column;
  align-items: center;
}

.theater-header-block {
  text-align: center;
  margin-bottom: 28px;
}

.theater-hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 5vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
  color: var(--ink);
  margin-bottom: 16px;
  animation: retro-color-cycle 6s linear infinite;
}

@keyframes retro-color-cycle {
  0%   { color: #ff00ff; }
  16%  { color: #00ffff; }
  33%  { color: #ff6600; }
  50%  { color: #39ff14; }
  66%  { color: #ff004d; }
  83%  { color: #ffff00; }
  100% { color: #ff00ff; }
}

@media (prefers-reduced-motion: reduce) {
  .theater-hero-title { animation: none; color: var(--ink); }
}

.theater-subtitle {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

/* =====================================================
   HERO TAGS — Sharp monochrome badges
   ===================================================== */
.hero-tags {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.hero-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--ink-2);
  padding: 5px 12px;
  border: 1px solid var(--wire);
  background: transparent;
}

/* =====================================================
   GAME CONTAINER — Edge-to-edge, razor-border
   ===================================================== */
.game-stage-container {
  position: relative;
  width: 100%;
  max-width: 1200px;
  display: flex;
  flex-direction: column;
}

.cinematic-glow-layer {
  display: none; /* killed — no more orange glow blob */
}

.relay-frame-shell {
  background: var(--void);
  border: 1px solid var(--wire);
  overflow: hidden;
}

.frame-hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--wire);
}
.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.hud-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--ink-3);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.hud-stage-name, .hud-progress-count {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink);
}

.relay-frame-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--void);
}
.relay-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.theater-notices {
  text-align: center;
  margin-top: 16px;
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

/* =====================================================
   OVERLAY — In-game overlays (Game Over, Victory)
   ===================================================== */
.relay-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 10;
}
.relay-overlay[hidden] {
  display: none !important;
}

.relay-overlay-card {
  width: min(90%, 460px);
  padding: 32px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--wire);
}

.blur-panel {
  background: var(--surface);
  border: 1px solid var(--wire);
}
.glass-panel {
  background: var(--surface-raised);
  border: 1px solid var(--wire);
}

.overlay-kicker {
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

#relay-overlay-title {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ink);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: -0.03em;
}
.overlay-copy {
  color: var(--ink-2);
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.5;
}
.overlay-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* =====================================================
   RANKING SAVE PANEL
   ===================================================== */
.ranking-save-panel {
  padding: 16px;
  text-align: left;
  margin-bottom: 20px;
}
.ranking-save-panel[hidden] {
  display: none !important;
}
.ranking-save-label {
  display: block;
  font-family: var(--font-mono);
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  color: var(--ink-2);
  text-transform: uppercase;
}
.ranking-save-row {
  display: flex;
  gap: 8px;
}
.ranking-save-input {
  flex: 1;
  background: var(--void);
  border: 1px solid var(--wire);
  padding: 0 14px;
  height: 40px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  transition: border-color 0.15s;
}
.ranking-save-input:focus {
  outline: none;
  border-color: var(--wire-active);
}
.ranking-save-input::placeholder {
  color: var(--ink-3);
}
.ranking-save-status {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-2);
  margin-top: 6px;
  min-height: 1.2rem;
}

/* =====================================================
   BUTTONS — Brutalist, functional
   ===================================================== */
.action-btn {
  appearance: none;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  padding: 10px 20px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  white-space: nowrap;
}

.action-btn-primary {
  background: var(--ink);
  color: var(--void);
  border: 1px solid var(--ink);
}
.action-btn-primary:hover {
  background: #d0d0d0;
  border-color: #d0d0d0;
}

.action-btn-ghost {
  background: transparent;
  color: var(--ink-2);
  border: 1px solid var(--wire);
}
.action-btn-ghost:hover {
  color: var(--ink);
  border-color: var(--wire-active);
  background: rgba(255, 255, 255, 0.03);
}

.action-btn[hidden] {
  display: none !important;
}

/* =====================================================
   MODALS (Prompt / Leaderboard)
   ===================================================== */
.prompt-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
}
.prompt-modal[aria-hidden="true"] {
  display: none;
}

.prompt-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.prompt-sheet {
  position: relative;
  width: min(100%, 620px);
  max-height: 90vh;
  padding: 28px;
  overflow-y: auto;
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--wire);
}
.prompt-sheet-leaderboard {
  width: min(100%, 700px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}
.panel-kicker {
  font-family: var(--font-mono);
  color: var(--ink-3);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.panel-head h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  margin-top: 4px;
  letter-spacing: -0.03em;
}
.panel-actions {
  display: flex;
  gap: 6px;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--wire);
  color: var(--ink-2);
  width: 36px;
  height: 36px;
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover {
  border-color: var(--wire-active);
  color: var(--ink);
}

/* Prompt Guide */
.prompt-guide {
  padding: 20px;
}
#prompt-guide-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
  text-transform: uppercase;
  color: var(--ink-2);
}
.prompt-steps {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.prompt-step-card {
  background: var(--void);
  border: 1px solid var(--wire);
  padding: 14px;
}
.prompt-step-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.step-num {
  background: var(--ink);
  color: var(--void);
  font-family: var(--font-mono);
  font-weight: 800;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
}
.prompt-step-title {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.82rem;
  flex: 1;
}
.prompt-step-code {
  background: var(--surface);
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--ink-2);
  overflow-x: auto;
  border: 1px solid var(--wire);
  white-space: pre-wrap;
  line-height: 1.6;
}
.copy-small-btn {
  appearance: none;
  background: transparent;
  border: 1px solid var(--wire);
  color: var(--ink-2);
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: border-color 0.15s, color 0.15s;
}
.copy-small-btn:hover {
  border-color: var(--wire-active);
  color: var(--ink);
}

/* Leaderboard */
.leaderboard-summary {
  margin-bottom: 20px;
}
.leaderboard-copy {
  font-size: 0.85rem;
  color: var(--ink-2);
  line-height: 1.5;
}
.leaderboard-status {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-3);
  margin-top: 6px;
}
.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.leaderboard-item {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  background: var(--void);
  border: 1px solid var(--wire);
  transition: border-color 0.12s;
}
.leaderboard-item:hover {
  border-color: var(--wire-hover);
}
.leaderboard-rank {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink-3);
  width: 28px;
  font-size: 0.85rem;
}
.leaderboard-main {
  flex: 1;
}
.leaderboard-name {
  font-weight: 700;
  font-size: 0.9rem;
}
.leaderboard-score {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-2);
}
.leaderboard-meta {
  text-align: right;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--ink-3);
}

/* =====================================================
   GLITCH TITLE — Always active, cyber color split
   ===================================================== */
.theater-hero-title.glitch-infinite {
  position: relative;
  display: inline-block;
}
.theater-hero-title.glitch-infinite::before,
.theater-hero-title.glitch-infinite::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  pointer-events: none;
}
.theater-hero-title.glitch-infinite::before {
  animation: glitch-anim-1 3s ease-in-out infinite;
  color: var(--glitch-cyan);
  z-index: -1;
}
.theater-hero-title.glitch-infinite::after {
  animation: glitch-anim-2 3s ease-in-out infinite reverse;
  color: var(--glitch-magenta);
  z-index: -2;
}

@keyframes glitch-anim-1 {
  0%, 55% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
  60% { clip-path: inset(20% 0 60% 0); transform: translate(-3px, 1px); opacity: 0.8; }
  65% { clip-path: inset(60% 0 10% 0); transform: translate(3px, -1px); }
  70% { clip-path: inset(40% 0 40% 0); transform: translate(-2px, 2px); }
  75% { clip-path: inset(80% 0 5% 0); transform: translate(2px, -2px); }
  80% { clip-path: inset(10% 0 70% 0); transform: translate(-1px, 1px); opacity: 0.8; }
  85%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
}
@keyframes glitch-anim-2 {
  0%, 50% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
  55% { clip-path: inset(10% 0 50% 0); transform: translate(3px, -1px); opacity: 0.8; }
  60% { clip-path: inset(30% 0 20% 0); transform: translate(-3px, 2px); }
  65% { clip-path: inset(70% 0 10% 0); transform: translate(2px, -1px); }
  70% { clip-path: inset(20% 0 60% 0); transform: translate(-2px, 2px); }
  75% { clip-path: inset(50% 0 30% 0); transform: translate(3px, -2px); opacity: 0.8; }
  80%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); opacity: 0; }
}

/* Scrambler dud characters */
.dud {
  color: var(--ink-3);
  opacity: 0.6;
}

/* =====================================================
   BACKGROUND — Subtle glitch atmosphere
   ===================================================== */
.bg-glitch-layer {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--void);
  overflow: hidden;
}
.bg-glitch-layer::before,
.bg-glitch-layer::after {
  content: "";
  position: absolute;
  inset: -10vw;
  background-size: 100% 8px;
  opacity: 0.08;
  mix-blend-mode: screen;
}
.bg-glitch-layer::before {
  background-image: repeating-linear-gradient(transparent 0, transparent 48%, var(--glitch-cyan) 49%, rgba(0,255,255,0.3) 50%);
  animation: bg-glitch-1 6s infinite steps(15, end);
}
.bg-glitch-layer::after {
  background-image: repeating-linear-gradient(transparent 0, transparent 48%, var(--glitch-magenta) 49%, rgba(255,0,255,0.3) 50%);
  animation: bg-glitch-2 8s infinite steps(15, end);
}

@keyframes bg-glitch-1 {
  0%, 100% { transform: translateY(0) translateX(0); }
  10% { transform: translateY(8px) translateX(-4px); }
  30% { transform: translateY(16px) translateX(4px); }
  50% { transform: translateY(-8px) translateX(0); }
  80% { transform: translateY(24px) translateX(-6px); }
}
@keyframes bg-glitch-2 {
  0%, 100% { transform: translateY(0) translateX(0); }
  15% { transform: translateY(-8px) translateX(4px); }
  40% { transform: translateY(-16px) translateX(-4px); }
  60% { transform: translateY(8px) translateX(0); }
  85% { transform: translateY(-24px) translateX(6px); }
}

/* CRT scanlines — very subtle */
.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg,
    transparent 0px,
    rgba(0, 0, 0, 0.12) 1px,
    transparent 2px
  );
  opacity: 0.5;
}

/* =====================================================
   INTERACTIVE UTILITY CLASSES
   ===================================================== */
.reveal-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}
.reveal-up.is-revealed {
  opacity: 1;
  transform: translateY(0);
}

.tilt-card {
  transition: transform 0.1s ease-out;
  transform-style: preserve-3d;
}

.glow-target {
  position: relative;
}
.glow-target::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(600px circle at var(--glow-x, 50%) var(--glow-y, 50%), rgba(255, 255, 255, 0.04), transparent 40%);
  pointer-events: none;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.glow-target:hover::before {
  opacity: 1;
}

.magnetic-btn {
  will-change: transform;
}

/* =====================================================
   FOCUS VISIBLE (a11y)
   ===================================================== */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 1px solid var(--ink);
  outline-offset: 2px;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 900px) {
  .theater-hero-title {
    font-size: 2.2rem;
  }
  .hero-tags {
    gap: 8px;
  }
  .hero-tag {
    font-size: 0.65rem;
    padding: 4px 8px;
  }
}

@media (max-width: 600px) {
  .navbar,
  .navbar-shell {
    top: 8px;
    height: 42px;
    padding: 0 4px;
  }
  .logo-text {
    font-size: 0.65rem;
    letter-spacing: 0.1em;
  }
  .nav-link,
  .nav-btn {
    font-size: 0.65rem;
    padding: 6px 10px;
  }
  .theater-main {
    padding: 64px 12px 32px;
  }
  .theater-hero-title {
    font-size: 1.8rem;
  }
  .frame-hud {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 12px;
  }
  .hud-stage-name,
  .hud-progress-count {
    font-size: 0.75rem;
  }
  .prompt-sheet {
    padding: 20px 16px;
  }
}

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