:root {
  color-scheme: dark;
  --bg: #03111f;
  --bg-deep: #010812;
  --text: #eef7ff;
  --muted: rgba(214, 231, 255, 0.76);
  --line: rgba(138, 197, 255, 0.18);
  --panel: rgba(3, 13, 28, 0.56);
  --panel-strong: rgba(4, 16, 34, 0.82);
  --accent: #7ad1ff;
  --accent-strong: #a8f0ff;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --drift-x: 0px;
  --drift-y: 0px;
  --scene-scale: 1.02;
  --scene-rotate: 0deg;
  --scene-brightness: 1;
  --phase-opacity: 0.62;
  --halo-strength: 1;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top, rgba(104, 184, 255, 0.12), transparent 26%),
    linear-gradient(180deg, #08192e, var(--bg-deep));
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  overflow-x: hidden;
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 18%, rgba(140, 205, 255, 0.08), transparent 18%),
    radial-gradient(circle at 85% 18%, rgba(123, 255, 249, 0.08), transparent 22%),
    linear-gradient(180deg, rgba(1, 10, 20, 0.76), rgba(1, 8, 18, 0.96));
}

.scene-band {
  position: relative;
  min-height: 100svh;
  padding: calc(14px + var(--safe-top)) 14px calc(14px + var(--safe-bottom));
  overflow: clip;
}

.scene-band::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 42%, rgba(168, 240, 255, 0.3), transparent 34%),
    linear-gradient(180deg, transparent, rgba(122, 209, 255, 0.12), transparent);
  opacity: 0;
  transform: scale(1.08);
}

.app-shell.is-switching .scene-band::after {
  animation: stageSwitch 720ms ease-out;
}

.scene-backdrop,
.scene-stage {
  position: absolute;
  inset: 0;
}

.scene-backdrop {
  overflow: hidden;
}

.scene-glow {
  position: absolute;
  border-radius: 999px;
  filter: blur(70px);
  opacity: 0.65;
}

.scene-glow-a {
  top: 7%;
  left: -8%;
  width: 46vw;
  height: 24vh;
  background: rgba(87, 169, 255, 0.22);
}

.scene-glow-b {
  right: -12%;
  bottom: 14%;
  width: 52vw;
  height: 26vh;
  background: rgba(103, 238, 255, 0.16);
}

.scene-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(163, 209, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(163, 209, 255, 0.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent 80%);
}

.scene-stage {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transform: translate3d(var(--drift-x), var(--drift-y), 0);
  will-change: transform;
}

.video-stack {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.walter-video {
  position: absolute;
  bottom: -4svh;
  width: auto;
  height: 106svh;
  max-width: none;
  object-fit: contain;
  transform:
    translate3d(calc(var(--drift-x) * 0.38), calc(var(--drift-y) * 0.24), 0)
    scale(var(--scene-scale))
    rotate(var(--scene-rotate));
  transform-origin: center 78%;
  transition:
    transform 900ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 700ms ease,
    opacity 700ms ease,
    filter 700ms ease;
  user-select: none;
  pointer-events: none;
  opacity: 0;
}

.walter-video.is-active {
  opacity: 1;
  z-index: 2;
  filter: brightness(var(--scene-brightness)) saturate(1.08);
}

.pulse-ring,
.scanline,
.cursor-orb {
  position: absolute;
  pointer-events: none;
}

.pulse-ring {
  left: 50%;
  top: 42%;
  width: min(70vw, 500px);
  aspect-ratio: 1;
  border: 1px solid rgba(181, 228, 255, 0.22);
  border-radius: 999px;
  transform: translate(-50%, -50%) scale(calc(0.82 + var(--halo-strength) * 0.06));
  opacity: calc(0.22 * var(--halo-strength));
  filter: blur(0.2px);
  animation: ringPulse 6.2s ease-in-out infinite;
}

.pulse-ring-b {
  animation-delay: -3.1s;
}

.scanline {
  inset: 0;
  background:
    linear-gradient(180deg, transparent 0%, rgba(141, 223, 255, 0.05) 45%, transparent 100%);
  mix-blend-mode: screen;
  animation: scanDrift 9s linear infinite;
  opacity: 0.75;
}

.cursor-orb {
  width: 160px;
  height: 160px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(160, 228, 255, 0.26), transparent 68%);
  filter: blur(10px);
  opacity: 0.34;
  transform: translate(-50%, -50%);
  left: 50%;
  top: 50%;
}

