:root {
  color-scheme: dark;
  --ui-scale: 1;
  --bg: #030407;
  --ink: #f4f4ee;
  --muted: #9ca1aa;
  --soft: rgba(255, 255, 255, 0.07);
  --line: rgba(255, 255, 255, 0.13);
  --amber: #ffcf6b;
  --ember: #ff7f4d;
  --aqua: #70efe4;
  --violet: #a58cff;
  --danger: #ff5f75;
  --good: #8ff0a4;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: auto;
  min-height: 100%;
  margin: 0;
  background: radial-gradient(circle at 50% 10%, #11131c 0, var(--bg) 52%);
  color: var(--ink);
  font-size: calc(16px * var(--ui-scale));
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: auto;
  -webkit-overflow-scrolling: touch;
  -webkit-tap-highlight-color: transparent;
}

body.graphics-low #void-canvas {
  display: none;
}

body.graphics-medium .ring-one {
  animation: none;
}

body.high-contrast {
  --ink: #ffffff;
  --muted: #d9d9d9;
  --line: rgba(255, 255, 255, 0.34);
  --aqua: #00ffff;
  --amber: #ffe66d;
}

body.colorblind-mode {
  --amber: #f5c542;
  --ember: #d55e00;
  --aqua: #56b4e9;
  --violet: #cc79a7;
  --danger: #e69f00;
  --good: #009e73;
}

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: 0.001ms !important;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  touch-action: manipulation;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

button:hover:not(:disabled) {
  border-color: rgba(255, 207, 107, 0.65);
  background: rgba(255, 207, 107, 0.12);
}

button:active:not(:disabled) {
  transform: translateY(1px) scale(0.99);
}

button:disabled,
.disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

#void-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1440px, calc(100% - clamp(12px, 3.4vw, 32px)));
  max-width: 100%;
  min-height: 100dvh;
  height: auto;
  max-height: 100dvh;
  margin: 0 auto;
  padding: clamp(10px, 2.7vw, 26px) 0 clamp(14px, 3.2vw, 34px);
  padding-top: max(clamp(10px, 2.7vw, 26px), env(safe-area-inset-top, 0px));
  padding-bottom: max(clamp(14px, 3.2vw, 34px), env(safe-area-inset-bottom, 0px));
  overflow-x: clip;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(300px, 1.5fr);
  gap: clamp(10px, 1.9vw, 18px);
  align-items: stretch;
}

.brand,
.meter-card,
.hearth-visual,
.side-rail,
.void-map,
.collapse-core {
  border: 1px solid var(--line);
  background: rgba(3, 4, 7, 0.72);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.brand {
  display: flex;
  align-items: center;
  min-height: clamp(74px, 12vw, 104px);
  padding: clamp(12px, 2vw, 20px);
  border-radius: 8px;
}

.ember-mark {
  width: 46px;
  height: 46px;
  margin-right: 15px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 8%, var(--amber) 18%, var(--ember) 42%, transparent 72%);
  box-shadow: 0 0 28px rgba(255, 207, 107, 0.92), 0 0 90px rgba(255, 127, 77, 0.45);
  animation: pulse 2.6s ease-in-out infinite;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.65rem, 4.8vw, 4.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.brand p,
.section-title p,
.fineprint {
  color: var(--muted);
  line-height: 1.5;
}

.meters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
  gap: 10px;
}

.meter-card {
  position: relative;
  min-height: clamp(74px, 10vw, 104px);
  padding: clamp(10px, 1.7vw, 16px);
  border-radius: 8px;
}

.meter-card span,
.meter-card small {
  display: block;
  color: var(--muted);
}

.meter-card strong {
  display: block;
  margin: 7px 0 4px;
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}

.hidden {
  display: none !important;
}

.stability-wrap {
  margin-top: 14px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.stability-label {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 9px;
  color: var(--muted);
}

.stability-label strong {
  color: var(--ink);
}

.stability-rate {
  font-size: 0.78em;
  opacity: 0.75;
  margin-left: auto;
}
.stability-rate.rate-positive { color: var(--accent); }
.stability-rate.rate-negative { color: #e05c5c; }

.stability-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

#stability-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--danger), var(--amber), var(--aqua));
  transition: width 220ms ease, background 400ms ease;
}
#stability-fill.stability-low {
  background: linear-gradient(90deg, var(--danger), var(--amber));
}
#stability-fill.stability-critical {
  background: var(--danger);
  animation: stability-pulse 1.2s ease-in-out infinite;
}
@keyframes stability-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.55; }
}

