.game-wrap {
  width: min(calc(100% - var(--gutter) * 2), 1420px);
  margin: clamp(1rem, 2.5vw, 1.75rem) auto clamp(3rem, 8vw, 6rem);
  scroll-margin-top: var(--scroll-offset);
}

/* Three rows: topbar / play area / tabs. The height must be definite so the
   middle row resolves to the leftover space instead of its content height;
   that lets the panels and the drawer size themselves off the real chrome
   heights rather than hard-coded offsets. */
.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: clamp(700px, 80vh, 840px);
  overflow: hidden;
  border: 1px solid rgba(141,164,240,.22);
  border-radius: 28px;
  background:
    radial-gradient(circle at 50% 38%, rgba(58,90,180,.22), transparent 25rem),
    linear-gradient(160deg, rgba(12,17,42,.97), rgba(6,9,24,.98));
  box-shadow: 0 28px 90px rgba(0,0,0,.45), 0 0 80px rgba(77,232,255,.05);
  isolation: isolate;
}

.game-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  opacity: .32;
  background-image: radial-gradient(circle, #fff 0 1px, transparent 1.25px);
  background-size: 61px 61px;
  mask-image: linear-gradient(to bottom, #000, transparent 76%);
  animation: starfield-drift 46s linear infinite, stars-twinkle 8s ease-in-out infinite;
  will-change: background-position, opacity;
}

/* ----------------------------------------------------------------- top bar */
.game-topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(5,8,23,.65);
}

.game-brand { display: flex; align-items: center; gap: .7rem; min-width: 176px; }
.game-brand strong { display: block; line-height: 1.15; }
.game-brand small { color: var(--muted); font-size: .76rem; }
.hud { display: flex; justify-content: center; align-items: center; gap: clamp(.6rem, 2vw, 1.5rem); flex: 1; min-width: 0; }
.hud-stat { min-width: 96px; }
.hud-stat__label {
  display: block;
  color: #9aa4c8;
  font-size: .72rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  font-weight: 800;
}
.hud-stat__value {
  display: block;
  color: #fff;
  font-size: clamp(.95rem, 2vw, 1.15rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  white-space: nowrap;
}
.hud-stat__value--energy { color: var(--cyan); }
.game-actions { min-width: 176px; display: flex; justify-content: flex-end; gap: .45rem; }

.icon-button {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 13px;
  color: #e3e8fb;
  background: rgba(255,255,255,.055);
  cursor: pointer;
  transition: background-color .18s ease, border-color .18s ease, transform .18s var(--ease), color .18s ease;
}
.icon-button:hover { background: rgba(255,255,255,.13); border-color: rgba(77,232,255,.45); color: #fff; transform: translateY(-1px); }
.icon-button:active { transform: translateY(1px) scale(.96); }

/* --------------------------------------------------------------- play area */
.game-main {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 290px) minmax(330px, 1fr) minmax(220px, 290px);
  min-height: 0;
}

.game-side {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: .9rem;
  background: rgba(8,12,31,.58);
}
.game-side--left { border-right: 1px solid var(--line); }
.game-side--right { border-left: 1px solid var(--line); }

/* Soft fade so a scrolling list never looks like it was chopped off. */
.game-side::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  bottom: 0;
  height: 58px;
  background: linear-gradient(to top, rgb(9 13 33) 12%, rgb(9 13 33 / .82) 45%, rgb(9 13 33 / 0));
  pointer-events: none;
}

/* Same cue for the overlay drawer, but only while it is actually open. */
.game-main:has(> .game-drawer[data-open="true"])::after {
  content: "";
  position: absolute;
  z-index: 26;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  background: linear-gradient(to top, rgb(6 9 24) 14%, rgb(6 9 24 / .82) 48%, rgb(6 9 24 / 0));
  pointer-events: none;
}

.panel-title { display: flex; justify-content: space-between; align-items: center; gap: .5rem; min-height: 40px; margin-bottom: .65rem; }
.panel-title h2 { margin: 0; font-size: .95rem; letter-spacing: .01em; }
.panel-title small { color: var(--muted); font-size: .78rem; }

