/* missilecalculator.com — 8-bit arcade UI. Font: Press Start 2P (SIL OFL 1.1), self-hosted. */
@font-face {
  font-family: "PressStart";
  src: url("../assets/fonts/press-start-2p.woff2") format("woff2"),
       url("../assets/fonts/press-start-2p.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #04061a; --bg1: #070d2b; --bg2: #0b1640; --bg3: #122463;
  --red: #ff3b5c; --orange: #ff9a3c; --yellow: #ffe14d; --green: #3cff7a; --cyan: #3ce6ff;
  --white: #f4f7ff; --purple: #a35cff; --pink: #ff6ad5; --grey: #5a6488; --dark: #1a2350;
  --font: "PressStart", ui-monospace, "Courier New", monospace;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #010208; color: var(--white);
  font-family: var(--font); font-size: 10px; line-height: 1.6;
  -webkit-font-smoothing: none; font-smooth: never;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none; touch-action: manipulation;
}
body {
  overflow: hidden;
  background-color: #010208;
  background-image: radial-gradient(#0b1640 1px, transparent 1px);
  background-size: 8px 8px;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; }
a { color: var(--cyan); }

/* phone-shaped column, centered on desktop */
#app {
  position: relative; margin: 0 auto; width: 100%; max-width: 430px;
  height: 100vh; height: 100dvh; overflow: hidden; background: var(--bg);
}
@media (min-width: 600px) and (min-height: 700px) {
  #app { height: min(100dvh - 32px, 932px); margin-top: 16px; border: 3px solid var(--bg3); box-shadow: 0 0 0 3px #000, 0 0 40px rgba(60, 230, 255, .12); }
}
/* CRT scanlines + vignette (pointer-events: none) */
#app::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 90;
  background:
    repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,.16) 2px, rgba(0,0,0,.16) 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 60%, rgba(0,0,0,.35) 100%);
}

.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px;
  padding: calc(var(--sat) + 14px) calc(var(--sar) + 16px) calc(var(--sab) + 14px) calc(var(--sal) + 16px);
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
}
.screen-game { padding: var(--sat) var(--sar) var(--sab) var(--sal); overflow: hidden; touch-action: none; background: var(--bg); }
#game {
  display: block; width: 100%; height: 100%; object-fit: contain;
  image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}

/* mute */
.mute {
  position: absolute; z-index: 80; top: calc(var(--sat) + 8px); right: calc(var(--sar) + 8px);
  width: 36px; height: 36px; display: grid; place-items: center;
  background: rgba(4,6,26,.7); border: 2px solid var(--bg3); padding: 0;
}
body[data-screen="game"] .mute { display: none; } /* HUD lives there; mute from menus */
.pix { display: inline-block; vertical-align: middle; image-rendering: pixelated; }

/* ---------- blink ---------- */
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }
.blink { animation: blink 1s steps(1) infinite; }
@media (prefers-reduced-motion: reduce) { .blink { animation: none; } }

