/* FLIGHT DELAYED — cheesy spy-airport action chrome */
:root {
  --ink: #0a1628;
  --pink: #ff2d92;
  --hot: #ff4d8d;
  --yellow: #ffe14a;
  --gold: #ffc107;
  --mint: #5ee0b5;
  --cream: #fff6e0;
  --sky: #7ec8ff;
  --neon: #39f7ff;
  --lime: #c8ff3d;
  --orange: #ff8a2a;
  --navy: #12264a;
  --navy-deep: #0a1628;
  --tsa: #4a7cff;
  --panel: rgba(10, 22, 40, 0.92);
}

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

html, body {
  height: 100%;
  height: 100vh;
  height: 100dvh;
  height: var(--app-h, 100vh);
  background: #0a1628;
  color: var(--cream);
  font-family: "Trebuchet MS", "Arial Black", Impact, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  touch-action: manipulation;
  position: fixed;
  inset: 0;
  width: 100%;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 40%, #1a3a5c 0%, #0a1628 70%);
}

#game {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  width: min(100vw, calc(100dvh * 16 / 9));
  height: min(100dvh, calc(100vw * 9 / 16));
  max-width: 100%;
  max-height: 100%;
  image-rendering: auto;
  background: #1a2a40;
  display: block;
  box-shadow: 0 0 0 6px var(--ink), 0 0 0 10px var(--gold), 0 20px 80px rgba(0,0,0,.55);
  cursor: crosshair;
  touch-action: none;
}

.hidden { display: none !important; }

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  width: 100%;
  height: 100%;
  margin: auto;
}

#hud-left {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  left: max(12px, env(safe-area-inset-left, 0px));
  z-index: 2;
}

#status-box {
  background: var(--ink);
  color: var(--neon);
  border: 4px solid var(--cream);
  box-shadow: 6px 6px 0 var(--gold), -3px -3px 0 var(--pink);
  padding: 10px 12px;
  transform: rotate(-2deg);
  width: 148px;
  text-align: center;
}

.status-tag {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--mint);
  font-weight: 900;
  margin-bottom: 4px;
}

#status-value {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--pink);
  line-height: 1.1;
}

#status-value.is-boarding { color: var(--orange); animation: flash 0.4s steps(2) infinite; }
#status-value.is-lastcall { color: var(--pink); animation: flash 0.25s steps(2) infinite; }
#status-value.is-departed { color: #ff4455; }

#timer-value {
  margin-top: 4px;
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  line-height: 1;
}

#leg-label {
  margin-top: 4px;
  font-size: 11px;
  color: var(--cream);
  letter-spacing: 1px;
}

#hud-score {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  min-width: 260px;
}

#score-label {
  font-size: 13px;
  letter-spacing: 3px;
  color: var(--yellow);
  text-shadow: 0 0 12px var(--pink), 2px 2px 0 var(--ink);
  animation: pulse 0.8s ease-in-out infinite;
}

#score-value {
  font-size: 48px;
  font-weight: 900;
  line-height: 0.9;
  color: #fff;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 #1a3a5c, 0 0 24px rgba(255, 193, 7, 0.45);
  transition: transform 0.08s ease-out, color 0.08s ease-out;
}

#score-sub {
  font-size: 12px;
  color: var(--ink);
  background: var(--cream);
  display: inline-block;
  padding: 2px 10px;
  margin-top: 2px;
  transform: rotate(-1deg);
  font-weight: 800;
}

#hud-right {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  text-align: right;
}

#route-wrap {
  background: var(--ink);
  border: 3px solid var(--cream);
  box-shadow: 4px 4px 0 var(--neon);
  padding: 6px 10px;
  transform: rotate(1deg);
  min-width: 140px;
}

#route-label, #docs-label {
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--mint);
  font-weight: 900;
}

#route-from, #route-to {
  font-size: 13px;
  font-weight: 900;
  color: var(--yellow);
  line-height: 1.15;
}

#route-arrow {
  font-size: 14px;
  color: var(--neon);
  line-height: 1;
}

