/* Copyright © 2026 Wonderflight Media */

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

html, body { height: 100%; }

body {
  background: #120E2E;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-family: 'Baloo 2', system-ui, sans-serif;
}

.hidden { display: none !important; }

#stage {
  position: relative;
  width: min(100vw, calc(100dvh * 32 / 15));
  aspect-ratio: 32 / 15;
  background: #1A1440;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  container-type: size;
  /* 16px at the 1280px design width — HUD type scales with the stage */
  font-size: 1.25cqw;
}

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

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

#hud { position: absolute; inset: 0; pointer-events: none; }

#zone-divider {
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  border-top: 1px dashed rgba(233, 227, 255, 0.25);
}

.hud-chips {
  position: absolute;
  top: 1.6%;
  left: 0.9%;
  display: flex;
  gap: 0.5em;
}

.chip {
  /* Tabular digits: every digit is the same width, so a counter only widens
     when it gains a digit — 111 and 888 match, and it never jitters. */
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  background: #2C2461;
  border-radius: 999px;
  padding: 0.2em 0.75em 0.2em 0.45em;
  color: #FFF3DC;
  font-size: 0.82em;
  font-weight: 700;
}

.chip-coin {
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  background: #FFC857;
  border: 2px solid #B97712;
}

.chip-gem {
  width: 0.9em;
  height: 0.9em;
  background: #4FE0C2;
  border: 2px solid #168F77;
  transform: rotate(45deg);
  border-radius: 2px;
}

#hud-top {
  position: absolute;
  top: 1%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.5em;
}

#hud-score {
  font-variant-numeric: tabular-nums;   /* see .chip */
  color: #FFF3DC;
  font-size: 1.15em;
  font-weight: 700;
}

/* M4 multiplier chip. The radial decay timer is a conic-gradient driven by
   --p (0..1) set from JS, with a filled centre punched out by a radial-
   gradient — no second canvas, no SVG. Hidden entirely at x1, so the chip
   simply *appearing* is the discovery signal. */
#hud-mult {
  --p: 1;
  width: 2.1em;
  height: 2.1em;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, #2C2461 0 62%, transparent 63%),
    conic-gradient(#FFC857 calc(var(--p) * 1turn), rgba(233, 227, 255, 0.18) 0);
  color: #FFC857;
  font-size: 0.95em;
  font-weight: 700;
  line-height: 1;
}

#hud-mult.bump,
.chip.bump { animation: mult-pop 0.26s ease-out; }

@keyframes mult-pop {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.32); }
  100% { transform: scale(1); }
}

/* ---- instructions overlay ---- */

#instructions-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(18, 14, 46, 0.72);
}

#instructions-overlay .panel {
  width: min(72%, 34em);
  background: #2C2461;
  border: 0.2em solid #1A1440;
  border-radius: 1.1em;
  padding: 1.4em 1.8em 1.5em;
  color: #FFF3DC;
  text-align: center;
  box-shadow: 0 0.6em 2em rgba(0, 0, 0, 0.35);
}

#instructions-overlay h2 {
  font-size: 1.5em;
  font-weight: 700;
  color: #FFC857;
  margin-bottom: 0.3em;
}

#instructions-overlay .lede {
  font-size: 0.86em;
  font-weight: 500;
  color: #BBA9F0;
  line-height: 1.4;
  margin-bottom: 1.1em;
}

/* device-adaptive control lists: only one shows, set by #stage's input class */
.ctl { display: none; }
#stage.input-desktop .ctl-desktop { display: block; }
#stage.input-touch .ctl-mobile { display: block; }

.ctl-row {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 0.5em 0;
  text-align: left;
}

.cap {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2em;
  height: 2em;
  padding: 0 0.5em;
  background: #1A1440;
  border: 0.13em solid #4FE0C2;
  border-radius: 0.5em;
  color: #FFF3DC;
  font-size: 0.9em;
  font-weight: 700;
}

.lbl { font-size: 0.9em; font-weight: 500; color: #FFF3DC; }

.note {
  font-size: 0.74em;
  font-weight: 500;
  color: #BBA9F0;
  line-height: 1.35;
  margin-top: 0.8em;
}

#instructions-close {
  font: inherit;
  font-size: 1em;
  font-weight: 700;
  color: #07382C;
  background: #4FE0C2;
  border: 0.2em solid #1A1440;
  border-radius: 999px;
  padding: 0.4em 1.8em;
  margin-top: 1.2em;
  cursor: pointer;
}