/* ---------- buttons ---------- */
.btn {
  display: block; width: 100%; padding: 14px 10px; border: 3px solid var(--white);
  background: var(--bg2); color: var(--white); font-size: 12px; letter-spacing: 1px; text-align: center;
  box-shadow: 0 4px 0 #000; position: relative; min-height: 48px;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-go { background: var(--green); color: #04110a; border-color: #b8ffd0; }
.btn-alt { background: var(--bg3); border-color: var(--cyan); color: var(--cyan); font-size: 10px; }
.btn-pink { background: var(--pink); color: #2a0420; border-color: #ffc4ef; }
.btn-ghost { background: transparent; border-color: var(--grey); color: var(--grey); box-shadow: none; font-size: 10px; min-height: 40px; padding: 10px; }
.btn-sm { width: auto; padding: 8px 10px; font-size: 8px; min-height: 0; border-width: 2px; background: var(--bg3); border-color: var(--cyan); color: var(--cyan); }
.btn-launch {
  margin-top: auto; background: var(--red); border-color: #ffc0cb; color: var(--white);
  font-size: 24px; padding: 18px 10px; text-shadow: 3px 3px 0 #6a0a1e;
}
.btn-launch:not(:disabled) { animation: pulse 1.2s steps(2) infinite; }
@keyframes pulse { 50% { background: #ff6680; } }
.menu-row { display: flex; gap: 10px; }
.menu-row .btn { flex: 1; }

/* ---------- title ---------- */
#scr-title { justify-content: space-between; }
#attract { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; z-index: 0; opacity: .9; }
.title-wrap, #scr-title .foot { position: relative; z-index: 1; }
.title-wrap { display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; margin-top: 28px; }
.logo { margin: 0; line-height: 1.15; display: flex; flex-direction: column; gap: 8px; }
.logo .l1 { font-size: clamp(32px, 11vw, 44px); color: var(--yellow); text-shadow: 3px 3px 0 var(--red), 6px 6px 0 var(--bg3); }
.logo .l2 { font-size: clamp(22px, 7.6vw, 32px); color: var(--white); text-shadow: 3px 3px 0 var(--cyan), 6px 6px 0 var(--bg3); }
.domain { margin: 0; color: var(--cyan); font-size: 8px; letter-spacing: 1px; }
.tag { margin: 0; color: var(--green); font-size: 12px; }
.menu { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.btn-daily { background: var(--yellow); color: #201800; border-color: #fff4b0; display: flex; flex-direction: column; gap: 6px; align-items: center; font-size: 14px; }
.btn-daily.pulse { animation: pulseY 1s steps(2) infinite; }
@keyframes pulseY { 50% { background: #fff4b0; } }
.btn-daily.done { background: #6b5e1a; color: var(--yellow); border-color: var(--yellow); }
.b-main { display: block; }
.b-sub { display: block; font-size: 8px; opacity: .9; }
.streak { color: #a33a00; }
.btn-daily.done .streak { color: var(--orange); }
.challenge-banner {
  border: 3px dashed var(--pink); background: #2a0420; color: var(--pink); padding: 12px 8px; font-size: 10px; line-height: 1.8;
  display: flex; flex-direction: column; gap: 4px; align-items: center;
}
.challenge-banner b { color: var(--white); font-weight: normal; }
.level-chip { margin: 0; font-size: 8px; color: var(--grey); display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.bar { display: inline-block; width: 70px; height: 8px; background: var(--dark); border: 1px solid var(--grey); vertical-align: middle; }
.bar i { display: block; height: 100%; background: var(--cyan); }
.league-chip { margin: 0; font-size: 9px; color: var(--cyan); display: flex; flex-direction: column; gap: 4px; }
.league-chip b { color: var(--white); font-weight: normal; }
.league-chip .b-sub { color: var(--yellow); font-size: 8px; }
.btn-go .b-sub { color: #0a4a22; margin-top: 4px; }
.setup-mode { margin: 0; font-size: 8px; color: var(--grey); text-align: center; }
.setup-mode.ranked { color: var(--yellow); }
.b-home { color: var(--yellow); }
.res-league { border: 2px solid var(--bg3); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.lg-main { font-size: 12px; }
.lg-sub { font-size: 8px; color: var(--grey); line-height: 1.8; }
.lg-up .lg-main { color: var(--green); }
.lg-flat .lg-main { color: var(--white); }
.insert { margin: 0; color: var(--grey); font-size: 8px; }

/* ---------- footer ---------- */
.foot { font-size: 7px; line-height: 1.8; color: var(--grey); text-align: center; padding-top: 8px; }
.foot p { margin: 0 0 4px; }
.foot a { color: var(--cyan); }

/* ---------- headers ---------- */
.bar-head { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--yellow); padding-right: 40px; min-height: 36px; }
.back { background: var(--bg3); border: 2px solid var(--cyan); color: var(--cyan); width: 36px; height: 36px; padding: 0; font-size: 12px; }

/* ---------- setup ---------- */
.pickers { display: flex; flex-direction: column; gap: 12px; }
.picker {
  display: flex; gap: 12px; align-items: stretch; text-align: left; width: 100%;
  background: var(--bg1); border: 3px solid var(--bg3); padding: 12px; min-height: 84px; box-shadow: 0 4px 0 #000;
}
.picker:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.picker.set { border-color: var(--green); }
.picker:disabled { opacity: .4; }
.pk-num { font-size: 24px; color: var(--yellow); min-width: 28px; text-shadow: 2px 2px 0 var(--red); }
.pk-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1; }
.pk-label { font-size: 8px; color: var(--cyan); }
.pk-val { font-size: 12px; color: var(--white); line-height: 1.5; word-break: break-word; }
.pk-sub { font-size: 8px; color: var(--grey); line-height: 1.6; }
.def-row { background: transparent; border: 2px dashed var(--bg3); color: var(--grey); font-size: 8px; padding: 10px; text-align: left; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.def-row b { color: var(--white); font-weight: normal; }
.def-row .chev { margin-left: auto; color: var(--cyan); }

/* badges */
.badge { display: inline-block; font-size: 7px; padding: 3px 4px 2px; border: 1px solid currentColor; vertical-align: middle; line-height: 1; letter-spacing: 0; }
.b-state { color: var(--cyan); } .b-group { color: var(--orange); } .b-status { color: var(--grey); } .b-good { color: var(--green); }
.b-icbm, .b-slbm { color: var(--red); } .b-hgv { color: var(--purple); } .b-drone { color: var(--orange); }
.b-cruise { color: var(--cyan); } .b-rocket { color: var(--yellow); } .b-irbm, .b-mrbm, .b-srbm { color: var(--pink); }

/* ---------- sheet ---------- */
.sheet { position: absolute; inset: 0; z-index: 70; background: rgba(1,2,8,.75); display: flex; align-items: flex-end; }
.sheet-panel {
  width: 100%; max-height: 88%; display: flex; flex-direction: column; background: var(--bg1);
  border-top: 3px solid var(--cyan); padding-bottom: var(--sab);
}
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; font-size: 12px; color: var(--yellow); border-bottom: 2px solid var(--bg3); }
.x { background: none; border: 2px solid var(--grey); color: var(--white); width: 40px; height: 40px; font-size: 16px; padding: 0; }
.sheet-body { overflow-y: auto; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.search {
  width: 100%; font-family: var(--font); font-size: 16px; /* >=16px: no iOS zoom */
  padding: 12px; background: #000; color: var(--white); border: 3px solid var(--cyan); border-radius: 0; -webkit-appearance: none; appearance: none;
}
.search::placeholder { color: var(--grey); }
.note { margin: 0; font-size: 8px; color: var(--grey); line-height: 1.8; }
.status { margin: 0; font-size: 8px; color: var(--orange); min-height: 1em; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.item {
  width: 100%; text-align: left; background: var(--bg2); border: 2px solid var(--bg3); padding: 12px;
  display: flex; flex-direction: column; gap: 6px; min-height: 48px;
}
.item:active { border-color: var(--green); background: var(--bg3); }
.it-name { font-size: 11px; color: var(--white); line-height: 1.6; }
.it-nick { font-size: 8px; color: var(--yellow); }
.it-range { font-size: 8px; color: var(--cyan); }
.it-sub { font-size: 8px; color: var(--grey); line-height: 1.7; }

/* ---------- result ---------- */
#scr-result { text-align: center; gap: 10px; }
.res-mode { margin: 0; color: var(--yellow); font-size: 10px; padding-right: 40px; padding-left: 40px; }
.verdict { margin: 8px 0 0; display: flex; flex-direction: column; gap: 10px; font-weight: normal; }
.verdict .pre { font-size: 12px; }
.verdict .big { font-size: clamp(18px, 6.4vw, 26px); line-height: 1.3; }
.v-alive .pre { color: var(--yellow); } .v-alive .big { color: var(--green); text-shadow: 3px 3px 0 #0a4a22; }
.v-dead .pre { color: var(--white); } .v-dead .big { color: var(--red); text-shadow: 3px 3px 0 #4a0a16; }
.v-out_of_range .pre { color: var(--orange); } .v-out_of_range .big { color: var(--green); text-shadow: 3px 3px 0 #0a4a22; }
.res-sprite { display: flex; justify-content: center; min-height: 40px; }
.res-sprite canvas { image-rendering: pixelated; animation: bob 1.2s steps(4) infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.res-challenge { margin: 0; font-size: 10px; color: var(--pink); line-height: 1.8; }
.stats { margin: 0; display: grid; grid-template-columns: 1fr; gap: 6px; text-align: left; background: var(--bg1); border: 2px solid var(--bg3); padding: 12px; }
.stats div { display: flex; justify-content: space-between; gap: 10px; font-size: 8px; }
.stats dt { color: var(--grey); flex-shrink: 0; }
.stats dd { margin: 0; color: var(--white); text-align: right; word-break: break-word; }
.res-xp { border: 2px solid var(--cyan); padding: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 10px; }
.xp-line { color: var(--cyan); }
.xp-parts { display: block; color: var(--grey); font-size: 7px; margin-top: 4px; }
.xp-bar { font-size: 8px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.levelup { color: var(--yellow); font-size: 12px; }
.unlock { color: var(--green); font-size: 9px; border: 2px dashed var(--green); padding: 8px; }
.unlock b { color: var(--white); font-weight: normal; }
.res-social { font-size: 9px; color: var(--yellow); display: flex; flex-direction: column; gap: 6px; line-height: 1.8; }
.res-care { margin: 0; font-size: 7px; color: var(--grey); line-height: 1.8; opacity: .8; }
.res-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }

/* ---------- armory ---------- */
.arm-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.def { display: flex; gap: 10px; background: var(--bg1); border: 2px solid var(--bg3); padding: 10px; align-items: flex-start; }
.def.equipped { border-color: var(--green); }
.def.locked { opacity: .5; filter: grayscale(1); }
.def-ico { flex-shrink: 0; width: 40px; display: flex; justify-content: center; padding-top: 2px; }
.def-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.def-name { font-size: 10px; color: var(--white); line-height: 1.5; }
.def-meta { font-size: 7px; color: var(--grey); }
.def-stats { display: flex; flex-direction: column; gap: 3px; }
.stat { display: flex; align-items: center; gap: 6px; font-size: 7px; }
.st-k { width: 40px; color: var(--cyan); }
.st-bar { flex: 1; max-width: 100px; height: 6px; background: var(--dark); }
.st-bar i { display: block; height: 100%; background: var(--cyan); }
.def-special { font-size: 7px; color: var(--pink); }
.def-good { font-size: 7px; color: var(--green); }
.def-blurb { font-size: 7px; color: var(--grey); line-height: 1.7; }
.def-lock { font-size: 8px; color: var(--grey); }
.def-act { flex-shrink: 0; }

/* ---------- leaderboard ---------- */
.tabs { display: flex; gap: 6px; }
.tabs button { flex: 1; background: var(--bg1); border: 2px solid var(--bg3); color: var(--grey); padding: 10px 4px; font-size: 8px; min-height: 40px; }
.tabs button.on { border-color: var(--yellow); color: var(--yellow); background: var(--bg2); }
.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.board-list .row { display: flex; gap: 8px; align-items: center; background: var(--bg1); padding: 8px; font-size: 9px; }
.board-list .row:nth-child(1) .r-rank { color: var(--yellow); }
.board-list .row:nth-child(2) .r-rank { color: var(--white); }
.board-list .row:nth-child(3) .r-rank { color: var(--orange); }
.r-rank { width: 28px; color: var(--grey); }
.r-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; word-break: break-word; }
.r-name small { font-size: 7px; color: var(--grey); }
.r-val { color: var(--green); }
.board-msg { text-align: center; color: var(--grey); font-size: 10px; padding: 30px 0; line-height: 2; }

/* ---------- initials ---------- */
.overlay { position: absolute; inset: 0; z-index: 75; background: rgba(1,2,8,.88); display: grid; place-items: center; padding: 16px; }
.ini-panel { width: 100%; max-width: 320px; background: var(--bg1); border: 3px solid var(--yellow); padding: 18px 16px; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.ini-title { margin: 0; font-size: 16px; color: var(--yellow); }
.ini-sub { margin: 0; font-size: 8px; color: var(--cyan); }
.ini-slots { display: flex; justify-content: center; gap: 14px; }
.ini-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.ini-slot .ini-ch { font-size: 32px; color: var(--white); width: 48px; padding: 6px 0; border-bottom: 4px solid var(--grey); }
.ini-slot.on .ini-ch { color: var(--yellow); border-color: var(--yellow); }
.ini-arrow { background: var(--bg3); border: 2px solid var(--cyan); color: var(--cyan); width: 48px; height: 40px; font-size: 12px; padding: 0; }
.ini-msg { margin: 0; color: var(--red); font-size: 8px; min-height: 1em; }

/* ---------- toast ---------- */
.toast {
  position: absolute; z-index: 85; left: 16px; right: 16px; bottom: calc(var(--sab) + 18px);
  background: var(--bg); border: 2px solid var(--yellow); color: var(--yellow); padding: 12px; font-size: 9px; text-align: center;
}
.noscript { padding: 40px 16px; text-align: center; }

@media (max-width: 360px) {
  html, body { font-size: 9px; }
  .btn { font-size: 11px; }
  .btn-launch { font-size: 20px; }
}
