:root {
  --sand: #e7c87d;
  --grass: #4f9a58;
  --grass-dark: #347143;
  --water-a: #0b6fa4;
  --water-b: #55c1d8;
  --ink: #10232d;
  --panel: #f7faf9;
  --danger: #dc3f3f;
  --runway-hitbox-width: calc(49% - 100px);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--ink);
  font-family: "Bungee", cursive;
  background: #2F92FF;
}

button {
  font: inherit;
}

.app-shell {
  width: 100vw;
  height: 100vh;
  padding: 0;
}

.game-panel {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
}

.top-bar {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
}

.top-bar > div:first-child,
#startButton {
  display: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.45rem, 2vw, 2.2rem);
  line-height: 1.05;
}

h2 {
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  line-height: 1.08;
}

.eyebrow {
  margin-bottom: 4px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  color: #336273;
}

.stats {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 6px;
}

.stats div {
  min-width: 58px;
  padding: 6px 12px;
  border-radius: 8px;
  corner-shape: squircle;
  background: #D5606E;
  border-bottom: 4px solid #b24a56;
  color: #ffffff;
  text-align: center;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 5px;
  backdrop-filter: blur(8px);
}

.stats svg {
  margin-right: 4px;
}

.stats div:last-child {
  display: none;
}

.stats span {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: #ffffff;
}

.stats strong {
  display: block;
  font-size: 0.8rem;
}

.primary-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 800;
  background: #1f6f57;
  cursor: pointer;
  border-bottom: 4px solid #165841;
}

.primary-button:hover {
  background: #165841;
}

.secondary-button {
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-weight: 800;
  background: #d5606e;
  cursor: pointer;
  border-bottom: 4px solid #b24a56;
}

.secondary-button:hover {
  background: #b94b59;
}

.game-area {
  position: relative;
  overflow: hidden;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  border: 0;
  border-radius: 0;
  background: #2F92FF;
  box-shadow: none;
  touch-action: none;
}

.game-area::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  opacity: 0;
  background:
    linear-gradient(90deg, rgba(220, 28, 40, 0.58), rgba(220, 28, 40, 0) 16%, rgba(220, 28, 40, 0) 84%, rgba(220, 28, 40, 0.58)),
    linear-gradient(180deg, rgba(220, 28, 40, 0.55), rgba(220, 28, 40, 0) 15%, rgba(220, 28, 40, 0) 85%, rgba(220, 28, 40, 0.55)),
    radial-gradient(circle at center, rgba(220, 28, 40, 0) 55%, rgba(220, 28, 40, 0.22) 100%);
}

.game-area.proximity-warning::after {
  animation: proximityScreenPulse 0.64s ease-in-out infinite;
}

.pause-button {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 21;
  width: 46px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  background: #d5606e;
  border-bottom: 4px solid #b24a56;
  cursor: pointer;
}

.pause-button:hover {
  background: #c55361;
}

.game-area.paused .spawn-warning,
.game-area.paused .aircraft,
.game-area.paused .aircraft.proximity-alert::after,
.game-area.paused .aircraft.proximity-alert .craft-visual,
.game-area.paused .rotor-img,
.game-area.paused .rotor,
.game-area.paused.proximity-warning::after {
  animation-play-state: paused;
}

.water-grid {
  position: absolute;
  inset: 0;
  display: none;
  opacity: 0.26;
  background-image: #2F92FF;
}

.island-layer,
.landing-zone-layer,
.path-layer,
.aircraft-layer {
  position: absolute;
  inset: 0;
}

.landing-zone-layer {
  z-index: 7;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.landing-zone-outline {
  fill: none;
  stroke: #ffd633;
  stroke-width: 4;
  vector-effect: non-scaling-stroke;
  opacity: 0;
  filter: drop-shadow(0 2px 4px rgba(76, 48, 0, 0.28));
  transition: opacity 140ms ease;
}

.landing-zone-outline.landing-connected {
  opacity: 1;
}

.path-layer {
  z-index: 8;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.route-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.38);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 1;
}

