:root {
  color-scheme: dark;
  --ink: #050505;
  --signal: #20e0c0;
  --rust: #6e44ff;
  --harbour: #b8a7ff;
  --paper: #f5f5f2;
  --safe-top: max(20px, env(safe-area-inset-top));
  --safe-right: max(22px, env(safe-area-inset-right));
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
  --safe-left: max(22px, env(safe-area-inset-left));
  font-family: "Courier New", "Noto Sans Mono", ui-monospace, monospace;
  background: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
}

button {
  font: inherit;
}

.game,
.stage {
  width: 100%;
  height: 100svh;
  min-height: 520px;
}

.stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background: var(--ink);
}

.stage::before {
  content: "";
  position: absolute;
  inset: 10px;
  z-index: 19;
  border: 3px solid var(--rust);
  box-shadow: inset 0 0 0 3px var(--ink), inset 0 0 0 5px rgba(184, 167, 255, 0.62);
  pointer-events: none;
}

.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(5, 5, 5, 0.72) 0%, transparent 27%, transparent 58%, rgba(5, 5, 5, 0.88) 100%),
    linear-gradient(90deg, rgba(5, 5, 5, 0.5), transparent 48%);
}

.media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scene-video {
  z-index: 1;
  opacity: 0;
  object-fit: contain;
  background: var(--ink);
  filter: saturate(0.8) contrast(1.1) brightness(0.76);
  transition: opacity 360ms steps(3, end);
}

.scene-video.is-ready {
  opacity: 1;
}

.event-video {
  z-index: 30;
  display: none;
  object-fit: cover;
  background: var(--ink);
  filter: saturate(0.9) contrast(1.05) brightness(0.92);
}

.event-video.is-playing {
  display: block;
}

.scene-fallback {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: grid;
  place-content: center;
  padding: 8vw;
  color: var(--harbour);
  text-align: center;
  background:
    repeating-linear-gradient(0deg, transparent 0 8px, rgba(184, 167, 255, 0.08) 8px 10px),
    var(--ink);
}

.scene-fallback h2 {
  max-width: 900px;
  margin: 18px 0;
  color: var(--rust);
  font-size: clamp(3rem, 8vw, 8rem);
  line-height: 0.9;
  letter-spacing: -0.08em;
}

.fallback-kicker,
.fallback-time {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.24em;
}

.pixel-dither {
  position: absolute;
  inset: 0;
  z-index: 18;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    radial-gradient(circle, var(--harbour) 0 1px, transparent 1px),
    linear-gradient(rgba(5, 5, 5, 0.1) 50%, transparent 50%);
  background-size: 6px 6px, 100% 4px;
  mix-blend-mode: screen;
}

.topbar,
.progress,
.scene-caption,
.control-hint,
.skip-button {
  position: absolute;
  z-index: 20;
}

