* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #05060f; color: #fff;
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
canvas { display: block; width: 100vw; height: 100vh; touch-action: none; }
button { font: inherit; color: inherit; border: none; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }

#hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 12px) 16px 0;
  pointer-events: none;
}
.pill {
  background: rgba(20, 24, 50, 0.75); border: 2px solid rgba(255,255,255,0.15);
  border-radius: 999px; padding: 8px 16px; font-size: 20px; font-weight: 700;
}
#missionHud { margin: 0 auto; }
.hudButtons { margin-left: auto; display: flex; gap: 10px; pointer-events: auto; }
.round {
  width: 56px; height: 56px; border-radius: 50%; font-size: 28px;
  background: rgba(20, 24, 50, 0.85); border: 2px solid rgba(255,255,255,0.2);
}
.round:active { transform: scale(0.92); }

#toast {
  position: fixed; top: calc(env(safe-area-inset-top) + 84px); left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 32px); text-align: center;
  background: rgba(20, 24, 50, 0.9); border: 2px solid #ffd45c; border-radius: 16px;
  padding: 10px 18px; font-size: 19px; font-weight: 600; pointer-events: none;
}
#hint {
  position: fixed; bottom: 40%; left: 50%; transform: translateX(-50%);
  font-size: 22px; opacity: 0.7; pointer-events: none; transition: opacity 1s;
}

#btnAction {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 24px); transform: translateX(-50%);
  background: linear-gradient(#5cd6ff, #2a8bff); border-radius: 999px;
  padding: 16px 28px; font-size: 22px; font-weight: 800;
  box-shadow: 0 0 24px rgba(92, 214, 255, 0.6);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 40px rgba(92, 214, 255, 0.95); } }

#btnBoost {
  --fill: 100%;
  position: fixed; right: 20px; bottom: calc(env(safe-area-inset-bottom) + 24px);
  width: 96px; height: 96px; border-radius: 50%;
  font-size: 17px; font-weight: 800; letter-spacing: 1px;
  border: 3px solid rgba(255,255,255,0.35);
  background: linear-gradient(to top, rgba(255,140,40,0.9) var(--fill), rgba(40,40,70,0.8) var(--fill));
}
#btnBoost.on { transform: scale(0.93); border-color: #fff; }