.stability-danger-hint {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 0.75rem;
  line-height: 1.4;
}

.news-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  margin-top: 14px;
  border: 1px solid rgba(112, 239, 228, 0.22);
  border-radius: 8px;
  background: rgba(3, 4, 7, 0.66);
  overflow: hidden;
}

.news-track {
  position: relative;
  min-height: 36px;
  overflow: hidden;
  white-space: nowrap;
}

.news-track::before,
.news-track::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 2;
  width: 48px;
  pointer-events: none;
}

.news-track::before {
  left: 0;
  background: linear-gradient(to right, rgba(3, 4, 7, 0.9), transparent);
}

.news-track::after {
  right: 0;
  background: linear-gradient(to left, rgba(3, 4, 7, 0.9), transparent);
}

#news-line {
  position: absolute;
  left: 100%;
  top: 50%;
  transform: translateY(-50%);
  color: #e8e8df;
  font-size: 0.92rem;
  animation: newsCrawl 15s linear 1;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab {
  min-width: 80px;
  padding: clamp(9px, 1.5vw, 12px) clamp(12px, 1.8vw, 16px);
}

.tab.active {
  border-color: rgba(112, 239, 228, 0.55);
  border-bottom-color: rgba(112, 239, 228, 0.92);
  background: rgba(112, 239, 228, 0.11);
  box-shadow: inset 0 -2px 0 rgba(112, 239, 228, 0.85), 0 0 20px rgba(112, 239, 228, 0.09);
  color: rgba(112, 239, 228, 0.95);
  font-weight: 700;
}

.panel {
  display: none;
}

.panel.active {
  display: grid;
  animation: panelFadeIn 180ms ease forwards;
}

@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}

#hearth-panel {
  grid-template-columns: minmax(0, 0.35fr) minmax(0, 1.65fr);
  gap: 16px;
}

.hearth-visual {
  min-height: clamp(220px, 40vh, 360px);
  padding: clamp(12px, 2vw, 18px);
  border-radius: 8px;
}

.hearth-core {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(150px, 30vh, 210px);
  margin-bottom: 10px;
}

.ring,
.core-flame {
  position: absolute;
  border-radius: 50%;
}

.ring {
  border: 1px solid rgba(255, 207, 107, 0.26);
  animation: breathe 4s ease-in-out infinite;
}

.ring-one {
  width: 160px;
  height: 160px;
}

.ring-two {
  width: 112px;
  height: 112px;
  border-color: rgba(112, 239, 228, 0.28);
  animation-delay: -1s;
}

.core-flame {
  width: 42px;
  height: 42px;
  background: radial-gradient(circle, #fff 0 12%, var(--amber) 28%, var(--ember) 54%, transparent 75%);
  box-shadow: 0 0 40px rgba(255, 207, 107, 0.8);
}

.section-title,
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title h2 {
  padding-left: 9px;
  border-left: 2px solid rgba(112, 239, 228, 0.6);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.controls {
  display: grid;
  gap: 16px;
}

.actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.action-button {
  min-height: 80px;
  padding: 16px;
  text-align: left;
}

.action-button span,
.action-button small {
  display: block;
}

.action-button span {
  margin-bottom: 8px;
  font-weight: 800;
}

.action-button small {
  color: var(--muted);
  line-height: 1.35;
}

.primary {
  border-color: rgba(255, 207, 107, 0.8);
  background: linear-gradient(135deg, rgba(255, 207, 107, 0.18), rgba(255, 127, 77, 0.08));
  box-shadow: 0 0 10px rgba(255, 207, 107, 0.18), inset 0 0 0 1px rgba(255, 207, 107, 0.15);
  animation: gather-pulse 3s ease-in-out infinite;
}

@keyframes gather-pulse {
  0%, 100% { box-shadow: 0 0 10px rgba(255, 207, 107, 0.18), inset 0 0 0 1px rgba(255, 207, 107, 0.15); }
  50%       { box-shadow: 0 0 18px rgba(255, 207, 107, 0.38), inset 0 0 0 1px rgba(255, 207, 107, 0.35); }
}

.primary:active {
  animation: none;
  box-shadow: 0 0 24px rgba(255, 207, 107, 0.55), inset 0 0 0 1px rgba(255, 207, 107, 0.6);
}

.smart-buy-action {
  border-color: rgba(112, 239, 228, 0.68);
  background: linear-gradient(135deg, rgba(112, 239, 228, 0.15), rgba(255, 207, 107, 0.06));
  box-shadow: 0 0 14px rgba(112, 239, 228, 0.14), inset 0 0 0 1px rgba(112, 239, 228, 0.12);
}

.smart-buy-action span::after {
  content: "Recommended";
  display: inline-block;
  margin-left: 8px;
  border: 1px solid rgba(112, 239, 228, 0.32);
  border-radius: 999px;
  padding: 2px 6px;
  color: var(--cyan);
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  vertical-align: middle;
}

.seasonal-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255, 207, 107, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 207, 107, 0.18), rgba(112, 239, 228, 0.06)),
    rgba(3, 4, 7, 0.72);
  box-shadow: 0 0 24px rgba(255, 207, 107, 0.08);
  padding: 10px 12px;
}