#route-price {
  margin-top: 3px;
  font-size: 11px;
  font-weight: 900;
  color: var(--pink);
  background: var(--cream);
  display: inline-block;
  padding: 1px 6px;
  transform: rotate(-2deg);
}

#docs-wrap {
  margin-top: 8px;
  background: var(--ink);
  border: 3px solid var(--gold);
  box-shadow: 4px 4px 0 var(--pink);
  padding: 6px 10px;
  transform: rotate(-2deg);
}

#docs-value {
  font-size: 14px;
  font-weight: 900;
  color: var(--lime);
  text-shadow: 2px 2px 0 var(--ink);
  line-height: 1.1;
}

#hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--cream);
  opacity: 0.8;
}

#intro-banner {
  position: absolute;
  top: 130px;
  left: 50%;
  transform: translateX(-50%) rotate(-3deg);
  background: var(--orange);
  color: #fff;
  border: 4px solid #fff;
  padding: 8px 18px 12px;
  box-shadow: 8px 8px 0 var(--ink);
  min-width: 280px;
  text-align: center;
  animation: flash 0.35s steps(2) infinite;
  pointer-events: none;
  z-index: 3;
}
.intro-title {
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 2px;
}
.intro-sub {
  font-size: 13px;
  margin-top: 2px;
  font-weight: 700;
}

/* Screens */
#title-screen, #pause-screen, #victory-screen, #clear-screen, #missed-screen {
  position: absolute;
  width: 100%;
  height: 100%;
  margin: auto;
  inset: 0;
  overflow: hidden;
  z-index: 3;
}

#title-screen {
  background:
    repeating-linear-gradient(90deg, #12264a 0 18px, #ffe14a 18px 36px, #1a3a5c 36px 54px, #ff2d92 54px 72px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#title-screen::before {
  content: "";
  position: absolute;
  inset: 16px;
  background:
    radial-gradient(circle at 20% 20%, #39f7ff, transparent 40%),
    radial-gradient(circle at 80% 30%, #ffc107, transparent 40%),
    linear-gradient(#1a3a5c, #0a1628);
  border: 6px solid var(--ink);
  pointer-events: none;
}

.marquee {
  position: absolute;
  top: 28px;
  left: 28px;
  right: 28px;
  overflow: hidden;
  background: var(--ink);
  color: var(--gold);
  font-weight: 900;
  letter-spacing: 2px;
  padding: 6px 0;
  z-index: 2;
  border: 3px solid var(--yellow);
  white-space: nowrap;
}
.marquee span {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 16s linear infinite;
}

.title-hero {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 72px 36px 48px;
  max-width: 980px;
  width: 100%;
}

.title-poster-wrap {
  position: relative;
  flex: 0 0 auto;
  width: min(260px, 30vw);
  transform: rotate(-2.5deg);
  filter: drop-shadow(10px 12px 0 var(--ink));
}

.title-poster {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  object-position: center top;
  border: 5px solid var(--ink);
  background: #0a1216;
}

.title-poster-glow {
  position: absolute;
  inset: -10px;
  border: 3px solid var(--yellow);
  box-shadow: 0 0 28px rgba(255, 193, 7, 0.55), 0 0 0 6px var(--pink);
  pointer-events: none;
}

.title-card {
  position: relative;
  z-index: 2;
  text-align: center;
  background: var(--cream);
  color: var(--ink);
  border: 6px solid var(--ink);
  box-shadow: 12px 12px 0 var(--pink), -8px -8px 0 var(--gold);
  padding: 22px 36px 18px;
  transform: rotate(1deg);
  max-width: 520px;
  flex: 1 1 420px;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 4px;
  color: var(--pink);
  font-weight: 900;
}

.title-card h1 {
  font-size: clamp(40px, 6.5vw, 62px);
  line-height: 0.85;
  letter-spacing: -2px;
  text-shadow: 4px 4px 0 var(--yellow), 8px 8px 0 #1a3a5c;
  margin: 8px 0 10px;
}

.tagline {
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--pink);
  line-height: 1.25;
}

.subtag {
  font-size: 12px;
  margin-top: 6px;
  opacity: 0.8;
  font-weight: 700;
}

@media (max-width: 820px) {
  .title-hero {
    flex-direction: column;
    gap: 14px;
    padding: 64px 20px 40px;
  }
  .title-poster-wrap {
    width: min(170px, 44vw);
  }
  .title-card {
    max-width: 92%;
    padding: 18px 22px 14px;
  }
  .title-card h1 { font-size: 40px; }
  .controls { font-size: 11px; }
}

#btn-start, #btn-resume, #btn-again, #btn-restart-pause, #btn-continue, #btn-retry, #btn-giveup {
  margin-top: 14px;
  font-family: inherit;
  font-size: 20px;
  font-weight: 900;
  padding: 10px 24px;
  border: 4px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 5px 5px 0 var(--ink);
  letter-spacing: 1px;
  -webkit-tap-highlight-color: rgba(255, 225, 74, 0.4);
  touch-action: manipulation;
}
#btn-start:hover, #btn-resume:hover, #btn-again:hover, #btn-restart-pause:hover,
#btn-continue:hover, #btn-retry:hover, #btn-giveup:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 var(--ink);
  background: var(--neon);
}
button.ghost {
  background: var(--cream);
  margin-left: 8px;
}

