/* Sky Fortress — real-3D isometric scroll-shooter. Full-bleed WebGL canvas. */
*,
*::before,
*::after { box-sizing: border-box; }

html, body {
  -webkit-tap-highlight-color: transparent;
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #04050d;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  overscroll-behavior: none;
}

#canvas {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* subtle vignette over the scene, under the HUD */
body::after {
  content: "";
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(115% 95% at 50% 45%, rgba(0, 0, 0, 0) 55%, rgba(1, 2, 8, 0.42) 100%);
}

/* ---------- death flash + confetti ---------- */
.flash {
  position: fixed; inset: 0; z-index: 7; pointer-events: none;
  background: radial-gradient(120% 90% at 50% 55%, rgba(255, 96, 60, 0.5), rgba(255, 60, 30, 0) 70%);
  opacity: 0; transition: opacity 100ms ease-out;
}
.flash.is-on { opacity: 1; transition: none; }
.confetti { position: fixed; inset: 0; z-index: 7; pointer-events: none; }
.confetti i {
  position: absolute; width: 7px; height: 11px; border-radius: 2px; opacity: 0.95;
  animation: confettiFall var(--d, 900ms) cubic-bezier(0.2, 0.5, 0.6, 1) forwards;
}
@keyframes confettiFall {
  from { transform: translate(0, 0) rotate(0deg); opacity: 1; }
  to { transform: translate(var(--dx, 0), var(--dy, 300px)) rotate(var(--rot, 360deg)); opacity: 0; }
}