.seasonal-banner strong {
  color: var(--amber);
  white-space: nowrap;
}

.seasonal-banner span {
  color: var(--text);
  text-align: right;
}

body.seasonal-ember-eclipse .core-flame {
  box-shadow: 0 0 54px rgba(255, 207, 107, 0.92), 0 0 90px rgba(112, 239, 228, 0.22);
}

.next-goal-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(112, 239, 228, 0.45);
  border-left: 3px solid rgba(112, 239, 228, 0.85);
  border-radius: 8px;
  background: rgba(112, 239, 228, 0.10);
  padding: 10px 14px;
  box-shadow: 0 0 10px rgba(112, 239, 228, 0.08);
}

.next-goal-card span {
  color: rgba(112, 239, 228, 0.75);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.next-goal-card strong {
  text-align: right;
  color: var(--text);
  font-size: 0.9rem;
}

.alpha-card {
  border-color: rgba(255, 207, 107, 0.28);
  background: rgba(255, 207, 107, 0.07);
}

.settings-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 4, 7, 0.58);
  padding: 14px;
}

.settings-panel.active {
  display: block;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.settings-grid button,
.settings-grid select,
.settings-grid label {
  min-height: 44px;
}

.settings-grid label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  padding: 8px 10px;
}

.settings-grid select {
  min-width: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
}

.toggle-row {
  justify-content: flex-start !important;
}

.settings-market {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.smart-buy-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.smart-buy-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.smart-buy-grid label,
.smart-buy-grid select {
  min-height: 44px;
}

.smart-buy-grid label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  padding: 8px 10px;
}

.smart-buy-grid select {
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
}

.achievement-toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10001;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  max-width: min(360px, calc(100vw - 36px));
  border: 1px solid rgba(112, 239, 228, 0.45);
  border-radius: 8px;
  background: rgba(3, 4, 7, 0.92);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  padding: 14px 12px 14px 16px;
  color: var(--ink);
}

.achievement-toast strong {
  display: block;
  color: var(--aqua);
  margin-bottom: 4px;
}

.toast-copy {
  min-width: 0;
  grid-column: 1;
  grid-row: 1;
}

.toast-close {
  grid-column: 2;
  grid-row: 1;
  width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-color: rgba(255, 95, 117, 0.58);
  background: rgba(255, 95, 117, 0.12);
  color: var(--danger);
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
}

.toast-close:hover {
  border-color: rgba(255, 95, 117, 0.9);
  background: rgba(255, 95, 117, 0.22);
}

.toast-clear {
  display: inline-flex;
  min-height: 28px;
  margin-top: 8px;
  padding: 4px 8px;
  border-color: rgba(255, 255, 255, 0.18);
  color: var(--muted);
  font-size: 0.75rem;
}

.mobile-smart-buy {
  position: fixed;
  left: 50%;
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  z-index: 9000;
  display: none;
  transform: translateX(-50%);
  min-width: min(320px, calc(100vw - 28px));
  min-height: 58px;
  padding: 10px 18px;
  border-color: rgba(255, 207, 107, 0.62);
  background: linear-gradient(135deg, rgba(255, 207, 107, 0.22), rgba(112, 239, 228, 0.12)), rgba(3, 4, 7, 0.94);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.52), 0 0 24px rgba(255, 207, 107, 0.18);
}

.mobile-smart-buy span,
.mobile-smart-buy small {
  display: block;
}

.mobile-smart-buy span {
  font-weight: 800;
}

.mobile-smart-buy small {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 0.72rem;
}

.resource-info-target {
  position: relative;
  cursor: help;
}

.resource-info-target:focus-visible {
  outline: 2px solid rgba(112, 239, 228, 0.72);
  outline-offset: 3px;
}