#btn-continue, #btn-retry {
  background: var(--neon);
  width: 100%;
  font-size: 22px;
  margin-left: 0;
}

#btn-giveup {
  width: 100%;
  margin-left: 0;
  margin-top: 8px;
  background: var(--cream);
}

.controls {
  margin-top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 14px;
  text-align: left;
  font-size: 12px;
}

#pause-screen, #victory-screen, #clear-screen, #missed-screen {
  background: rgba(8, 16, 28, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.panel {
  background: var(--cream);
  color: var(--ink);
  border: 6px solid var(--ink);
  padding: 32px 40px;
  text-align: center;
  box-shadow: 10px 10px 0 var(--neon);
  max-width: 560px;
}
.panel h2 {
  font-size: 40px;
  text-shadow: 3px 3px 0 var(--yellow);
}
.panel.victory {
  box-shadow: 10px 10px 0 var(--pink), -6px -6px 0 var(--gold);
}
.panel.clear {
  box-shadow: 10px 10px 0 var(--yellow), -6px -6px 0 var(--neon);
}
.panel.dead {
  box-shadow: 10px 10px 0 var(--pink), -6px -6px 0 #ff4455;
}
.confetti-label {
  background: var(--pink);
  color: #fff;
  display: inline-block;
  padding: 2px 10px;
  font-weight: 900;
  transform: rotate(-6deg);
}
.clear-stage {
  font-size: 20px;
  font-weight: 900;
  color: #12264a;
  letter-spacing: 1px;
  margin: 4px 0 8px;
}
.clear-next {
  margin: 10px 0;
  padding: 10px;
  background: var(--ink);
  color: var(--yellow);
  border: 3px solid var(--gold);
  font-weight: 900;
  font-size: 14px;
  line-height: 1.4;
  transform: rotate(-1deg);
}
.clear-stats {
  font-size: 14px;
  font-weight: 700;
  margin: 8px 0 4px;
  line-height: 1.5;
}
.clear-hint {
  margin-top: 8px;
  font-size: 11px;
  opacity: 0.65;
  font-weight: 700;
}

#toast {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--yellow);
  border: 3px solid var(--yellow);
  padding: 8px 16px;
  font-weight: 900;
  z-index: 9;
  pointer-events: none;
  text-align: center;
  max-width: 90%;
}

@keyframes pulse {
  50% { transform: scale(1.06); }
}
@keyframes flash {
  50% { filter: brightness(1.35); }
}
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* ---- mobile / touch chrome ---- */
.ctrl-touch, .hint-touch { display: none; }
body.touch-on .ctrl-kb, body.touch-on .hint-kb { display: none; }
body.touch-on .ctrl-touch, body.touch-on .hint-touch { display: block; }
body.touch-on .controls { grid-template-columns: 1fr; }

img {
  -webkit-user-drag: none;
  user-drag: none;
}

#touch-controls {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