/* ---------- HUD (score) ---------- */
.hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 0; right: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
}
.hud__score {
  font-size: clamp(1.9rem, 7vw, 3.1rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  color: #d7ecff;
  text-shadow: 0 0 12px rgba(90, 190, 255, 0.55), 0 0 34px rgba(60, 140, 255, 0.3);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.hud__best {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(150, 200, 245, 0.5);
  font-variant-numeric: tabular-nums;
}

/* ---------- fuel gauge (top-left) ---------- */
.fuel {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: max(16px, env(safe-area-inset-left));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.fuel__label {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(150, 200, 245, 0.55);
}
.fuel__track {
  width: clamp(72px, 17vw, 130px);
  height: 9px;
  border-radius: 5px;
  background: rgba(120, 180, 240, 0.14);
  border: 1px solid rgba(140, 200, 255, 0.22);
  overflow: hidden;
  display: block;
}
.fuel__bar {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, #2fe08c, #7dffbe);
  box-shadow: 0 0 10px rgba(80, 255, 170, 0.5);
  transition: width 180ms linear;
}
.fuel.is-low .fuel__bar {
  background: linear-gradient(90deg, #ff5a4a, #ffab52);
  box-shadow: 0 0 12px rgba(255, 110, 70, 0.65);
  animation: fuelPulse 700ms ease-in-out infinite;
}
@keyframes fuelPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ---------- altimeter (left edge) ---------- */
.alt {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  pointer-events: none;
}
.alt__label {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(150, 200, 245, 0.5);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.alt__track {
  position: relative;
  width: 7px;
  height: clamp(120px, 26vh, 210px);
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(120, 180, 240, 0.2), rgba(120, 180, 240, 0.08));
  border: 1px solid rgba(140, 200, 255, 0.22);
  display: block;
}
.alt__marker {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 15px;
  height: 5px;
  border-radius: 3px;
  transform: translate(-50%, 50%);
  background: #8fd8ff;
  box-shadow: 0 0 10px rgba(120, 210, 255, 0.9), 0 0 22px rgba(80, 170, 255, 0.5);
  will-change: bottom;
}

.sound-btn {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  z-index: 6;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1.5px solid rgba(120, 190, 255, 0.3);
  background: rgba(10, 14, 26, 0.5);
  color: #9fd4ff;
  font-size: 1.05rem;
  cursor: pointer;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: border-color 140ms ease, background 140ms ease;
}
.sound-btn:hover { border-color: rgba(120, 190, 255, 0.7); }
.sound-btn:focus-visible { outline: 2px solid #8fd8ff; outline-offset: 2px; }
.sound-btn[aria-pressed="false"] { color: rgba(130, 170, 210, 0.35); }

/* ---------- overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(120% 90% at 50% 44%, rgba(10, 16, 34, 0.72), rgba(3, 4, 10, 0.92));
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  transition: opacity 260ms ease;
}
.overlay[hidden] { display: none; }
.overlay.is-hidden { opacity: 0; pointer-events: none; }

.panel {
  text-align: center;
  max-width: 480px;
  padding: 34px 30px 32px;
  border-radius: 24px;
  color: #c3d6ec; /* inherited by the injected share pill */
  background: rgba(9, 13, 26, 0.88);
  border: 1px solid rgba(110, 180, 255, 0.18);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8), inset 0 0 60px -30px rgba(70, 150, 255, 0.4);
  animation: pop 320ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
}
@keyframes pop { from { transform: scale(0.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel__title {
  margin: 0 0 6px;
  font-size: clamp(2.2rem, 9vw, 3.7rem);
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 0.95;
  padding-bottom: 0.16em;
  background: linear-gradient(176deg, #eaf6ff 0%, #7cc4ff 46%, #3d7bff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 4px 26px rgba(80, 150, 255, 0.45));
}
.panel__text { margin: 0 0 26px; font-size: clamp(0.96rem, 3.3vw, 1.06rem); line-height: 1.55; font-weight: 500; color: #c3d6ec; }
.panel__text .stat { color: #8fd8ff; font-weight: 800; }
.play-btn {
  appearance: none;
  font-family: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  color: #04121f;
  background: linear-gradient(180deg, #9fe0ff, #3d9bf5);
  border: 0;
  padding: 16px 42px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 30px -6px rgba(70, 160, 255, 0.55);
  transition: transform 140ms ease, box-shadow 140ms ease;
}
.play-btn:hover { transform: translateY(-2px); box-shadow: 0 16px 40px -8px rgba(70, 160, 255, 0.7); }
.play-btn:active { transform: translateY(0); }
.play-btn:focus-visible { outline: 2px solid #d7ecff; outline-offset: 3px; }

/* ---------- frame + hint ---------- */
.frame { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.frame__corner {
  position: absolute;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(160, 205, 250, 0.45);
}
.frame__corner--tl { top: max(58px, calc(env(safe-area-inset-top) + 44px)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner--tr { top: max(14px, env(safe-area-inset-top)); right: 62px; }
.frame__corner--bl { bottom: max(14px, env(safe-area-inset-bottom)); left: max(16px, env(safe-area-inset-left)); }
.frame__corner a { color: inherit; text-decoration: none; pointer-events: auto; }
.frame__corner a:hover { color: #8fd8ff; }
.frame__corner a:focus-visible { outline: 2px solid #8fd8ff; outline-offset: 2px; }

.hint {
  position: fixed;
  bottom: max(26px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 4;
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(160, 205, 250, 0.5);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 300ms ease;
}
.hint.is-gone { opacity: 0; }

@media (max-width: 560px) {
  .frame__corner--bl { display: none; }
  .frame__corner--tr { display: none; }
  .hint { font-size: 0.64rem; }
}

/* short landscape phones: compact the overlay so nothing clips */
@media (max-height: 520px) {
  .overlay { padding: 12px; overflow-y: auto; }
  .panel { max-width: min(640px, calc(100vw - 132px)); padding: 14px 26px 16px; border-radius: 18px; }
  .panel__title { font-size: clamp(1.6rem, 9vh, 2.4rem); padding-bottom: 0.1em; margin-bottom: 2px; }
  .panel__text { font-size: 0.85rem; line-height: 1.42; margin-bottom: 12px; }
  .play-btn { padding: 10px 34px; font-size: 0.95rem; }
}

@media (prefers-reduced-motion: reduce) {
  .fuel.is-low .fuel__bar { animation: none; }
  .panel { animation: none; }
  .confetti i { animation-duration: 1ms; }
}