.resource-tooltip {
  position: fixed;
  z-index: 10000;
  width: min(340px, calc(100vw - 20px));
  white-space: pre-line;
  pointer-events: none;
  border: 1px solid rgba(112, 239, 228, 0.42);
  border-radius: 8px;
  background: rgba(3, 4, 7, 0.98);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.58);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.35;
  padding: 10px 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.68);
  padding: 18px;
}

.modal-card {
  width: min(620px, 100%);
  max-height: min(82vh, 720px);
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 4, 7, 0.96);
  box-shadow: 0 28px 100px rgba(0, 0, 0, 0.62);
  padding: 20px;
}

.modal-card h2 {
  font-size: 1.35rem;
  margin-bottom: 12px;
}

.modal-card p,
.modal-card li {
  color: var(--muted);
  line-height: 1.45;
}

.modal-card ul {
  margin: 10px 0 0;
  padding-left: 18px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}

.modal-actions button {
  min-width: 112px;
  padding: 11px 14px;
}

.floating-layer {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.float-text {
  position: absolute;
  right: 28px;
  top: 134px;
  color: var(--amber);
  font-weight: 800;
  text-shadow: 0 0 18px rgba(255, 207, 107, 0.65);
  animation: float-up 1.4s ease-out forwards;
}

.tab.has-news {
  border-color: rgba(255, 207, 107, 0.72);
  box-shadow: 0 0 18px rgba(255, 207, 107, 0.12);
}

@keyframes float-up {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(-34px);
  }
}

@keyframes val-flash {
  0%   { color: inherit; }
  25%  { color: rgba(112, 239, 228, 0.95); }
  100% { color: inherit; }
}

.val-flash {
  animation: val-flash 320ms ease forwards;
}

@keyframes newsCrawl {
  0% {
    left: 100%;
  }
  100% {
    left: -120%;
  }
}

.buildings-section {
  /* no forced min-height — grid grows with content */
}

.building-grid,
.dimension-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.building-grid {
  grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.building,
.dimension-card {
  position: relative;
  min-height: 154px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  overflow: hidden;
}

.building::before,
.dimension-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 12% 0%, rgba(255, 207, 107, 0.18), transparent 38%);
  pointer-events: none;
}

.building.locked {
  opacity: 0.55;
}

.building.affordable {
  border-left: 2px solid rgba(112, 239, 228, 0.7);
  background: rgba(112, 239, 228, 0.065);
}

.card-top {
  position: relative;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-top strong {
  display: block;
  font-size: 1.06rem;
}

.owned {
  color: var(--aqua);
  white-space: nowrap;
}

.desc,
.flavor {
  position: relative;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.38;
}

.flavor {
  color: #c8bda5;
  font-style: italic;
}

.reward-hint {
  color: rgba(112, 239, 228, 0.65);
  font-size: 0.78rem;
  margin-top: 4px;
}

.buy-button {
  position: relative;
  width: 100%;
  margin-top: 13px;
  padding: 10px 12px;
}

.forge-layout,
.expedition-layout,
.collapse-layout,
.endgame-layout,
.aether-forge-layout {
  grid-template-columns: minmax(0, 1fr) min(320px, 100%);
  gap: 16px;
}

.side-rail,
.void-map,
.collapse-core {
  border-radius: 8px;
  padding: 20px;
}

.side-rail {
  min-height: 320px;
}

.stat-row {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.stat-row span {
  color: var(--muted);
}

.wide-button,
#collapse-button,
#singularity-button,
#omega-button {
  width: 100%;
  margin-top: 16px;
  padding: 13px 14px;
  font-weight: 800;
}

.dimension-card {
  min-height: 126px;
  display: grid;
  gap: 14px;
  align-items: center;
}

.dimension-card::before {
  background: radial-gradient(circle at 8% 0%, rgba(112, 239, 228, 0.18), transparent 38%);
}

.dim-production {
  color: var(--aqua);
}

.dimension-expanded {
  grid-template-columns: 1fr;
}

.tier-grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(84px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.tier-button {
  min-height: 54px;
  padding: 8px;
  font-weight: 800;
}

.tier-button small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.expedition-list,
.upgrade-shop {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.mini-card,
.automation-card,
.formula-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  padding: 13px;
  transition: transform 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}

.mini-card:not(.locked):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.28);
  border-color: rgba(255, 255, 255, 0.22);
}

.formula-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.formula-card strong {
  color: var(--aqua);
  white-space: nowrap;
}

