:root {
  color-scheme: dark;
  --native-banner-inset: 0px;
  --app-vh: 100dvh;
  --app-vw: 100vw;
  --game-frame-height: 52vh;
  --upgrades-shell-width: 500px;
  --bg-top: #091018;
  --bg-bottom: #18263a;
  --panel: rgba(10, 15, 24, 0.72);
  --panel-strong: rgba(10, 15, 24, 0.9);
  --line: rgba(255, 255, 255, 0.12);
  --text: #eef3f7;
  --muted: #9aacbc;
  --accent-red: #ff5b6e;
  --accent-blue: #56c1ff;
  --accent-gold: #ffd166;
  --studio-orange: #ff7a1a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  min-height: var(--app-vh);
  height: var(--app-vh);
  overflow: hidden;
  font-family: "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(circle at top, rgba(86, 193, 255, 0.2), transparent 35%),
    linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  color: var(--text);
}

body {
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding-top: env(safe-area-inset-top);
  padding-right: env(safe-area-inset-right);
  padding-bottom: calc(var(--native-banner-inset) + env(safe-area-inset-bottom));
  padding-left: env(safe-area-inset-left);
}

.hidden {
  display: none !important;
}

.boot-splash {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: var(--studio-orange);
}

.boot-splash-card {
  width: min(92vw, 420px);
}

.splash-logo {
  width: 100%;
  border-radius: 18px;
  box-shadow: 0 22px 40px rgba(0, 0, 0, 0.25);
}

.app-shell {
  width: min(100%, 760px);
  height: calc(var(--app-vh) - var(--native-banner-inset) - env(safe-area-inset-bottom));
  padding: 10px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 8px;
  overflow: hidden;
}

.hud {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.meta-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.hud-chip {
  padding: 18px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
}

.session-total-chip {
  min-height: 106px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(86, 193, 255, 0.2), rgba(255, 209, 102, 0.16));
}

.meta-chip {
  padding: 12px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(8, 13, 22, 0.58);
}

.hud-label {
  display: block;
  font-size: 1.12rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 6px;
}

.hud strong,
.meta-chip strong {
  font-size: 2rem;
}

.polarity-chip.attract strong {
  color: var(--accent-blue);
}

.polarity-chip.repel strong {
  color: var(--accent-red);
}

.game-frame {
  position: relative;
  width: min(100%, calc(var(--game-frame-height) * 9 / 16));
  height: var(--game-frame-height);
  aspect-ratio: 9 / 16;
  max-height: 100%;
  min-height: 0;
  justify-self: center;
  align-self: center;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(5, 8, 14, 0.7);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(3, 6, 10, 0.5);
  backdrop-filter: blur(7px);
}

.ship-ability-button {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 12;
  min-height: 38px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: linear-gradient(135deg, rgba(203, 168, 255, 0.28), rgba(86, 193, 255, 0.26));
  color: #f3f8ff;
  font-weight: 700;
  font-size: 0.78rem;
}

#startOverlay {
  background:
    radial-gradient(circle at 18% 22%, rgba(86, 193, 255, 0.26), rgba(86, 193, 255, 0) 34%),
    radial-gradient(circle at 78% 30%, rgba(255, 91, 110, 0.24), rgba(255, 91, 110, 0) 36%),
    radial-gradient(circle at 46% 74%, rgba(255, 209, 102, 0.18), rgba(255, 209, 102, 0) 40%),
    linear-gradient(180deg, #060d16, #111c2b 60%, #0f1825);
  backdrop-filter: none;
}

#startOverlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 24% 60%, rgba(255, 255, 255, 0.08) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 52%, rgba(255, 255, 255, 0.08) 0 1.5px, transparent 3px),
    radial-gradient(circle at 84% 18%, rgba(255, 255, 255, 0.09) 0 2px, transparent 3px),
    radial-gradient(circle at 10% 28%, rgba(255, 255, 255, 0.06) 0 1.5px, transparent 3px);
  pointer-events: none;
}

.card,
.title-card {
  width: min(100%, 400px);
  min-height: 470px;
  padding: 30px 26px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: var(--panel-strong);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.28);
  position: relative;
  overflow: hidden;
}

.title-card > * {
  position: relative;
  z-index: 2;
}