#instructions-close:active { transform: scale(0.96); }

/* ---- title screen ---- */

#title-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9em;
}

.logo { width: 44%; }

.tagline {
  color: #BBA9F0;
  font-size: 0.95em;
  font-weight: 700;
  margin-top: -0.8em;
}

/* Sparkling border: something new to look at. The title's hangar button and
   the hangar card of a trail the Konami code just unlocked. A gold/pink/mint
   gradient runs round the border while a star twinkles on the corner. */
@property --sparkle-angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

.sparkle {
  position: relative;
  animation: sparkle-glow 1.6s ease-in-out infinite;
}

.sparkle::before {
  content: '';
  position: absolute;
  inset: -0.22em;
  padding: 0.18em;
  border-radius: inherit;
  background: conic-gradient(from var(--sparkle-angle), #FFC857, #FF9EC4, #4FE0C2, #BBA9F0, #FFC857);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: sparkle-spin 2.4s linear infinite;
  pointer-events: none;
}

.sparkle::after {
  content: '✦';
  position: absolute;
  top: -0.7em;
  right: -0.35em;
  color: #FFF3DC;
  font-size: 1.1em;
  line-height: 1;
  text-shadow: 0 0 0.4em #FFC857;
  animation: sparkle-twinkle 1.2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes sparkle-spin { to { --sparkle-angle: 360deg; } }
@keyframes sparkle-glow {
  0%, 100% { box-shadow: 0 0 0.3em rgba(255, 200, 87, 0.25); }
  50%      { box-shadow: 0 0 0.9em rgba(255, 200, 87, 0.6); }
}
@keyframes sparkle-twinkle {
  0%, 100% { opacity: 0.35; transform: scale(0.7) rotate(0deg); }
  50%      { opacity: 1;    transform: scale(1.15) rotate(20deg); }
}

/* While the hangar button sparkles, a gold label makes it the thing to press. */
#hangar-btn.sparkle { color: #FFC857; }

/* Konami code accepted (title.js) */
.tagline.is-secret {
  color: #FFC857;
  animation: mult-pop 0.4s ease-out;
}

#play-btn {
  font: inherit;
  font-size: 1.3em;
  font-weight: 700;
  color: #07382C;
  background: #4FE0C2;
  border: 0.22em solid #2C2461;
  border-radius: 999px;
  padding: 0.4em 2em;
  cursor: pointer;
  margin-top: 0.4em;
}

#play-btn:active { transform: scale(0.96); }

.title-link {
  font: inherit;
  font-size: 0.9em;
  font-weight: 700;
  color: #4FE0C2;
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  padding: 0.2em 0.4em;
}

.title-link:active { transform: scale(0.96); }

.title-stubs { display: flex; gap: 1.2em; }

.stub {
  font: inherit;
  font-size: 0.85em;
  font-weight: 700;
  color: #BBA9F0;
  background: none;
  border: 2px solid #3A2D78;
  border-radius: 999px;
  padding: 0.35em 1.4em;
  opacity: 0.8;
}

/* ---- dev panel (Cmd+/ or Ctrl+/) ----
   Follows space-captain's devtools panel. Never visible unless opened. */

#dev-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 310px;
  max-height: 88vh;
  overflow-y: auto;
  background: #140F33;
  border: 1px solid #4FE0C2;
  border-radius: 10px;
  z-index: 200;
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.6);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  color: #FFF3DC;
}

.dev-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(79, 224, 194, 0.12);
  border-bottom: 1px solid #2C2461;
  letter-spacing: 1px;
  font-weight: 700;
}

.dev-header button {
  background: none;
  border: none;
  color: #FFF3DC;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  padding: 2px 4px;
}

.dev-body { padding: 10px 12px 14px; }

.dev-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 8px;
  margin-bottom: 10px;
  background: #0E0A24;
  border: 1px solid #2C2461;
  border-radius: 6px;
}

.dev-readout span { white-space: nowrap; }
.dev-readout em {
  font-style: normal;
  color: #9A8FD0;
  margin-right: 5px;
}

.dev-section { margin-top: 12px; }

.dev-section h3 {
  margin: 0 0 6px;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #4FE0C2;
}

.dev-hint {
  margin: 6px 0 0;
  color: #9A8FD0;
  line-height: 1.45;
}

.dev-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}

