:root {
  --ink: #eaf5ff;
  --muted: #8eaed6;
  --cyan: #5cc9ff;
  --cyan-soft: rgba(92, 201, 255, 0.45);
  --orange: #ff8a3d;
  --orange-hi: #ffb768;
  --deep: #040a1e;
  --panel: rgba(8, 20, 46, 0.86);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #030716;
  overflow: hidden;
}

body {
  position: fixed;
  inset: 0;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC",
    "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

.game-shell {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #030716;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- scene ---------- */

.scene-art {
  position: absolute;
  inset: -2px;
  background-image: url("images/gen/gptimg_1795389432_look.png");
  background-position: 50% 50%;
  background-size: cover;
  background-repeat: no-repeat;
  filter: blur(1.1px) brightness(0.76) saturate(1.38) contrast(1.04);
  mix-blend-mode: screen;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, transparent 82px, rgba(0, 0, 0, 0.35) 126px, #000 200px);
  mask-image: linear-gradient(180deg, transparent 0, transparent 82px, rgba(0, 0, 0, 0.35) 126px, #000 200px);
}

.scene-art--left {
  background-position: 0% 50%;
}

.scene-art--right {
  background-position: 100% 50%;
}

.scene-tint {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(3, 8, 24, 0.82) 0, rgba(3, 8, 24, 0.32) 9%, rgba(3, 8, 24, 0) 21%, rgba(3, 8, 24, 0) 79%, rgba(3, 8, 24, 0.32) 91%, rgba(3, 8, 24, 0.82) 100%),
    linear-gradient(180deg, rgba(3, 8, 24, 0.9) 0, rgba(4, 11, 30, 0.62) 72px, rgba(4, 11, 30, 0.24) 142px, rgba(4, 11, 30, 0) 220px),
    radial-gradient(120% 72% at 50% 112%, rgba(34, 128, 255, 0.34) 0%, rgba(18, 62, 160, 0.12) 42%, transparent 70%),
    radial-gradient(90% 58% at 88% 16%, rgba(126, 74, 214, 0.26) 0%, transparent 62%),
    radial-gradient(80% 60% at 6% 34%, rgba(22, 78, 180, 0.2) 0%, transparent 64%),
    linear-gradient(180deg, rgba(3, 8, 24, 0.74) 0%, rgba(4, 11, 30, 0.34) 26%, rgba(4, 10, 27, 0.44) 62%, rgba(2, 6, 19, 0.9) 100%);
}

.scene-tint::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(85% 68% at 50% 44%, transparent 40%, rgba(1, 4, 14, 0.52) 100%);
}

#game {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0.22;
  background: repeating-linear-gradient(
    180deg,
    rgba(160, 215, 255, 0.05) 0px,
    rgba(160, 215, 255, 0.05) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: overlay;
}

/* ---------- HUD ---------- */

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

.lives-pill {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 6px 13px 6px 10px;
  border-radius: 12px;
  border: 1px solid rgba(101, 199, 255, 0.55);
  background: linear-gradient(160deg, rgba(25, 55, 108, 0.82) 0%, rgba(7, 18, 45, 0.9) 100%);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.35),
    0 0 16px rgba(48, 143, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: transform 0.16s ease, opacity 0.2s ease;
}

.lives-pill.is-hit {
  animation: lives-shake 0.32s ease;
}

.mini-ship {
  width: 21px;
  height: 21px;
  color: #8fdcff;
  filter: drop-shadow(0 0 6px rgba(92, 201, 255, 0.85));
}

.lives-x {
  margin-left: 1px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(190, 225, 255, 0.72);
}

.lives-num {
  min-width: 12px;
  font-family: "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 0 10px rgba(92, 201, 255, 0.6);
}

.hud-right {
  display: flex;
  align-items: stretch;
  gap: 9px;
}

.score-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  min-width: 122px;
  min-height: 46px;
  padding: 5px 16px 6px;
  border-radius: 12px;
  border: 1px solid rgba(101, 199, 255, 0.55);
  background: linear-gradient(160deg, rgba(25, 55, 108, 0.82) 0%, rgba(7, 18, 45, 0.9) 100%);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.35),
    0 0 16px rgba(48, 143, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
}

.score-cap {
  font-family: "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.24em;
  line-height: 1;
  color: rgba(196, 228, 255, 0.72);
  text-indent: 0.24em;
}

.score-num {
  margin-top: 2px;
  font-family: "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  color: #ffce7d;
  background: linear-gradient(180deg, #fff2cf 0%, #ffc663 45%, #ff8a3d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 9px rgba(255, 138, 61, 0.45));
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 46px;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(101, 199, 255, 0.55);
  background: linear-gradient(160deg, rgba(25, 55, 108, 0.86) 0%, rgba(7, 18, 45, 0.94) 100%);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.35),
    0 0 16px rgba(48, 143, 255, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  clip-path: polygon(10px 0, 100% 0, 100% calc(100% - 10px), calc(100% - 10px) 100%, 0 100%, 0 10px);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.icon-btn .mp-icon {
  width: 22px;
  height: 22px;
  color: #a9e2ff;
  filter: drop-shadow(0 0 6px rgba(92, 201, 255, 0.7));
}

.icon-btn:active {
  transform: scale(0.92);
  filter: brightness(1.25);
}

/* ---------- hint ---------- */

.drag-hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 22px);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(108, 190, 255, 0.24);
  background: rgba(4, 12, 30, 0.62);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(205, 232, 255, 0.86);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  transform: translateX(-50%);
  transition: opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}

.drag-hint.is-hidden {
  opacity: 0;
  transform: translate(-50%, 8px);
}

