/* Cyber-Steampunk Synth Design Tokens & HSL Variables */
:root {
  --bg-darker: #000000; /* Pure Transparent Black on Waveguide */
  --border-glow: hsla(20, 100%, 60%, 0.2);
  
  /* Curated Harmonious Palette */
  --brass: hsl(20, 100%, 62%); /* Fluorescent Neon Copper */
  --brass-dark: hsl(20, 50%, 25%); /* Deep Carbon-Copper Slate */
  --cyan-glow: hsl(180, 100%, 50%); /* Holographic Electric Cyan */
  --amber-glow: hsl(38, 100%, 50%); /* Fluorescent Neon Amber */
  --green-glow: hsl(145, 95%, 45%);
  --red-glow: hsl(355, 95%, 55%);
  
  --text-primary: hsl(210, 30%, 95%);
  --text-muted: hsl(215, 14%, 66%);
  
  /* Fonts */
  --font-display: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, sans-serif;
  --font-mono: "SF Mono", "Cascadia Mono", "Roboto Mono", monospace;
  --font-steampunk: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, sans-serif;
}

/* Reset & Global Elements */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-darker);
  color: var(--text-primary);
  font-family: var(--font-display);
  min-height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
}

body.mobile-play-blocked {
  width: 100%;
  height: auto;
  min-height: 100dvh;
  display: block;
  overflow: hidden;
}

body.mobile-play-blocked .app-deck {
  display: none;
}

.mobile-play-guard {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 100dvw;
  min-height: 100dvh;
  padding: max(20px, env(safe-area-inset-top)) 16px max(22px, env(safe-area-inset-bottom));
  overflow-y: auto;
  background:
    radial-gradient(circle at 50% 0%, rgba(0, 242, 254, 0.14), transparent 42%),
    linear-gradient(180deg, #080b10 0%, #000000 100%);
  text-align: center;
}

.mobile-play-guard[hidden] {
  display: none;
}

.mobile-play-guard-panel {
  width: min(100%, 440px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  border: 1px solid var(--brass);
  border-radius: 12px;
  padding: clamp(22px, 6vw, 30px) clamp(18px, 5vw, 24px);
  background: rgba(10, 10, 15, 0.96);
  box-shadow: 0 0 24px rgba(255, 112, 56, 0.18);
}

.mobile-play-guard-panel img {
  width: clamp(54px, 16vw, 72px);
  height: clamp(54px, 16vw, 72px);
  border-radius: 8px;
  margin-bottom: 14px;
}

.guard-kicker {
  margin: 0 0 8px;
  color: var(--cyan-glow);
  font-family: var(--font-mono);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.mobile-play-guard h1 {
  margin: 0 0 12px;
  color: var(--brass);
  font-size: clamp(30px, 8vw, 40px);
  line-height: 1.04;
}

.mobile-play-guard p {
  max-width: 38ch;
  margin: 0 auto;
  color: var(--text-primary);
  font-size: clamp(16px, 4vw, 18px);
  line-height: 1.5;
}

.mobile-play-guard-actions {
  display: grid;
  gap: 10px;
  margin-top: 22px;
}

.guard-primary {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 18px;
  font-family: var(--font-display);
  font-weight: 800;
  text-decoration: none;
}

.guard-primary {
  background: var(--brass);
  color: #1c0f07;
}

/* Premium Layout Core */
.app-deck {
  width: 600px;
  height: 600px;
  max-width: 600px;
  max-height: 600px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Inner 600x600 Display Viewport */
.lens-glass-waveguide {
  width: 600px;
  height: 600px;
  background-color: var(--bg-darker);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05); /* Faint centering border for desktop */
}

.lens-glass-waveguide::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  display: none;
  background: #000000;
  pointer-events: none;
}

body.modal-active .lens-glass-waveguide::before {
  display: block;
}

#gameCanvas {
  display: block;
  position: relative;
  z-index: 1;
  width: 600px;
  height: 600px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.focusable:focus-visible {
  outline: 2px solid var(--cyan-glow);
  outline-offset: -6px;
}

/* Waveguide HUD overlays */
.lens-hud-scenery {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: none;
  justify-content: space-between;
  pointer-events: none;
  transition: opacity 0.16s ease;
  z-index: 2;
}

body.modal-active .lens-hud-scenery {
  opacity: 0;
}

.scenery-pill {
  border: 1px solid hsla(180, 100%, 48%, 0.2);
  border-radius: 8px;
  padding: 6px 12px;
  background: rgba(10, 10, 15, 0.88);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--cyan-glow);
  text-shadow: 0 0 6px var(--cyan-glow);
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 1px;
}

.level-pill {
  color: var(--amber-glow);
  text-shadow: 0 0 6px var(--amber-glow);
  border-color: hsla(38, 100%, 50%, 0.2);
}

/* Modal alerts in-lens */
.lens-modal-alert {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 470px;
  max-height: calc(100% - 36px);
  overflow: hidden;
  border: 1px solid var(--brass);
  background: rgba(10, 10, 15, 0.96);
  border-radius: 12px;
  padding: 22px;
  text-align: center;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.9);
  z-index: 4;
}