.title-brand {
  margin: 0;
  color: var(--accent-gold);
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.title-heading {
  margin: 6px 0 10px;
  font-size: clamp(2.8rem, 10vw, 3.8rem);
  line-height: 0.95;
}

.title-howto {
  min-height: 44px;
  font-weight: 800;
}

.title-subhead {
  margin: 0 0 16px;
  color: #c4d4e4;
  font-size: 1.45rem;
  line-height: 1.35;
}

.title-actions {
  display: grid;
  gap: 14px;
}

.title-play {
  min-height: 70px;
  font-size: 1.52rem;
}

.title-upgrades {
  min-height: 62px;
  font-size: 1.35rem;
}

.title-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.deco-orb {
  position: absolute;
  border-radius: 999px;
  filter: blur(0.4px);
}

.deco-orb.blue {
  width: 86px;
  height: 86px;
  background: radial-gradient(circle, rgba(86, 193, 255, 0.65), rgba(86, 193, 255, 0));
  top: -20px;
  right: 8px;
}

.deco-orb.red {
  width: 94px;
  height: 94px;
  background: radial-gradient(circle, rgba(255, 91, 110, 0.58), rgba(255, 91, 110, 0));
  bottom: -24px;
  left: -6px;
}

.deco-ring {
  position: absolute;
  width: 140px;
  height: 140px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 999px;
  right: -42px;
  bottom: 24px;
}

.deco-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #ffe8a5;
  top: 28px;
  left: 16px;
  box-shadow: 36px 16px 0 #7ad5ff, 88px -4px 0 #ff8d9a, 122px 22px 0 #9de3ff;
}