.hint-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 8px rgba(255, 138, 61, 0.9);
  animation: hint-pulse 1.4s ease-in-out infinite;
}

/* ---------- overlays ---------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 24px) 22px calc(var(--safe-bottom) + 24px);
  background: rgba(2, 7, 20, 0.58);
  backdrop-filter: blur(9px) saturate(0.9);
  -webkit-backdrop-filter: blur(9px) saturate(0.9);
}

.panel {
  position: relative;
  width: min(86vw, 336px);
  padding: 26px 22px 22px;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid rgba(98, 190, 255, 0.34);
  background:
    radial-gradient(130% 80% at 50% -10%, rgba(54, 132, 255, 0.26) 0%, transparent 58%),
    linear-gradient(158deg, rgba(20, 40, 78, 0.97) 0%, rgba(6, 15, 37, 0.98) 72%, rgba(4, 10, 26, 0.99) 100%);
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.62),
    0 0 44px rgba(32, 116, 255, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  animation: panel-in 0.32s cubic-bezier(0.2, 0.9, 0.28, 1.15) both;
}

.panel::after {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  top: 0;
  height: 2px;
  border-radius: 0 0 4px 4px;
  background: linear-gradient(90deg, transparent, var(--orange) 30%, #ffd79a 50%, var(--orange) 70%, transparent);
  box-shadow: 0 0 16px rgba(255, 138, 61, 0.75);
}

.panel-glow {
  position: absolute;
  top: -80px;
  left: 50%;
  width: 210px;
  height: 150px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(92, 201, 255, 0.24), transparent);
  pointer-events: none;
}

.panel-kicker {
  position: relative;
  margin: 0 0 7px;
  font-family: "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  color: rgba(120, 208, 255, 0.8);
}

.panel-kicker--warn {
  color: rgba(255, 166, 115, 0.9);
}

.panel-title {
  position: relative;
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.16;
  color: #f4faff;
  text-shadow: 0 2px 18px rgba(88, 180, 255, 0.3);
}

.panel-sub {
  position: relative;
  margin: 8px 0 24px;
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.final-score {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin: 18px 0 12px;
  padding: 15px 12px 13px;
  border-radius: 16px;
  border: 1px solid rgba(98, 190, 255, 0.24);
  background: rgba(3, 10, 26, 0.56);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.final-cap {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: rgba(158, 194, 230, 0.8);
}

.final-score strong {
  font-family: "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 44px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.04em;
  color: #ffd27f;
  background: linear-gradient(180deg, #fff5da 0%, #ffc25c 46%, #ff8a3d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 16px rgba(255, 138, 61, 0.45));
  font-variant-numeric: tabular-nums;
}

.best-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 20px;
  font-size: 12.5px;
  color: var(--muted);
}

.best-row b {
  font-family: "DIN Alternate", "Arial Narrow", "Helvetica Neue", sans-serif;
  font-size: 15px;
  color: #bfe8ff;
  font-variant-numeric: tabular-nums;
}

.btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 15px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  transition: transform 0.12s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  color: #2c1304;
  background: linear-gradient(180deg, #ffc47e 0%, #ff9b4e 38%, #ff7a2e 100%);
  box-shadow:
    0 10px 26px rgba(255, 122, 46, 0.34),
    0 2px 0 rgba(255, 226, 188, 0.5) inset,
    0 -3px 0 rgba(158, 60, 8, 0.18) inset;
}

.btn-primary:active {
  filter: brightness(1.08);
  box-shadow: 0 4px 14px rgba(255, 122, 46, 0.32);
}

.btn-ghost {
  margin-top: 10px;
  color: #b9dcff;
  border: 1px solid rgba(92, 201, 255, 0.3);
  background: rgba(11, 28, 62, 0.5);
}

.btn-ghost:active {
  background: rgba(18, 44, 90, 0.7);
}

/* ---------- animations ---------- */

@keyframes panel-in {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes hint-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(0.72);
  }
}

@keyframes lives-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-4px) rotate(-2deg);
  }
  45% {
    transform: translateX(4px) rotate(2deg);
  }
  70% {
    transform: translateX(-2px);
  }
}

/* short screens */
@media (max-height: 640px) {
  .hud {
    padding-top: calc(var(--safe-top) + 8px);
  }
  .panel {
    padding: 20px 20px 18px;
  }
  .panel-title {
    font-size: 25px;
  }
  .final-score strong {
    font-size: 38px;
  }
  .btn {
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel {
    animation: none;
  }
  .hint-dot {
    animation: none;
  }
  .scene-art {
    transform: none;
  }
}

/* dynamic states */
.score-panel.is-bump {
  animation: score-bump 0.24s ease;
}

.lives-pill.is-low {
  border-color: rgba(255, 104, 82, 0.72);
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.35),
    0 0 18px rgba(255, 78, 54, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.lives-pill.is-low .mini-ship {
  color: #ff9c86;
  filter: drop-shadow(0 0 6px rgba(255, 102, 76, 0.85));
}

.lives-pill.is-low .lives-num {
  color: #ffb4a1;
  text-shadow: 0 0 10px rgba(255, 92, 64, 0.7);
}

@keyframes score-bump {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.055);
    filter: brightness(1.1);
  }
  100% {
    transform: scale(1);
  }
}

/* wide screens stay atmospheric instead of showing the reference art's center crop */
@media (min-aspect-ratio: 1/1) {
  .scene-art {
    background-size: auto 270%;
  }
  .scene-art--left {
    background-position: 0% 52%;
  }
  .scene-art--right {
    background-position: 100% 52%;
  }
}