.mini-card.locked {
  opacity: 0.52;
}

.mini-card.complete {
  border-color: rgba(112, 239, 228, 0.48);
  background: rgba(112, 239, 228, 0.075);
}

.compact-title {
  margin-top: 18px;
}

.aether-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.aether-slot {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(112, 239, 228, 0.08), rgba(255, 255, 255, 0.035));
  min-height: 92px;
  padding: 13px;
}

.aether-slot.affordable {
  border-color: rgba(112, 239, 228, 0.55);
  box-shadow: 0 0 18px rgba(112, 239, 228, 0.08);
}

.aether-slot span,
.aether-slot small {
  display: block;
  color: var(--muted);
}

.aether-slot strong {
  display: block;
  margin: 8px 0 4px;
  color: var(--aqua);
}

.aether-codex {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.aether-law-card {
  cursor: default;
}

.aether-law-card.selected {
  outline: 1px solid rgba(255, 207, 107, 0.72);
  background: rgba(255, 207, 107, 0.075);
}

.recipe-line {
  margin-top: 10px;
  color: var(--gold);
  font-size: 0.82rem;
  line-height: 1.35;
}

.active-laws-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.law-toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.upgrade-shop .complete {
  order: 999;
}

.prestige-tree {
  position: relative;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.prestige-tree::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  bottom: 10px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(112, 239, 228, 0.32), transparent);
  pointer-events: none;
}

.prestige-node {
  position: relative;
}

.prestige-node::after {
  content: "";
  position: absolute;
  top: 24px;
  width: 18px;
  height: 1px;
  background: rgba(112, 239, 228, 0.28);
}

.prestige-node:nth-child(odd)::after {
  right: -10px;
}

.prestige-node:nth-child(even)::after {
  left: -10px;
}

.automation-card {
  margin-top: 18px;
}

.roadmap-row {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.roadmap-row:last-child {
  border-bottom: 0;
}

.roadmap-row span {
  color: #c8bda5;
}

.roadmap-row strong {
  color: var(--muted);
  font-size: 0.9rem;
}

.roadmap-row.active strong {
  color: var(--aqua);
}

.endgame-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.achievements-layout,
.reality-scripting-layout {
  grid-template-columns: minmax(0, 1.4fr) min(330px, 100%);
}

.achievement-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.filter-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.filter-button.active {
  border-color: rgba(112, 239, 228, 0.58);
  background: rgba(112, 239, 228, 0.1);
}

.filter-button small {
  color: var(--muted);
}

.achievement-grid,
.script-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.achievement-card.locked {
  filter: grayscale(0.7);
}

.achievement-card strong {
  display: flex;
  align-items: center;
  gap: 8px;
}

.achievement-symbol {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex: 0 0 18px;
  background: radial-gradient(circle, var(--aqua), transparent 68%);
  box-shadow: 0 0 12px rgba(112, 239, 228, 0.35);
}

.achievement-card.locked .achievement-symbol {
  background: radial-gradient(circle, rgba(255,255,255,0.3), transparent 68%);
  box-shadow: none;
}

.script-card.complete {
  border-color: rgba(255, 207, 107, 0.45);
  background: rgba(255, 207, 107, 0.07);
}

body.final-dawn-achieved .hearth-core {
  filter: drop-shadow(0 0 36px rgba(255, 207, 107, 0.45)) drop-shadow(0 0 70px rgba(112, 239, 228, 0.22));
}

body.final-dawn-achieved .news-banner {
  border-color: rgba(255, 207, 107, 0.42);
  box-shadow: 0 0 28px rgba(255, 207, 107, 0.08);
}

.modal-backdrop.victory-modal {
  background: radial-gradient(circle at 50% 20%, rgba(255, 207, 107, 0.18), transparent 34%),
    radial-gradient(circle at 50% 80%, rgba(112, 239, 228, 0.16), transparent 38%),
    rgba(0, 0, 0, 0.88);
}

.modal-backdrop.victory-modal .modal-card {
  width: min(820px, calc(100vw - 28px));
  border-color: rgba(255, 207, 107, 0.52);
  background: linear-gradient(180deg, rgba(26, 23, 14, 0.96), rgba(4, 7, 13, 0.97));
  box-shadow: 0 0 80px rgba(255, 207, 107, 0.16);
}

.victory-cinematic {
  text-align: center;
}

.victory-kicker {
  margin: 0 0 8px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}

.victory-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.victory-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.05);
}

.victory-stats span,
.victory-stats strong {
  display: block;
}

