:root {
  color-scheme: dark;
  font: 16px/1.45 "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #fff2df;
  background: #16100e;
  --cream: #fff2df;
  --subtle: #dfc9ad;
  --ember: #ffb166;
  --line: #c29872;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 280px;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

button {
  color: inherit;
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid #ffe0a1;
  outline-offset: 4px;
}

.game {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: radial-gradient(ellipse at 65% 38%, #453129, #1a1414 61%, #100d0c);
  -webkit-tap-highlight-color: transparent;
}

.game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  cursor: none;
  touch-action: none;
}

.hud {
  position: absolute;
  z-index: 5;
  top: max(14px, env(safe-area-inset-top, 0px));
  right: max(20px, env(safe-area-inset-right, 0px));
  left: max(20px, env(safe-area-inset-left, 0px));
  display: grid;
  grid-template-columns: minmax(180px, 242px) 1fr minmax(48px, 242px);
  align-items: start;
  justify-items: start;
  gap: 12px 18px;
  pointer-events: none;
  user-select: none;
}

.vitals, .boss-status, .objective, .pause-button, .burn-tally, .pickup-status, .upgrade-status {
  background: #17100fda;
  border: 1px solid #d6a57755;
  box-shadow: 0 5px 19px #0005, inset 0 1px #fff1;
}

.vitals {
  display: grid;
  justify-self: stretch;
  gap: 8px;
  padding: 10px 12px 11px;
  border-radius: 8px;
}

.meter {
  --meter-start: #92be72;
  --meter-end: #d2e3a2;
  display: grid;
  gap: 4px;
}

.meter-fire { --meter-start: #d85d32; --meter-end: #ffb166; }
.meter-boss { --meter-start: #b93634; --meter-end: #ed7e5f; }

.meter-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  color: #f9e8d2;
  font-size: .67rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: .11em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

.meter progress {
  display: block;
  width: 100%;
  height: 7px;
  border: 0;
  border-radius: 5px;
  appearance: none;
  background: #332521;
  overflow: hidden;
}

.meter progress::-webkit-progress-bar { background: #332521; }
.meter progress::-webkit-progress-value { background: linear-gradient(90deg, var(--meter-start), var(--meter-end)); border-radius: 5px; }
.meter progress::-moz-progress-bar { background: linear-gradient(90deg, var(--meter-start), var(--meter-end)); border-radius: 5px; }

.flight-speed {
  padding-top: 5px;
  border-top: 1px solid #d6a57738;
  color: #dfc9ad;
}

.flight-speed strong { color: #fce6c8; }

.upgrade-status {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  align-items: center;
  justify-self: stretch;
  gap: 6px;
  min-width: 0;
  margin: 0;
  padding: 5px 8px;
  border-color: #edaf755e;
  border-radius: 7px;
  color: #ffd797;
  font-size: .73rem;
  font-weight: 760;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.upgrade-status:empty { display: none; }

.upgrade-status[data-upgrade="bluefire"] {
  border-color: #80dff674;
  color: #aeeeff;
}

.upgrade-status[data-upgrade]::before {
  flex: none;
  width: 24px;
  height: 24px;
  content: '';
  background: center / contain no-repeat;
}

.upgrade-status[data-upgrade="inferno"]::before { background-image: url('./assets/pickup-inferno.webp'); }
.upgrade-status[data-upgrade="bluefire"]::before { background-image: url('./assets/pickup-bluefire.webp'); }

.objective {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  justify-self: center;
  gap: 2px;
  max-width: min(550px, 100%);
  padding: 9px 17px 10px;
  border-radius: 8px;
  text-align: center;
  color: var(--cream);
  text-wrap: balance;
}

.level-value {
  color: var(--ember);
  font-size: .66rem;
  font-weight: 850;
  line-height: 1.1;
  letter-spacing: .13em;
  text-transform: uppercase;
}

.objective strong {
  font-size: clamp(.78rem, 1.45vw, 1.01rem);
  line-height: 1.16;
  font-weight: 740;
}

.challenge-status, .tower-status {
  font-size: .68rem;
  font-weight: 710;
  line-height: 1.15;
  color: #f7c78e;
  font-variant-numeric: tabular-nums;
}

.tower-status { color: #f6d8a7; }
.challenge-status:empty, .tower-status:empty { display: none; }

.pause-button {
  grid-column: 3;
  grid-row: 1;
  display: grid;
  place-items: center;
  justify-self: end;
  width: 45px;
  height: 45px;
  padding: 0;
  border-radius: 8px;
  pointer-events: auto;
}

.pause-button:hover { background: #4b3024ed; }
.pause-icon { width: 14px; height: 15px; border-inline: 4px solid #f8e6ce; border-radius: 1px; }

.boss-status {
  grid-column: 2;
  grid-row: 2;
  justify-self: center;
  width: min(410px, 95%);
  padding: 7px 10px 8px;
  border-color: #e9856666;
  border-radius: 8px;
}

.burn-tally {
  grid-column: 3;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, auto));
  justify-self: end;
  gap: 0;
  margin: 0;
  padding: 4px 1px;
  border-radius: 7px;
  color: #dfc9ad;
  text-align: center;
}

.burn-tally div {
  display: grid;
  gap: 1px;
  padding: 0 7px;
}

.burn-tally::before {
  grid-column: 1 / -1;
  margin-bottom: 1px;
  color: #f2bc88;
  content: "Burned";
  font-size: .59rem;
  font-weight: 750;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.burn-tally div + div { border-inline-start: 1px solid #d6a57735; }
.burn-tally dt { font-size: .61rem; font-weight: 640; }

.burn-tally dd {
  margin: 0;
  color: #fff0d3;
  font-size: .86rem;
  font-weight: 780;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
}

.pickup-status {
  grid-column: 2;
  grid-row: 3;
  justify-self: center;
  max-width: 100%;
  margin: 0;
  padding: 5px 12px;
  border-radius: 5px;
  color: #ffe6aa;
  font-size: clamp(.68rem, 1.5vw, .87rem);
  font-weight: 700;
  text-align: center;
}

.pickup-status:empty { display: none; }
.pickup-status[data-tone="recharge"] { color: #8fefff; }
.pickup-status[data-tone="healing"] { color: #b7f6ad; }
.pickup-status[data-tone="powerup"] { color: #ffcf85; }

.score-value {
  margin-top: 3px;
  color: #dbc3a9;
  font-size: .64rem;
  font-variant-numeric: tabular-nums;
}

.game[data-damage="hit"]::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  content: "";
  box-shadow: inset 0 0 95px #bc241a7d;
}

.crosshair {
  position: absolute;
  z-index: 3;
  top: 48%;
  left: 50%;
  width: 28px;
  height: 28px;
  transform: translate(-50%, -50%);
  border: 1px solid #fff3cfad;
  border-radius: 50%;
  background:
    linear-gradient(#fff3d0, #fff3d0) center / 9px 1px no-repeat,
    linear-gradient(#fff3d0, #fff3d0) center / 1px 9px no-repeat;
  filter: drop-shadow(0 1px 2px #17100f);
  pointer-events: none;
}

.game[data-firing="true"] .crosshair {
  border-color: #ffb656;
  filter: drop-shadow(0 0 3px #f73d18);
}

.crosshair[data-locked="true"] {
  border-color: #ffc66f;
  box-shadow: inset 0 0 0 1px #ffca754f;
}

.overlay-kicker:empty { display: none; }
.studio-signature a { color: inherit; text-decoration: none; }
.studio-signature a:hover { text-decoration: underline; }

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

.look-pad {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  touch-action: none;
}

.wing-line {
  position: absolute;
  inset: 70% 0 auto;
  height: 1px;
  background: linear-gradient(90deg, transparent 2%, #ffe5b99c 10%, #ffe5b92a 29%, transparent 36% 64%, #ffe5b92a 71%, #ffe5b99c 90%, transparent 98%);
  filter: drop-shadow(0 1px 1px #170f0c);
  pointer-events: none;
}

.flight-stick {
  position: absolute;
  width: clamp(59px, 15vmin, 76px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border: 1px solid #f7d9a898;
  border-radius: 50%;
  background:
    linear-gradient(#ffe6ae51, #ffe6ae51) center / 40% 1px no-repeat,
    linear-gradient(#ffe6ae51, #ffe6ae51) center / 1px 40% no-repeat,
    #24181339;
  box-shadow: 0 2px 8px #150e0d55;
  pointer-events: none;
}

.flight-thumb {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 29%;
  aspect-ratio: 1;
  translate: -50% -50%;
  border: 1px solid #fff0cda4;
  border-radius: 50%;
  background: #78503cb2;
  box-shadow: 0 1px 4px #120a08a6;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  overflow: auto;
  overscroll-behavior: contain;
  padding: max(28px, env(safe-area-inset-top, 0px)) max(22px, env(safe-area-inset-right, 0px)) max(28px, env(safe-area-inset-bottom, 0px)) max(22px, env(safe-area-inset-left, 0px));
  background: radial-gradient(ellipse, #241612a1, #100b0bdf 79%);
}

.overlay-panel {
  width: min(480px, 100%);
  padding: clamp(24px, 4.4vw, 64px);
  border: 1px solid #d1a27269;
  border-radius: 14px;
  background: linear-gradient(145deg, #38241ffd, #201413fa 63%);
  color: var(--cream);
  text-align: center;
  box-shadow: 0 17px 58px #0008, inset 0 1px #fff1;
}

.overlay-kicker {
  margin: 0 0 9px;
  color: #ffc583;
  font-size: .68rem;
  font-weight: 850;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.overlay-kicker:empty { display: none; }

.overlay h1 {
  margin: 0;
  color: #fff0d2;
  font-family: Cinzel, Georgia, "Times New Roman", serif;
  font-size: clamp(2.15rem, 5vw, 3.6rem);
  font-weight: 700;
  line-height: .99;
  letter-spacing: -.039em;
  text-wrap: balance;
}

.overlay-message {
  margin: 15px 0 0;
  color: #eddbc2;
  font-size: clamp(.92rem, 2vw, 1.07rem);
  line-height: 1.43;
  text-wrap: pretty;
}

.flight-choice { display: none; }

.overlay[data-screen="title"] .flight-choice {
  display: grid;
  gap: 5px;
  width: min(340px, 100%);
  margin-top: clamp(15px, 2.7vh, 25px);
  text-align: left;
}

.flight-choice label {
  color: #efd6b5;
  font-size: .69rem;
  font-weight: 780;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.flight-choice select {
  width: 100%;
  min-height: 45px;
  padding: .6em .8em;
  border: 1px solid #d7ac7887;
  border-radius: 6px;
  color: #fff0d8;
  background: #231714ed;
  font: inherit;
  font-size: .87rem;
  font-weight: 670;
  cursor: pointer;
}

.flight-choice select:focus-visible {
  outline: 3px solid #ffe0a1;
  outline-offset: 3px;
}

.flight-choice option:disabled { color: #b3a296; }

.overlay-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 9px;
  margin-top: clamp(17px, 4vh, 32px);
}

.primary-button, .secondary-button {
  min-width: 112px;
  min-height: 48px;
  padding: .68em 1.3em;
  border: 1px solid #f3be79;
  border-radius: 6px;
  color: #241209;
  background: linear-gradient(152deg, #ffcf94, #f79759 95%);
  box-shadow: 0 5px 17px #1207046b, inset 0 1px #fff7;
  font-size: .94rem;
  font-weight: 860;
  line-height: 1.15;
  letter-spacing: .02em;
}

.primary-button:hover { background: linear-gradient(152deg, #ffe1b3, #f9af75 95%); }

.secondary-button {
  border-color: #d5aa7587;
  color: #f6e6ce;
  background: #38231fee;
  box-shadow: 0 5px 17px #12070449;
}

.secondary-button:hover { background: #4d3025; }

.overlay[data-screen="title"] {
  place-items: center start;
  padding: max(25px, env(safe-area-inset-top, 0px)) max(24px, env(safe-area-inset-right, 0px)) max(49px, env(safe-area-inset-bottom, 0px)) max(6.9vw, env(safe-area-inset-left, 0px));
  background:
    linear-gradient(90deg, #120d0cdf 3%, #18110fe1 29%, #19110f68 59%, transparent 94%),
    linear-gradient(0deg, #100c0be8 0%, #100c0b13 36%, #100c0b08 68%, #190d0c49 100%),
    url('./assets/cover.webp') center 52% / cover no-repeat;
}

.overlay[data-screen="title"] .overlay-panel {
  width: min(550px, 100%);
  padding: 0;
  border: none;
  border-radius: 0;
  background: none;
  box-shadow: none;
  text-align: left;
}

.overlay[data-screen="title"] h1 {
  max-width: 9ch;
  color: #ffe9bf;
  font-size: clamp(4.7rem, 10vw, 10.8rem);
  line-height: .78;
  letter-spacing: -.059em;
  text-transform: uppercase;
  text-shadow: 0 4px 24px #150907a3;
}

.overlay[data-screen="title"] .overlay-message {
  max-width: 29em;
  margin-top: clamp(20px, 4vh, 38px);
  color: #fff1db;
  font-size: clamp(1rem, 1.6vw, 1.2rem);
  text-shadow: 0 2px 3px #110b09;
}

.overlay[data-screen="title"] .overlay-actions {
  justify-content: start;
  margin-top: 12px;
}

.overlay[data-screen="title"] .primary-button {
  min-width: 161px;
  min-height: 52px;
  padding: .73em 1.38em;
  box-shadow: 0 7px 22px #0f08078a, inset 0 1px #fff7;
}

.controls-help, .studio-signature { display: none; }

.overlay[data-screen="title"] .controls-help {
  display: block;
  margin-top: clamp(14px, 4vh, 35px);
  color: #f4dec3;
  font-size: .81rem;
  font-weight: 660;
  line-height: 1.45;
  text-shadow: 0 1px 3px #110907;
}

.keyboard-help { display: flex; flex-wrap: wrap; gap: 5px 13px; }
.keyboard-help span { white-space: nowrap; }

kbd {
  display: inline-block;
  padding: .12em .38em;
  border: 1px solid #e8bc8f67;
  border-bottom-width: 2px;
  border-radius: 3px;
  background: #271815c7;
  color: #fff1d8;
  font-family: ui-monospace, monospace;
  font-size: .84em;
  font-weight: 720;
  letter-spacing: -.02em;
  line-height: 1.15;
}

.gesture-help, .orientation-tip { display: none; }

.overlay[data-screen="title"] .studio-signature {
  display: block;
  position: absolute;
  bottom: max(20px, env(safe-area-inset-bottom, 0px));
  left: max(6.9vw, env(safe-area-inset-left, 0px));
  color: #cbb496;
  font-size: .62rem;
  font-weight: 790;
  letter-spacing: .18em;
  text-transform: uppercase;
}

.no-script {
  position: absolute;
  z-index: 10;
  inset: auto 18px 18px;
  padding: 12px 16px;
  border: 1px solid #fbc691;
  border-radius: 8px;
  color: white;
  background: #593027;
  text-align: center;
}

@media (pointer: coarse), (hover: none) {
  .touch-controls { display: block; }
  .keyboard-help { display: none; }
  .gesture-help { display: grid; gap: 3px; }
}

@media (max-width: 700px) {
  .hud {
    top: max(8px, env(safe-area-inset-top, 0px));
    right: max(9px, env(safe-area-inset-right, 0px));
    left: max(9px, env(safe-area-inset-left, 0px));
    grid-template-columns: minmax(80px, 1fr) minmax(0, 1.6fr) 44px;
    gap: 6px;
  }

  .vitals { gap: 5px; padding: 6px 7px; }
  .upgrade-status { gap: 3px; padding: 4px 5px; font-size: .65rem; }
  .upgrade-status[data-upgrade]::before { width: 19px; height: 19px; }
  .meter { gap: 3px; }
  .meter-heading { gap: 4px; font-size: .59rem; }
  .meter progress { height: 5px; }
  .objective { padding: 6px 8px 7px; }
  .level-value { font-size: .6rem; }
  .objective strong { font-size: .77rem; }
  .challenge-status, .tower-status { font-size: .64rem; }
  .pause-button { width: 44px; height: 44px; }
  .boss-status, .pickup-status { grid-column: 1 / -1; }
  .boss-status { width: min(81%, 330px); }
}

@media (max-width: 700px), (max-height: 490px) and (orientation: landscape) {
  .burn-tally {
    position: fixed;
    bottom: max(9px, env(safe-area-inset-bottom, 0px));
    left: max(9px, env(safe-area-inset-left, 0px));
  }
}

@media (orientation: portrait) and (max-width: 840px) {
  .overlay[data-screen="title"] {
    place-items: end start;
    padding-inline: max(23px, env(safe-area-inset-left, 0px));
    padding-bottom: max(68px, calc(55px + env(safe-area-inset-bottom, 0px)));
    background:
      linear-gradient(0deg, #110b0af7 0%, #160d0cdd 33%, #120d0c52 65%, #150c0b0f),
      url('./assets/cover.webp') 63% 44% / cover no-repeat;
  }

  .overlay[data-screen="title"] h1 { font-size: clamp(3.35rem, 16vw, 7.55rem); }
  .overlay[data-screen="title"] .studio-signature { left: max(23px, env(safe-area-inset-left, 0px)); }
  .orientation-tip { display: block; margin: .35em 0 0; color: #d8bda1; }
}

@media (max-height: 490px) and (orientation: landscape) {
  .overlay { padding-block: 12px; }
  .overlay-panel { padding: 17px 25px; }
  .overlay h1 { font-size: clamp(2rem, 8vh, 3.2rem); }
  .overlay[data-screen="title"] { align-items: safe center; padding-block: 11px 31px; }
  .overlay[data-screen="title"] .overlay-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 10px;
  }
  .overlay[data-screen="title"] :is(.overlay-kicker, h1, .overlay-message, .controls-help) { grid-column: 1 / -1; }
  .overlay[data-screen="title"] h1 { font-size: min(15vh, 10vw); }
  .overlay[data-screen="title"] .overlay-message { margin-top: 11px; font-size: .87rem; }
  .overlay[data-screen="title"] .flight-choice { gap: 3px; margin-top: 10px; }
  .overlay[data-screen="title"] .overlay-actions { align-self: end; margin-top: 0; }
  .flight-choice select { min-height: 44px; padding-block: .4em; }
  .overlay-actions { margin-top: 11px; }
  .overlay[data-screen="title"] .primary-button { min-height: 44px; }
  .overlay[data-screen="title"] .controls-help { margin-top: 10px; }
  .overlay[data-screen="title"] .studio-signature { bottom: max(9px, env(safe-area-inset-bottom, 0px)); }
  .hud { top: max(7px, env(safe-area-inset-top, 0px)); }
}

.studio-signature a { display: inline-flex; align-items: center; gap: 8px; font-size: .75rem; letter-spacing: .05em; }
.studio-signature img { width: 56px; height: 28px; object-fit: contain; }
