/* ===== Star Read ===== */

@font-face {
  font-family: "Lexend";
  src: url("../assets/fonts/Lexend-Regular.ttf") format("truetype");
  font-weight: 400;
}
@font-face {
  font-family: "Lexend";
  src: url("../assets/fonts/Lexend-Bold.ttf") format("truetype");
  font-weight: 700;
}
@font-face {
  font-family: "Andika";
  src: url("../assets/fonts/Andika-Regular.ttf") format("truetype");
  font-weight: 400;
}
@font-face {
  font-family: "Andika";
  src: url("../assets/fonts/Andika-Bold.ttf") format("truetype");
  font-weight: 700;
}
@font-face {
  font-family: "KenneyFuture";
  src: url("../assets/fonts/KenneyFuture.ttf") format("truetype");
}

:root {
  --navy: #0b1026;
  --navy-2: #141b3a;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-2: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.16);
  --text: #f4f6ff;
  --muted: #9aa3c7;
  --cyan: #22d3ee;
  --orange: #f97316;
  --yellow: #facc15;
  --green: #4ade80;
  --red: #f87171;
  --text-scale: 1;              /* settings: text size */
  --read-base: 32px;
  --read-size: calc(var(--read-base) * var(--text-scale));
  --reading-font: "Lexend";     /* settings: Lexend or Andika */
  --display: "KenneyFuture", "Lexend", sans-serif;
  --body: var(--reading-font), "Lexend", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--body);
  font-size: calc(16px * var(--text-scale));
  color: var(--text);
  background: var(--navy) url("../assets/img/bg.png") repeat;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

#app {
  max-width: 720px;
  height: 100%;
  margin: 0 auto;
  position: relative;
}

.screen {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  display: none;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(12px, env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; min-height: 56px;
}
.logo {
  font-family: var(--display);
  font-size: 28px; margin: 0; letter-spacing: 1px;
  color: var(--yellow);
  text-shadow: 0 3px 0 rgba(0,0,0,0.4);
}
.screen-title { font-family: var(--display); font-size: 22px; margin: 0; }
.stars-pill, .streak-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 2px solid var(--line);
  border-radius: 999px; padding: 6px 14px;
  font-weight: 700; font-size: 20px;
}
.stars-pill img { width: 24px; height: 24px; }
.icon-btn {
  width: 56px; height: 56px; border-radius: 16px;
  border: 2px solid var(--line); background: var(--panel);
  font-size: 22px;
}
.icon-btn:active { background: var(--panel-2); }

/* ---------- Home ---------- */
.hangar {
  display: flex; flex-direction: column; align-items: center;
  padding: 8px 0 4px;
}
.rank-badge {
  font-family: var(--display); font-size: 18px; letter-spacing: 1px;
  color: var(--navy); background: var(--cyan);
  padding: 6px 18px; border-radius: 999px;
  box-shadow: 0 4px 0 #0e7490;
}
.hangar-ship {
  width: 150px; margin: 10px 0 6px;
  animation: bob 3s ease-in-out infinite;
  filter: drop-shadow(0 12px 12px rgba(0,0,0,0.5));
}
.ship-btn { background: none; border: none; padding: 0; position: relative; display: flex; flex-direction: column; align-items: center; }
.ship-btn:active .hangar-ship { transform: scale(0.95); }
.ship-name small { font-weight: 400; font-size: 12px; opacity: 0.7; }
.rank-progress {
  width: 200px; height: 12px; margin-top: 10px; border-radius: 999px;
  background: rgba(0,0,0,0.35); border: 2px solid var(--line); padding: 2px;
}
.rank-progress span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--yellow), var(--orange)); transition: width 0.6s; }
.rank-next { font-size: 13px; color: var(--muted); margin-top: 4px; }
.rank-badge.big { font-size: 26px; padding: 10px 28px; }