.top-hud {
  position: absolute;
  z-index: 14;
  top: calc(12px + var(--safe-top));
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.brand-chip,
.talk-button {
  min-height: 42px;
  border: 1px solid rgba(168, 240, 255, 0.24);
  border-radius: 999px;
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}

.brand-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 96px);
  padding: 5px 6px 5px 14px;
  background: rgba(3, 13, 28, 0.44);
  pointer-events: auto;
}

.brand-title {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 900;
  white-space: nowrap;
}

.talk-button {
  min-width: 76px;
  padding: 0 16px;
  background:
    radial-gradient(circle at 20% 10%, rgba(168, 240, 255, 0.32), transparent 40%),
    rgba(5, 18, 38, 0.66);
  color: var(--text);
  cursor: pointer;
  font-weight: 900;
  pointer-events: auto;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.talk-button:hover,
.talk-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(168, 240, 255, 0.68);
  outline: none;
}

.talk-button:disabled {
  cursor: wait;
  opacity: 0.78;
}

.hotspot-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  opacity: 1;
  pointer-events: none;
  transition: opacity 320ms ease, filter 320ms ease;
}

.action-hotspot {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid rgba(168, 240, 255, 0.34);
  border-radius: 999px;
  background: rgba(3, 13, 28, 0.5);
  color: var(--text);
  padding: 0 12px 0 8px;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
  pointer-events: auto;
  backdrop-filter: blur(14px);
  box-shadow:
    0 14px 42px rgba(0, 0, 0, 0.24),
    0 0 38px rgba(122, 209, 255, 0.12);
  transform: translate(-50%, -50%);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, opacity 220ms ease;
}

.action-hotspot:hover,
.action-hotspot:focus-visible {
  transform: translate(-50%, -50%) scale(1.04);
  border-color: rgba(168, 240, 255, 0.84);
  outline: none;
}

.action-hotspot:disabled {
  cursor: wait;
  opacity: 0.54;
}

.hotspot-dot {
  width: 18px;
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(circle, #f5feff 0 24%, #9ceaff 28% 58%, rgba(122, 209, 255, 0.14) 62%);
  box-shadow: 0 0 22px rgba(122, 209, 255, 0.84);
  animation: hotspotPulse 2.3s ease-in-out infinite;
}

.hotspot-label {
  white-space: nowrap;
}

.hotspot-systems {
  left: 21%;
  top: 55%;
}

.hotspot-projects {
  left: 73%;
  top: 43%;
}

.hotspot-contact {
  left: 66%;
  top: 72%;
}

.app-shell:not([data-phase="idle"]) .hotspot-layer {
  opacity: 0;
  pointer-events: none;
  filter: blur(5px);
}

.hud {
  position: absolute;
  z-index: 5;
  left: 12px;
  right: 12px;
  bottom: calc(16px + var(--safe-bottom));
  display: flex;
  justify-content: flex-end;
  pointer-events: none;
}

.dialogue-block,
.world-panel {
  backdrop-filter: blur(18px);
}

.eyebrow,
.detail-kicker,
.dialogue-label {
  margin: 0 0 8px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--accent-strong);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.4rem, 14vw, 4.4rem);
  line-height: 0.94;
}