.lens-modal-alert h2 {
  font-family: var(--font-steampunk);
  font-size: 28px;
  color: var(--brass);
  text-shadow: 0 0 10px hsla(28, 70%, 55%, 0.5);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.lens-modal-alert p {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #ffffff;
  line-height: 1.4;
  letter-spacing: 1px;
}

.modal-replay-intro {
  margin-top: 10px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 242, 254, 0.3);
  border-radius: 6px;
  padding: 0 12px;
  background: rgba(0, 242, 254, 0.06);
  color: var(--cyan-glow);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
}

.modal-replay-intro:hover,
.modal-replay-intro:focus-visible {
  border-color: rgba(0, 242, 254, 0.7);
  outline: none;
}

/* In-Lens Ready Screen Handbook Explanations */
.modal-handbook {
  margin-top: 16px;
  border-top: 1px dashed var(--brass-dark);
  padding-top: 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-handbook-item {
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.5;
  color: #ffffff;
}

.modal-handbook-item strong {
  color: var(--cyan-glow);
  letter-spacing: 1px;
}

.modal-handbook-item span {
  color: var(--text-primary);
}

/* In-Lens Scoreboard & Dynamic Info Specs Card */
.modal-scoreboard {
  margin-top: 14px;
  border-top: 1px dashed var(--brass-dark);
  padding-top: 12px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.modal-specs-details {
  margin-top: 14px;
  border-top: 1px dashed var(--brass-dark);
  padding-top: 12px;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-primary);
}

body.glasses-mode .lens-modal-alert {
  padding: 20px;
}

body.glasses-mode .modal-handbook,
body.glasses-mode .modal-specs-details {
  margin-top: 12px;
  padding-top: 10px;
}

body.glasses-mode .modal-handbook {
  gap: 6px;
}

body.glasses-mode .modal-handbook-item,
body.glasses-mode .modal-specs-details {
  font-size: 12.5px;
  line-height: 1.42;
}

.opening-prologue {
  --prologue-loop: 24s;
  position: absolute;
  inset: 0;
  z-index: 8;
  overflow: hidden;
  background: #000000;
  color: var(--text-primary);
  isolation: isolate;
}

.opening-prologue[hidden] {
  display: none;
}

.opening-prologue * {
  box-sizing: border-box;
}

.prologue-stars {
  position: absolute;
  inset: 0;
  opacity: 0.45;
}

.prologue-sun {
  position: absolute;
  left: -156px;
  top: -156px;
  width: 330px;
  height: 330px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 241, 168, 0.5) 0 9%, rgba(255, 189, 56, 0.16) 34%, rgba(255, 122, 56, 0) 70%);
  opacity: 0.62;
  animation: prologueSunPulse 7s ease-in-out infinite alternate;
}

.prologue-sunbeam {
  position: absolute;
  left: -96px;
  top: 24px;
  width: 780px;
  height: 76px;
  background: linear-gradient(90deg, rgba(255, 241, 168, 0), rgba(255, 241, 168, 0.11), rgba(0, 242, 254, 0.055), rgba(255, 241, 168, 0));
  opacity: 0.42;
  transform: rotate(24deg);
  transform-origin: left center;
  animation: prologueBeamBreathe 9s ease-in-out infinite alternate;
}

