:root {
  --yellow: #d8c56a;
  --ink: #0a0904;
}

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

html,
body {
  height: 100%;
  background: var(--ink);
  color: var(--yellow);
  font-family: "Courier New", Courier, ui-monospace, monospace;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
}

#nl-hud-frame,
#nl-badge-frame {
  display: none !important;
}

#app {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: #070704;
}

#app.playing {
  background: #c4b056;
}

/* ---------- VHS overlays ---------- */
#fx-grain,
#fx-scan,
#fx-vignette,
#fx-chroma,
#fx-glitch,
#fx-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 80;
}

#fx-grain {
  opacity: 0.1;
  background: repeating-radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
  animation: grain-shift 0.35s steps(3) infinite;
}

#fx-scan {
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.12) 0px,
    rgba(0, 0, 0, 0.12) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.28;
}

#fx-vignette {
  background: radial-gradient(ellipse at center, transparent 55%, rgba(20, 16, 6, 0.38) 100%);
}

#fx-chroma {
  box-shadow: inset 10px 0 28px rgba(255, 0, 60, 0.05), inset -10px 0 28px rgba(0, 80, 255, 0.06);
  mix-blend-mode: screen;
  opacity: 0.5;
}

#fx-glitch {
  opacity: 0;
  background: linear-gradient(90deg, transparent 40%, rgba(255, 40, 40, 0.12) 41%, transparent 42%, transparent 58%, rgba(40, 80, 255, 0.12) 59%, transparent 60%);
}

#fx-glitch.is-on {
  opacity: 1;
  animation: tear 0.18s steps(2) both;
}

#fx-noise {
  width: 100%;
  height: 100%;
  opacity: 0.05;
  mix-blend-mode: overlay;
}

#app.is-glitch {
  filter: contrast(1.18) saturate(0.75) hue-rotate(-6deg);
}

#app.is-flicker #view {
  filter: brightness(0.8) saturate(1.04);
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  50% { transform: translate(-2%, 1%); }
  100% { transform: translate(1%, -2%); }
}

@keyframes tear {
  0% { transform: translate(-3%, 2%) skewX(-2deg); }
  50% { transform: translate(4%, -1%) skewX(3deg); }
  100% { transform: none; }
}

@keyframes pulse-glow {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.85; }
}

@keyframes title-flicker {
  0%, 92%, 100% { opacity: 1; }
  93% { opacity: 0.55; }
  95% { opacity: 1; }
  97% { opacity: 0.7; }
}

/* ---------- Landing ---------- */
#landing {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: #050503;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.1s ease;
}

#landing.is-on {
  opacity: 1;
  pointer-events: auto;
}

.landing-glow {
  position: absolute;
  width: 70vmin;
  height: 70vmin;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(212, 192, 98, 0.22), transparent 68%);
  animation: pulse-glow 5.5s ease-in-out infinite;
  filter: blur(8px);
  pointer-events: none;
}

.landing-copy {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 24px 20px 72px;
}

.landing-kicker {
  letter-spacing: 0.55em;
  font-size: 11px;
  color: rgba(216, 197, 106, 0.55);
  margin-bottom: 22px;
}

.landing-copy h1 {
  font-weight: 700;
  font-size: clamp(32px, 8vw, 72px);
  line-height: 0.95;
  letter-spacing: 0.08em;
  text-shadow: 0 0 28px rgba(216, 197, 106, 0.35), 2px 0 0 rgba(255, 40, 40, 0.12), -2px 0 0 rgba(40, 80, 255, 0.12);
  animation: title-flicker 7s infinite;
}

.landing-line {
  margin: 22px 0 36px;
  color: rgba(230, 214, 140, 0.72);
  letter-spacing: 0.12em;
  font-size: clamp(12px, 2.4vw, 16px);
}

.btn-enter,
.btn-ghost {
  font-family: inherit;
  cursor: pointer;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.btn-enter {
  color: var(--ink);
  background: var(--yellow);
  border: 1px solid var(--yellow);
  padding: 16px 28px;
  font-size: clamp(12px, 2.2vw, 15px);
  font-weight: 700;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 0 40px rgba(216, 197, 106, 0.25);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn-enter:hover,
.btn-enter:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 0 50px rgba(216, 197, 106, 0.45);
  filter: brightness(1.05);
}

.btn-ghost {
  background: transparent;
  color: var(--yellow);
  border: 1px solid rgba(216, 197, 106, 0.45);
  padding: 16px 22px;
  font-size: clamp(12px, 2.2vw, 15px);
}

.btn-ghost:hover,
.btn-ghost:focus-visible {
  background: rgba(216, 197, 106, 0.1);
}

/* ---------- Game ---------- */
#game {
  position: fixed;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
  background: #c4b056;
}

#game.is-on {
  opacity: 1;
  pointer-events: auto;
}