#detailBody,
.dialogue-line {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.status-row {
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-pill,
.detail-item,
.world-action {
  min-height: 42px;
  border-radius: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid rgba(133, 204, 255, 0.24);
  background: rgba(9, 25, 49, 0.58);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
}

.dialogue-block {
  width: min(100%, 340px);
  padding: 12px 14px 14px;
  border: 1px solid rgba(139, 197, 255, 0.16);
  border-radius: 999px 999px 8px 999px;
  background: rgba(3, 13, 28, 0.42);
  transition: opacity 260ms ease, transform 360ms ease;
  pointer-events: auto;
}

.dialogue-line {
  color: var(--text);
  min-height: 3.2em;
  font-size: 1rem;
}

.back-button {
  position: absolute;
  z-index: 12;
  top: calc(64px + var(--safe-top));
  right: 12px;
  min-height: 42px;
  border: 1px solid rgba(168, 240, 255, 0.36);
  border-radius: 999px;
  background: rgba(2, 10, 22, 0.6);
  color: var(--text);
  padding: 0 16px;
  font-weight: 900;
  cursor: pointer;
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 240ms ease, transform 240ms ease, border-color 240ms ease;
}

.back-button:hover,
.back-button:focus-visible {
  border-color: rgba(168, 240, 255, 0.8);
  outline: none;
}

.app-shell[data-phase="playing"] .back-button,
.app-shell[data-phase="settled"] .back-button {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.world-panel {
  position: absolute;
  z-index: 8;
  left: 14px;
  right: 14px;
  bottom: calc(18px + var(--safe-bottom));
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(168, 240, 255, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(6, 22, 48, 0.74), rgba(3, 13, 28, 0.44)),
    radial-gradient(circle at 18% 12%, rgba(122, 209, 255, 0.16), transparent 42%);
  box-shadow:
    0 20px 70px rgba(0, 0, 0, 0.34),
    inset 0 0 34px rgba(122, 209, 255, 0.08);
  opacity: 0;
  transform: translateY(22px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 460ms ease,
    transform 620ms cubic-bezier(0.22, 1, 0.36, 1);
}

.world-panel::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(168, 240, 255, 0.12);
  border-radius: 7px;
  pointer-events: none;
}

.app-shell[data-phase="settled"] .world-panel,
.app-shell[data-phase="playing"] .world-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.app-shell[data-phase="playing"] .world-panel {
  opacity: 0.62;
  transform: translateY(12px) scale(0.985);
}

.app-shell[data-phase="returning"] .world-panel,
.app-shell[data-mode="intro"] .world-panel {
  opacity: 0;
  transform: translateY(22px) scale(0.98);
  pointer-events: none;
}

.world-panel-copy {
  display: grid;
  gap: 8px;
}

.world-panel h2 {
  font-size: clamp(1.35rem, 6vw, 2rem);
  line-height: 1;
}

.world-panel #detailBody {
  font-size: 0.94rem;
}

.app-shell:not([data-mode="intro"]) .dialogue-block {
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
}

.app-shell[data-mode="systems"] .dialogue-block,
.app-shell[data-mode="projects"] .dialogue-block,
.app-shell[data-mode="contact"] .dialogue-block {
  display: none;
}

h2 {
  font-size: clamp(1.45rem, 6vw, 2.4rem);
  line-height: 0.96;
}

.detail-list {
  display: grid;
  gap: 8px;
}

.detail-item {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid rgba(141, 209, 255, 0.16);
  border-radius: 999px;
  background: rgba(9, 22, 44, 0.5);
  color: var(--text);
  font-weight: 700;
}

.world-action {
  position: relative;
  z-index: 2;
  justify-self: start;
  border: 1px solid rgba(168, 240, 255, 0.46);
  background:
    radial-gradient(circle at 20% 15%, rgba(245, 254, 255, 0.26), transparent 34%),
    linear-gradient(180deg, rgba(111, 208, 255, 0.22), rgba(25, 78, 130, 0.26));
  color: var(--text);
  padding: 0 16px;
  cursor: pointer;
  font-weight: 950;
  text-transform: uppercase;
  box-shadow: 0 0 28px rgba(122, 209, 255, 0.16);
  transition: transform 180ms ease, border-color 180ms ease, filter 180ms ease;
}

.world-action:hover,
.world-action:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(168, 240, 255, 0.9);
  outline: none;
}

.world-action:disabled {
  cursor: wait;
  filter: grayscale(0.25);
  opacity: 0.68;
}

.world-action[hidden] {
  display: none;
}

.app-shell[data-mode="intro"] {
  --scene-scale: 1.02;
  --scene-rotate: 0deg;
  --scene-brightness: 1;
  --phase-opacity: 0.64;
  --halo-strength: 1;
}

.app-shell[data-mode="systems"] {
  --scene-scale: 1.06;
  --scene-rotate: -0.6deg;
  --scene-brightness: 1.1;
  --phase-opacity: 0.78;
  --halo-strength: 1.12;
}

.app-shell[data-mode="projects"] {
  --scene-scale: 1.09;
  --scene-rotate: 0.5deg;
  --scene-brightness: 1.08;
  --phase-opacity: 0.72;
  --halo-strength: 1.08;
}

.app-shell[data-mode="contact"] {
  --scene-scale: 1.04;
  --scene-rotate: 0deg;
  --scene-brightness: 1.08;
  --phase-opacity: 0.84;
  --halo-strength: 1.18;
}

@keyframes ringPulse {
  0%,
  100% {
    opacity: calc(0.18 * var(--halo-strength));
    transform: translate(-50%, -50%) scale(0.82);
  }
  50% {
    opacity: calc(0.36 * var(--halo-strength));
    transform: translate(-50%, -50%) scale(1.02);
  }
}

@keyframes scanDrift {
  0% {
    transform: translateY(-100%);
  }
  100% {
    transform: translateY(100%);
  }
}

@keyframes stageSwitch {
  0% {
    opacity: 0;
    transform: scale(1.12);
  }
  34% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1);
  }
}