.route-line.active-route {
  stroke-width: 3;
}

.map-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
}

.tree,
.rock {
  position: absolute;
  z-index: 4;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.tree {
  width: 20px;
  height: 28px;
}

.tree::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 5px;
  height: 12px;
  border-radius: 3px;
  background: #765531;
  transform: translateX(-50%);
}

.tree::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 50% 50% 48% 48%;
  background: #28643c;
  box-shadow: 0 5px 0 #1f5734;
  transform: translateX(-50%);
}

.rock {
  width: 16px;
  height: 11px;
  border-radius: 50% 45% 35% 55%;
  background: #8e9790;
}

.landing-zone {
  position: absolute;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 6px;
  color: transparent;
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0;
  box-shadow: none;
  pointer-events: none;
}

.runway {
  height: 5.66%;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.runway::before,
.runway::after {
  content: none;
}

.runway::before {
  left: 7px;
}

.runway::after {
  right: 7px;
}

.runway-main {
  left: 48.5%;
  top: 49.25%;
  width: var(--runway-hitbox-width);
  transform: translate(-50%, -50%) rotate(9deg);
}

.runway-short {
  left: 51.9%;
  top: 67.34%;
  width: var(--runway-hitbox-width);
  transform: translate(-50%, -50%) rotate(9deg);
}

.runway.landing-connected {
  z-index: 7;
  outline: 4px solid #ffd633;
  outline-offset: 0;
}

.helipad {
  left: 55.18%;
  top: 31.25%;
  width: 7.8125vh !important;
  height: 7.8125%;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  font-size: 2.1rem;
  transform: translate(-50%, -50%);
}

.helipad.landing-connected {
  z-index: 7;
  outline: 4px solid #ffd633;
  outline-offset: 0;
}

.spawn-warning {
  position: absolute;
  z-index: 9;
  width: 28px;
  height: 25px;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  padding-top: 4px;
  color: #3a2800;
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1;
  background: #ffd633;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
  filter: drop-shadow(0 5px 6px rgba(65, 43, 0, 0.32));
  pointer-events: none;
  animation: spawnWarningPulse 0.72s ease-in-out infinite;
}

.aircraft {
  position: absolute;
  z-index: 10;
  width: 48px;
  height: 48px;
  translate: -50% -50%;
  cursor: grab;
  user-select: none;
  will-change: transform, left, top;
  transition: filter 160ms ease, scale 160ms ease;
}

.aircraft.dragging {
  cursor: grabbing;
  filter: drop-shadow(0 12px 15px rgba(5, 30, 38, 0.28));
  scale: 1.08;
}

.aircraft.landing {
  animation: land 420ms ease forwards;
}

.aircraft.crash {
  animation: crash 620ms ease forwards;
}

.aircraft.proximity-alert:not(.crash):not(.landing)::after {
  content: "";
  position: absolute;
  inset: -10px;
  z-index: 3;
  border: 3px solid rgba(255, 24, 30, 0.92);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(255, 24, 30, 0.86), inset 0 0 16px rgba(255, 24, 30, 0.28);
  pointer-events: none;
  animation: proximityHaloBlink 0.46s ease-in-out infinite;
}

.aircraft.proximity-alert:not(.crash):not(.landing) .craft-visual {
  animation: proximityCraftTint 0.46s ease-in-out infinite;
}

.aircraft.proximity-alert:not(.crash):not(.landing) .aircraft-label {
  background: rgba(168, 0, 14, 0.86);
}

.craft-shadow {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 38px;
  height: 14px;
  border-radius: 50%;
  background: rgba(10, 28, 34, 0.22);
  transform: translate(-50%, -50%);
}

.craft-visual {
  position: absolute;
  inset: 0;
  transform: rotate(var(--angle, 0deg));
  transition: transform 120ms linear;
}

.plane-shape,
.heli-shape {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.plane-shape {
  width: 38px;
  height: 38px;
}

.plane-shape::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  width: 12px;
  height: 34px;
  border-radius: 70% 70% 8px 8px;
  background: var(--craft-color);
  transform: translateX(-50%);
}

.plane-shape::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 17px;
  width: 38px;
  height: 10px;
  border-radius: 10px;
  background: var(--craft-color);
  transform: translateX(-50%);
  box-shadow: 0 13px 0 -3px color-mix(in srgb, var(--craft-color), #101f28 16%);
}

.plane-img,
.heli-img,
.rotor-img {
  position: absolute;
  left: 50%;
  top: 50%;
  display: none;
  width: 56px;
  height: 56px;
  object-fit: contain;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.aircraft.use-plane-image .plane-img,
.aircraft.use-heli-image .heli-img {
  display: block;
  filter: var(--craft-filter, none);
}

.aircraft.use-heli-image .rotor-img {
  display: block;
  width: 66px;
  height: 66px;
  animation: rotorImageSpin 1.2s linear infinite;
}

.aircraft.use-plane-image .plane-shape,
.aircraft.use-heli-image .heli-shape,
.aircraft.use-heli-image .rotor {
  display: none;
}

.heli-shape {
  width: 34px;
  height: 20px;
  border-radius: 16px 16px 10px 10px;
  background: var(--craft-color);
}

.heli-shape::before {
  content: "";
  position: absolute;
  right: -17px;
  top: 8px;
  width: 22px;
  height: 4px;
  border-radius: 4px;
  background: var(--craft-color);
}

.heli-shape::after {
  content: "";
  position: absolute;
  right: -22px;
  top: 4px;
  width: 7px;
  height: 12px;
  border-radius: 2px;
  background: #d8f4f8;
}

.rotor {
  position: absolute;
  left: 50%;
  top: 48%;
  width: 45px;
  height: 5px;
  border-radius: 999px;
  background: rgba(12, 31, 39, 0.72);
  transform: translate(-50%, -50%);
  animation: spin 1.2s linear infinite;
}

.rotor::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 45px;
  border-radius: 999px;
  background: rgba(12, 31, 39, 0.48);
  transform: translate(-50%, -50%);
}

.aircraft-label {
  position: absolute;
  left: 50%;
  bottom: -18px;
  min-width: fit-content;
  padding: 2px 5px;
  border-radius: 4px;
  color: #fff;
  font-size: 0.54rem;
  font-weight: 800;
  text-align: center;
  background: rgba(8, 24, 32, 0.7);
  transform: translateX(-50%);
  white-space: nowrap;
}

.path-dot {
  position: absolute;
  z-index: 8;
  width: 8px;
  height: 8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #243f4a;
  translate: -50% -50%;
  opacity: 0.88;
  pointer-events: none;
}

.overlay,
.popup {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(9, 36, 45, 0.48);
}

.overlay {
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.overlay .modal {
  transform: translateY(18px) scale(0.96);
  opacity: 0;
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease;
}

.overlay.overlay-visible,
.overlay.overlay-hiding {
  display: grid;
}

.overlay.overlay-visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay.overlay-visible .modal {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.popup {
  position: fixed;
}

.hidden {
  display: none;
}

.modal {
  width: min(440px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(247, 250, 249, 0.96);
  box-shadow: 0 25px 65px rgba(4, 24, 31, 0.35);
}

.result-modal {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100vh - 24px);
  justify-items: center;
  gap: 9px;
  padding: 16px 20px 20px;
  overflow: auto;
  text-align: center;
  background: #fff8ed;
  border: 3px solid #ffffff;
  box-shadow: 0 28px 65px rgba(4, 24, 31, 0.35), 0 0 0 8px rgba(213, 96, 110, 0.18);
}

.game-over-image {
  width: min(340px, 78vw);
  max-height: 160px;
  object-fit: contain;
  display: block;
  margin: -6px auto 0;
  filter: drop-shadow(0 12px 18px rgba(99, 38, 45, 0.18));
}

.result-modal .eyebrow {
  color: #b24a56;
}

.result-modal h2 {
  color: #10232d;
  font-size: clamp(1.55rem, 4.5vw, 2.35rem);
  line-height: 1;
}

.result-score {
  padding: 7px 13px;
  border-radius: 8px;
  color: #b24a56 !important;
  line-height: 1.1 !important;
  border: 4px solid #b24a56;
}

.result-modal .primary-button {
  min-width: 170px;
  margin-top: 2px;
  background: #1f6f57;
  border-bottom: 5px solid #165841;
}

.modal p:not(.eyebrow) {
  line-height: 1.5;
  color: #385760;
}

.pause-modal {
  text-align: center;
}

.menu-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

@keyframes spin {
  to {
    transform: translate(-50%, -50%) rotate(1turn);
  }
}

@keyframes rotorImageSpin {
  to {
    transform: translate(-50%, -50%) rotate(1turn);
  }
}

@keyframes spawnWarningPulse {
  0%,
  100% {
    transform: scale(0.86);
  }

  50% {
    transform: scale(1.22);
  }
}

@keyframes land {
  to {
    opacity: 0;
    scale: 0.35;
  }
}

@keyframes crash {
  30% {
    scale: 1.3;
    filter: brightness(1.8) saturate(1.4);
  }
  100% {
    opacity: 0;
    scale: 0.5;
    rotate: 35deg;
  }
}

@keyframes proximityScreenPulse {
  0%,
  100% {
    opacity: 0.2;
  }

  50% {
    opacity: 0.88;
  }
}

@keyframes proximityHaloBlink {
  0%,
  100% {
    opacity: 0.22;
    transform: scale(0.92);
  }

  50% {
    opacity: 1;
    transform: scale(1.08);
  }
}

@keyframes proximityCraftTint {
  0%,
  100% {
    filter: drop-shadow(0 0 0 rgba(255, 24, 30, 0));
  }

  50% {
    filter: sepia(1) saturate(5) hue-rotate(310deg) brightness(1.38) drop-shadow(0 0 14px rgba(255, 24, 30, 0.95));
  }
}

/* Splash screen */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #2F92FF;
  overflow: hidden;
  transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.06);
}

.splash-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  text-align: center;
}