.prologue-star {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 999px;
  background: #dff;
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.9);
  animation: prologueTwinkle 4s ease-in-out infinite alternate;
}

.prologue-star:nth-of-type(3) { left: 72px; top: 108px; animation-delay: -0.5s; }
.prologue-star:nth-of-type(4) { left: 118px; top: 420px; width: 2px; height: 2px; animation-delay: -1.6s; }
.prologue-star:nth-of-type(5) { left: 246px; top: 92px; animation-delay: -2.2s; }
.prologue-star:nth-of-type(6) { left: 388px; top: 356px; width: 2px; height: 2px; animation-delay: -3s; }
.prologue-star:nth-of-type(7) { left: 516px; top: 104px; animation-delay: -1s; }
.prologue-star:nth-of-type(8) { left: 552px; top: 474px; width: 2px; height: 2px; animation-delay: -2.8s; }

.prologue-planet-marker {
  position: absolute;
  right: 78px;
  top: 154px;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: #b86843;
  box-shadow: 0 0 10px rgba(255, 122, 56, 0.5);
  opacity: 0.42;
  animation: prologueTwinkle 5s ease-in-out infinite alternate;
}

.prologue-horizon {
  position: absolute;
  left: -80px;
  right: -80px;
  bottom: 68px;
  height: 72px;
  opacity: 0.42;
  animation: prologueHorizonDrift var(--prologue-loop) linear infinite;
}

.prologue-horizon::before,
.prologue-horizon::after {
  content: "";
  position: absolute;
  inset: 0;
  border-top: 1px solid rgba(0, 242, 254, 0.44);
  border-radius: 50%;
  transform: rotate(-2deg);
}

.prologue-horizon::after {
  top: 30px;
  border-top-color: rgba(255, 189, 56, 0.32);
  transform: rotate(-1deg);
}

.prologue-caption {
  position: absolute;
  left: 42px;
  right: 42px;
  top: 46px;
  min-height: 184px;
  font-family: var(--font-mono);
  pointer-events: none;
}

.prologue-eyebrow {
  color: var(--cyan-glow);
  font-size: 13px;
  letter-spacing: 1.8px;
  margin-bottom: 18px;
  animation: prologueEyebrowPulse var(--prologue-loop) ease-in-out infinite;
}

.prologue-line {
  position: absolute;
  left: 0;
  top: 62px;
  max-width: 500px;
  font-size: 20px;
  line-height: 1.35;
  color: #f4f8fb;
  font-style: italic;
  opacity: 0;
  text-shadow: 0 0 16px rgba(255, 255, 255, 0.16);
  animation: prologueLineRead var(--prologue-loop) ease-in-out infinite;
}

.prologue-quote-mark {
  color: var(--amber-glow);
  font-style: normal;
}

.prologue-line:nth-child(2) { animation-delay: 0s; }
.prologue-line:nth-child(3) { animation-delay: 3s; }
.prologue-line:nth-child(4) { animation-delay: 6s; }
.prologue-line:nth-child(5) { animation-delay: 9s; }
.prologue-line:nth-child(6) {
  max-width: 540px;
  font-size: 18px;
  animation-delay: 12s;
}

.prologue-attribution {
  position: absolute;
  left: 0;
  top: 142px;
  max-width: 360px;
  color: rgba(255, 189, 56, 0.86);
  font-size: 10px;
  line-height: 1.35;
  letter-spacing: 1px;
  opacity: 0;
  animation: prologueAttributionRead var(--prologue-loop) ease-in-out infinite;
}

.prologue-attribution span {
  display: block;
}