#modal {
  position: fixed; inset: 0; background: rgba(2, 3, 12, 0.7);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#modalBox {
  background: #141a3a; border: 2px solid rgba(255,255,255,0.15); border-radius: 24px;
  padding: 24px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto;
  text-align: center;
}
#modalBox h2 { margin: 8px 0; font-size: 30px; }
#modalBox p { font-size: 20px; line-height: 1.4; margin: 10px 0; }
#modalBox .planetImg { width: 120px; height: 120px; }
#modalBox .big { font-size: 64px; line-height: 1; }
.btn {
  display: inline-block; margin: 8px 6px 0; padding: 14px 26px; border-radius: 999px;
  font-size: 21px; font-weight: 800; background: #2a8bff;
}
.btn.ghost { background: rgba(255,255,255,0.12); }
.btn:disabled { opacity: 0.4; }
.answers { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.answers .btn { margin: 0; background: #283266; }
.answers .btn.right { background: #22a35a; }
.answers .btn.wrong { background: #a33a3a; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin: 16px 0; }
.card {
  background: #1f2753; border-radius: 16px; padding: 12px 8px; font-size: 17px; font-weight: 700;
  border: 2px solid rgba(255,255,255,0.12);
}
.card img { width: 70px; height: 70px; display: block; margin: 0 auto 6px; }
.card.locked { opacity: 0.45; }
.card.locked img { filter: grayscale(1) brightness(0.4); }
.card .q { font-size: 44px; height: 70px; line-height: 70px; }
.facts { text-align: left; font-size: 19px; line-height: 1.45; padding-left: 22px; }
.facts li { margin-bottom: 8px; }

.upgrade {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: #1f2753; border-radius: 16px; padding: 12px 14px; margin: 10px 0;
}
.upgrade .icon { font-size: 38px; }
.upgrade .info { flex: 1; }
.upgrade .info b { font-size: 20px; }
.upgrade .info div { font-size: 16px; opacity: 0.8; }
.upgrade .btn { margin: 0; padding: 10px 16px; font-size: 18px; white-space: nowrap; }

/* v0.2 */
#hint { text-align: center; width: calc(100vw - 32px); font-size: 20px; }
#missionHud {
  position: fixed; top: calc(env(safe-area-inset-top) + 76px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; white-space: nowrap; font-size: 18px;
}
#btnQuit { background: rgba(255,255,255,0.15); border-radius: 50%; width: 30px; height: 30px; font-size: 15px; }
#toast { top: calc(env(safe-area-inset-top) + 130px); }
#bossBar {
  position: fixed; top: calc(env(safe-area-inset-top) + 76px); right: 16px; width: 220px;
  font-size: 14px; font-weight: 800; color: #ff9a9a; text-align: right; pointer-events: none;
}
#bossBar > div { margin-top: 4px; height: 12px; background: rgba(255,255,255,0.15); border-radius: 6px; overflow: hidden; }
#bossFill { height: 100%; width: 100%; background: linear-gradient(90deg, #ff3d6e, #ff9a3d); }
#btnFire {
  position: fixed; right: 130px; bottom: calc(env(safe-area-inset-bottom) + 30px);
  width: 84px; height: 84px; border-radius: 50%; font-size: 16px; font-weight: 800; letter-spacing: 1px;
  background: rgba(40, 200, 255, 0.75); border: 3px solid rgba(255,255,255,0.35);
}
#btnFire:active { transform: scale(0.93); border-color: #fff; }
#btnAction { left: 24px; transform: none; max-width: calc(100vw - 260px); }
@media (max-width: 600px) {
  .round { width: 46px; height: 46px; font-size: 22px; }
  .pill { font-size: 16px; padding: 6px 12px; }
  #btnAction { bottom: calc(env(safe-area-inset-bottom) + 130px); max-width: calc(100vw - 48px); font-size: 18px; }
}
#modalBox .small { font-size: 16px; opacity: 0.8; }
.missionList { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.mission {
  display: flex; align-items: center; gap: 14px; text-align: left;
  background: #1f2753; border: 2px solid rgba(255,255,255,0.12); border-radius: 16px; padding: 12px 16px;
}
.mission:active { transform: scale(0.98); }
.mission .medal { font-size: 34px; }
.mission .info { display: flex; flex-direction: column; font-size: 20px; }
.mission .info span { font-size: 15px; opacity: 0.75; }
.colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; margin: 12px 0; }
.color { background: #1f2753; border: 2px solid transparent; border-radius: 14px; padding: 10px 6px; font-size: 15px; font-weight: 700; }
.color.on { border-color: #ffd45c; }
.color:disabled { opacity: 0.4; }
.swatch { display: block; width: 36px; height: 36px; border-radius: 50%; margin: 0 auto 6px; }
#mapCanvas { width: 100%; max-width: 480px; aspect-ratio: 1; display: block; margin: 8px auto; }
.gemRegions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 15px; opacity: 0.85; }
#mapCanvas { width: min(100%, 58vh); height: auto; }
#bossBar { left: 50%; right: auto; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 76px); text-align: center; }
#modalBox.wide { max-width: 860px; }
#mapCanvas { width: min(100%, calc(100vh - 220px)); height: auto; }
.pill.hull { display: flex; align-items: center; gap: 8px; }
.hullBar { width: 110px; height: 14px; border-radius: 7px; background: rgba(255,255,255,0.15); overflow: hidden; }
#hullFill { height: 100%; width: 100%; background: #4ade80; transition: width 0.2s; }
@media (max-width: 600px) { .hullBar { width: 60px; } }

/* v0.4: tutorial coach, settings, grown-ups stats, left-handed buttons */
#coach {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 76px);
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 32px);
  background: rgba(20, 24, 50, 0.92); border: 3px solid #5cd6ff; border-radius: 20px;
  padding: 12px 14px 12px 20px; font-size: 21px; font-weight: 700; box-shadow: 0 0 30px rgba(92, 214, 255, 0.4);
}
#btnSkipTut { background: rgba(255,255,255,0.15); border-radius: 999px; padding: 8px 14px; font-size: 15px; font-weight: 700; white-space: nowrap; }
.glow { animation: glowPulse 0.9s ease-in-out infinite !important; }
@keyframes glowPulse { 50% { box-shadow: 0 0 0 8px rgba(255, 212, 92, 0.55), 0 0 40px rgba(255, 212, 92, 0.9); } }
body.coaching #toast { top: calc(env(safe-area-inset-top) + 160px); }
@media (max-width: 600px) { #coach { font-size: 17px; } body.coaching #toast { top: calc(env(safe-area-inset-top) + 190px); } }

.setting {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; text-align: left;
  background: #1f2753; border-radius: 16px; padding: 12px 16px; margin: 10px 0; font-size: 19px; font-weight: 700;
}
.setting input[type=range] { flex: 1; max-width: 240px; accent-color: #5cd6ff; height: 32px; }
.toggle { min-width: 76px; padding: 10px 16px; border-radius: 999px; font-weight: 800; background: rgba(255,255,255,0.15); }
.toggle.on { background: #22a35a; }
.seg { display: inline-flex; background: rgba(255,255,255,0.1); border-radius: 999px; padding: 3px; }
.seg button { background: transparent; color: #fff; padding: 9px 14px; border-radius: 999px; font-size: 16px; font-weight: 800; }
.seg button.on { background: #2a8bff; }
.settingBtns { display: flex; flex-wrap: wrap; justify-content: center; }
.btn.danger { background: #c0392b; }

.gateQ { font-size: 34px !important; font-weight: 800; }
.gateInput {
  font: inherit; font-size: 28px; width: 160px; text-align: center; padding: 10px; border-radius: 14px;
  border: 2px solid rgba(255,255,255,0.3); background: #0b1030; color: #fff;
}
.bars { display: flex; gap: 8px; height: 150px; align-items: flex-end; margin: 12px 0 18px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; font-size: 13px; }
.bar span { display: block; width: 100%; min-height: 3px; background: linear-gradient(#5cd6ff, #2a8bff); border-radius: 6px 6px 2px 2px; }
.bar small { opacity: 0.75; margin-top: 3px; }
.stats { text-align: left; }
.statRow { display: flex; justify-content: space-between; gap: 12px; padding: 9px 4px; border-bottom: 1px solid rgba(255,255,255,0.08); font-size: 17px; }
.statRow b { text-align: right; }

body.lefty #btnBoost { right: auto; left: 20px; }
body.lefty #btnFire { right: auto; left: 130px; }
body.lefty #btnAction { left: auto; right: 24px; }

/* pilots (player profiles) */
.pilots { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 6px; }
.pilot {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 16px 8px;
  background: #1f2753; border: 2px solid rgba(255,255,255,0.15); border-radius: 20px; font-size: 20px;
}
.pilot:active { transform: scale(0.96); }
.pilot .pIcon { font-size: 46px; line-height: 1.1; }
.pilot b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pilot small { font-size: 14px; opacity: 0.75; }
.pilot.new { border-style: dashed; background: transparent; }
.nameInput {
  font: inherit; font-size: 26px; font-weight: 700; width: min(100%, 320px); text-align: center; padding: 12px; border-radius: 16px;
  border: 2px solid rgba(255,255,255,0.3); background: #0b1030; color: #fff; -webkit-user-select: text; user-select: text;
}
.iconPick { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 6px 0; }
.iconPick button { width: 54px; height: 54px; font-size: 30px; border-radius: 16px; background: #1f2753; border: 3px solid transparent; }
.iconPick button.on { border-color: #ffd45c; background: #2c3670; }
.pilotTabs { flex-wrap: wrap; justify-content: center; border-radius: 22px; margin: 4px 0 8px; }
.gateInput { -webkit-user-select: text; user-select: text; }

/* playing together */
#chatPanel {
  position: fixed; top: calc(env(safe-area-inset-top) + 80px); right: 16px; width: 300px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px;
  background: rgba(20, 24, 50, 0.95); border: 2px solid rgba(255,255,255,0.2); border-radius: 20px;
}
#chatPanel button { padding: 12px 8px; border-radius: 14px; background: #2a3470; font-size: 17px; font-weight: 700; }
#chatPanel button:active { transform: scale(0.95); background: #2a8bff; }
.ageGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 6px; margin: 6px auto 10px; max-width: 460px; }
.ageGrid button { padding: 10px 4px; border-radius: 10px; background: rgba(120, 220, 255, 0.1); border: 2px solid transparent; font-size: 16px; font-weight: 700; color: inherit; }
.ageGrid button:first-child, .ageGrid button:last-child { grid-column: span 2; }
.ageGrid button.on { border-color: #ffcf5c; background: rgba(255, 207, 92, 0.12); }
.roomJoin { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin: 10px 0; }
.roomJoin .nameInput { font-size: 20px; width: min(100%, 220px); padding: 8px; text-transform: uppercase; }
.roomCode { letter-spacing: 0.06em; color: #ffcf5c; }
.appNote { margin: 10px 0; padding: 10px 14px; border-radius: 10px; border: 1px solid rgba(120, 220, 255, 0.35); background: rgba(120, 220, 255, 0.08); text-align: center; }
.appNote .btn { display: inline-block; margin-top: 4px; text-decoration: none; }
.warnText { color: #ffb36b; }

/* v0.5: rank badge, Scout Log, mission levels and stars */
.rankPill { display: flex; align-items: center; gap: 8px; pointer-events: auto; color: #fff; font-size: 22px; padding: 6px 14px; }
.rankPill:active { transform: scale(0.95); }
.xpBar { display: block; width: 70px; height: 10px; border-radius: 5px; background: rgba(255,255,255,0.15); overflow: hidden; }
#xpFill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffd45c, #ff9a3d); transition: width 0.3s; }
.xpBig { height: 16px; border-radius: 8px; background: rgba(255,255,255,0.12); overflow: hidden; margin: 6px auto; max-width: 360px; }
.xpBig span { display: block; height: 100%; background: linear-gradient(90deg, #ffd45c, #ff9a3d); }
#modalBox h3 { margin: 18px 0 6px; font-size: 21px; }
.goals { text-align: left; }
.goal { display: flex; align-items: center; gap: 10px; background: #1f2753; border-radius: 12px; padding: 9px 12px; margin: 6px 0; font-size: 17px; }
.goal span:nth-child(2) { flex: 1; }
.goal.done { opacity: 0.65; }
.stars { color: #ffd45c; letter-spacing: 1px; }
.stars i { font-style: normal; color: rgba(255,255,255,0.18); }
.starsBig { font-size: 44px; line-height: 1; }
.levels { display: flex; justify-content: center; gap: 8px; margin: 12px 0 4px; flex-wrap: wrap; }
.lvl { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 70px; padding: 8px 4px; border-radius: 14px; background: #1f2753; border: 3px solid transparent; font-size: 13px; }
.lvl b { font-size: 22px; }
.lvl.on { border-color: #ffd45c; background: #2c3670; }
.lvl:disabled { opacity: 0.45; }
@media (max-width: 600px) { .xpBar { width: 40px; } .pill.hull .hullBar { width: 50px; } }
.card .sci { display: block; font-size: 13px; font-weight: 600; opacity: 0.8; margin-top: 2px; }
.facts .hiddenFact { opacity: 0.55; font-style: italic; }

/* v0.7: shop tabs, wallet, hangar */
.wallet { font-size: 19px !important; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 14px; }
.shopTabs { flex-wrap: wrap; justify-content: center; margin: 4px 0 10px; }
.shopTabs button { font-size: 17px; padding: 10px 16px; }
.upgrade small { opacity: 0.7; font-weight: 600; }
.btnCol { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.btnCol .btn { margin: 0; padding: 9px 14px; font-size: 16px; }
#modalBox a.ext { color: #5cd6ff; font-weight: 700; }
#modalBox .note { background: rgba(74, 222, 128, 0.15); border: 2px solid #4ade80; border-radius: 14px; padding: 10px 14px; font-weight: 800; font-size: 19px; margin: 10px 0; }

/* v0.8: parent feedback in the Grown-ups area */
.fb { background: #1f2753; border-radius: 16px; padding: 12px 14px; margin: 14px 0; }
.fb h3 { margin: 4px 0 8px; font-size: 20px; }
.fbStars button { background: none; font-size: 38px; color: rgba(255,255,255,0.25); padding: 0 4px; }
.fbStars button.on { color: #ffd45c; }
.fbTags { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0 4px; }
.fbTags button { background: rgba(255,255,255,0.1); border: 2px solid transparent; border-radius: 999px; padding: 7px 12px; font-size: 15px; font-weight: 700; }
.fbTags button.on { border-color: #5cd6ff; background: rgba(92,214,255,0.2); }

/* ===================== v0.9: the new look =====================
   Dark glass panels with cut corners, thin cyan lines, Orbitron for headings and numbers, Exo 2 for
   reading text, and line icons instead of emoji. Phone sizes further down still apply on top. */
@font-face { font-family: 'Exo 2'; src: url(assets/fonts/exo2.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }
@font-face { font-family: 'Orbitron'; src: url(assets/fonts/orbitron.woff2) format('woff2'); font-weight: 400 900; font-display: swap; }
:root {
  --panel: rgba(7, 13, 28, 0.84); --panel2: rgba(16, 28, 54, 0.88); --line: rgba(120, 220, 255, 0.28); --line2: rgba(120, 220, 255, 0.55);
  --accent: #5cf0ff; --accent2: #2a8bff; --warn: #ffb347; --danger: #ff4a5e; --good: #4ade80; --text: #e6f4ff; --muted: rgba(200, 225, 245, 0.68);
  --cut: none; --cutS: none; /* closed boxes with slightly rounded corners (Scott didn't like the cut corners) */
}
html, body { font-family: 'Exo 2', system-ui, -apple-system, sans-serif; background: #04060f; color: var(--text); }
.ic { width: 1.15em; height: 1.15em; vertical-align: -0.2em; display: inline-block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.fill { fill: currentColor; stroke: none; }
.c-gold { color: #ffcf5c; } .c-silver { color: #d6dee8; } .c-bronze { color: #e0965a; } .c-red { color: #ff5a5a; } .c-green { color: #4ade80; }
.c-cyan { color: #5cf0ff; } .c-teal { color: #5cffd6; } .c-violet { color: #c9a8ff; } .c-orange { color: #ffa04a; } .c-ice { color: #bfefff; }
.ico { display: inline-flex; width: 1.2em; height: 1.2em; align-items: center; justify-content: center; }
.ico .ic { width: 100%; height: 100%; vertical-align: 0; }

/* HUD */
#hud { gap: 8px; align-items: center; }
.pill {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; clip-path: var(--cut);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-family: Orbitron, 'Exo 2', sans-serif; font-weight: 700; font-size: 15px; letter-spacing: 0.5px; padding: 7px 14px;
  display: flex; align-items: center; gap: 7px;
}
.pill.num .ico { color: #c9d2dc; }
.rankPill { padding: 5px 14px 5px 10px; gap: 9px; color: var(--text); }
.rankIc { display: inline-flex; width: 30px; height: 30px; color: #ffcf5c; filter: drop-shadow(0 0 6px rgba(255, 207, 92, 0.6)); }
.rankIc .ic { width: 100%; height: 100%; vertical-align: 0; }
.rankTxt { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.rankTxt b { font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: #ffe39a; }
.xpBar { width: 84px; height: 6px; border-radius: 0; background: rgba(255, 255, 255, 0.12); }
#xpFill { background: linear-gradient(90deg, #ffcf5c, #ff8a3d); box-shadow: 0 0 8px rgba(255, 180, 80, 0.8); }
.pill.hpBars { flex-direction: column; align-items: stretch; gap: 4px; padding: 6px 12px; justify-content: center; }
.barRow { display: flex; align-items: center; gap: 6px; }
.barRow .ico { width: 14px; height: 14px; color: var(--muted); }
#shieldRow .ico { color: #7fe8ff; }
.hullBar { width: 120px; height: 8px; border-radius: 0; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
#hullFill { background: linear-gradient(90deg, #2bd45a, #7dff9a); box-shadow: 0 0 8px rgba(74, 222, 128, 0.7); }
#hullFill.mid { background: linear-gradient(90deg, #e0a020, #ffd45c); }
#hullFill.low { background: linear-gradient(90deg, #c01a2a, #ff5a5a); animation: lowHull 0.6s ease-in-out infinite alternate; }
@keyframes lowHull { to { opacity: 0.55; } }
#shieldFill { height: 100%; width: 100%; background: linear-gradient(90deg, #2a8bff, #7fe8ff); box-shadow: 0 0 8px rgba(120, 220, 255, 0.8); transition: width 0.15s; }
.cargoTag { display: inline-flex; align-items: center; gap: 3px; margin-left: 4px; padding-left: 8px; border-left: 1px solid var(--line); color: #ffd45c; font-size: 13px; }
.cargoTag .ico { color: #ffd45c !important; width: 14px; height: 14px; }
.threat { color: #ffa04a; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 7px; height: 14px; background: rgba(255, 255, 255, 0.12); transform: skewX(-12deg); }
.pips i.half { background: rgba(255, 140, 60, 0.45); }
.pips i.on { background: linear-gradient(#ffd45c, #ff5a3d); box-shadow: 0 0 6px rgba(255, 120, 60, 0.9); }
.hudButtons { gap: 8px; align-self: flex-start; }
.round {
  width: 50px; height: 50px; border-radius: 50%; font-size: 22px; color: #cfe8ff;
  background: radial-gradient(circle at 50% 35%, rgba(30, 50, 90, 0.92), rgba(6, 10, 22, 0.92));
  border: 1px solid var(--line2); box-shadow: 0 0 12px rgba(80, 200, 255, 0.18), inset 0 0 10px rgba(80, 200, 255, 0.12);
  display: inline-flex; align-items: center; justify-content: center;
}
.round .ico { width: 24px; height: 24px; }
.round:active { transform: scale(0.92); box-shadow: 0 0 18px rgba(80, 200, 255, 0.5); }

#btnFire, #btnBoost {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-family: Orbitron, sans-serif; font-size: 11px; font-weight: 800; letter-spacing: 1.5px; color: #eaf6ff;
}
#btnFire .ico, #btnBoost .ico { width: 28px; height: 28px; }
#btnFire {
  background: radial-gradient(circle at 50% 40%, rgba(40, 140, 220, 0.85), rgba(8, 30, 70, 0.9));
  border: 2px solid rgba(120, 220, 255, 0.7); box-shadow: 0 0 22px rgba(60, 180, 255, 0.45), inset 0 0 18px rgba(120, 220, 255, 0.35);
}
#btnFire:active { box-shadow: 0 0 30px rgba(60, 180, 255, 0.9), inset 0 0 22px rgba(255, 255, 255, 0.4); }
#btnBoost {
  border: 2px solid rgba(255, 180, 90, 0.7); box-shadow: 0 0 22px rgba(255, 140, 40, 0.35), inset 0 0 16px rgba(255, 160, 60, 0.25);
  background: linear-gradient(to top, rgba(255, 130, 30, 0.85) var(--fill), rgba(14, 18, 34, 0.88) var(--fill));
}
#btnBoost.on { border-color: #fff; box-shadow: 0 0 34px rgba(255, 160, 60, 0.9); }

#toast {
  background: var(--panel2); border: 1px solid var(--line); border-left: 4px solid #ffd45c; border-radius: 6px; clip-path: var(--cutS);
  font-weight: 600; font-size: 18px; padding: 10px 18px; box-shadow: 0 6px 30px rgba(0, 0, 0, 0.5);
}
#toast .ic { margin: 0 2px; }
#coach { background: var(--panel2); border: 1px solid var(--line2); border-left: 4px solid var(--accent); border-radius: 6px; clip-path: var(--cutS); }
#btnSkipTut, #btnQuit { border-radius: 6px; clip-path: var(--cutS); font-family: Orbitron, sans-serif; font-size: 12px; }
#missionHud { font-family: Orbitron, sans-serif; font-size: 14px; color: #ffe39a; }
#bossBar { font-family: Orbitron, sans-serif; font-size: 12px; letter-spacing: 1px; color: #ff9a9a; text-transform: uppercase; width: 340px; }
#bossBar > div { border-radius: 0; height: 10px; background: rgba(255, 255, 255, 0.1); box-shadow: 0 0 0 1px rgba(255, 90, 90, 0.4); }
#bossFill { background: linear-gradient(90deg, #ff2a4a, #ff9a3d); box-shadow: 0 0 10px rgba(255, 60, 60, 0.9); }
#btnAction {
  border-radius: 8px; clip-path: var(--cut); font-family: Orbitron, sans-serif; font-size: 16px; letter-spacing: 1px; text-transform: uppercase;
  background: linear-gradient(135deg, #36c8ff, #2a6bff); color: #fff; padding: 14px 24px;
}
#hint { font-family: Orbitron, sans-serif; font-size: 15px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
#rotateTip:not(.hidden) .ico { width: 28px; height: 28px; animation: tilt 1.6s ease-in-out infinite; }

/* Screens */
#modal { background: radial-gradient(ellipse at center, rgba(4, 8, 20, 0.55), rgba(2, 3, 10, 0.85)); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
#modalBox {
  background: linear-gradient(180deg, rgba(14, 24, 48, 0.97), rgba(6, 10, 22, 0.97)); border: 1px solid var(--line2); border-radius: 8px; clip-path: var(--cut);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.6), 0 20px 60px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(120, 220, 255, 0.35);
  position: relative;
}
#modalBox::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, transparent, var(--accent), transparent); }
#modalBox h2 { font-family: Orbitron, sans-serif; font-weight: 800; font-size: 25px; letter-spacing: 1.5px; text-transform: uppercase; color: #fff; text-shadow: 0 0 18px rgba(92, 240, 255, 0.45); }
#modalBox h2 .ic { color: var(--accent); }
#modalBox h3 { font-family: Orbitron, sans-serif; font-size: 15px; letter-spacing: 1.5px; text-transform: uppercase; color: #9fe8ff; }
#modalBox p { font-size: 18px; }
#modalBox .small { color: var(--muted); opacity: 1; font-size: 15px; }
#modalBox .big { font-size: 64px; line-height: 1; color: #ffcf5c; filter: drop-shadow(0 0 14px rgba(255, 207, 92, 0.6)); }
#modalBox .big .ic { width: 1em; height: 1em; }
.btn {
  border-radius: 6px; clip-path: var(--cutS); font-family: Orbitron, sans-serif; font-size: 15px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase;
  background: linear-gradient(135deg, #36c8ff, #2a6bff); color: #fff; padding: 13px 24px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.btn:active { filter: brightness(1.25); }
.btn.ghost { background: rgba(120, 220, 255, 0.08); box-shadow: inset 0 0 0 1px var(--line2); color: #cfeeff; }
.btn.danger { background: linear-gradient(135deg, #ff5a6a, #b0182a); }
.answers .btn { background: rgba(120, 220, 255, 0.1); box-shadow: inset 0 0 0 1px var(--line2); text-transform: none; font-family: 'Exo 2', sans-serif; font-size: 18px; letter-spacing: 0; }
.answers .btn.right { background: #1f9a50; } .answers .btn.wrong { background: #a3283a; }
.card, .upgrade, .mission, .setting, .goal, .fb, .color, .pilot, .lvl, .statRow {
  border-radius: 0; background: rgba(120, 200, 255, 0.06); border: 1px solid rgba(120, 220, 255, 0.16);
}
.card, .upgrade, .mission, .setting, .fb, .pilot, .goal, .color, .lvl, .slot, .gearTile, .gearPanel, .egg, .dexItem, .cargoTag { border-radius: 6px; }
.upgrade .icon, .mission .medal { font-size: 30px; color: #9fe8ff; display: flex; }
.upgrade .info b, .mission .info b { font-family: Orbitron, sans-serif; font-size: 15px; letter-spacing: 0.5px; }
.card { font-family: Orbitron, sans-serif; font-size: 12px; letter-spacing: 0.5px; }
.lvl.on, .color.on, .iconPick button.on { border-color: #ffcf5c; background: rgba(255, 207, 92, 0.12); }
.seg { border-radius: 0; background: rgba(120, 220, 255, 0.08); clip-path: var(--cutS); }
.seg button { border-radius: 0; font-family: Orbitron, sans-serif; font-size: 13px; letter-spacing: 1px; text-transform: uppercase; }
.seg button.on { background: linear-gradient(135deg, #36c8ff, #2a6bff); }
.toggle { border-radius: 6px; clip-path: var(--cutS); font-family: Orbitron, sans-serif; font-size: 13px; }
.toggle.on { background: #1f9a50; }
.wallet { font-family: Orbitron, sans-serif; font-size: 15px !important; }
.goal.done span:first-child { color: var(--good); }
#chatPanel { border-radius: 8px; clip-path: var(--cut); background: var(--panel2); border: 1px solid var(--line2); }
#chatPanel button { border-radius: 6px; background: rgba(120, 220, 255, 0.1); }
.pilot .pIcon, .iconPick button { color: #9fe8ff; }
.pilot .pIcon .ic { width: 46px; height: 46px; }
.iconPick button .ic { width: 28px; height: 28px; }

/* Hangar: gear and aliens */
.slots { display: grid; gap: 6px; text-align: left; margin: 8px 0; }
.slotLabel { font-family: Orbitron, sans-serif; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
.slot { display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: rgba(120, 200, 255, 0.06); border: 1px solid var(--rc, var(--line)); border-left: 4px solid var(--rc, var(--line)); clip-path: var(--cutS); color: var(--text); text-align: left; }
.slot .ic { width: 30px; height: 30px; color: var(--rc); }
.slot span { display: flex; flex-direction: column; }
.slot b { font-family: Orbitron, sans-serif; font-size: 14px; }
.slot small { color: var(--muted); font-size: 14px; }
.slot.empty { border-style: dashed; opacity: 0.6; }
.gearGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; margin: 10px 0; }
.gearTile {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.25)); border: 1px solid var(--rc); clip-path: var(--cutS);
  box-shadow: inset 0 -12px 18px -12px var(--rc);
}
.gearTile .ic { width: 30px; height: 30px; color: var(--rc); }
.gearTile b { font-size: 12px; line-height: 1.15; }
.gearTile small { font-family: Orbitron, sans-serif; font-size: 10px; color: var(--rc); letter-spacing: 1px; text-transform: uppercase; }
.gearTile.on { outline: 2px solid #fff; outline-offset: -3px; }
.gearTile.eq::after { content: 'ON'; font-family: Orbitron, sans-serif; font-size: 9px; color: #04060f; background: var(--good); padding: 1px 5px; margin-top: 2px; }
.gearPanel { text-align: left; border: 1px solid var(--rc); background: rgba(120, 200, 255, 0.07); clip-path: var(--cut); padding: 12px 14px; margin: 10px 0; }
.gpHead { display: flex; align-items: center; gap: 12px; }
.gpHead .ic { width: 40px; height: 40px; color: var(--rc); }
.gpHead b { font-family: Orbitron, sans-serif; font-size: 17px; display: block; }
.gpHead small { font-family: Orbitron, sans-serif; font-size: 12px; letter-spacing: 1px; text-transform: uppercase; }
.gearPanel p { font-size: 16px !important; }
.gpBtns { display: flex; flex-wrap: wrap; gap: 6px; }
.gpBtns .btn { margin: 0; padding: 10px 14px; font-size: 12px; }
.eggs { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.egg { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px; border: 1px solid var(--rc); clip-path: var(--cutS); background: rgba(255, 255, 255, 0.04); }
.egg .ic { width: 34px; height: 34px; color: var(--rc); filter: drop-shadow(0 0 6px var(--rc)); }
.egg b { font-family: Orbitron, sans-serif; font-size: 12px; }
.egg small { color: var(--muted); }
.egg .btn { margin: 4px 0 0; padding: 8px 12px; font-size: 12px; }
.petImg { width: 56px; height: 56px; }
.petImg.big { width: 150px; height: 150px; }
.petImg.shiny { filter: drop-shadow(0 0 8px #ffd45c); }
.gearTile.pet img { width: 54px; height: 54px; }
.rar { font-family: Orbitron, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; font-size: 14px !important; }
.dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; }
.dexItem { display: flex; flex-direction: column; align-items: center; padding: 6px 2px; border: 1px solid var(--rc, rgba(255, 255, 255, 0.12)); clip-path: var(--cutS); }
.dexItem img { width: 46px; height: 46px; }
.dexItem small { font-size: 11px; color: var(--muted); }
.dexItem.unknown span { font-family: Orbitron, sans-serif; font-size: 26px; height: 46px; line-height: 46px; color: rgba(255, 255, 255, 0.2); }

/* v0.8: phones. Landscape phones are short (under ~500px tall); portrait phones are narrow. */
@media (max-height: 500px) {
  #hud { gap: 6px; padding: calc(env(safe-area-inset-top) + 6px) calc(env(safe-area-inset-right) + 10px) 0 calc(env(safe-area-inset-left) + 10px); }
  .pill { font-size: 15px; padding: 4px 10px; border-width: 1.5px; }
  .rankPill { font-size: 17px; padding: 3px 10px; }
  .xpBar { width: 40px; height: 8px; }
  .hullBar, .pill.hull .hullBar { width: 56px; height: 10px; }
  .hudButtons { gap: 6px; }
  .round { width: 40px; height: 40px; font-size: 20px; }
  #btnBoost { width: 76px; height: 76px; font-size: 14px; right: calc(env(safe-area-inset-right) + 12px); bottom: calc(env(safe-area-inset-bottom) + 12px); }
  #btnFire { width: 66px; height: 66px; font-size: 13px; right: calc(env(safe-area-inset-right) + 98px); bottom: calc(env(safe-area-inset-bottom) + 18px); }
  #btnAction { left: calc(env(safe-area-inset-left) + 14px); bottom: calc(env(safe-area-inset-bottom) + 14px); padding: 10px 18px; font-size: 16px; max-width: calc(100vw - 230px); }
  body.lefty #btnBoost { left: calc(env(safe-area-inset-left) + 12px); }
  body.lefty #btnFire { left: calc(env(safe-area-inset-left) + 98px); }
  body.lefty #btnAction { right: calc(env(safe-area-inset-right) + 14px); }
  #toast { top: calc(env(safe-area-inset-top) + 56px); font-size: 15px; padding: 6px 12px; max-width: calc(100vw - 200px); }
  body.coaching #toast { top: calc(env(safe-area-inset-top) + 112px); }
  #missionHud, #bossBar, #coach { top: calc(env(safe-area-inset-top) + 52px); }
  #missionHud { font-size: 14px; }
  #bossBar { width: 170px; font-size: 12px; }
  #coach { font-size: 15px; padding: 6px 8px 6px 12px; border-width: 2px; }
  #hint { bottom: 30%; font-size: 15px; }
  #modal { padding: 8px; }
  #modalBox { padding: 12px 16px; border-radius: 18px; max-height: calc(100vh - 16px); }
  #modalBox h2 { font-size: 22px; margin: 4px 0; }
  #modalBox p { font-size: 16px; margin: 6px 0; }
  #modalBox .big { font-size: 40px; }
  #modalBox .planetImg { width: 72px; height: 72px; }
  .btn { padding: 9px 18px; font-size: 17px; }
  .upgrade { padding: 8px 10px; margin: 6px 0; }
  .upgrade .icon { font-size: 28px; }
  .upgrade .info b { font-size: 16px; }
  .upgrade .info div { font-size: 13px; }
  .upgrade .btn { font-size: 15px; padding: 8px 12px; }
  .mission { padding: 8px 12px; }
  .mission .info { font-size: 16px; }
  .setting { font-size: 16px; padding: 8px 12px; margin: 6px 0; }
  #mapCanvas { width: min(100%, calc(100vh - 110px)) !important; }
  .gemRegions { font-size: 12px; }
  .gateQ { font-size: 24px !important; }
  #chatPanel button { padding: 8px 6px; font-size: 15px; }
}
@media (max-width: 600px) {
  #hud { gap: 5px; padding-left: 8px; padding-right: 8px; }
  .pill { font-size: 14px; padding: 4px 8px; }
  .rankPill { font-size: 16px; padding: 3px 8px; gap: 5px; }
  .xpBar { width: 28px; }
  .hullBar, .pill.hull .hullBar { width: 36px; }
  .hudButtons { gap: 4px; }
  .round { width: 36px; height: 36px; font-size: 18px; }
  #modalBox { padding: 16px 12px; }
}
/* holding a phone upright: suggest turning it (the game still works) */
#rotateTip { display: none; }
@media (max-width: 600px) and (orientation: portrait) and (pointer: coarse) {
  #rotateTip:not(.hidden) {
    display: flex; align-items: center; gap: 10px; position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 130px);
    background: rgba(20, 24, 50, 0.95); border: 2px solid #5cd6ff; border-radius: 16px; padding: 10px 12px; font-size: 16px; font-weight: 700;
  }
  #rotateTip span { font-size: 30px; animation: tilt 1.6s ease-in-out infinite; }
  #rotateTip button { margin-left: auto; background: rgba(255,255,255,0.15); border-radius: 999px; padding: 6px 12px; font-size: 14px; }
}
@keyframes tilt { 50% { transform: rotate(-90deg); } }
@media (max-width: 600px) and (orientation: portrait) {
  #hud { flex-wrap: wrap; row-gap: 6px; }
  .hudButtons { width: 100%; justify-content: flex-end; }
  #missionHud, #bossBar, #coach { top: calc(env(safe-area-inset-top) + 100px); }
  #toast { top: calc(env(safe-area-inset-top) + 150px); }
  body.coaching #toast { top: calc(env(safe-area-inset-top) + 230px); }
}

/* v0.9 phone sizes for the new pieces */
@media (max-height: 500px) {
  .rankIc { width: 22px; height: 22px; }
  .rankTxt b { font-size: 9px; }
  .hullBar { width: 70px; height: 6px; }
  .pill.hpBars { padding: 4px 8px; gap: 3px; }
  .round .ico { width: 20px; height: 20px; }
  #btnFire .ico, #btnBoost .ico { width: 22px; height: 22px; }
  #btnFire, #btnBoost { font-size: 9px; }
  #modalBox h2 { font-size: 19px; }
  .btn { font-size: 13px; padding: 9px 16px; }
  .gearGrid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  #bossBar { width: 240px; }
}
@media (max-width: 600px) {
  .rankTxt b { display: none; }
  .hullBar { width: 46px; }
  .round .ico { width: 18px; height: 18px; }
  .pill.gemPill { display: none; }
  #bossBar { width: calc(100vw - 32px); }
}
/* v0.9.1: landscape phones keep the controls small so the game has room */
@media (max-height: 500px) {
  #hud { gap: 5px; padding-top: calc(env(safe-area-inset-top) + 5px); }
  .pill { font-size: 12px; padding: 3px 8px; }
  .rankPill { padding: 3px 8px 3px 6px; gap: 6px; }
  .rankIc { width: 18px; height: 18px; }
  .xpBar { width: 44px; height: 4px; }
  .hullBar { width: 56px; height: 5px; }
  .pill.hpBars { padding: 4px 7px; gap: 3px; }
  .barRow .ico { width: 11px; height: 11px; }
  .hudButtons { gap: 5px; }
  .round { width: 41px; height: 41px; }
  .round .ico { width: 20px; height: 20px; }
  #btnBoost { width: 74px; height: 74px; right: calc(env(safe-area-inset-right) + 10px); bottom: calc(env(safe-area-inset-bottom) + 10px); }
  #btnFire { width: 65px; height: 65px; right: calc(env(safe-area-inset-right) + 92px); bottom: calc(env(safe-area-inset-bottom) + 15px); }
  #btnFire .ico, #btnBoost .ico { width: 22px; height: 22px; }
  #btnFire, #btnBoost { font-size: 9px; letter-spacing: 1px; gap: 1px; }
  body.lefty #btnBoost { left: calc(env(safe-area-inset-left) + 10px); }
  body.lefty #btnFire { left: calc(env(safe-area-inset-left) + 92px); }
  #btnAction {
    font-size: 11px; letter-spacing: 0.5px; padding: 6px 12px; bottom: calc(env(safe-area-inset-bottom) + 10px); left: calc(env(safe-area-inset-left) + 10px);
    max-width: 40vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; animation: none; box-shadow: 0 0 12px rgba(92, 214, 255, 0.5);
  }
  body.lefty #btnAction { right: calc(env(safe-area-inset-right) + 10px); }
  #toast { font-size: 13px; padding: 5px 10px; top: calc(env(safe-area-inset-top) + 76px); }
  #missionHud, #bossBar, #coach { top: calc(env(safe-area-inset-top) + 44px); }
  #missionHud { font-size: 11px; padding: 3px 8px; }
  #bossBar { font-size: 10px; width: 220px; }
  #hint { font-size: 12px; }
}
/* boss/base bar: one line, never wraps over the screen-edge markers */
#bossBar { width: min(560px, 62vw); white-space: nowrap; }
#bossName { display: block; overflow: hidden; text-overflow: ellipsis; }
/* menus: extra room at the bottom so the last button scrolls clear of the phone's edge (home bar) */
#modal { padding-bottom: calc(env(safe-area-inset-bottom) + 8px); }
#modalBox { padding-bottom: calc(env(safe-area-inset-bottom) + 28px); }
@media (max-height: 500px) {
  #modal { padding-top: calc(env(safe-area-inset-top) + 6px); padding-left: calc(env(safe-area-inset-left) + 8px); padding-right: calc(env(safe-area-inset-right) + 8px); }
  #modalBox { padding-bottom: calc(env(safe-area-inset-bottom) + 56px); max-height: calc(100vh - env(safe-area-inset-bottom) - 16px); }
}

/* v1.0 Home Station level pips */
.pips { display: inline-flex; gap: 4px; margin-left: 6px; vertical-align: middle; }
.pips i { width: 9px; height: 9px; border-radius: 50%; border: 1.5px solid var(--good, #4ade80); }
.pips i.on { background: var(--good, #4ade80); }