.victory-stats span {
  color: var(--muted);
  font-size: 0.78rem;
}

.chronos-core {
  background: radial-gradient(circle at 50% 40%, rgba(112, 239, 228, 0.16), transparent 26%),
    rgba(3, 4, 7, 0.72);
}

.omega-core {
  background: radial-gradient(circle at 50% 40%, rgba(165, 140, 255, 0.18), transparent 28%),
    rgba(3, 4, 7, 0.72);
}

.monetization-card {
  margin-top: 14px;
  border-color: rgba(255, 207, 107, 0.35);
}

.void-map {
  position: relative;
  min-height: 460px;
  overflow: hidden;
  background: radial-gradient(circle at 22% 30%, rgba(112, 239, 228, 0.13), transparent 16%),
    radial-gradient(circle at 72% 42%, rgba(255, 207, 107, 0.12), transparent 18%),
    rgba(3, 4, 7, 0.72);
}

.void-map h2,
.void-map p {
  position: relative;
  z-index: 2;
}

.map-node {
  position: absolute;
  display: grid;
  place-items: center;
  width: 112px;
  min-height: 58px;
  padding: 8px;
  border-radius: 50%;
  background: var(--aqua);
  box-shadow: 0 0 28px rgba(112, 239, 228, 0.8);
  text-align: center;
  font-size: 0.72rem;
  z-index: 3;
}

.map-node span,
.map-node small {
  display: block;
  max-width: 96px;
  overflow-wrap: anywhere;
}

.map-node small {
  color: rgba(3, 4, 7, 0.72);
  font-weight: 800;
}

.map-node.ready {
  border-color: rgba(255, 207, 107, 0.9);
  box-shadow: 0 0 28px rgba(255, 207, 107, 0.8);
}

.route-0,
.node-a {
  left: 24%;
  top: 34%;
}

.route-1,
.node-b {
  left: 63%;
  top: 48%;
  background: var(--amber);
  box-shadow: 0 0 28px rgba(255, 207, 107, 0.8);
}

.route-2,
.node-c {
  left: 43%;
  top: 72%;
  background: var(--violet);
  box-shadow: 0 0 28px rgba(165, 140, 255, 0.72);
}

.route-3 {
  left: 14%;
  top: 68%;
}

.route-4 {
  left: 72%;
  top: 24%;
}

.rule-toggle {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.35;
}

.rule-toggle input[type="number"],
.rule-toggle select {
  max-width: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  padding: 6px 8px;
}

.rule-toggle:last-child {
  border-bottom: 0;
}

.mini-card.active-rule {
  border-color: rgba(255, 207, 107, 0.62);
  background: rgba(255, 207, 107, 0.08);
}

/* Ascended Echo cards */
.echo-card .card-top {
  align-items: flex-start;
  gap: 8px;
}

.echo-pips {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  margin-top: 2px;
}

.echo-pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(112, 239, 228, 0.45);
  background: transparent;
  transition: background 0.25s;
}

.echo-pip.filled {
  background: var(--aqua);
  border-color: var(--aqua);
  box-shadow: 0 0 5px rgba(112, 239, 228, 0.5);
}

.echo-lore {
  font-size: 0.78rem;
  color: #b8ad97;
  font-style: italic;
  margin-top: 7px;
}

.echo-effect {
  font-size: 0.82rem;
  margin-top: 6px;
}

.effect-label {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.mini-card.partial {
  border-color: rgba(112, 239, 228, 0.22);
  background: rgba(112, 239, 228, 0.03);
}

.map-path {
  position: absolute;
  left: 25%;
  top: 37%;
  width: 44%;
  height: 32%;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.2);
  transform: rotate(12deg);
}

.multiverse-map {
  min-height: 650px;
}

.universe-orbits {
  position: absolute;
  inset: 110px 30px 30px;
}

.universe-orbits span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 26px rgba(255, 95, 117, 0.65);
  transform: rotate(calc(var(--i) * 30deg)) translate(190px) rotate(calc(var(--i) * -30deg));
}

.universe-orbits span.saved {
  background: var(--aqua);
  box-shadow: 0 0 30px rgba(112, 239, 228, 0.8);
}

.collapse-core {
  display: grid;
  align-content: center;
  min-height: 240px;
  text-align: center;
  background: radial-gradient(circle at 50% 40%, rgba(255, 207, 107, 0.14), transparent 26%),
    rgba(3, 4, 7, 0.72);
}