.deco-planet {
  position: absolute;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.deco-planet::after {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
}

.deco-planet.p1 {
  width: 56px;
  height: 56px;
  top: 14%;
  left: 10%;
  background: radial-gradient(circle at 30% 30%, #98deff, #3f83c5);
}

.deco-planet.p2 {
  width: 42px;
  height: 42px;
  bottom: 18%;
  right: 12%;
  background: radial-gradient(circle at 30% 30%, #ffc06e, #dd5a44);
}

.deco-planet.p3 {
  width: 48px;
  height: 48px;
  top: 10%;
  right: 14%;
  background: radial-gradient(circle at 34% 30%, #8dffb2, #2d9f6d);
}

.deco-rocket {
  position: absolute;
  width: 16px;
  height: 42px;
  border-radius: 12px 12px 8px 8px;
  background: linear-gradient(180deg, #f0f7ff, #8ea8c7);
  border: 1px solid rgba(255, 255, 255, 0.34);
}

.deco-rocket::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 9px solid #ff8fa2;
}

.deco-rocket::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -8px;
  transform: translateX(-50%);
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ffd166;
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.8);
}

.deco-rocket.r1 {
  top: 18%;
  right: 18%;
  transform: rotate(28deg);
}

.deco-rocket.r2 {
  bottom: 20%;
  left: 18%;
  transform: rotate(-24deg);
}

.deco-rocket.r3 {
  bottom: 6%;
  right: 6%;
  left: auto;
  transform: rotate(18deg);
  opacity: 0.45;
}

.gameover-card {
  position: relative;
  overflow: hidden;
}

.gameover-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.gameover-card > :not(.gameover-decor) {
  position: relative;
  z-index: 2;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-gold);
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0 0 12px;
  line-height: 1;
}

h2 {
  font-size: clamp(2.2rem, 7vw, 3rem);
}

.body-copy {
  color: var(--muted);
  line-height: 1.45;
  margin: 0 0 18px;
  font-size: 1.35rem;
}

.policy-link-row {
  margin: 14px 0 0;
  text-align: right;
  position: relative;
  z-index: 1;
}

.policy-link {
  font-size: 0.78rem;
  color: #b6cadc;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.upgrade-hint {
  margin: 12px 0 0;
  font-size: 0.82rem;
  color: #b8cbe0;
  text-align: center;
}

.primary-button {
  width: 100%;
  border: none;
  border-radius: 18px;
  min-height: 64px;
  padding: 16px 20px;
  font-size: 1.4rem;
  font-weight: 700;
  color: #07111a;
  background: linear-gradient(135deg, var(--accent-gold), #ffef8d);
  cursor: pointer;
}

.primary-button.compact {
  width: auto;
  min-height: 54px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 1.1rem;
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 14px;
  min-height: 56px;
  padding: 13px 14px;
  font-size: 1.12rem;
  cursor: pointer;
}

.reward-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 18px;
  padding: 16px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.reward-line strong {
  color: var(--accent-gold);
  font-size: 1.7rem;
}

.control-dock {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 8px;
}

.control-button {
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-radius: 14px;
  font-weight: 700;
  font-size: 0.95rem;
}

.control-button.action {
  background: linear-gradient(135deg, rgba(86, 193, 255, 0.26), rgba(255, 91, 110, 0.26));
  border-color: rgba(255, 255, 255, 0.2);
}

.upgrades-screen {
  position: fixed;
  top: env(safe-area-inset-top);
  right: env(safe-area-inset-right);
  bottom: 0;
  left: env(safe-area-inset-left);
  z-index: 30;
  background:
    radial-gradient(circle at 10% 8%, rgba(86, 193, 255, 0.24), transparent 32%),
    radial-gradient(circle at 82% 15%, rgba(255, 91, 110, 0.2), transparent 36%),
    radial-gradient(circle at 76% 84%, rgba(255, 209, 102, 0.14), transparent 34%),
    linear-gradient(180deg, #0a121c, #141f31);
  display: grid;
  justify-items: center;
  align-items: start;
  padding: 10px 10px 12px;
  padding-bottom: calc(10px + var(--native-banner-inset) + env(safe-area-inset-bottom));
  overflow: hidden;
}

.upgrades-screen::before,
.upgrades-screen::after {
  content: "";
  position: fixed;
  pointer-events: none;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.28);
}

.upgrades-screen::before {
  width: 82px;
  height: 82px;
  left: 12px;
  top: 110px;
  background: radial-gradient(circle at 34% 30%, #94e2ff, #3e79be);
}

.upgrades-screen::after {
  width: 46px;
  height: 46px;
  right: 18px;
  bottom: calc(100px + var(--native-banner-inset));
  background: radial-gradient(circle at 30% 30%, #ffd491, #e76156);
}

.upgrades-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.upgrades-planet {
  position: absolute;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.38);
  opacity: 0.88;
}

.u-planet-1 {
  width: 60px;
  height: 60px;
  left: -14px;
  top: 23%;
  background: radial-gradient(circle at 34% 30%, #8fe3ff, #3e79be);
  animation: floatDecorA 5.8s ease-in-out infinite;
}

.u-planet-2 {
  width: 54px;
  height: 54px;
  right: -10px;
  top: 42%;
  background: radial-gradient(circle at 32% 30%, #ffcc8b, #e66057);
  animation: floatDecorB 6.5s ease-in-out infinite;
}

.u-planet-3 {
  width: 46px;
  height: 46px;
  right: 6px;
  left: auto;
  bottom: calc(114px + var(--native-banner-inset));
  background: radial-gradient(circle at 30% 30%, #a5ffb2, #2ea06f);
  animation: floatDecorA 6.9s ease-in-out infinite;
}

.upgrades-rocket {
  position: absolute;
  width: 13px;
  height: 35px;
  border-radius: 12px 12px 8px 8px;
  background: linear-gradient(180deg, #f0f7ff, #8ea8c7);
  border: 1px solid rgba(255, 255, 255, 0.4);
  opacity: 0.9;
  --decor-rotate: 0deg;
  transform: rotate(var(--decor-rotate));
}

.upgrades-rocket::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -8px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 9px solid #ff9eb0;
}

.upgrades-rocket::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -9px;
  transform: translateX(-50%);
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #ffd166;
}

.u-rocket-1 {
  left: -4px;
  right: auto;
  top: 58%;
  --decor-rotate: 24deg;
  animation: floatDecorB 6.2s ease-in-out infinite;
}

.u-rocket-2 {
  right: -2px;
  left: auto;
  top: 12%;
  bottom: auto;
  --decor-rotate: -22deg;
  animation: floatDecorA 6.8s ease-in-out infinite;
}

@keyframes floatDecorA {
  0%,
  100% { transform: translateY(0) rotate(var(--decor-rotate)); }
  50% { transform: translateY(-6px) rotate(calc(var(--decor-rotate) + 1deg)); }
}

@keyframes floatDecorB {
  0%,
  100% { transform: translateY(0) rotate(var(--decor-rotate)); }
  50% { transform: translateY(5px) rotate(calc(var(--decor-rotate) - 1deg)); }
}

.howto-screen {
  position: fixed;
  inset: 0;
  z-index: 31;
  background:
    radial-gradient(circle at top, rgba(86, 193, 255, 0.16), transparent 36%),
    radial-gradient(circle at 84% 22%, rgba(255, 91, 110, 0.14), transparent 32%),
    linear-gradient(180deg, #07111a, #101a29);
  display: grid;
  place-items: center;
  padding: 14px;
}

.howto-shell {
  width: min(100%, 520px);
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(9, 15, 24, 0.94);
  padding: 18px;
  display: grid;
  gap: 12px;
}

.howto-copy {
  margin: 0;
  color: #c5d6e8;
  line-height: 1.42;
}

.howto-actions {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.upgrades-shell {
  width: min(100%, var(--upgrades-shell-width));
  height: min(100%, calc(var(--app-vh) - var(--native-banner-inset) - env(safe-area-inset-bottom) - 20px));
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 80% 24%, rgba(255, 116, 155, 0.16), transparent 32%),
    radial-gradient(circle at 18% 78%, rgba(91, 203, 255, 0.14), transparent 30%),
    rgba(10, 16, 25, 0.93);
  padding: 18px 16px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 12px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.upgrades-shell::before {
  content: "";
  position: absolute;
  right: 26px;
  top: 96px;
  width: 16px;
  height: 42px;
  border-radius: 12px 12px 8px 8px;
  background: linear-gradient(180deg, #f0f7ff, #8ea8c7);
  border: 1px solid rgba(255, 255, 255, 0.34);
  transform: rotate(24deg);
  opacity: 0.7;
  pointer-events: none;
}

.upgrades-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.upgrades-header-actions {
  display: flex;
  gap: 8px;
}

.panel-title {
  margin: 0;
  flex: 1;
  font-size: clamp(1.8rem, 6vw, 2.5rem);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f7fbff;
  padding: 8px 12px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(86, 193, 255, 0.18), rgba(255, 91, 110, 0.18));
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.upgrades-wallet {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  padding: 12px 12px;
}

.wallet-coin-icon {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: 0 0 auto;
}

.wallet-label {
  font-size: 1.2rem;
  color: #c1d2e3;
}

.upgrades-wallet strong {
  margin-left: auto;
  color: var(--accent-gold);
  font-size: 1.6rem;
}

.ship-shop-list {
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  overscroll-behavior: contain;
  display: grid;
  gap: 8px;
}

.ship-shop-row {
  min-height: 228px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.045);
  padding: 20px 16px;
  display: grid;
  grid-template-columns: 136px 1fr auto;
  gap: 14px;
  align-items: center;
}

.ship-shop-image {
  width: 136px;
  height: 136px;
  object-fit: contain;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.05));
  padding: 4px;
}

.ship-shop-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.ship-shop-title {
  margin: 0;
  font-size: 2.1rem;
  line-height: 1.04;
  color: #f2f7ff;
}

.ship-shop-desc {
  margin: 0;
  font-size: 1.52rem;
  line-height: 1.22;
  color: #bcd0e5;
}

.ship-shop-cost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 209, 102, 0.08);
  color: var(--accent-gold);
  font-size: 1.12rem;
  font-weight: 700;
  padding: 6px 10px;
  width: fit-content;
}

.ship-shop-cost img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.ship-shop-action {
  min-height: 56px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, #7dd6ff, #ffd78a);
  color: #08131d;
  font-weight: 700;
  font-size: 1.04rem;
  padding: 8px 12px;
}

.ship-shop-action[data-state="equipped"] {
  background: linear-gradient(135deg, #6fffab, #7dd6ff);
}

.ship-shop-action[data-state="locked"] {
  background: linear-gradient(135deg, #ffd166, #ffe9a5);
}

.shop-buy-modal {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: rgba(4, 7, 12, 0.62);
  display: grid;
  place-items: center;
  padding: 14px;
}

.shop-buy-modal::before {
  content: "";
  position: absolute;
  width: 160px;
  height: 160px;
  border-radius: 999px;
  left: calc(50% - 176px);
  top: calc(50% - 118px);
  background: radial-gradient(circle at 34% 30%, #fff08d, #ff9f3c);
  border: 3px solid rgba(255, 255, 255, 0.42);
}

.shop-buy-card {
  width: min(100%, 420px);
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 211, 106, 0.34), transparent 32%),
    radial-gradient(circle at 84% 10%, rgba(110, 170, 255, 0.3), transparent 36%),
    linear-gradient(160deg, #3a284f, #1f3557);
  padding: 22px 18px;
  display: grid;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.shop-buy-title {
  margin: 0;
  text-align: center;
  font-size: 1.55rem;
  color: #f8fcff;
}

.shop-buy-cost {
  margin: 0;
  text-align: center;
  color: #ffd166;
  font-size: 1.3rem;
}

.shop-buy-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.zone-track {
  display: none;
}

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-content: start;
}

.empty-upgrades {
  grid-template-columns: 1fr;
}

.upgrade-empty-note {
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #c3d4e7;
  line-height: 1.4;
}

.upgrade-card {
  text-align: left;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  display: grid;
  gap: 8px;
}

.upgrade-card.disabled {
  opacity: 0.55;
}

.upgrade-controls {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.upgrade-step {
  min-width: 34px;
  min-height: 28px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-weight: 700;
}

.upgrade-step:disabled,
.upgrade-buy:disabled {
  opacity: 0.45;
}

.upgrade-name,
.upgrade-cost {
  display: block;
}

.upgrade-name {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 2px;
}

.upgrade-card strong {
  display: block;
  font-size: 1.05rem;
}

.upgrade-cost {
  color: var(--accent-gold);
  font-size: 0.85rem;
}

.upgrade-buy {
  min-height: 33px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #08131d;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-gold), #ffe78f);
}

.tutorial-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  pointer-events: none;
}

.tutorial-card {
  position: fixed;
  z-index: 10002;
  left: 50%;
  top: 62%;
  transform: translateX(-50%);
  width: min(92vw, 540px);
  padding: 18px 18px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(5, 10, 16, 0.92);
  color: #f3f7fb;
  font-size: 1.34rem;
  line-height: 1.3;
  text-align: center;
}

.tutorial-arrow {
  position: fixed;
  z-index: 10001;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  filter: drop-shadow(0 3px 8px rgba(0, 0, 0, 0.4));
}

.tutorial-arrow.down {
  border-top: 16px solid #ffd166;
}

.tutorial-arrow.up {
  border-bottom: 16px solid #ffd166;
}

.tutorial-highlight {
  position: relative;
  z-index: 9999;
  box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.5);
  border-radius: 12px;
}

@media (max-width: 560px) {
  .app-shell {
    width: 100%;
    padding: 8px;
    gap: 6px;
  }

  .meta-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .upgrade-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .upgrades-header {
    flex-direction: column;
    align-items: stretch;
  }

  .upgrades-header-actions {
    justify-content: flex-end;
  }

  .upgrades-shell {
    width: min(100%, 460px);
    padding: 12px 10px;
    gap: 8px;
  }

  .ship-shop-row {
    min-height: 176px;
    grid-template-columns: 108px 1fr auto;
    padding: 12px;
  }

  .ship-shop-image {
    width: 108px;
    height: 108px;
  }

  .ship-shop-title {
    font-size: 1.56rem;
  }

  .ship-shop-desc {
    font-size: 1.12rem;
  }

  .ship-shop-action {
    min-height: 48px;
    font-size: 0.92rem;
    padding: 7px 9px;
  }

  .title-card,
  .card {
    min-height: 420px;
    padding: 24px 20px;
  }

  .title-heading {
    font-size: clamp(2.2rem, 10vw, 3rem);
  }

  .title-subhead {
    font-size: 1.15rem;
  }

  .body-copy {
    font-size: 1.08rem;
  }

}

@media (orientation: landscape) and (max-height: 620px) {
  .app-shell {
    width: min(100%, 980px);
    padding: 6px 8px;
    gap: 5px;
  }

  .hud-chip {
    padding: 6px 8px;
  }

  .meta-chip {
    padding: 5px 7px;
  }

  .hud strong,
  .meta-chip strong {
    font-size: 0.84rem;
  }

  .hud-label {
    font-size: 0.58rem;
    margin-bottom: 2px;
  }

  .upgrades-screen {
    padding: 8px;
    padding-bottom: calc(8px + var(--native-banner-inset) + env(safe-area-inset-bottom));
  }

  .upgrades-shell {
    height: min(100%, calc(var(--app-vh) - var(--native-banner-inset) - env(safe-area-inset-bottom) - 16px));
    padding: 9px;
    gap: 7px;
  }
}

@media (max-height: 760px) {
  .app-shell {
    padding: 8px;
    gap: 6px;
  }

  .hud-chip {
    padding: 8px 10px;
  }

  .meta-chip {
    padding: 6px 8px;
  }

  .control-button {
    min-height: 42px;
    font-size: 0.88rem;
  }

  .game-frame {
    border-radius: 18px;
  }

  .upgrades-shell {
    padding: 10px;
    gap: 8px;
  }
}

@media (min-width: 900px) {
  .upgrades-shell {
    width: min(100%, 560px);
  }
}