.splash-logo {
  width: 460px;
  max-width: 78vw;
  display: block;
  filter: drop-shadow(0 12px 32px rgba(4, 30, 80, 0.05));
}

.splash-score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: #fff;
}

.splash-score-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.65;
}

.splash-score-box strong {
  font-size: 2.2rem;
  line-height: 1;
}

.splash-play-btn {
  font-size: 1.1rem;
  padding: 14px 48px;
  min-height: 52px;
  border-radius: 12px;
  border-bottom: 5px solid #1f5734;
  letter-spacing: 0.03em;
  transition: all 0.2s ease;
}

/* Map zoom-in animation on game start */
@keyframes mapZoomIn {
  from {
    transform: scale(1.14);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.map-image-zoom-in {
  animation: mapZoomIn 750ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transform-origin: center center;
}

@media (max-width: 760px) {
  .app-shell {
    padding: 0;
  }

  .top-bar {
    top: 8px;
    right: 8px;
  }

  .pause-button {
    left: 8px;
    top: 8px;
  }

  .stats {
    justify-content: flex-end;
  }

  .stats div {
    flex: 0 0 auto;
    min-width: 0;
  }

  .game-area {
    min-height: 100vh;
  }

  .runway-main {
    left: 48.06%;
    top: 49.27%;
    width: var(--runway-hitbox-width);
  }

  .runway-short {
    left: 52.46%;
    top: 67.34%;
    width: var(--runway-hitbox-width);
  }
}