.collapse-core h2 {
  font-size: clamp(2.4rem, 7vw, 5.8rem);
  line-height: 0.95;
}

.collapse-core p {
  max-width: 620px;
  margin: 14px auto 0;
  color: var(--muted);
  line-height: 1.5;
}

@keyframes pulse {
  50% {
    transform: scale(1.08);
    filter: brightness(1.16);
  }
}

@keyframes breathe {
  50% {
    transform: scale(1.08);
    opacity: 0.55;
  }
}

@media (max-width: 980px) {
  .topbar,
  #hearth-panel,
  .forge-layout,
  .expedition-layout,
  .collapse-layout,
  .endgame-layout,
  .achievements-layout,
  .reality-scripting-layout,
  .aether-forge-layout {
    grid-template-columns: 1fr;
  }

  .meters {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }

  .actions,
  .building-grid,
  .settings-grid,
  .smart-buy-grid,
  .settings-market {
    grid-template-columns: 1fr;
  }

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

  .hearth-visual {
    min-height: auto;
  }

  .mobile-smart-buy:not(.hidden) {
    display: block;
  }

  body:has(.mobile-smart-buy:not(.hidden)) .achievement-toast {
    bottom: max(86px, calc(env(safe-area-inset-bottom, 0px) + 86px));
  }

  body:has(.mobile-smart-buy:not(.hidden)) .shell {
    padding-bottom: max(92px, env(safe-area-inset-bottom, 0px));
  }
}

@media (max-height: 620px) and (min-width: 760px) {
  .shell {
    width: min(960px, calc(100% - 16px));
    padding-top: 8px;
    padding-bottom: 12px;
  }

  .topbar {
    grid-template-columns: minmax(190px, 0.7fr) minmax(0, 1.8fr);
    gap: 8px;
  }

  .brand {
    min-height: 68px;
    padding: 10px;
  }

  .brand p {
    font-size: 0.78rem;
  }

  h1 {
    font-size: clamp(1.45rem, 3.4vw, 2.8rem);
  }

  .meters {
    grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
    gap: 8px;
  }

  .meter-card {
    min-height: 68px;
    padding: 9px;
  }

  .meter-card strong {
    margin: 4px 0 2px;
    font-size: 1.05rem;
  }

  .stability-wrap,
  .news-banner,
  .tabs {
    margin-top: 8px;
    margin-bottom: 8px;
  }

  .news-track {
    min-height: 30px;
  }

  .tab {
    min-width: 96px;
    padding: 8px 10px;
  }

  #hearth-panel,
  .forge-layout,
  .expedition-layout,
  .collapse-layout {
    gap: 10px;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 16px, 1440px);
    padding-top: 12px;
  }

  .brand {
    align-items: flex-start;
  }

  .ember-mark {
    width: 34px;
    height: 34px;
  }

  .meters {
    grid-template-columns: 1fr;
  }

  .dimension-card {
    grid-template-columns: 1fr;
  }

  .tier-grid {
    grid-template-columns: repeat(2, minmax(92px, 1fr));
  }

  .endgame-grid {
    grid-template-columns: 1fr;
  }

  .news-track {
    min-height: 32px;
  }

  #news-line {
    font-size: 0.82rem;
  }
}

/* ── Desktop viewport-fit (itch.io / browser) ─────────────────────────── */
@media (min-width: 981px) {
  .shell {
    min-height: 100dvh;
    height: auto;
    max-height: 100dvh;
    overflow-x: clip;
    overflow-y: auto;
    display: block;
    box-sizing: border-box;
  }

  .panel.active {
    display: grid;
    min-height: auto;
    overflow: visible;
  }

  .panel.active > * {
    min-height: auto;
    overflow-y: visible;
  }
}

/* ── Expedition auto-resend toggle ─────────────────────────────────── */
.auto-resend-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  font-size: 0.76rem;
  color: rgba(255,255,255,0.48);
  cursor: pointer;
  user-select: none;
}
.auto-resend-label:hover { color: rgba(255,255,255,0.72); }
.auto-resend-check { accent-color: var(--aqua); width: 13px; height: 13px; cursor: pointer; }

/* ── Send All button ───────────────────────────────────────────────── */
#expedition-send-all {
  width: 100%;
  margin-bottom: 10px;
  padding: 8px 12px;
  font-size: 0.82rem;
  background: rgba(112, 239, 228, 0.08);
  border: 1px solid rgba(112, 239, 228, 0.3);
}
#expedition-send-all:not(:disabled):hover {
  background: rgba(112, 239, 228, 0.16);
  border-color: rgba(112, 239, 228, 0.6);
}