/* ---------- Prizes ---------- */
.drift-layer { position: absolute; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#screen-home > .topbar, #screen-home > .hangar, #screen-home > .mode-grid, #screen-home > .homebar, #screen-home > .full-mission { position: relative; z-index: 1; }
.drift {
  position: absolute; width: 44px; height: 44px; object-fit: contain; pointer-events: auto; cursor: pointer;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}
.drift.r2 { width: 52px; height: 52px; }
.drift.r3 { width: 60px; height: 60px; filter: drop-shadow(0 0 10px rgba(250,204,21,0.6)); }
@keyframes driftx { from { margin-left: -30px; } to { margin-left: 30px; } }
@keyframes drifty { from { margin-top: -14px; } to { margin-top: 14px; } }
.cameo { position: absolute; left: 0; width: 40px; height: 40px; object-fit: contain; pointer-events: none; opacity: 0; z-index: 0; }
.full-mission {
  display: flex; align-items: center; gap: 12px; width: 100%; margin-top: 14px;
  padding: 10px 14px; border-radius: 20px; text-align: left;
  background: linear-gradient(90deg, #1e3a8a, #0e7490); border: 3px solid var(--cyan);
  box-shadow: 0 6px 0 #164e63;
}
.full-mission:active { transform: translateY(4px); box-shadow: 0 2px 0 #164e63; }
.fm-icon { font-size: 34px; }
.full-mission.test-flight { background: linear-gradient(90deg, #4c1d95, #1e3a8a); border-color: #a78bfa; box-shadow: 0 6px 0 #312e81; margin-top: 10px; }
.flight-table { width: 100%; border-collapse: collapse; font-size: 14px; margin-bottom: 8px; }
.flight-table td, .flight-table th { padding: 4px; border-bottom: 1px solid var(--line); text-align: left; }
.flight-table th { color: var(--muted); font-weight: 400; }
.fm-text { flex: 1; display: flex; flex-direction: column; }
.fm-text b { font-family: var(--display); font-size: 18px; letter-spacing: 1px; color: var(--yellow); }
.fm-text small { font-size: 13px; color: var(--muted); }
.fm-go { font-family: var(--display); font-size: 18px; background: var(--yellow); color: var(--navy); padding: 8px 14px; border-radius: 12px; }
#screen-prize { justify-content: center; align-items: center; }
.prize-card {
  width: 100%; max-width: 440px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--panel); border: 2px solid var(--yellow); border-radius: 28px; padding: 22px 18px; animation: pop 0.5s;
}
.prize-sub { margin: 0; color: var(--muted); font-size: 15px; text-align: center; }
.prize-choices { display: flex; gap: 10px; width: 100%; }
.prize-choice {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 6px; border-radius: 18px; background: rgba(0,0,0,0.3); border: 3px solid var(--line);
  cursor: pointer; transition: transform 0.1s, border-color 0.2s;
}
.prize-choice:active { transform: scale(0.95); }
.prize-choice img { width: 64px; height: 64px; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0,0,0,0.5)); animation: bob 2.4s ease-in-out infinite; }
.prize-choice .pc-name { font-size: 13px; font-weight: 700; text-align: center; }
.prize-choice .pc-r { font-size: 11px; color: var(--muted); }
.prize-choice.r2 { border-color: #67e8f9; }
.prize-choice.r3 { border-color: var(--yellow); box-shadow: 0 0 14px rgba(250,204,21,0.35); }
.prize-choice.chosen { border-color: var(--green); transform: scale(1.06); }
.prize-choice.faded { opacity: 0.3; pointer-events: none; }
.prize-picked { font-weight: 700; font-size: 18px; color: var(--green); text-align: center; animation: pop 0.4s; }
.levelup.full { background: var(--green); color: var(--navy); }
.prize-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.prize-cell {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 14px;
}
.prize-cell img { width: 40px; height: 40px; object-fit: contain; }
.prize-cell span { font-size: 11px; text-align: center; color: var(--muted); }
.prize-cell.locked img { filter: brightness(0) opacity(0.5); }
.prize-cell.r3:not(.locked) { border-color: var(--yellow); }
.prize-cell.r2:not(.locked) { border-color: #67e8f9; }

/* ---------- Estimate ---------- */
.est-block { background: var(--panel); border: 2px solid var(--line); border-radius: 18px; padding: 12px; }
.est-row { display: flex; align-items: baseline; gap: 12px; }
.est-num { font-family: var(--display); font-size: 40px; color: var(--cyan); }
.est-num.text { font-size: 26px; }
.est-note { font-size: 14px; color: var(--muted); }
.est-chart { width: 100%; height: auto; margin-top: 8px; }

/* ---------- Docking Bay ---------- */
.dock-station { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 0 4px; }
.dock-rule { font-size: 16px; color: var(--muted); text-align: center; }
.dock-target {
  font-family: var(--body); font-size: calc(var(--read-size) + 8px); font-weight: 700; letter-spacing: 1px;
  background: var(--panel); border: 3px solid var(--yellow); color: var(--yellow); border-radius: 18px; padding: 6px 22px;
}
.dock-lane { flex: 1; position: relative; overflow: hidden; border-radius: 20px; background: radial-gradient(ellipse at 0% 50%, rgba(250,204,21,0.10), transparent 55%); }
.dock-lane::before { content: ""; position: absolute; left: 0; top: 10%; bottom: 10%; width: 14px; background: linear-gradient(#67e8f9, #0e7490); border-radius: 0 8px 8px 0; box-shadow: 0 0 14px var(--cyan); }
.dship {
  position: absolute; left: 0; display: flex; align-items: center; gap: 6px; cursor: pointer;
  will-change: transform; transition: opacity 0.4s;
}
.dship img { width: 56px; transform: rotate(-90deg); filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5)); }
.dship span {
  font-size: var(--read-size); font-weight: 700; background: rgba(11,16,38,0.75); padding: 4px 12px; border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.25); white-space: nowrap;
}
.dship.docking { transition: left 0.6s ease-in, opacity 0.6s, transform 0.6s; left: -10% !important; transform: scale(0.6); opacity: 0; }
.dship.docking span { border-color: var(--green); }
.dship.bounce { animation: shake 0.45s; }
.dship.bounce span { border-color: var(--red); }
.dship.gone { transition: opacity 0.5s, transform 0.5s; opacity: 0; transform: translateX(60px); }
.dship.parked { animation: bob 2.4s ease-in-out infinite; }
.dship.parked.v2 { animation-delay: -0.8s; }
.dship.parked.v3 { animation-delay: -1.6s; }
.dship.parked.bounce { animation: shake 0.45s; }
#screen-dock .bolt-bubble { top: auto; bottom: 14px; }
.topbar-right { display: flex; gap: 6px; align-items: center; }
.topbar-right .streak-pill { padding: 4px 10px; font-size: 16px; }
@media (max-width: 440px) { .logo { font-size: 22px; } }
.logo-mark { width: 1.5em; height: 1.5em; vertical-align: -0.35em; margin-right: 0.3em; border-radius: 22%; }
.welcome-card .logo-mark { width: 2.2em; height: 2.2em; display: block; margin: 0 auto 8px; }
.gear.help { right: auto; left: max(10px, env(safe-area-inset-left)); font-family: var(--display); font-size: 20px; color: var(--yellow); }
.howto-card { align-items: center; text-align: center; }
.credits-logo { width: 84px; height: 84px; border-radius: 22%; margin: 0 auto 6px; }
.credits-main { font-size: 18px; line-height: 1.5; margin: 6px 0 10px; }
.credits-list { font-size: 13px; line-height: 1.6; color: var(--muted); margin: 0 0 12px; }
.btn-quiet { background: transparent; border: 2px solid rgba(255,255,255,0.2); color: var(--muted); }
.howto-icon { font-size: 56px; }
.howto-text { font-size: 18px; line-height: 1.5; margin: 0; }

/* ---------- Placement ---------- */
.place-head { text-align: center; }
.place-head .prize-sub { margin-top: 4px; }
.small-btn { font-size: 15px; min-height: 44px; padding: 6px 14px; color: var(--muted); }
#place-result .results-card { margin: auto; }

/* ---------- Flags ---------- */
.flags { display: flex; gap: 10px; margin-bottom: 8px; }
#parent-flags { margin-bottom: 0; }
#parent-flags .flag-btn { width: 48px; height: 34px; }
.flag-btn {
  width: 58px; height: 42px; padding: 3px; border-radius: 10px; background: rgba(0,0,0,0.35);
  border: 3px solid var(--line); opacity: 0.55; cursor: pointer; transition: transform 0.1s, opacity 0.2s;
}
.flag-btn svg { width: 100%; height: 100%; display: block; border-radius: 6px; }
.flag-btn.active { opacity: 1; border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(250,204,21,0.25); }
.flag-btn:active { transform: scale(0.94); }
.set-row input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--cyan); }
.mem-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.mem-chips .chip b { color: var(--cyan); }

/* ---------- Pilot, companion, welcome ---------- */
.pilot-tag { font-family: var(--display); font-size: 13px; letter-spacing: 2px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; }
.companion { width: 64px; height: 64px; }
.companion svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 5px rgba(0,0,0,0.45)); }
.companion.cheer { animation: boltjump 0.45s ease-out 3; }
.companion.groan { animation: boltshake 0.5s ease-in-out; }
.hangar { position: relative; }
.companion-spot { position: absolute; left: calc(50% + 84px); top: 150px; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; z-index: 2; }
.companion-spot .companion-bubble { position: absolute; bottom: 100%; margin-bottom: 4px; white-space: normal; width: 130px; }
.companion-spot .companion { animation: bob 3.4s ease-in-out infinite; }
.companion-spot .companion.cheer { animation: boltjump 0.45s ease-out 3; }
.companion-bubble {
  background: #fff; color: var(--navy); font-size: 13px; font-weight: 700; padding: 6px 10px; border-radius: 12px;
  max-width: 150px; text-align: center; opacity: 0; transition: opacity 0.2s; pointer-events: none;
}
.companion-bubble.show { opacity: 1; }
.companion-row { display: flex; align-items: center; gap: 10px; }
.companion-row .companion { width: 56px; height: 56px; animation: boltjump 0.5s ease-out 4; }
.companion-row .companion-bubble { font-size: 15px; max-width: 240px; }
#unlock-companion { width: 60px; height: 60px; }
.welcome-card {
  width: 100%; max-width: 440px; margin: auto; display: flex; flex-direction: column; gap: 14px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 28px; padding: 22px 20px;
}
#screen-welcome { justify-content: center; align-items: center; overflow-y: auto; }
.welcome-card .logo { text-align: center; }
.unlock-title.small { font-size: 22px; text-align: center; color: var(--cyan); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 15px; color: var(--muted); }
.field input {
  font-family: inherit; font-size: 22px; padding: 12px 14px; border-radius: 14px;
  background: rgba(0,0,0,0.3); color: var(--text); border: 2px solid var(--line); outline: none;
}
.field input:focus { border-color: var(--cyan); }
.companion-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.companion-choice {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px;
  background: rgba(0,0,0,0.3); border: 3px solid var(--line); border-radius: 18px; color: var(--text); font-weight: 700;
}
.companion-choice.selected { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(250,204,21,0.25); }
.companion-choice .companion { width: 64px; height: 64px; }
.set-row.col .set-actions { margin-top: 2px; }
.set-row.col .set-actions .btn { min-height: 44px; font-size: 14px; }