.card-list {
  display: grid;
  align-content: start;
  gap: .6rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  /* room for focus rings on the left and for the bottom fade */
  padding: 4px 6px 2.5rem 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(107,140,255,.55) transparent;
}
.card-list::-webkit-scrollbar { width: 8px; }
.card-list::-webkit-scrollbar-thumb { background: rgba(107,140,255,.45); border-radius: 8px; }
.card-list::-webkit-scrollbar-thumb:hover { background: rgba(107,140,255,.7); }

/* -------------------------------------------------------------- shop cards */
.shop-card {
  display: flex;
  flex-direction: column;
  padding: .85rem;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.045);
  transition: border-color .2s ease, background-color .2s ease, transform .2s var(--ease);
}
.shop-card:hover { border-color: var(--line-strong); background: rgba(255,255,255,.07); }
.shop-card[data-affordable="true"] { border-color: rgba(77,232,255,.3); background: rgba(77,232,255,.045); }
.shop-card[data-affordable="true"]:hover { border-color: rgba(77,232,255,.55); transform: translateY(-1px); }
.shop-card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.shop-card h3 { margin: 0; font-size: .88rem; line-height: 1.35; }
.shop-card__level { color: var(--cyan); font-size: .75rem; font-weight: 800; white-space: nowrap; }
.shop-card__meta { margin: .4rem 0 .75rem; color: var(--muted); font-size: .76rem; line-height: 1.5; }
/* auto margin keeps every buy button on the same line inside a row of cards */
.shop-card__buy { width: 100%; min-height: 40px; margin-top: auto; padding: .5rem .65rem; font-size: .8rem; }