.prologue-earth {
  position: absolute;
  left: 462px;
  top: 236px;
  width: 84px;
  height: 84px;
  margin: -42px 0 0 -42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 34% 26%, #f2ffff 0 6%, transparent 7%),
    radial-gradient(circle at 44% 40%, #aaf7ff 0 18%, #2479ba 48%, #081d38 100%);
  box-shadow: 0 0 22px rgba(0, 242, 254, 0.72);
  transform-origin: center;
  animation: prologueEarthReveal var(--prologue-loop) ease-in-out infinite;
}

.prologue-earth::before,
.prologue-earth::after {
  content: "";
  position: absolute;
  inset: 12px 8px;
  border: 2px solid rgba(180, 255, 255, 0.72);
  border-left-color: transparent;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: 0;
  transform: rotate(-14deg);
  animation: prologueEarthLines var(--prologue-loop) ease-in-out infinite;
}

.prologue-earth::after {
  inset: 7px 22px;
  transform: rotate(10deg);
}

.prologue-moon {
  position: absolute;
  left: 482px;
  top: 198px;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fff8dc 0 10%, #d8d4c8 58%, #746f68 100%);
  box-shadow: 0 0 8px rgba(255, 248, 220, 0.52);
  opacity: 0;
  transform-origin: -34px 34px;
  animation: prologueMoonReveal var(--prologue-loop) ease-in-out infinite;
}

.prologue-ship {
  position: absolute;
  left: 0;
  top: 0;
  width: 84px;
  height: 44px;
  filter: drop-shadow(0 0 8px rgba(0, 242, 254, 0.9));
  animation: prologueShipFly var(--prologue-loop) cubic-bezier(0.2, 0.65, 0.18, 1) infinite;
  transform-origin: center;
}

.prologue-ship svg {
  width: 84px;
  height: 44px;
  animation: prologueShipBob 1.2s ease-in-out infinite alternate;
}

.prologue-ray {
  position: absolute;
  left: 381px;
  top: 208px;
  width: 82px;
  height: 56px;
  opacity: 0;
  animation: prologueRayFire var(--prologue-loop) ease-in-out infinite;
}

.prologue-ray::before,
.prologue-ray::after {
  content: "";
  position: absolute;
  left: 0;
  top: 27px;
  width: 74px;
  height: 5px;
  border-radius: 999px;
  background: var(--amber-glow);
  box-shadow: 0 0 18px var(--amber-glow);
  transform: rotate(-38deg);
}

.prologue-ray::after {
  height: 2px;
  background: var(--cyan-glow);
  box-shadow: 0 0 10px var(--cyan-glow);
}

.prologue-blast {
  position: absolute;
  left: 438px;
  top: 210px;
  width: 110px;
  height: 110px;
  margin: -55px 0 0 -55px;
  border-radius: 50%;
  opacity: 0;
  background: radial-gradient(circle, #fff7c9 0 12%, #ff7a38 36%, rgba(255, 61, 90, 0) 72%);
  filter: drop-shadow(0 0 24px rgba(255, 122, 56, 0.82));
  animation: prologueBlastBloom var(--prologue-loop) ease-out infinite;
}

.prologue-shard {
  position: absolute;
  left: 438px;
  top: 210px;
  width: 26px;
  height: 18px;
  clip-path: polygon(0 0, 100% 50%, 12% 100%);
  opacity: 0;
  background: var(--amber-glow);
  animation: prologueShardFly var(--prologue-loop) ease-out infinite;
}

.prologue-shard:nth-of-type(1) { --prologue-dx: -72px; --prologue-dy: -48px; --prologue-rot: -34deg; }
.prologue-shard:nth-of-type(2) { --prologue-dx: 76px; --prologue-dy: -30px; --prologue-rot: 42deg; background: var(--cyan-glow); }
.prologue-shard:nth-of-type(3) { --prologue-dx: 32px; --prologue-dy: 70px; --prologue-rot: 88deg; background: var(--red-glow); }
.prologue-shard:nth-of-type(4) { --prologue-dx: -78px; --prologue-dy: 44px; --prologue-rot: -96deg; background: #e8ffff; }

.prologue-twist {
  position: absolute;
  left: 36px;
  right: 36px;
  top: 386px;
  text-align: center;
  opacity: 0;
  animation: prologueTwistReveal var(--prologue-loop) ease-in-out infinite;
}

.prologue-twist strong {
  display: block;
  color: var(--brass);
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1.08;
  font-weight: 900;
  text-shadow: 0 0 18px rgba(255, 122, 56, 0.32);
}

.prologue-twist span {
  display: block;
  margin-top: 12px;
  color: #f4f0e9;
  font-family: var(--font-display);
  font-size: 23px;
  line-height: 1.18;
  font-weight: 800;
}

.prologue-skip {
  position: absolute;
  left: 26px;
  bottom: 26px;
  color: var(--amber-glow);
  opacity: 0.72;
  font: 11px var(--font-mono);
  letter-spacing: 0.3px;
}

@keyframes prologueTwinkle {
  from { opacity: 0.28; transform: scale(0.8); }
  to { opacity: 0.86; transform: scale(1.14); }
}

@keyframes prologueSunPulse {
  from { opacity: 0.48; transform: scale(0.96); }
  to { opacity: 0.68; transform: scale(1.04); }
}

@keyframes prologueBeamBreathe {
  from { opacity: 0.24; }
  to { opacity: 0.48; }
}

@keyframes prologueHorizonDrift {
  from { transform: translateX(-40px); }
  to { transform: translateX(40px); }
}

@keyframes prologueEyebrowPulse {
  0%, 62% { opacity: 0.95; }
  68%, 100% { opacity: 0; }
}

@keyframes prologueLineRead {
  0%, 3% { opacity: 0; transform: translateY(10px); }
  7%, 13% { opacity: 1; transform: translateY(0); }
  18%, 100% { opacity: 0; transform: translateY(-8px); }
}

@keyframes prologueAttributionRead {
  0%, 52% { opacity: 0; transform: translateY(6px); }
  58%, 66% { opacity: 0.95; transform: translateY(0); }
  73%, 100% { opacity: 0; transform: translateY(-6px); }
}

@keyframes prologueShipFly {
  0% { transform: translate(64px, 320px) scale(0.56) rotate(-4deg); }
  47% { transform: translate(252px, 264px) scale(0.76) rotate(-2deg); }
  63% { transform: translate(330px, 246px) scale(0.9) rotate(0deg); }
  100% { transform: translate(330px, 246px) scale(0.9) rotate(0deg); }
}

@keyframes prologueShipBob {
  from { transform: translateY(-3px); }
  to { transform: translateY(4px); }
}

@keyframes prologueEarthReveal {
  0%, 20% { transform: scale(0.08); opacity: 0.92; }
  55% { transform: translate(-20px, -20px) scale(0.58); opacity: 1; }
  67% { transform: translate(-24px, -24px) scale(0.96); opacity: 1; }
  73% { transform: translate(-24px, -24px) scale(1.05); opacity: 1; }
  78%, 100% { transform: translate(-24px, -24px) scale(1.18); opacity: 0; }
}

@keyframes prologueEarthLines {
  0%, 46% { opacity: 0; }
  58%, 73% { opacity: 0.75; }
  78%, 100% { opacity: 0; }
}

@keyframes prologueMoonReveal {
  0%, 50% { opacity: 0; transform: rotate(-24deg) scale(0.35); }
  60%, 73% { opacity: 0.86; transform: rotate(22deg) scale(1); }
  78%, 100% { opacity: 0; transform: rotate(42deg) scale(1.12); }
}

@keyframes prologueRayFire {
  0%, 69% { opacity: 0; transform: scaleX(0.1); transform-origin: left center; }
  71%, 76% { opacity: 1; transform: scaleX(1); transform-origin: left center; }
  80%, 100% { opacity: 0; transform: scaleX(1); }
}

@keyframes prologueBlastBloom {
  0%, 72% { opacity: 0; transform: scale(0.1); }
  77% { opacity: 0.95; transform: scale(1.02); }
  90%, 100% { opacity: 0; transform: scale(1.75); }
}

@keyframes prologueShardFly {
  0%, 73% { opacity: 0; transform: translate(0, 0) rotate(0deg); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--prologue-dx), var(--prologue-dy)) rotate(var(--prologue-rot)); }
}

@keyframes prologueTwistReveal {
  0%, 76% { opacity: 0; transform: translateY(12px); }
  82%, 94% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-4px); }
}