/* ---------- Bolts ---------- */
.bolts-row { display: flex; gap: 6px; justify-content: center; align-items: flex-end; min-height: 56px; }
.bolt { width: 52px; height: 52px; cursor: pointer; position: relative; }
.bolt svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 4px rgba(0,0,0,0.45)); }
.bolt.idle { animation: bob 2.6s ease-in-out infinite; }
.bolt.cheer { animation: boltjump 0.45s ease-out 2; }
.bolt.groan { animation: boltshake 0.5s ease-in-out; }
@keyframes boltjump { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-22px) rotate(-8deg); } }
@keyframes boltshake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-12deg) translateY(4px); } 75% { transform: rotate(12deg) translateY(4px); } }
.bolts-row.named .bolt { width: 72px; height: 88px; }
.bolts-row.named .bolt svg { height: 72px; }
.bolt-name { display: block; width: 100%; text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); background: none; border: 0; padding: 2px 0; font-family: inherit; cursor: pointer; }
.bolt-name:hover, .bolt-name:focus { color: var(--yellow); }
.flag-sm { display: inline-block; width: 20px; height: 14px; vertical-align: -2px; margin-right: 4px; }
.flag-sm svg { width: 100%; height: 100%; display: block; border-radius: 2px; }
.bolt-rename { display: block; width: 84px; margin: 0 auto; text-align: center; font-size: 14px; font-weight: 700; font-family: inherit; padding: 3px 4px; border-radius: 8px; border: 2px solid var(--cyan); background: var(--panel); color: #fff; }
.bolts-row.named .bolt { width: 88px; height: 96px; }
#home-bolts { position: absolute; right: 100%; bottom: 10px; margin-right: 4px; gap: 2px; }
@media (max-width: 480px) { .companion-spot .companion { width: 54px; height: 54px; } }
#home-bolts .bolt { width: 42px; height: 42px; }
.bolt-bubble::before {
  content: ""; position: absolute; left: 6px; top: 50%; width: 32px; height: 32px;
  transform: translateY(-50%);
  background: var(--bolt-idle) center / contain no-repeat;
}
.bolt-bubble.cheer::before { background-image: var(--bolt-cheer); animation: facejump 0.4s ease-out 1; }
.bolt-bubble.groan::before { background-image: var(--bolt-groan); animation: faceshake 0.5s ease-in-out 1; }
@keyframes facejump { 0%,100% { transform: translateY(-50%); } 50% { transform: translateY(-50%) translateY(-8px) rotate(-8deg); } }
@keyframes faceshake { 0%,100% { transform: translateY(-50%) rotate(0); } 25% { transform: translateY(-50%) rotate(-14deg); } 75% { transform: translateY(-50%) rotate(14deg); } }

/* ---------- Hangar screen ---------- */
.hangar-body { flex: 1; overflow-y: auto; padding: 8px 0 24px; }
.rank-card { display: flex; flex-direction: column; align-items: center; padding: 10px 0 16px; }
.hangar-h { font-family: var(--display); font-size: 16px; letter-spacing: 1px; color: var(--cyan); margin: 14px 0 8px; }
.ship-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.ship-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 12px 8px; border-radius: 18px;
  background: var(--panel); border: 2px solid var(--line); cursor: pointer;
}
.ship-card img { width: 64px; height: 64px; object-fit: contain; }
.ship-card.locked img { filter: grayscale(1) brightness(0.5) contrast(0.8); opacity: 0.8; }
.ship-card.locked { opacity: 0.7; cursor: default; }
.ship-card.selected { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(250,204,21,0.25); }
.ship-card .sc-name { font-weight: 700; }
.ship-card .sc-sub { font-size: 12px; color: var(--muted); text-align: center; }
.ship-card.selected .sc-sub { color: var(--yellow); }
.trophies { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.trophy {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: rgba(0,0,0,0.3); border-radius: 16px; padding: 10px 6px;
}
.trophy .t-icon { font-size: 26px; }
.trophy .t-num { font-family: var(--display); font-size: 22px; color: var(--yellow); }
.trophy .t-label { font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Rank up ---------- */
#screen-unlock { justify-content: center; align-items: center; }
.unlock-card {
  width: 100%; max-width: 420px; display: flex; flex-direction: column; align-items: center; gap: 12px;
  background: var(--panel); border: 2px solid var(--yellow); border-radius: 28px; padding: 24px 20px;
  animation: pop 0.5s;
}
.unlock-title { font-family: var(--display); font-size: 34px; color: var(--yellow); text-shadow: 0 4px 0 rgba(0,0,0,0.4); }
.unlock-ship { width: 160px; animation: shipin 1.2s cubic-bezier(0.2,0.8,0.3,1.2), bob 3s 1.2s ease-in-out infinite; filter: drop-shadow(0 12px 14px rgba(0,0,0,0.5)); }
@keyframes shipin { 0% { transform: scale(0) rotate(-360deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
.unlock-name { font-weight: 700; font-size: 20px; }
.unlock-extra { font-size: 16px; color: var(--cyan); text-align: center; min-height: 1em; }

/* ---------- FX layer ---------- */
#fx-layer { position: fixed; top: 0; right: 0; bottom: 0; left: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.fx-p { position: absolute; width: 10px; height: 10px; border-radius: 50%; }
.fx-star { width: 22px; height: 22px; border-radius: 0; background: url("../assets/img/star.png") center / contain no-repeat; }
.fx-c { position: absolute; border-radius: 2px; }
.fx-flash { position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.ship-name { font-weight: 700; font-size: 18px; color: var(--muted); }
.route-strip {
  display: flex; align-items: center; gap: 10px; margin-top: 10px;
  font-size: 16px; color: var(--muted);
}
.route-strip img { width: 36px; height: 36px; border-radius: 50%; }

.mode-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  margin-top: 14px; flex: 1; align-content: start;
}
.mode-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-height: 130px; padding: 14px 10px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 22px;
  transition: transform 0.08s;
}
.mode-card:not(.locked):active { transform: scale(0.96); background: var(--panel-2); }
.mode-card:not(.locked) { border-color: var(--orange); box-shadow: 0 6px 0 rgba(249,115,22,0.35); }
.mode-card.locked { opacity: 0.45; }
.mode-icon { font-size: 40px; }
.mode-title { font-weight: 700; font-size: 18px; }
.mode-status { font-size: 14px; color: var(--muted); }
.mode-status.ready { color: var(--yellow); }
.mode-status.done { color: var(--green); }

.gear {
  position: fixed; right: max(10px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom));
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px; z-index: 80;
  background: rgba(11,16,38,0.6); border: 2px solid var(--line); opacity: 0.75;
}
.gear:active { opacity: 1; transform: rotate(30deg); }

/* ---------- Settings modal ---------- */
.modal { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 85; background: rgba(0,0,0,0.6); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card {
  width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto;
  background: var(--navy-2); border: 2px solid var(--line); border-radius: 24px; padding: 16px 18px 20px;
  display: flex; flex-direction: column; gap: 12px; animation: pop 0.3s;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.icon-btn.small { width: 44px; height: 44px; font-size: 18px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 16px; }
.set-row.col { flex-direction: column; align-items: stretch; gap: 8px; }
.set-row.sub { font-size: 14px; color: var(--muted); padding-left: 6px; }
.set-row.sub select { max-width: 60%; }
.set-row input[type=range] { flex: 1; max-width: 200px; accent-color: var(--cyan); height: 32px; }
.set-row select {
  font-family: inherit; font-size: 15px; padding: 10px 12px; border-radius: 12px;
  background: var(--panel); color: var(--text); border: 2px solid var(--line);
}
.set-row select option { color: #000; }
.set-actions { display: flex; gap: 10px; }
.set-actions .btn { flex: 1; font-size: 16px; min-height: 52px; }
.set-actions .btn small { font-weight: 400; font-size: 11px; color: var(--muted); }
.debug { right: 60px; }

/* ---------- Launch Codes ---------- */
.fuel {
  flex: 1; display: flex; gap: 4px; height: 26px;
  padding: 4px; border-radius: 999px;
  background: rgba(0,0,0,0.35); border: 2px solid var(--line);
}
.fuel span {
  flex: 1; border-radius: 999px; background: rgba(255,255,255,0.08);
  transition: background 0.3s, box-shadow 0.3s;
}
.fuel span.on { background: var(--orange); box-shadow: 0 0 8px var(--orange); }
.fuel-wrap { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.fuel-wrap .fuel { width: 100%; }
.level-tag { font-size: 12px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }

.play-area {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; padding: 8px 0; position: relative;
}
.pic {
  font-size: 84px; line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.5));
  transition: filter 0.4s;
}
.pic.blurred { filter: blur(14px) saturate(0.6); }
.sentence {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 8px;
  font-size: var(--read-size); font-weight: 400; line-height: 1.3;
  max-width: 100%;
}
.sentence.long { font-size: calc(var(--read-size) - 4px); gap: 4px 6px; }
.sentence.long .word { padding: 2px 6px; }
.sentence.xlong { font-size: calc(var(--read-size) - 8px); }
.slots .tile, .slot-box { font-size: inherit; }
.repair-area.dense .tile, .repair-area.dense .slot-box { font-size: calc(var(--read-size) - 8px); min-height: 44px; }
.repair-area.dense .slots { gap: 6px; }
.word {
  padding: 4px 8px; border-radius: 10px;
  transition: background 0.15s;
}
.word:active, .word.speaking { background: rgba(34,211,238,0.25); }
.word.slot {
  min-width: 3.2em; text-align: center;
  border-bottom: 4px solid var(--yellow);
  border-radius: 6px 6px 0 0;
  color: var(--yellow);
}
.word.slot.filled { color: var(--green); border-bottom-color: var(--green); }
.word.target { background: rgba(250,204,21,0.12); outline: 2px dashed rgba(250,204,21,0.5); }
.word.hit { background: rgba(74,222,128,0.35); outline: 2px solid var(--green); }
.word.miss { background: rgba(248,113,113,0.35); outline: 2px solid var(--red); animation: shake 0.4s; }

.choices {
  display: flex; flex-direction: column; gap: 12px;
  width: 100%; max-width: 420px;
  transition: opacity 0.35s, transform 0.35s;
}
.choices.waiting { opacity: 0; transform: translateY(12px); pointer-events: none; }
.choices.gone { display: none; }
.choice {
  font-size: var(--read-size); font-weight: 700;
  min-height: 72px; padding: 10px 20px;
  border-radius: 20px;
  background: linear-gradient(#2a3670, #1b2350);
  border: 3px solid #4256a8;
  box-shadow: 0 6px 0 #0f1538;
  transition: transform 0.08s, background 0.2s, border-color 0.2s, opacity 0.2s;
}
.choice:active { transform: translateY(4px); box-shadow: 0 2px 0 #0f1538; }
.choice.correct {
  background: linear-gradient(#3ec96e, #22a052); border-color: #7cf0a6;
  box-shadow: 0 6px 0 #14602f;
}
.choice.wrong {
  background: #3a2230; border-color: #6b2b3b; opacity: 0.55;
  animation: shake 0.4s;
}
.choice.hint { animation: pulse 0.9s infinite; border-color: var(--yellow); }
.choice:disabled { cursor: default; }
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%,60% { transform: translateX(-10px); }
  40%,80% { transform: translateX(10px); }
}
@keyframes pulse {
  0%,100% { box-shadow: 0 6px 0 #0f1538, 0 0 0 0 rgba(250,204,21,0.0); }
  50% { box-shadow: 0 6px 0 #0f1538, 0 0 0 10px rgba(250,204,21,0.25); }
}

.bolt-bubble {
  position: absolute; top: 0; left: 50%; transform: translateX(-50%) translateY(-10px); z-index: 5;
  background: var(--yellow); color: var(--navy);
  font-weight: 700; font-size: 18px;
  padding: 8px 16px 8px 46px; border-radius: 16px;
  opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none;
  white-space: nowrap;
}
.bolt-bubble.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.check-prompt {
  font-size: 22px; font-weight: 700; min-height: 72px; padding: 10px 20px;
  width: 100%; max-width: 420px; border-radius: 20px;
  background: linear-gradient(#facc15, #eab308); color: var(--navy);
  border: 3px solid #fde68a; box-shadow: 0 6px 0 #a16207;
  animation: pop 0.4s;
}
.check-prompt span { font-size: 26px; }
.check-prompt:active { transform: translateY(4px); box-shadow: 0 2px 0 #a16207; }

.pad {
  position: relative; height: 120px; flex: 0 0 auto;
  display: flex; align-items: flex-end; justify-content: center;
}
.pad-line {
  position: absolute; bottom: 0; left: 10%; right: 10%; height: 6px;
  background: var(--line); border-radius: 3px;
}
.rocket-wrap {
  position: relative; display: flex; flex-direction: column; align-items: center;
  margin-bottom: 6px;
  transition: transform 1.6s cubic-bezier(0.5, 0, 0.9, 0.4);
}
.rocket { width: 36px; filter: drop-shadow(0 6px 6px rgba(0,0,0,0.5)); }
.flame {
  width: 18px; margin-top: -4px; opacity: 0;
  transform-origin: top center;
}
.rocket-wrap.launch { transform: translateY(-120vh); }
.rocket-wrap.launch .flame { opacity: 1; animation: flicker 0.12s infinite alternate; }
.rocket-wrap.spin .rocket { animation: spin 0.8s ease-in-out; }
@keyframes flicker { from { transform: scaleY(1); } to { transform: scaleY(1.5) scaleX(0.85); } }
@keyframes spin { to { transform: rotate(360deg); } }

.fly-star {
  position: fixed; width: 30px; height: 30px; pointer-events: none; z-index: 50;
}

/* ---------- Asteroid Blitz ---------- */
.timer {
  width: 100%; height: 22px; padding: 3px; border-radius: 999px;
  background: rgba(0,0,0,0.35); border: 2px solid var(--line);
}
.timer span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--cyan), #67e8f9);
  box-shadow: 0 0 8px var(--cyan);
  transition: width 0.25s linear;
}
.blitz-field {
  flex: 1; position: relative; overflow: hidden;
  border-radius: 20px;
  background: radial-gradient(ellipse at 50% 120%, rgba(34,211,238,0.10), transparent 60%);
}
.asteroid {
  position: absolute; left: 0; top: 0;
  width: 120px; height: 100px;
  display: flex; align-items: center; justify-content: center;
  background: url("../assets/img/meteor1.png") center / contain no-repeat;
  cursor: pointer; will-change: transform;
  filter: drop-shadow(0 6px 8px rgba(0,0,0,0.5));
}
.asteroid.v2 { background-image: url("../assets/img/meteor2.png"); }
.asteroid.v3 { background-image: url("../assets/img/meteor3.png"); }
.asteroid.v4 { background-image: url("../assets/img/meteor4.png"); }
.asteroid span {
  font-size: 26px; font-weight: 700; color: #fff;
  background: rgba(11,16,38,0.72); padding: 4px 12px; border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.25);
  pointer-events: none; white-space: nowrap;
}
.asteroid.shake { animation: shake 0.4s; }
.asteroid.shake span { border-color: var(--red); }
.asteroid.reveal span { border-color: var(--yellow); box-shadow: 0 0 0 6px rgba(250,204,21,0.35); }
.asteroid.boom { animation: boom 0.35s forwards; }
@keyframes boom {
  0% { filter: brightness(2) drop-shadow(0 0 0 #fff); }
  100% { transform: scale(1.8); opacity: 0; filter: brightness(3) drop-shadow(0 0 30px var(--orange)); }
}
.laser {
  position: absolute; width: 6px; margin-left: -3px;
  transform-origin: top center;
  background: linear-gradient(#fecaca, var(--red));
  border-radius: 3px; box-shadow: 0 0 10px var(--red);
  pointer-events: none;
}
.blitz-dock {
  display: flex; align-items: flex-end; justify-content: space-between;
  min-height: 96px; padding: 6px 4px 0;
}
.blitz-ship {
  width: 86px; cursor: pointer;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,0.5));
  transition: transform 0.15s;
}
.blitz-ship.talk { transform: scale(1.08); }
.blitz-ship:active { transform: scale(0.95); }
.dock-spacer { width: 56px; }
.icon-btn.replay { font-size: 26px; border-color: var(--cyan); }
.blitz-flash {
  position: absolute; left: 50%; top: 120px; transform: translateX(-50%) translateY(-10px);
  background: var(--yellow); color: var(--navy); font-weight: 700; font-size: 20px;
  padding: 8px 18px; border-radius: 16px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 5; white-space: nowrap;
}
.blitz-flash.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.blitz-count {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 96px; color: var(--yellow);
  text-shadow: 0 6px 0 rgba(0,0,0,0.5); background: rgba(11,16,38,0.45);
  z-index: 10; animation: pop 0.4s;
}

/* ---------- Repair Bay ---------- */
.pic.small { font-size: 56px; }
.repair-area { justify-content: flex-start; padding-top: 16px; gap: 14px; }
.slots {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  width: 100%; min-height: 64px;
}
.slot-box {
  min-height: 60px; min-width: 2.2em; padding: 4px;
  border: 3px dashed rgba(250,204,21,0.5); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: var(--read-size); cursor: pointer;
}
.slot-box.filled { border-style: solid; border-color: rgba(255,255,255,0.35); }
.slot-box.locked { border-color: var(--green); background: rgba(74,222,128,0.12); cursor: default; }
.tray {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 10px;
  width: 100%; min-height: 64px; padding: 10px;
  background: rgba(0,0,0,0.25); border-radius: 18px; border: 2px solid var(--line);
}
.tile {
  font-size: var(--read-size); font-weight: 700; line-height: 1;
  min-height: 52px; padding: 8px 14px; border-radius: 12px;
  background: linear-gradient(#2a3670, #1b2350); border: 3px solid #4256a8;
  box-shadow: 0 4px 0 #0f1538; touch-action: manipulation;
  transition: transform 0.08s, background 0.2s, border-color 0.2s;
}
.tile:active { transform: translateY(3px); box-shadow: 0 1px 0 #0f1538; }
.slot-box .tile { box-shadow: none; padding: 4px 10px; min-height: 44px; }
.tile.locked { background: linear-gradient(#3ec96e, #22a052); border-color: #7cf0a6; cursor: default; }
.tile.wrong { background: #3a2230; border-color: var(--red); animation: shake 0.4s; }
.tile.speaking { border-color: var(--cyan); }
.hint-line { margin: 0; font-size: 15px; color: var(--muted); text-align: center; }
.weld { width: 100%; max-width: 320px; font-size: 24px; }
.spark {
  position: absolute; left: 50%; top: 30%; width: 120px; transform: translate(-50%,-50%) scale(0.2);
  opacity: 0; pointer-events: none; transition: transform 0.25s, opacity 0.25s;
}
.spark.show { opacity: 1; transform: translate(-50%,-50%) scale(1.6) rotate(20deg); }

/* ---------- Mission Log ---------- */
.log-scroll {
  flex: 1; overflow-y: auto; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0 20px;
}
.log-card {
  width: 100%; background: var(--panel); border: 2px solid var(--line);
  border-radius: 22px; padding: 14px 16px;
}
.log-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.log-title { font-family: var(--display); font-size: 16px; color: var(--cyan); letter-spacing: 1px; }
.passage {
  display: flex; flex-wrap: wrap; gap: 4px 6px;
  font-size: calc(var(--read-size) - 4px); line-height: 1.45;
}
.passage .word { padding: 2px 5px; }
.check-prompt.waiting { opacity: 0.5; filter: saturate(0.5); cursor: default; }
.question { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.q-text {
  font-size: calc(var(--read-size) - 4px); font-weight: 700; text-align: center;
  color: var(--yellow); padding: 6px 10px;
}
#log-answers .choice { font-size: calc(var(--read-size) - 6px); min-height: 64px; }
#screen-log .bolt-bubble { position: fixed; top: 84px; }

/* ---------- Results ---------- */
#screen-results { justify-content: center; align-items: center; }
.results-card {
  width: 100%; max-width: 440px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 28px;
  padding: 24px 20px; display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.results-title { font-family: var(--display); font-size: 30px; margin: 0; color: var(--yellow); }
.results-planet {
  width: 140px; height: 140px; border-radius: 50%;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,0.5));
  animation: bob 4s ease-in-out infinite;
}
.results-planet-name { font-weight: 700; color: var(--muted); }
.results-stats { display: flex; flex-wrap: wrap; gap: 12px; width: 100%; margin-top: 6px; }
.stat {
  flex: 1 1 40%; display: flex; flex-direction: column; align-items: center;
  background: rgba(0,0,0,0.3); border-radius: 18px; padding: 12px 6px;
}
.stat-num { font-family: var(--display); font-size: 28px; color: var(--cyan); }
.stat-label { font-size: 14px; color: var(--muted); }
.levelup {
  width: 100%; text-align: center; font-weight: 700; font-size: 18px;
  background: var(--cyan); color: var(--navy); padding: 10px; border-radius: 16px;
  animation: pop 0.5s;
}
.levelup.best { background: var(--orange); color: #fff; }
.rankup {
  width: 100%; text-align: center; font-weight: 700; font-size: 20px;
  background: var(--yellow); color: var(--navy); padding: 12px; border-radius: 16px;
  animation: pop 0.5s;
}
@keyframes pop { 0% { transform: scale(0.6); } 70% { transform: scale(1.08); } 100% { transform: scale(1); } }
.results-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; margin-top: 8px; }

.btn {
  font-size: 20px; font-weight: 700; min-height: 60px; padding: 10px 20px;
  border-radius: 18px; border: 3px solid var(--line); background: var(--panel);
}
.btn:active { background: var(--panel-2); }
.btn-primary {
  background: linear-gradient(#fb923c, #ea580c); border-color: #fdba74; color: #fff;
  box-shadow: 0 6px 0 #9a3412;
}
.btn-primary:active { transform: translateY(4px); box-shadow: 0 2px 0 #9a3412; }
.btn-danger { border-color: var(--red); color: var(--red); }

/* ---------- Parent page ---------- */
.parent-body { flex: 1; overflow-y: auto; padding: 8px 0 24px; user-select: text; }
.parent-block { margin-bottom: 18px; }
.parent-block h3 { margin: 0 0 8px; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.parent-row { font-size: 18px; }
.parent-table { width: 100%; border-collapse: collapse; font-size: 16px; }
.parent-table td, .parent-table th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.parent-table th { color: var(--muted); font-weight: 400; }
.tier-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.tier-name { flex: 1; font-size: 17px; }
.tier-val { min-width: 72px; text-align: center; font-weight: 700; }
.tier-btn {
  width: 44px; height: 44px; border-radius: 12px; font-size: 22px; font-weight: 700;
  background: var(--panel); border: 2px solid var(--line);
}
.parent-note { font-size: 13px; color: var(--muted); margin: 8px 0 0; }
.parent-table { font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 16px; }
.chip b { color: var(--red); }
.parent-actions { display: flex; flex-direction: column; gap: 10px; }
.credits { font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Toast & debug ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--cyan); color: var(--navy); font-weight: 700;
  padding: 10px 18px; border-radius: 14px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 60; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.debug {
  position: fixed; bottom: 8px; left: 8px; z-index: 70;
  display: flex; gap: 6px; flex-wrap: wrap;
}
.debug button { font-size: 12px; padding: 4px 8px; border-radius: 8px; background: #000; border: 1px solid #555; }

/* ---------- Landscape / wide ---------- */
@media (min-width: 720px) and (orientation: landscape) {
  :root { --read-base: 36px; }
  #app { max-width: 960px; }
  .mode-grid { grid-template-columns: repeat(4, 1fr); }
  .blitz-dock { min-height: 80px; }
  .repair-area { max-width: 900px; margin: 0 auto; }
  #log-answers { flex-direction: row; }
  .blitz-ship { width: 70px; }
  .choices { flex-direction: row; max-width: 720px; }
  .choice { flex: 1; }
  .pad {
    position: absolute; right: 70px; bottom: 16px;
    height: auto; width: 120px;
  }
  .pad-line { left: 0; right: 0; }
  .play-area { padding-bottom: 24px; }
}
@media (max-height: 760px) {
  .pic { font-size: 60px; }
  .pad { height: 100px; }
  .rocket { width: 30px; }
  .choice { min-height: 60px; }
  .play-area { gap: 12px; }
}