.dev-grid button {
  background: #2C2461;
  border: 1px solid #3A2D78;
  border-radius: 5px;
  color: #FFF3DC;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  padding: 6px 4px;
  transition: background 0.12s;
}

.dev-grid button:hover { background: #3A2D78; }
.dev-grid button.dev-ok { animation: dev-ok 0.45s ease-out; }
.dev-grid button.dev-fail { animation: dev-fail 0.45s ease-out; }

@keyframes dev-ok   { 0% { background: #4FE0C2; color: #07382C; } 100% { background: #2C2461; } }
@keyframes dev-fail { 0% { background: #FF9EC4; color: #2C2461; } 100% { background: #2C2461; } }

.dev-check {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  cursor: pointer;
  line-height: 1.35;
}

.dev-field {
  display: grid;
  grid-template-columns: 1fr 100px 40px;
  align-items: center;
  gap: 7px;
  margin-top: 5px;
}

.dev-field input[type="range"] { width: 100%; accent-color: #4FE0C2; }
.dev-field output { text-align: right; color: #4FE0C2; }
.dev-field select { grid-column: 2 / 4; font: inherit; font-size: 11px; background: #1A1440; color: #FFF3DC; border: 1px solid #3A2D78; border-radius: 4px; }

/* ---- game-over / run summary (plan §4.7) ----
   Tone is "one more run", never punishing: the banked total leads, the
   headline is encouraging, and Fly again is the obvious primary action. */

#gameover-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(18, 14, 46, 0.72);
  z-index: 20;
}

#gameover-overlay .panel {
  width: min(78%, 30em);
  padding: 1.6em 2em 1.8em;
  background: #2C2461;
  border: 4px solid #1A1440;
  border-radius: 1.1em;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
  text-align: center;
}

#go-headline {
  margin: 0;
  font-size: 2em;
  font-weight: 700;
  color: #FFC857;
}

#go-headline.is-best { color: #4FE0C2; }

.go-sub {
  margin: 0.25em 0 0;
  color: #BBA9F0;
  font-size: 0.95em;
  min-height: 1.2em;
}

.go-banked {
  font-variant-numeric: tabular-nums;   /* see .chip */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  margin: 0.9em 0 0.2em;
  font-size: 2.1em;
  font-weight: 700;
  color: #FFF3DC;
}

.go-coin {
  width: 0.8em;
  height: 0.8em;
  border-radius: 50%;
  background: #FFC857;
  border: 0.14em solid #B97712;
}

.go-banked-label {
  font-size: 0.42em;
  font-weight: 500;
  color: #BBA9F0;
  letter-spacing: 0.04em;
}

.go-stats {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35em 1em;
  margin: 1.1em 0 1.3em;
  text-align: left;
  font-size: 0.95em;
}

.go-stats dt { color: #BBA9F0; }
.go-stats dd { margin: 0; text-align: right; font-weight: 700; color: #FFF3DC; }

.go-buttons {
  display: flex;
  gap: 0.6em;
  justify-content: center;
  flex-wrap: wrap;
}

.go-primary,
.go-secondary {
  font-family: inherit;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  padding: 0.6em 1.5em;
  font-size: 1em;
  border: 3px solid #1A1440;
  transition: transform 0.08s, filter 0.12s;
}

.go-primary { background: #4FE0C2; color: #07382C; }
.go-secondary { background: #3A2D78; color: #FFF3DC; }
.go-primary:hover, .go-secondary:hover:not(:disabled) { filter: brightness(1.08); }
.go-primary:active, .go-secondary:active:not(:disabled) { transform: translateY(2px); }
.go-secondary:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---- M6: puff-shield HUD chip ---- */
.chip-shield {
  width: 1.05em;
  height: 1.05em;
  border-radius: 50%;
  background: #E9E3FF;
  box-shadow: 0.35em -0.1em 0 -0.12em #E9E3FF, -0.3em 0.05em 0 -0.18em #E9E3FF;
}
#hud-shield.is-empty { opacity: 0.55; }
#hud-shield { padding: 0.2em 0.6em; }
#hud-shield-icons { display: inline-flex; gap: 0.75em; padding: 0 0.3em; }
#hud-shield-n:empty { display: none; }

/* Title's hangar button is live now; the star chart stub stays disabled. */
#hangar-btn { cursor: pointer; opacity: 1; color: #FFF3DC; border-color: #BBA9F0; }
#hangar-btn:hover { filter: brightness(1.12); }

/* ---- M6: the hangar (layout after prototypes/tappy_ship_hangar_shop_screen.html) ---- */
#hangar-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 1.6%;
  background: rgba(18, 14, 46, 0.55);
  z-index: 20;
}

.hg-panel {
  /* Sized by its content: a max-height here clipped the footer and pushed
     Fly past the panel's bottom edge (playtest catch, 2026-10-16). */
  width: 92%;
  padding: 1em 1.4em 1.1em;
  background: rgba(26, 20, 64, 0.94);
  border: 3px solid #2C2461;
  border-radius: 1.1em;
  color: #FFF3DC;
  display: flex;
  flex-direction: column;
}

.hg-head { display: flex; align-items: center; gap: 0.6em; }
.hg-head h2 { flex: 1; margin: 0; font-size: 1.5em; }
.hg-wallet { font-size: 0.95em; }

.hg-back {
  width: 1.9em;
  height: 1.9em;
  border-radius: 50%;
  border: none;
  background: #2C2461;
  color: #BBA9F0;
  font: inherit;
  font-size: 1.2em;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.hg-section { margin: 0.7em 0 0.4em; font-size: 1em; }

/* One row however many cards there are: the unlocked Lucky stars trail makes
   five, and a second row pushed Fly off the bottom of the stage. */
.hg-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0.7em;
}

.hg-card {
  background: #241B56;
  border: 2px solid #3A2D78;
  border-radius: 1em;
  padding: 0.6em 0.75em 0.7em;
  display: flex;
  flex-direction: column;
  gap: 0.15em;
  min-width: 0;
}
.hg-card.is-equipped { border-color: #4FE0C2; }
.hg-card.is-soon { opacity: 0.6; border-style: dashed; }

.hg-card h4 { margin: 0.2em 0 0; font-size: 1em; }
.hg-swatch { width: 100%; height: 2.6em; }
.hg-perk { margin: 0; font-size: 0.78em; color: #BBA9F0; display: flex; align-items: center; gap: 0.5em; }
.hg-now { margin: 0; font-size: 0.78em; line-height: 1.3; }
.hg-next { margin: 0; font-size: 0.72em; line-height: 1.3; color: #BBA9F0; }

.hg-pips { display: inline-flex; gap: 0.25em; }
.hg-pips i {
  width: 0.75em;
  height: 0.75em;
  border-radius: 50%;
  border: 0.15em solid #4FE0C2;
}
.hg-pips i.on { background: #4FE0C2; }

.hg-actions { display: flex; gap: 0.4em; margin-top: auto; padding-top: 0.45em; flex-wrap: wrap; }

.hg-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3em;
  font: inherit;
  font-size: 0.8em;
  font-weight: 700;
  border-radius: 999px;
  padding: 0.3em 0.8em;
  border: 2px solid #3A2D78;
  background: #2C2461;
  color: #FFF3DC;
  cursor: pointer;
  white-space: nowrap;
}
.hg-btn:hover:not(:disabled) { filter: brightness(1.15); }
.hg-btn:active:not(:disabled) { transform: translateY(1px); }
.hg-btn:disabled { cursor: default; opacity: 0.5; }
.hg-buy, .hg-up { border-color: #FFC857; }
.hg-equip { background: #4FE0C2; color: #07382C; border-color: #4FE0C2; }
.hg-equipped:disabled { opacity: 1; color: #4FE0C2; background: none; border-color: #4FE0C2; }
.hg-maxed:disabled { opacity: 0.7; }

.hg-coin, .hg-gem { display: inline-block; width: 0.85em; height: 0.85em; }
.hg-coin { border-radius: 50%; background: #FFC857; border: 2px solid #B97712; }
.hg-gem { background: #4FE0C2; border: 2px solid #168F77; transform: rotate(45deg) scale(0.85); border-radius: 2px; }

.hg-ability { flex-direction: row; align-items: center; gap: 0.8em; }
.hg-ability > div:nth-child(2) { flex: 1; }
.hg-ability .hg-actions { margin-top: 0; padding-top: 0; flex: 0 0 auto; min-width: 9em; }
.hg-icon { width: 2.6em; height: 2.6em; flex: 0 0 auto; }

.hg-foot { display: flex; align-items: center; gap: 1em; margin-top: 0.8em; }
.hg-msg { flex: 1; margin: 0; min-height: 1.3em; font-size: 0.9em; color: #FFC857; }