body.touch-on[data-state="play"] #touch-controls,
body.touch-on[data-state="intro"] #touch-controls {
  display: block;
}

.touch-stick {
  pointer-events: auto;
  position: absolute;
  left: max(4px, env(safe-area-inset-left, 0px));
  bottom: max(8px, env(safe-area-inset-bottom, 0px));
  width: min(176px, 46vmin);
  height: min(176px, 46vmin);
  touch-action: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
}

.stick-base {
  position: relative;
  width: 78%;
  height: 78%;
  border-radius: 50%;
  border: 5px solid var(--yellow);
  background: rgba(10, 22, 40, 0.45);
  box-shadow: 5px 5px 0 rgba(255, 193, 7, 0.4), inset 0 0 0 3px var(--ink);
}

.stick-cross {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  border: 2px dashed rgba(255, 246, 224, 0.35);
  pointer-events: none;
}
.stick-cross::before,
.stick-cross::after {
  content: "";
  position: absolute;
  background: rgba(255, 225, 74, 0.28);
  pointer-events: none;
}
.stick-cross::before {
  left: 50%;
  top: 8%;
  bottom: 8%;
  width: 3px;
  transform: translateX(-50%);
}
.stick-cross::after {
  top: 50%;
  left: 8%;
  right: 8%;
  height: 3px;
  transform: translateY(-50%);
}

.stick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  height: 46%;
  margin: -23% 0 0 -23%;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #7ec8ff, #4a7cff 62%, #12264a);
  border: 4px solid var(--ink);
  box-shadow: 0 5px 0 var(--yellow), 0 0 12px rgba(57, 247, 255, 0.55);
  pointer-events: none;
}

.stick-label {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 2px;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink);
  pointer-events: none;
}

.touch-stick.is-held .stick-base {
  background: rgba(10, 22, 40, 0.65);
  box-shadow: 5px 5px 0 var(--neon), inset 0 0 0 3px var(--ink);
}

.touch-dash {
  pointer-events: auto;
  position: absolute;
  right: max(10px, env(safe-area-inset-right, 0px));
  bottom: max(28px, env(safe-area-inset-bottom, 0px));
  width: min(118px, 28vmin);
  height: min(118px, 28vmin);
  border-radius: 50%;
  border: 5px solid var(--ink);
  background: radial-gradient(circle at 35% 30%, #fff6a0, #ffe14a 45%, #ffc107 80%);
  color: var(--ink);
  font-family: inherit;
  font-size: clamp(16px, 4.2vmin, 22px);
  font-weight: 900;
  letter-spacing: 1px;
  box-shadow: 0 8px 0 #8a6a00, 0 0 18px rgba(255, 193, 7, 0.55);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.05;
  padding: 0;
}

.touch-dash.is-held {
  transform: translateY(4px);
  box-shadow: 0 4px 0 #8a6a00, 0 0 12px rgba(255, 193, 7, 0.7);
  background: radial-gradient(circle at 35% 30%, #fff, #39f7ff 55%, #4a7cff);
}

.touch-pause {
  pointer-events: auto;
  position: absolute;
  right: max(12px, env(safe-area-inset-right, 0px));
  top: max(12px, env(safe-area-inset-top, 0px));
  font-family: inherit;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 1px;
  padding: 8px 12px;
  border: 3px solid var(--cream);
  background: rgba(10, 22, 40, 0.75);
  color: var(--cream);
  box-shadow: 3px 3px 0 var(--pink);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@media (max-height: 500px), (max-width: 600px) {
  #status-box { width: 120px; padding: 6px 8px; }
  #status-value { font-size: 14px; }
  #timer-value { font-size: 22px; }
  #score-value { font-size: 36px; }
  #route-wrap, #docs-wrap { min-width: 110px; padding: 4px 8px; }
  #intro-banner { top: 100px; min-width: 220px; padding: 6px 12px; }
  .intro-title { font-size: 18px; }
  .panel { padding: 22px 24px; max-width: 92%; }
  .panel h2 { font-size: 28px; }
  #toast { bottom: max(140px, env(safe-area-inset-bottom, 0px)); font-size: 12px; }
}