/* ── Collapse readiness hint ───────────────────────────────────────── */
.collapse-hint {
  font-size: 0.78rem;
  margin-top: 6px;
  line-height: 1.4;
}
.collapse-hint.hint-locked  { color: rgba(255,255,255,0.36); }
.collapse-hint.hint-ready   { color: rgba(112, 239, 228, 0.85); }
.collapse-hint.hint-waiting { color: rgba(255, 207, 107, 0.78); }

/* ── Recommended upgrade badge ─────────────────────────────────────── */
.upgrade-recommended {
  border-left-color: rgba(255, 207, 107, 0.7);
  background: rgba(255, 207, 107, 0.05);
}
.rec-badge {
  display: inline-block;
  margin-left: 5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 207, 107, 0.18);
  color: rgba(255, 207, 107, 0.9);
  font-size: 0.7rem;
  font-weight: 700;
  vertical-align: middle;
}

/* ── Challenge live-penalty label ──────────────────────────────────── */
.challenge-penalty-live {
  color: rgba(255, 207, 107, 0.75);
  font-size: 0.8em;
}

/* ── Tab new-unlock flash ───────────────────────────────────────────── */
@keyframes tab-new-flash {
  0%   { box-shadow: 0 0 0 2px rgba(112, 239, 228, 0.0); }
  25%  { box-shadow: 0 0 0 3px rgba(112, 239, 228, 0.9), 0 0 18px rgba(112, 239, 228, 0.4); }
  60%  { box-shadow: 0 0 0 2px rgba(112, 239, 228, 0.6), 0 0 12px rgba(112, 239, 228, 0.25); }
  100% { box-shadow: none; }
}
.tab.tab-new-flash {
  animation: tab-new-flash 1.4s ease-out forwards;
}

/* ── has-news tab: add subtle pulse so it's not just a border change ── */
@keyframes news-tab-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(255, 207, 107, 0.1); }
  50%       { box-shadow: 0 0 22px rgba(255, 207, 107, 0.32); }
}
.tab.has-news {
  border-color: rgba(255, 207, 107, 0.72);
  box-shadow: 0 0 18px rgba(255, 207, 107, 0.12);
  animation: news-tab-pulse 2.4s ease-in-out infinite;
}

/* ── 3-column building grid on wide screens ────────────────────────── */
@media (min-width: 1200px) {
  .building-grid {
    grid-template-columns: repeat(3, minmax(200px, 1fr));
  }
}

/* ── Meter tier separator: subtle amber line before first prestige card */
#infinity-meter {
  position: relative;
}
#infinity-meter::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 12px;
  bottom: 12px;
  width: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 207, 107, 0.35) 30%, rgba(255, 207, 107, 0.35) 70%, transparent);
  pointer-events: none;
}

/* ── Mobile: restore collapse-action-first order (shop flipped to left on desktop) */
@media (max-width: 980px) {
  .collapse-layout .collapse-core {
    order: -1;
  }
}

/* ── Prestige layer tab tints ──────────────────────────────────────── */
/* Collapse = amber/gold  Chronos = teal  Omega = violet               */
.tab[data-tab="collapse"]:not(.active):not(.has-news) {
  border-color: rgba(255, 207, 107, 0.3);
  background: rgba(255, 207, 107, 0.055);
}
.tab[data-tab="chronos"]:not(.active) {
  border-color: rgba(112, 239, 228, 0.28);
  background: rgba(112, 239, 228, 0.045);
}
.tab[data-tab="omega"]:not(.active) {
  border-color: rgba(165, 140, 255, 0.3);
  background: rgba(165, 140, 255, 0.055);
}

/* ── Next Goal card — tappable state (points to a tab) ─────────────── */
.next-goal-card.next-goal-tabbable {
  cursor: pointer;
}
.next-goal-card.next-goal-tabbable::after {
  content: "→";
  color: rgba(112, 239, 228, 0.5);
  font-size: 0.82em;
  flex-shrink: 0;
  transition: color 160ms ease, transform 160ms ease;
  display: inline-block;
}
.next-goal-card.next-goal-tabbable:hover {
  border-color: rgba(112, 239, 228, 0.72);
  background: rgba(112, 239, 228, 0.12);
}
.next-goal-card.next-goal-tabbable:hover::after {
  color: rgba(112, 239, 228, 0.9);
  transform: translateX(4px);
}