@keyframes hotspotPulse {
  0%,
  100% {
    transform: scale(0.92);
    opacity: 0.78;
  }
  50% {
    transform: scale(1.16);
    opacity: 1;
  }
}

@media (min-width: 900px) {
  .scene-band {
    min-height: 100vh;
    padding-left: 28px;
    padding-right: 28px;
  }

  .hud {
    left: 28px;
    right: 28px;
    bottom: 28px;
  }

  .walter-video {
    height: min(98vh, 980px);
    width: auto;
    bottom: -2vh;
  }

  .world-panel {
    left: auto;
    right: 30px;
    bottom: 32px;
    width: min(380px, 30vw);
  }

  .world-panel h2 {
    font-size: clamp(1.4rem, 2.4vw, 2.1rem);
  }
}

@media (max-width: 899px) {
  .scene-band {
    min-height: 100svh;
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: calc(14px + var(--safe-bottom));
  }

  .dialogue-block {
    width: min(100%, 330px);
    max-width: calc(100vw - 24px);
    font-size: 0.92rem;
  }

  .walter-video {
    inset: 0;
    width: 100%;
    height: 100%;
    bottom: auto;
    object-fit: cover;
    object-position: center center;
  }

  .hotspot-systems {
    left: 28%;
    top: 56%;
  }

  .hotspot-projects {
    left: 68%;
    top: 42%;
  }

  .hotspot-contact {
    left: 67%;
    top: 73%;
  }

  .hud {
    left: 12px;
    right: auto;
    width: calc(100vw - 24px);
    justify-content: flex-start;
  }

  .dialogue-line {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .walter-video,
  .action-hotspot,
  .pulse-ring,
  .scanline,
  .world-panel,
  .back-button {
    animation: none !important;
    transition: none !important;
  }
}