#view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #c4b056;
}

#hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  z-index: 60;
  letter-spacing: 0.28em;
  font-size: 11px;
  color: rgba(243, 230, 176, 0.72);
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.hud-label {
  margin-bottom: 5px;
}

#vhs-stamp {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 60;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: rgba(220, 80, 80, 0.72);
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.7);
}

#discover {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%);
  z-index: 60;
  letter-spacing: 0.42em;
  font-size: clamp(16px, 3vw, 28px);
  color: rgba(236, 220, 140, 0.82);
  text-shadow: 0 0 18px rgba(0, 0, 0, 0.8), 1px 0 0 rgba(255, 40, 40, 0.25);
  text-align: center;
  pointer-events: none;
}

#hint {
  position: fixed;
  left: 50%;
  bottom: 110px;
  transform: translateX(-50%);
  z-index: 60;
  letter-spacing: 0.32em;
  font-size: 11px;
  color: rgba(216, 197, 106, 0.5);
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}

#hint.is-on {
  opacity: 1;
}

#btn-sound {
  position: fixed;
  left: 50%;
  top: 12%;
  transform: translateX(-50%);
  z-index: 110;
  background: var(--yellow);
  color: #0a0904;
  border: 0;
  padding: 12px 18px;
  font-family: inherit;
  letter-spacing: 0.2em;
  cursor: pointer;
}

#btn-sound[hidden] {
  display: none !important;
}

#pad {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(64px, env(safe-area-inset-bottom));
  z-index: 70;
  display: grid;
  grid-template-columns: 56px 56px 56px;
  grid-template-rows: 56px 56px;
  gap: 8px;
  opacity: 0.38;
}

#pad button {
  width: 56px;
  height: 56px;
  border: 1px solid rgba(216, 197, 106, 0.4);
  background: rgba(10, 9, 4, 0.45);
  color: var(--yellow);
  font-size: 20px;
  cursor: pointer;
  border-radius: 4px;
}

.pad-fwd { grid-column: 2; grid-row: 1; }
.pad-left { grid-column: 1; grid-row: 2; }
.pad-back { grid-column: 2; grid-row: 2; }
.pad-right { grid-column: 3; grid-row: 2; }

@media (max-width: 800px) {
  #pad { opacity: 0.92; }
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: rgba(5, 5, 3, 0.72);
  padding: 24px;
}

.modal[hidden],
#lore[hidden],
#vhs-stamp[hidden],
#discover[hidden] {
  display: none !important;
}

.modal-card {
  text-align: center;
  max-width: 520px;
}

.modal-kicker,
.lore-kicker {
  letter-spacing: 0.42em;
  font-size: 11px;
  color: rgba(216, 197, 106, 0.5);
  margin-bottom: 16px;
}

.modal-card h2 {
  font-size: clamp(28px, 6vw, 44px);
  letter-spacing: 0.12em;
  margin-bottom: 18px;
  text-shadow: 0 0 20px rgba(216, 197, 106, 0.25);
}

.modal-sub {
  color: rgba(230, 214, 140, 0.7);
  line-height: 1.6;
  margin-bottom: 28px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

#lore {
  position: fixed;
  inset: 0;
  z-index: 95;
  overflow: auto;
  background: rgba(6, 5, 2, 0.94);
  padding: 48px 20px 96px;
}

.lore-inner {
  max-width: 640px;
  margin: 0 auto;
}

.lore-inner h2 {
  letter-spacing: 0.16em;
  margin: 8px 0 28px;
}

.lore-inner h3 {
  letter-spacing: 0.28em;
  font-size: 13px;
  margin: 28px 0 10px;
  color: #efe3a8;
}

.lore-inner p {
  color: rgba(230, 214, 140, 0.78);
  line-height: 1.7;
  font-size: 15px;
}

.lore-end {
  margin: 32px 0;
  color: rgba(200, 80, 70, 0.85) !important;
}

#btn-lore-close {
  margin-top: 8px;
}

#ticker {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(5, 5, 3, 0.55), transparent);
  font-size: 11px;
  letter-spacing: 0.28em;
}

.ticker-mark {
  color: rgba(216, 197, 106, 0.7);
  text-shadow: 0 0 10px rgba(216, 197, 106, 0.25);
}

#btn-lore {
  background: none;
  border: 0;
  color: rgba(216, 197, 106, 0.65);
  font-family: inherit;
  letter-spacing: 0.22em;
  cursor: pointer;
}

#btn-lore:hover {
  color: #fff4c4;
}

@media (max-width: 600px) {
  #hud { font-size: 10px; }
  .landing-kicker { letter-spacing: 0.4em; }
}

@media (prefers-reduced-motion: reduce) {
  .landing-copy h1,
  .landing-glow,
  #fx-grain {
    animation: none !important;
  }
}