.topbar {
  top: calc(var(--safe-top) + 10px);
  left: calc(var(--safe-left) + 8px);
  right: calc(var(--safe-right) + 8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark,
.text-button,
.progress-text,
.eyebrow,
.control-hint,
.skip-button,
.hotspot-label,
.instructions {
  font-size: 0.8rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.12em;
}

.wordmark {
  margin: 0;
  padding: 7px 9px 6px;
  color: var(--ink);
  background: var(--signal);
  box-shadow: 4px 4px 0 var(--ink), 6px 6px 0 var(--harbour);
}

.wordmark span {
  white-space: nowrap;
}

.text-button,
.skip-button {
  padding: 7px 9px 6px;
  border: 2px solid var(--harbour);
  border-radius: 0;
  color: var(--harbour);
  background: rgba(5, 5, 5, 0.86);
  cursor: pointer;
}

.text-button:hover,
.text-button:focus-visible,
.skip-button:hover,
.skip-button:focus-visible {
  border-color: var(--signal);
  color: var(--ink);
  background: var(--signal);
  outline: none;
  box-shadow: 4px 4px 0 var(--harbour);
}

.progress {
  top: calc(var(--safe-top) + 68px);
  left: calc(var(--safe-left) + 8px);
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-line {
  position: relative;
  display: block;
  width: min(210px, 34vw);
  height: 10px;
  overflow: hidden;
  border: 2px solid var(--harbour);
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(33.333% - 3px), var(--ink) calc(33.333% - 3px) 33.333%),
    var(--ink);
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 33.333%;
  background: var(--signal);
  transition: width 320ms steps(3, end);
}

.progress-text {
  color: var(--harbour);
  text-shadow: 2px 2px var(--ink);
}

.scene-caption {
  left: calc(var(--safe-left) + 8px);
  bottom: calc(var(--safe-bottom) + 48px);
  max-width: min(680px, 70vw);
  padding: 16px 18px 15px;
  border-left: 5px solid var(--signal);
  border-bottom: 3px solid var(--rust);
  background: rgba(5, 5, 5, 0.84);
  box-shadow: 7px 7px 0 rgba(184, 167, 255, 0.72);
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--rust);
}

.scene-caption h1 {
  margin: 0;
  max-width: 680px;
  color: var(--signal);
  font-size: clamp(2.1rem, 5vw, 5.2rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 rgba(5, 5, 5, 0.9);
}

.scene-local-title {
  margin: 8px 0 0;
  color: var(--paper);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: clamp(1rem, 1.6vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.2em;
}

.scene-caption > p:last-child {
  max-width: 430px;
  margin: 11px 0 0;
  color: var(--harbour);
  font-size: 1rem;
  line-height: 1.45;
}

.hotspot {
  --x: 72%;
  --y: 44%;
  position: absolute;
  z-index: 24;
  top: var(--y);
  left: var(--x);
  width: 50px;
  height: 50px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  transform: translate(-50%, -50%);
}

.hotspot-ring,
.hotspot-ring::before,
.hotspot-ring::after {
  position: absolute;
  inset: 0;
  border-radius: 0;
}

.hotspot-ring {
  border: 4px solid var(--signal);
  background:
    linear-gradient(90deg, transparent 44%, var(--signal) 44% 56%, transparent 56%),
    linear-gradient(0deg, transparent 44%, var(--signal) 44% 56%, transparent 56%),
    rgba(5, 5, 5, 0.64);
  box-shadow: 5px 5px 0 var(--harbour);
}

.hotspot-ring::before,
.hotspot-ring::after {
  content: "";
  border: 2px solid var(--signal);
  animation: pixel-pulse 1.4s steps(4, end) infinite;
}

.hotspot-ring::after {
  animation-delay: 0.7s;
}

.hotspot-label {
  position: absolute;
  top: 50%;
  left: calc(100% + 18px);
  width: max-content;
  max-width: 210px;
  padding: 7px 9px;
  border: 2px solid var(--rust);
  color: var(--paper);
  text-align: left;
  background: rgba(5, 5, 5, 0.9);
  transform: translateY(-50%);
}

.hotspot-label::before {
  content: ">";
  margin-right: 8px;
  color: var(--signal);
}

.hotspot:hover .hotspot-ring,
.hotspot:focus-visible .hotspot-ring {
  background: var(--signal);
  box-shadow: 7px 7px 0 var(--paper);
}

.hotspot:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 7px;
}

.control-hint {
  right: calc(var(--safe-right) + 8px);
  bottom: calc(var(--safe-bottom) + 8px);
  margin: 0;
  color: var(--harbour);
  text-shadow: 2px 2px var(--ink);
}

.control-hint::before {
  content: "■ ";
  color: var(--signal);
  animation: pixel-blink 1s steps(1, end) infinite;
}

.control-hint span {
  color: var(--rust);
}

.skip-button {
  right: calc(var(--safe-right) + 8px);
  bottom: calc(var(--safe-bottom) + 8px);
  z-index: 44;
  color: var(--signal);
}

.screen {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: end;
  padding: clamp(38px, 6vw, 88px);
  background:
    repeating-linear-gradient(0deg, transparent 0 10px, rgba(184, 167, 255, 0.12) 10px 12px),
    repeating-linear-gradient(90deg, transparent 0 10px, rgba(110, 68, 255, 0.08) 10px 12px),
    var(--ink);
}

.screen::before {
  content: "HK 852 // ARCHIVE MODE";
  position: absolute;
  top: calc(var(--safe-top) + 20px);
  right: calc(var(--safe-right) + 20px);
  padding: 7px 9px;
  border: 2px solid var(--harbour);
  color: var(--harbour);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.screen::after {
  content: "";
  position: absolute;
  top: 11%;
  right: 10%;
  width: min(26vw, 300px);
  aspect-ratio: 1;
  border: 10px solid var(--rust);
  box-shadow: -18px 18px 0 var(--signal), -36px 36px 0 var(--harbour);
  opacity: 0.32;
  transform: rotate(45deg);
}

.screen[hidden] {
  display: none;
}

.screen-copy {
  position: relative;
  z-index: 1;
  width: min(900px, 100%);
  padding-left: 18px;
  border-left: 6px solid var(--signal);
}

.screen h1 {
  margin: 0;
  color: var(--signal);
  font-size: clamp(4.8rem, 14vw, 12rem);
  line-height: 0.73;
  letter-spacing: -0.1em;
  text-shadow: 7px 7px 0 var(--ink), 11px 11px 0 var(--harbour);
}

.end-screen h1 {
  max-width: 1000px;
  font-size: clamp(3.2rem, 8.5vw, 7.5rem);
  line-height: 0.84;
}

.local-intro {
  margin: 24px 0 0;
  color: var(--paper);
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.16em;
}

.intro {
  max-width: 580px;
  margin: 12px 0 0;
  color: var(--harbour);
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  line-height: 1.5;
}

.primary-button {
  margin-top: 28px;
  padding: 13px 16px 11px;
  border: 3px solid var(--signal);
  border-radius: 0;
  color: var(--signal);
  background: var(--ink);
  box-shadow: 6px 6px 0 var(--harbour);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  cursor: pointer;
}

.primary-button:hover,
.primary-button:focus-visible {
  color: var(--ink);
  background: var(--signal);
  box-shadow: 8px 8px 0 var(--paper);
  outline: none;
}

.primary-button:focus-visible {
  outline: 3px solid var(--paper);
  outline-offset: 6px;
}

.instructions {
  margin: 20px 0 0;
  color: var(--rust);
}

.fade {
  position: absolute;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  opacity: 0;
  background: var(--ink);
  transition: opacity 280ms steps(3, end);
}

.fade.is-active {
  opacity: 1;
}

.game.is-event-playing .topbar,
.game.is-event-playing .progress,
.game.is-event-playing .scene-caption,
.game.is-event-playing .hotspot,
.game.is-event-playing .control-hint {
  opacity: 0;
  pointer-events: none;
}

@keyframes pixel-pulse {
  from { opacity: 0.9; transform: scale(0.75); }
  to { opacity: 0; transform: scale(1.65); }
}

@keyframes pixel-blink {
  50% { opacity: 0; }
}

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

@media (max-width: 720px) {
  .game,
  .stage { min-height: 480px; }

  .stage::before { inset: 6px; border-width: 2px; }

  .topbar {
    top: calc(var(--safe-top) + 4px);
    left: calc(var(--safe-left) + 2px);
    right: calc(var(--safe-right) + 2px);
  }

  .wordmark,
  .text-button,
  .progress-text,
  .eyebrow,
  .control-hint,
  .skip-button,
  .hotspot-label,
  .instructions { font-size: 0.75rem; }

  .wordmark span { display: none; }

  .progress {
    top: calc(var(--safe-top) + 60px);
    left: calc(var(--safe-left) + 2px);
  }

  .progress-line { width: 34vw; }

  .screen {
    padding: var(--safe-top) var(--safe-right) calc(var(--safe-bottom) + 28px) var(--safe-left);
  }

  .screen::before {
    top: calc(var(--safe-top) + 16px);
    right: calc(var(--safe-right) + 4px);
    max-width: 44vw;
    text-align: right;
  }

  .screen::after {
    top: 22%;
    right: 5%;
    width: 32vw;
    border-width: 7px;
  }

  .screen h1 { font-size: clamp(4.3rem, 25vw, 8rem); }
  .end-screen h1 { font-size: clamp(2.9rem, 14vw, 4.8rem); }

  .scene-caption {
    left: calc(var(--safe-left) + 2px);
    right: calc(var(--safe-right) + 2px);
    bottom: calc(var(--safe-bottom) + 60px);
    max-width: none;
    padding: 13px 14px 12px;
    box-shadow: 5px 5px 0 rgba(184, 167, 255, 0.72);
  }

  .scene-caption h1 { font-size: clamp(2.3rem, 11vw, 4rem); }

  .scene-caption > p:last-child {
    max-width: 280px;
    font-size: 0.92rem;
  }

  .hotspot {
    --x: 68%;
    width: 50px;
    height: 50px;
  }

  .event-video { object-fit: contain; }

  .hotspot-label {
    top: calc(100% + 14px);
    left: 50%;
    max-width: 160px;
    text-align: center;
    transform: translateX(-50%);
  }

  .control-hint {
    left: calc(var(--safe-left) + 2px);
    right: auto;
  }

  .control-hint span { display: none; }
  .scene-fallback h2 { font-size: 17vw; }
}

@media (orientation: landscape) and (max-height: 560px) {
  .progress { display: none; }

  .scene-caption {
    bottom: calc(var(--safe-bottom) + 12px);
    max-width: 58vw;
    padding: 10px 12px;
  }

  .scene-caption h1 { font-size: clamp(1.8rem, 6vw, 3.5rem); }

  .scene-caption > p:last-child,
  .control-hint,
  .local-intro { display: none; }

  .screen {
    padding: 30px max(36px, env(safe-area-inset-right)) 24px max(36px, env(safe-area-inset-left));
  }

  .screen h1 { font-size: clamp(3.6rem, 17vh, 6.5rem); }
  .intro { margin-top: 12px; }
  .primary-button { margin-top: 16px; }
}