.buy-mode { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; margin-bottom: .75rem; }
.buy-mode button {
  min-height: 38px;
  padding: .25rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #b9c1de;
  background: rgba(255,255,255,.04);
  cursor: pointer;
  font-size: .76rem;
  font-weight: 800;
  transition: background-color .18s ease, color .18s ease, border-color .18s ease;
}
.buy-mode button:hover { color: #fff; background: rgba(255,255,255,.1); border-color: var(--line-strong); }
.buy-mode button[aria-pressed="true"] { color: #07101c; background: var(--cyan); border-color: var(--cyan); }
.buy-mode button[aria-pressed="true"]:hover { background: #6fefff; color: #07101c; }

/* ------------------------------------------------------------ planet stage */
.planet-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-width: 0;
  min-height: 0;
  padding: 1rem;
  overflow: hidden;
}
.planet-stage::before {
  content: "";
  position: absolute;
  z-index: 1;
  width: min(90%, 520px);
  aspect-ratio: 1;
  border: 1px solid rgba(132,156,234,.12);
  border-radius: 50%;
  box-shadow: 0 0 0 50px rgba(111,142,239,.025), 0 0 0 110px rgba(111,142,239,.018);
}
.planet-stage::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 3%;
  pointer-events: none;
  opacity: .34;
  background-image:
    radial-gradient(circle, rgba(255,255,255,.82) 0 1px, transparent 1.4px),
    radial-gradient(circle, rgba(115,197,255,.72) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(202,178,255,.6) 0 .8px, transparent 1.3px);
  background-position: 0 0, 31px 47px, 73px 19px;
  background-size: 137px 89px, 113px 127px, 79px 101px;
  mask-image: radial-gradient(circle at center, transparent 0 32%, #000 48%, rgba(0,0,0,.78) 70%, transparent 88%);
  animation: near-stars-drift 58s linear infinite, stars-twinkle 6.5s ease-in-out infinite reverse;
  will-change: background-position, opacity;
}
.planet-info { position: relative; z-index: 3; text-align: center; margin-bottom: .9rem; }
.planet-info__name { display: block; font-size: .8rem; letter-spacing: .16em; text-transform: uppercase; color: #eaeeff; font-weight: 800; }
.planet-info__level { display: block; color: var(--muted); font-size: .78rem; }
.level-bar {
  width: min(240px, 68vw);
  height: 6px;
  margin: .5rem auto 0;
  overflow: hidden;
  border-radius: 9px;
  background: rgba(255,255,255,.14);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.level-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--cyan), var(--violet)); transition: width .3s ease; }

.planet-button {
  position: relative;
  z-index: 2;
  isolation: isolate;
  width: min(clamp(190px, 28vw, 320px), 46vh);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  filter: drop-shadow(0 22px 28px rgba(0,0,20,.52)) drop-shadow(0 0 24px rgba(85,193,255,.22));
  transition: transform .28s var(--ease), filter .35s ease;
  transform: translateZ(0);
  backface-visibility: hidden;
}
.planet-button:hover { filter: drop-shadow(0 22px 30px rgba(0,0,20,.55)) drop-shadow(0 0 34px rgba(85,193,255,.34)); }
.planet-button::before {
  content: "";
  position: absolute;
  inset: 5%;
  border-radius: 50%;
  background: var(--planet-surface, radial-gradient(circle at 34% 28%, #c7f5ff 0 3%, #4ebdd1 4% 14%, #2075a2 15% 30%, #3152ad 32% 58%, #102259 72%));
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  box-shadow: inset -40px -25px 45px rgba(0,0,16,.72), inset 15px 10px 28px rgba(255,255,255,.18), 0 0 26px 7px var(--planet-glow, rgba(77,232,255,.2));
  animation: planet-breathe 6s ease-in-out infinite;
  will-change: transform, filter;
  backface-visibility: hidden;
}
.planet-button::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 3%;
  border: 1px solid var(--planet-ring, rgba(77,232,255,.34));
  border-radius: 50%;
  box-shadow: 0 0 26px var(--planet-glow, rgba(77,232,255,.3)), inset 0 0 20px rgba(77,232,255,.13);
  pointer-events: none;
}
.planet-texture { position: absolute; z-index: 2; inset: 6%; overflow: hidden; border-radius: 50%; background: repeating-radial-gradient(ellipse at 35% 45%, transparent 0 7%, rgba(255,255,255,.08) 8%, transparent 14%); mix-blend-mode: soft-light; animation: planet-rotate 36s linear infinite; will-change: transform; backface-visibility: hidden; }
.planet-shine { position: absolute; z-index: 3; inset: 7%; border-radius: 50%; background: radial-gradient(circle at 29% 22%, rgba(255,255,255,.16), transparent 30%), linear-gradient(125deg, transparent 48%, rgba(1,4,18,.18) 67%, rgba(1,3,14,.48) 100%); box-shadow: inset 10px 6px 20px rgba(255,255,255,.06); pointer-events: none; }
.planet-button:active { transform: translateZ(0) scale(.972); }
.planet-button.is-picked { animation: planet-pick .34s var(--ease); }
.planet-button[data-planet="earth"] { --planet-surface: url("../assets/images/planet-picker-earth-globe-v2.webp"); --planet-glow: rgba(68,190,255,.38); --planet-ring: rgba(138,224,255,.52); }
.planet-button[data-planet="earth"]::before { inset: 1%; background-size: 116% 116%; box-shadow: 0 0 18px rgba(76,199,255,.4), 0 0 54px rgba(29,105,208,.24); animation: earth-float-360 16s ease-in-out infinite; }
.planet-button[data-planet="earth"]::after { inset: 1%; border-color: rgba(139,224,255,.45); box-shadow: 0 0 12px rgba(110,215,255,.42), 0 0 38px rgba(44,127,244,.24), inset 0 0 14px rgba(170,232,255,.15); animation: atmosphere-pulse 7s ease-in-out infinite; will-change: transform, opacity; backface-visibility: hidden; }
.planet-button[data-planet="earth"] .planet-texture { inset: 2%; background: radial-gradient(circle at 32% 25%, rgba(255,255,255,.09), transparent 30%), repeating-radial-gradient(ellipse at 53% 51%, transparent 0 12%, rgba(255,255,255,.018) 13%, transparent 18%); mix-blend-mode: screen; opacity: .7; animation-duration: 96s; }
.planet-button[data-planet="earth"] .planet-shine { inset: 2%; background: radial-gradient(circle at 28% 20%, rgba(255,255,255,.11), transparent 24%), linear-gradient(128deg, transparent 52%, rgba(0,2,12,.13) 69%, rgba(0,2,10,.38) 100%); }
.planet-button[data-planet="moon"] { --planet-surface: radial-gradient(circle at 38% 32%, #f5f2de 0 6%, #9da5ad 7% 13%, #c7c9c8 14% 38%, #6d7680 70%); --planet-glow: rgba(220,226,255,.24); }
.planet-button[data-planet="mars"] { --planet-surface: radial-gradient(circle at 35% 28%, #ffd0a1 0 4%, #c5583f 5% 22%, #9f3028 23% 48%, #541922 73%); --planet-glow: rgba(255,107,74,.32); --planet-ring: rgba(255,139,91,.45); }
.planet-button[data-planet="venus"] { --planet-surface: repeating-radial-gradient(ellipse at 42% 34%, #ffe2a0 0 6%, #ce7843 7% 13%, #eca85c 14% 20%); --planet-glow: rgba(255,180,89,.3); }
.planet-button[data-planet="mercury"] { --planet-surface: radial-gradient(circle at 32% 30%, #e3d6c5, #857a78 42%, #3c3743 78%); --planet-glow: rgba(214,205,190,.22); }
.planet-button[data-planet="jupiter"] { --planet-surface: repeating-linear-gradient(5deg, #8e563e 0 7%, #e1b07b 8% 17%, #b67c58 18% 25%, #f3d4a5 26% 34%); --planet-glow: rgba(255,198,137,.28); }
.planet-button[data-planet="saturn"] { --planet-surface: repeating-linear-gradient(-3deg, #d2a65a 0 10%, #f0d499 11% 22%, #a77b43 23% 28%); --planet-glow: rgba(255,216,139,.3); }
.planet-button[data-planet="uranus"] { --planet-surface: linear-gradient(145deg,#bff7f2,#54aabd 65%,#32657c); --planet-glow: rgba(120,255,244,.28); }
.planet-button[data-planet="neptune"] { --planet-surface: repeating-linear-gradient(0deg,#1f57e1 0 12%,#1335a0 13% 25%,#4c78ed 26% 31%); --planet-glow: rgba(72,111,255,.36); }
.planet-button[data-planet="pluto"] { --planet-surface: radial-gradient(circle at 35% 33%,#f0d1b6,#a67561 38%,#51424a 72%); --planet-glow: rgba(214,184,173,.25); }

.planet-prompt { position: relative; z-index: 3; margin-top: 1.1rem; text-align: center; color: var(--muted); font-size: .8rem; }
.planet-prompt strong { display: block; color: #fff; font-size: .95rem; }
.combo-pill { display: none; min-height: 30px; margin-top: .6rem; padding: .25rem .8rem; border-radius: 999px; color: var(--gold); background: rgba(255,211,106,.12); border: 1px solid rgba(255,211,106,.28); font-size: .8rem; font-weight: 800; opacity: 0; transform: translateY(5px); transition: opacity .2s ease, transform .2s ease; }
.combo-pill.is-active { display: block; opacity: 1; transform: none; }
.floating-reward { position: absolute; z-index: 10; left: var(--x, 50%); top: var(--y, 45%); color: var(--cyan); font-weight: 900; text-shadow: 0 2px 12px #000; pointer-events: none; animation: float-reward .9s ease-out forwards; }
.floating-reward.is-critical { color: var(--gold); font-size: 1.1rem; }
.spark { position: absolute; z-index: 7; left: var(--x); top: var(--y); width: 5px; height: 5px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 8px var(--cyan); pointer-events: none; animation: spark-fly .65s ease-out forwards; }

/* ------------------------------------------------------------------- tabs */
.game-tabs { min-height: 68px; display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); background: rgba(5,8,23,.72); }
.game-tab {
  position: relative;
  display: grid;
  place-items: center;
  align-content: center;
  gap: .2rem;
  min-width: 0;
  min-height: 68px;
  padding: .4rem .3rem;
  border: 0;
  border-right: 1px solid var(--line);
  color: #99a3c4;
  background: transparent;
  cursor: pointer;
  font-size: .78rem;
  font-weight: 700;
  transition: color .18s ease, background-color .18s ease;
}
.game-tab:last-child { border-right: 0; }
.game-tab span:first-child { font-size: 1.05rem; }
.game-tab:hover { color: #e6edff; background: rgba(255,255,255,.05); }
.game-tab[aria-selected="true"] { color: var(--cyan); background: rgba(77,232,255,.07); }
.game-tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
}

/* ------------------------------------------------------------------ drawer */
.game-drawer {
  position: absolute;
  z-index: 25;
  inset: 0;
  display: none;
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(1rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2.5rem) clamp(2.5rem, 5vw, 3.5rem);
  background: rgba(6,9,24,.97);
  backdrop-filter: blur(20px);
  scrollbar-width: thin;
  scrollbar-color: rgba(107,140,255,.55) transparent;
}
.game-drawer[data-open="true"] { display: block; }
.game-drawer::-webkit-scrollbar { width: 10px; }
.game-drawer::-webkit-scrollbar-thumb { background: rgba(107,140,255,.45); border-radius: 8px; }
.game-drawer::-webkit-scrollbar-thumb:hover { background: rgba(107,140,255,.7); }

.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; max-width: 1060px; margin: 0 auto 1.35rem; }
.drawer-head h2 { margin: 0; font-size: clamp(1.3rem, 3vw, 1.9rem); letter-spacing: -.018em; }
.drawer-grid { max-width: 1060px; margin-inline: auto; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .85rem; align-items: stretch; }

/* The upgrade and generator panels reuse the side-panel list markup. Inside the
   drawer the drawer itself scrolls, so the list must lay out full width and
   grow with its content instead of becoming a nested scroller. */
.game-drawer[data-panel="upgrades"] .drawer-grid,
.game-drawer[data-panel="generators"] .drawer-grid { grid-template-columns: minmax(0, 1fr); }
.game-drawer .card-list { flex: none; overflow: visible; padding: 4px 6px .5rem 4px; }

.drawer-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255,255,255,.04);
  transition: border-color .2s ease, background-color .2s ease, transform .2s var(--ease);
}
.drawer-card:hover { border-color: var(--line-strong); background: rgba(255,255,255,.065); transform: translateY(-2px); }
.drawer-card h3 { margin: .5rem 0 .45rem; font-size: 1rem; line-height: 1.35; }
.drawer-card p { margin: .3rem 0; color: var(--muted); font-size: .84rem; }
.drawer-card .badge { align-self: flex-start; }
/* the action always sits on the card floor so a row of cards stays aligned */
.drawer-card > .button { margin-top: auto; }
.progress {
  height: 7px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255,255,255,.16);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.07);
}
.drawer-card .progress { margin: .75rem 0 .5rem; }
.drawer-card .progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--cyan),var(--violet)); transition: width .35s ease; }
.drawer-card.is-complete { border-color: rgba(102,242,178,.36); background: rgba(102,242,178,.05); }
.drawer-card.is-complete:hover { border-color: rgba(102,242,178,.55); }
.drawer-card.is-locked { opacity: .8; }
.drawer-card.is-locked:hover { opacity: 1; }

.badge { display: inline-flex; padding: .25rem .55rem; border-radius: 999px; color: var(--cyan); background: rgba(77,232,255,.12); box-shadow: inset 0 0 0 1px rgba(77,232,255,.2); font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.badge--gold { color: var(--gold); background: rgba(255,211,106,.12); box-shadow: inset 0 0 0 1px rgba(255,211,106,.22); }
.requirements { margin: .6rem 0; padding: 0; list-style: none; font-size: .78rem; line-height: 1.6; color: var(--muted); }
.requirements li::before { content: "○"; margin-right: .4rem; color: var(--danger); }
.requirements li.is-met { color: #cfd6ef; }
.requirements li.is-met::before { content: "✓"; color: var(--green); }

/* ----------------------------------------------------------- solar system */
.solar-system {
  position: relative;
  min-height: 430px;
  grid-column: 1 / -1;
  overflow: hidden;
  margin-bottom: .25rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: radial-gradient(circle at 50% 50%, rgba(255,208,89,.12), transparent 18%, rgba(76,99,193,.06) 48%, transparent 65%);
}
.sun {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  transform: translate(-50%,-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,#fff8c1,#ffd45e 35%,#f27b32 72%);
  box-shadow: 0 0 32px #f6ae4b, 0 0 70px rgba(246,174,75,.35);
}
.orbit {
  --angle: 0deg;
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--orbit);
  aspect-ratio: 1;
  transform: translate(-50%,-50%) rotate(var(--angle));
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
}
/* Spread the eight worlds around their rings; stacked at 12 o'clock they
   collided and their name labels piled on top of each other. */
.solar-system .orbit:nth-child(2) { --angle: 20deg; }
.solar-system .orbit:nth-child(3) { --angle: 65deg; }
.solar-system .orbit:nth-child(4) { --angle: 110deg; }
.solar-system .orbit:nth-child(5) { --angle: 155deg; }
.solar-system .orbit:nth-child(6) { --angle: 200deg; }
.solar-system .orbit:nth-child(7) { --angle: 245deg; }
.solar-system .orbit:nth-child(8) { --angle: 290deg; }
.solar-system .orbit:nth-child(9) { --angle: 335deg; }

.orbit button {
  position: absolute;
  left: 50%;
  top: -16px;
  width: 32px;
  height: 32px;
  margin-left: -16px;
  border: 1px solid rgba(255,255,255,.4);
  border-radius: 50%;
  background: var(--orb-color,#688cff);
  color: #fff;
  font-size: 0;
  cursor: pointer;
  box-shadow: 0 0 12px var(--orb-color,#688cff), inset 0 -4px 8px rgba(0,0,20,.4);
  transform: rotate(calc(-1 * var(--angle)));
  transition: box-shadow .2s ease, scale .2s var(--ease), filter .2s ease;
}
.orbit button:hover,
.orbit button:focus-visible { scale: 1.2; box-shadow: 0 0 22px var(--orb-color,#688cff), inset 0 -4px 8px rgba(0,0,20,.4); }
.orbit button::after {
  content: attr(aria-label);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: .2rem .45rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: #e7ecff;
  background: rgba(5,7,19,.94);
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity .18s ease;
  pointer-events: none;
}
.orbit button:hover::after,
.orbit button:focus-visible::after { opacity: 1; }
/* rings sitting in the lower half get their label above the dot instead */
.solar-system .orbit:nth-child(4) button::after,
.solar-system .orbit:nth-child(5) button::after,
.solar-system .orbit:nth-child(6) button::after,
.solar-system .orbit:nth-child(7) button::after { top: auto; bottom: calc(100% + 8px); }
.orbit button[disabled] { filter: grayscale(.85) brightness(.75); opacity: .65; cursor: not-allowed; }
.orbit button[disabled]:hover { scale: 1.1; opacity: .9; }

/* --------------------------------------------------------- asteroid event */
.asteroid-event {
  position: absolute;
  z-index: 31;
  left: 50%;
  top: 48%;
  width: min(340px, calc(100% - 2rem));
  transform: translate(-50%,-50%);
  padding: 1.15rem;
  text-align: center;
  border: 1px solid rgba(255,211,106,.42);
  border-radius: 18px;
  background: rgba(15,14,32,.96);
  box-shadow: var(--shadow);
}
.asteroid-event[hidden] { display: none; }
.asteroid-event h2 { margin: 0; color: var(--gold); font-size: 1.05rem; }
.asteroid-target {
  width: 112px;
  height: 112px;
  margin: .9rem auto;
  border: 0;
  border-radius: 46% 54% 42% 58%;
  background: radial-gradient(circle at 35% 30%,#ae9276,#665548 42%,#2a2530 74%);
  box-shadow: inset -18px -15px 22px rgba(0,0,0,.42),0 0 22px rgba(255,211,106,.15);
  cursor: crosshair;
  animation: asteroid-wobble 2s ease-in-out infinite;
  transition: box-shadow .18s ease, filter .18s ease;
}
.asteroid-target:hover { filter: brightness(1.12); box-shadow: inset -18px -15px 22px rgba(0,0,0,.42), 0 0 32px rgba(255,211,106,.35); }
.asteroid-target:active { filter: brightness(1.25); }
.asteroid-event.is-golden .asteroid-target { background: radial-gradient(circle at 35% 30%,#fff3b1,#daa738 45%,#705016 75%); box-shadow: 0 0 34px rgba(255,211,106,.45); }
.asteroid-event .progress { margin: 0; }
.asteroid-event .progress span { display: block; height: 100%; width: 100%; border-radius: inherit; background: linear-gradient(90deg,var(--danger),var(--gold)); }
.asteroid-meta { display: flex; justify-content: space-between; margin-top: .45rem; color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ modals */
.modal-backdrop { position: fixed; z-index: 250; inset: 0; display: grid; place-items: center; padding: 1rem; background: rgba(2,4,13,.82); backdrop-filter: blur(9px); }
.modal-backdrop[hidden] { display: none; }
.modal {
  position: relative;
  width: min(560px, 100%);
  max-height: min(780px, calc(100vh - 2rem));
  overflow: auto;
  padding: clamp(1.35rem,4vw,2rem);
  border: 1px solid rgba(141,164,240,.28);
  border-radius: 20px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}
.modal--wide { width: min(760px,100%); }
/* right gutter keeps headings clear of the floating close button */
.modal h2 { margin: 0 2.9rem .5rem 0; font-size: 1.45rem; line-height: 1.3; letter-spacing: -.018em; }
#tutorialModal h2 { margin-right: 0; }
.modal p { color: var(--muted); }
.modal-close { position: absolute; right: .8rem; top: .8rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: 1.4rem; }
.modal-actions .button { flex: 1 1 150px; }
.settings-grid { display: grid; gap: .55rem; }
.setting-row {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.035);
  transition: border-color .18s ease, background-color .18s ease;
}
.setting-row:hover { border-color: var(--line-strong); background: rgba(255,255,255,.06); }
.setting-row label { font-size: .9rem; font-weight: 600; cursor: pointer; }

/* Switch-style checkboxes: the browser default renders as a washed-out
   khaki square on this dark surface and reads as broken rather than "off". */
.setting-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 46px;
  height: 26px;
  margin: 0;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255,255,255,.09);
  cursor: pointer;
  transition: background-color .22s ease, border-color .22s ease;
}
.setting-row input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border-radius: 50%;
  background: #c6cee9;
  transition: transform .22s var(--ease), background-color .22s ease;
}
.setting-row input[type="checkbox"]:hover { border-color: rgba(77,232,255,.45); }
.setting-row input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  border-color: rgba(77,232,255,.6);
}
.setting-row input[type="checkbox"]:checked::after { transform: translateX(20px); background: #05121f; }

.setting-row input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: min(180px,42vw);
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.setting-row input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 6px; background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 1px rgba(255,255,255,.07); }
.setting-row input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -6px; border: 2px solid #061024; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px rgba(77,232,255,.5); }
.setting-row input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: rgba(255,255,255,.16); }
.setting-row input[type="range"]::-moz-range-progress { height: 6px; border-radius: 6px; background: var(--cyan); }
.setting-row input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border: 2px solid #061024; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 10px rgba(77,232,255,.5); }

.save-text {
  width: 100%;
  min-height: 130px;
  resize: vertical;
  padding: .8rem;
  color: #dce4ff;
  background: #080c20;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .78rem;
  line-height: 1.55;
  transition: border-color .18s ease;
}
.save-text:focus, .confirm-input:focus { border-color: rgba(77,232,255,.6); }
.confirm-input {
  width: 100%;
  min-height: 46px;
  margin-top: .5rem;
  padding: .7rem .85rem;
  color: #fff;
  background: #080c20;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  transition: border-color .18s ease;
}
.tutorial-step { display: block; color: var(--cyan); font-size: .8rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.tutorial-visual { display: grid; place-items: center; width: 90px; height: 90px; margin: 1.1rem auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%,#9df6ff,#286bb5 55%,#102652); box-shadow: 0 0 28px rgba(77,232,255,.28); font-size: 2rem; }
.reward-reveal { padding: 1.1rem; margin: 1.1rem 0; text-align: center; border: 1px solid rgba(255,211,106,.32); border-radius: 14px; background: rgba(255,211,106,.06); color: var(--muted); }
.reward-reveal strong { display: block; color: var(--gold); font-size: 1.45rem; line-height: 1.3; }

/* ------------------------------------------------------------------ toasts */
.toast-region { position: fixed; z-index: 400; right: 1rem; bottom: 1rem; display: grid; gap: .6rem; width: min(350px, calc(100% - 2rem)); pointer-events: none; }
.toast { padding: .85rem 1rem; border: 1px solid rgba(77,232,255,.3); border-radius: var(--radius-sm); color: #eef4ff; background: rgba(14,22,49,.97); box-shadow: 0 12px 40px rgba(0,0,0,.35); font-size: .88rem; line-height: 1.5; animation: toast-in .25s ease both; }
.toast--error { border-color: rgba(255,102,141,.5); }
.toast--reward { border-color: rgba(255,211,106,.5); }

.mobile-game-nav { display: none; }

body.reduce-motion .planet-button::before,
body.reduce-motion .planet-button::after,
body.reduce-motion .planet-texture,
body.reduce-motion .asteroid-target,
body.reduce-motion .game-shell::before,
body.reduce-motion .planet-stage::after { animation: none !important; }
body.no-particles .spark { display: none; }
