/* ============================================================
   DASHBOARD - Resources, tasks, planet info
   ============================================================ */

/* --- Resource Cards --- */
.resource-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--grid-gap);
}

/* Mobile mini-cards: 3 columns, reduced height */
@media (max-width: 499px) {
  /* Compact planet info */
  .planet-info-grid { min-height: auto; }
  .planet-info-row { gap: 6px !important; }
  .planet-visual { width: 80px !important; height: 80px !important; overflow: hidden; }
  .planet-img { width: 80px !important; height: 80px !important; }
  .planet-gl { width: 80px !important; height: 80px !important; }
  .star-display { min-height: 100px !important; }
  .planet-stats { padding-top: 0; gap: 4px !important; grid-template-columns: 1fr !important; }
  .planet-stats .planet-stat:not(.stat-full):not(.stat-modifiers) {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px 12px;
  }
  .planet-stats .planet-stat .stat-label { font-size: 0.65rem; }
  .planet-stats .stat-span-2 { grid-column: auto; }
  .stat-ratios { gap: 8px !important; }
  .ratio-balance-link { padding: 4px 8px !important; }
  .resource-grid:not(.resource-compact) {
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }
  .resource-grid:not(.resource-compact) .resource-card {
    --frame-width: 6px;
    padding: 10px 8px 8px;
    gap: 3px;
  }
  .resource-grid:not(.resource-compact) .resource-card::before {
    background:
      repeating-linear-gradient(0deg,
        transparent 0px, transparent 2px,
        rgba(0, 0, 0, 0.12) 2px, rgba(0, 0, 0, 0.12) 3px),
      linear-gradient(180deg,
        rgba(var(--res-glow-rgb, 255,255,255), 0.85) 0px,
        rgba(var(--res-glow-rgb, 255,255,255), 0.85) 2px,
        transparent 2px),
      linear-gradient(180deg, rgba(6, 6, 15, 0.55) 0%, rgba(6, 6, 15, 0.9) 50%);
  }
  .resource-grid:not(.resource-compact) .resource-card::after {
    animation: none;
  }
  .resource-grid:not(.resource-compact) .res-label {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 2px 6px;
  }
  .resource-grid:not(.resource-compact) .res-amount {
    font-size: 1.25rem;
    padding: 2px 6px;
  }
  .resource-grid:not(.resource-compact) .res-rate {
    font-size: 0.78rem;
    padding: 2px 6px;
  }
  .resource-grid:not(.resource-compact) .res-stock-label {
    display: none;
  }
  .resource-grid:not(.resource-compact) .res-bar {
    height: 4px;
    margin-top: 2px;
  }
  .resource-grid:not(.resource-compact) .res-energy-warn {
    font-size: 11.5px;
    padding: 1px 5px;
  }
  .resource-grid:not(.resource-compact) .happiness-badge {
    font-size: 0.72rem;
  }
  .resource-grid:not(.resource-compact) .happiness-icon {
    width: 11px;
    height: 11px;
  }
  .resource-grid:not(.resource-compact) .res-combined-box {
    flex-direction: column;
    gap: 0;
  }
  .resource-grid:not(.resource-compact) .res-combined-row {
    flex: 1;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    gap: 6px;
  }
  .resource-grid:not(.resource-compact) .res-combined-row .res-inline-icon {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
  }
  .resource-grid:not(.resource-compact) .res-combined-row .res-label-text {
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
  }
  .resource-grid:not(.resource-compact) .res-combined-row .res-amount {
    font-size: 1.15rem;
    flex-shrink: 0;
  }
  .planet-stats .stat-ratios {
    display: none;
  }
  .dashboard-shell-free .planet-info-grid {
    min-height: auto;
  }
  .dashboard-shell-free .planet-info-row {
    gap: 6px;
  }
  .dashboard-shell-free .planet-visual {
    width: 80px !important;
    height: 80px !important;
  }
  .dashboard-shell-free .planet-img {
    width: 80px !important;
    height: 80px !important;
  }
  .dashboard-shell-free .planet-gl {
    width: 80px !important;
    height: 80px !important;
  }
  .dashboard-shell-free .star-display {
    width: 60px;
    min-height: 120px;
  }
  .dashboard-shell-free .planet-stats {
    padding-top: 0;
    gap: 3px 8px;
  }
  .dashboard-shell-free .stat-ratios {
    gap: 8px;
  }
  .dashboard-shell-free .ratio-balance-link {
    padding: 4px 8px;
    border-radius: 6px;
  }
}

@media (min-width: 500px) {
  .resource-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  .resource-grid:not(.resource-compact) .res-combined-box {
    display: none;
  }
}
/* Compact resource bar (non-planet-info tabs) */
.resource-grid.resource-compact {
  display: flex;
  flex-wrap: wrap;
  gap: var(--grid-gap);
  padding: 0;
  margin-bottom: 4px;
}

/* Sticky compact resource bar */
#screen-empire > .main-content:has(.resource-compact) {
  padding-top: 0;
}
.section.full-width:has(.resource-compact) {
  position: sticky;
  top: var(--sticky-tabs-h, var(--sticky-header-h, 0px));
  z-index: 30;
  isolation: isolate;
  background: var(--bg-void);
  padding-top: 6px;
  padding-bottom: 0;
  margin-top: 0;
  margin-right: calc(var(--panel-padding) * -1);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.42);
}
.resource-compact .resource-card {
  flex: 1 1 calc(33.33% - var(--grid-gap));
  min-width: 80px;
  flex-direction: row;
  align-items: center;
  padding: 6px 8px;
  gap: 5px;
  text-align: left;
  background-position: center 30%;
}
.resource-compact .resource-card::before { background: rgba(6, 6, 15, 0.7); }
/* Storage fill tint only on mobile compact */
@media (pointer: coarse) {
  .resource-compact .resource-card::before {
    background:
      linear-gradient(90deg,
        rgba(var(--res-glow-rgb, 255,255,255), 0.18) 0%,
        rgba(var(--res-glow-rgb, 255,255,255), 0.12) var(--fill-pct, 0%),
        transparent var(--fill-pct, 0%)),
      rgba(6, 6, 15, 0.7);
  }
}
.resource-compact .resource-card .res-label { font-size: 0; line-height: 0; white-space: nowrap; }
.resource-compact .resource-card .res-label .res-inline-icon { width: 16px; height: 16px; }
.resource-compact .resource-card .res-amount {
  font-size: 0.78rem;
  font-weight: 600;
  color: #eef6ff;
  white-space: nowrap;
  background: var(--scrim-50);
  padding: 1px 6px;
  border-radius: 2px;
}
.resource-compact .resource-card .res-rate,
.resource-compact .resource-card .res-stock-label,
.resource-compact .resource-card .res-energy-warn,
.resource-compact .resource-card .res-debt,
.resource-compact .resource-card-combined { display: none; }
.resource-compact .resource-card .res-bar { height: 3px; margin-top: 2px; }
/* Credits card: hide rate in compact mode */
.resource-compact .res-credits-card .res-rate {
  display: none;
}

/* Storage percentage - hidden in full mode, shown in compact */
.resource-card .res-pct { display: none; }
.resource-compact .resource-card .res-pct {
  display: inline;
  font-size: 0.6rem;
  color: var(--text-dim);
  background: var(--scrim-50);
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
}

/* Combined Energy + Q-bits box */
.res-combined-box {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: rgba(13, 13, 31, 0.94);
  border: 1px solid rgba(80, 95, 110, 0.5);
  border-radius: var(--panel-radius);
  overflow: hidden;
  position: relative;
}
.res-combined-row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  position: relative;
  background-size: cover;
  background-position: center;
  border: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.res-combined-row::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 6, 15, 0.55) 0%, rgba(6, 6, 15, 0.85) 70%);
  z-index: 0;
}
.res-combined-row > * {
  position: relative;
  z-index: 1;
}
.res-combined-row[data-resource="energy"] {
  background-image: url('../../assets/resources/energy.webp');
  border-bottom: 1px solid rgba(80, 95, 110, 0.3);
}
.res-combined-row[data-resource="qbits"] {
  background-image: url('../../assets/resources/qbits.webp?v=5');
}
.res-combined-row .res-inline-icon {
  width: 16px;
  height: 16px;
}
.res-combined-row .res-label-text {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  flex: 1;
}
.res-combined-row .res-amount {
  font-size: 0.78rem;
  white-space: nowrap;
}
/* Full mode: combined box takes a grid cell like other cards */
.resource-grid:not(.resource-compact) .res-combined-box {
  padding: 0;
}
.resource-grid:not(.resource-compact) .res-combined-row {
  padding: 10px 14px;
  gap: 8px;
}
.resource-grid:not(.resource-compact) .res-combined-row .res-inline-icon {
  width: 20px;
  height: 20px;
}
.resource-grid:not(.resource-compact) .res-combined-row .res-label-text {
  font-size: 0.65rem;
}
.resource-grid:not(.resource-compact) .res-combined-row .res-amount {
  font-size: 0.92rem;
}
/* Compact mode: combined box sits inline */
.resource-compact .res-combined-box {
  flex: 1 1 calc(33.33% - var(--grid-gap));
  min-width: 80px;
  flex-direction: row;
  gap: 0;
}
.resource-compact .res-combined-row {
  flex: 1;
  padding: 3px 6px;
  gap: 4px;
}
.resource-compact .res-combined-row .res-label-text {
  display: none;
}
.resource-compact .res-combined-row[data-resource="energy"] {
  border-bottom: none;
  border-right: 1px solid rgba(80, 95, 110, 0.3);
}
.resource-compact .res-combined-row .res-amount {
  font-size: 0.72rem;
  background: var(--scrim-50);
  padding: 1px 6px;
  border-radius: 2px;
}

/* Credits card: visible in both compact and full mode (no balance-card hide rule needed) */
.resource-grid:not(.resource-compact) .res-credits-card { display: flex; }

/* Narrow phones: tighten compact chips so values and percentages fit */
@media (max-width: 429px) {
  .resource-compact .resource-card {
    padding: 6px 5px;
    gap: 4px;
  }
  .resource-compact .resource-card .res-label .res-inline-icon { width: 14px; height: 14px; }
  .resource-compact .resource-card .res-amount {
    font-size: 0.75rem;
    padding: 1px 4px;
  }
  .resource-compact .resource-card .res-pct {
    font-size: 0.58rem;
    padding: 1px 3px;
  }
  .resource-compact .resource-card .happiness-badge {
    font-size: 0.7rem;
    margin-left: 2px;
  }
  .resource-compact .resource-card .happiness-icon {
    width: 12px;
    height: 12px;
  }
  /* !important: the mobile .ratio-balance-link rule above also uses it */
  .resource-compact .res-combined-row {
    padding: 3px 4px !important;
    gap: 3px;
  }
  .resource-compact .res-combined-row .res-inline-icon { width: 14px; height: 14px; }
  .resource-compact .res-combined-row .res-amount {
    font-size: 0.7rem;
    padding: 1px 3px;
  }
}
@media (max-width: 389px) {
  .resource-compact .resource-card {
    padding: 6px 4px;
    gap: 3px;
  }
  .resource-compact .resource-card .res-amount { font-size: 0.72rem; }
}

/* Desktop compact: show resource names and production rate */
@media (min-width: 1024px) {
  .resource-compact .resource-card .res-label {
    font-size: 0.72rem;
    line-height: normal;
    color: var(--text-primary);
  }
  .resource-compact .resource-card .res-amount {
    font-size: 0.95rem;
  }
  .resource-compact .resource-card .res-rate {
    display: inline;
    font-size: 0.72rem;
    white-space: nowrap;
    background: var(--scrim-50);
    padding: 1px 6px;
    border-radius: 2px;
  }
  .resource-compact .resource-card .res-pct {
    font-size: 0.68rem;
    color: var(--text-secondary);
  }
  .resource-compact .res-combined-row .res-amount {
    font-size: 0.8rem;
  }
  /* "No housing" label does not fit the elongated population row */
  .resource-compact .resource-card[data-resource="population"] .res-rate.is-pop-capped {
    display: none;
  }
  .resource-compact .res-combined-row .res-inline-icon {
    width: 18px;
    height: 18px;
  }
}

.resource-card {
  --frame-width: 7px;
  border-image-source: url('../../assets/ui/hud-frame.webp');
  border-image-slice: 94;
  border-image-width: var(--frame-width);
  border-image-repeat: stretch;
  padding: 14px 12px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-align: center;
  position: relative;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.15s ease;
  background-size: cover;
  background-position: center;
  overflow: hidden;
}

/* Dark overlay + scan lines (only affects image, not frame) */
.resource-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    /* Static scan lines over background image */
    repeating-linear-gradient(0deg,
      transparent 0px, transparent 2px,
      rgba(0, 0, 0, 0.12) 2px, rgba(0, 0, 0, 0.12) 3px),
    /* Colored top accent line (border-top is overridden by border-image) */
    linear-gradient(180deg,
      rgba(var(--res-glow-rgb, 255,255,255), 0.85) 0px,
      rgba(var(--res-glow-rgb, 255,255,255), 0.85) 2px,
      transparent 2px),
    /* Dark overlay */
    linear-gradient(180deg, rgba(6, 6, 15, 0.5) 0%, rgba(6, 6, 15, 0.85) 60%);
  z-index: 0;
}

/* Ensure all content sits above the overlay */
.resource-card > * {
  position: relative;
  z-index: 1;
}

/* Background images per resource type */
.resource-card[data-resource="ore"] {
  --res-glow-rgb: 245, 158, 11;
  background-image: url('../../assets/resources/ore.webp?v=5');
}
.resource-card[data-resource="helium"] {
  --res-glow-rgb: 59, 130, 246;
  background-image: url('../../assets/resources/helium.webp?v=5');
}
.resource-card[data-resource="qbits"] {
  --res-glow-rgb: 139, 92, 207;
  background-image: url('../../assets/resources/qbits.webp?v=5');
}
.resource-card[data-resource="credits"] {
  --res-glow-rgb: 16, 185, 129;
  background-image: url('../../assets/resources/credits.webp?v=5');
}
.resource-card[data-resource="plasma"] {
  --res-glow-rgb: 176, 184, 200;
  background-image: url('../../assets/resources/plasma.webp?v=5');
}
.resource-card[data-resource="population"] {
  --res-glow-rgb: 6, 182, 212;
  background-image: url('../../assets/resources/population.webp');
}
.resource-card[data-resource="energy"] {
  --res-glow-rgb: 234, 179, 8;
  background-image: url('../../assets/resources/energy.webp');
}

/* Idle shimmer on top border */
.resource-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(var(--res-glow-rgb, 255,255,255), 0.8) 50%, transparent 100%);
  z-index: 2;
  animation: resShimmer 3s ease-in-out infinite;
  opacity: 0.5;
}
@keyframes resShimmer {
  0%, 100% { opacity: 0.3; transform: scaleX(0.5); }
  50% { opacity: 0.9; transform: scaleX(1); }
}

/* Combined balance card (energy + qbits stacked) */
.resource-card-combined {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.balance-row {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  padding: 8px 10px;
  position: relative;
  background-size: cover;
  background-position: center;
}
.balance-row::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 6, 15, 0.45) 0%, rgba(6, 6, 15, 0.8) 70%);
  z-index: 0;
}
.balance-row > * {
  position: relative;
  z-index: 1;
}
.balance-row[data-resource="energy"] {
  border-top: 2px solid var(--energy-color);
  background-image: url('../../assets/resources/energy.webp');
  border-radius: var(--panel-radius) var(--panel-radius) 0 0;
}
.balance-row[data-resource="qbits"] {
  border-top: 1px solid rgba(139, 92, 246, 0.3);
  background-image: url('../../assets/resources/qbits.webp?v=5');
  border-radius: 0 0 var(--panel-radius) var(--panel-radius);
}
.balance-row .res-label {
  background: var(--scrim-50);
  padding: 2px 8px;
  border-radius: 2px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-primary);
}
.balance-nums {
  display: flex;
  align-items: baseline;
  gap: 3px;
  background: var(--scrim-50);
  padding: 2px 8px;
  border-radius: 2px;
}
.balance-cap {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--green);
}
.balance-sep {
  font-size: 0.7rem;
  color: var(--text-dim);
}
.balance-dem {
  font-size: 0.85rem;
  font-weight: 400;
}
.balance-dem.positive { color: var(--text-dim); }
.balance-dem.negative { color: #ff4444; }
.balance-bar {
  width: 80%;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
}
.balance-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.5s;
}
.balance-bar-fill.positive {
  background: var(--green);
}
.balance-bar-fill.negative {
  background: #ff4444;
  animation: negativePulse 1.5s ease-in-out infinite;
}

.resource-card .res-icon {
  display: none;
}
.res-inline-icon {
  width: 20px;
  height: 20px;
  vertical-align: -4px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 3px currentColor);
}
[data-resource="ore"] .res-inline-icon { color: var(--ore-color); }
[data-resource="helium"] .res-inline-icon { color: var(--helium-color); }
[data-resource="credits"] .res-inline-icon { color: var(--credits-color); }
[data-resource="plasma"] .res-inline-icon { color: var(--plasma-color); }
[data-resource="qbits"] .res-inline-icon { color: var(--qbits-color); }
[data-resource="energy"] .res-inline-icon { color: var(--energy-color); }

.resource-card .res-label,
.resource-card .res-amount,
.resource-card .res-rate,
.resource-card .res-stock-label {
  background: var(--scrim-50);
  padding: 2px 8px;
  border-radius: 2px;
}

.resource-card .res-label {
  font-size: 0.85rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.resource-card .res-amount {
  font-family: var(--font-mono);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text-primary);
}

.resource-card .res-rate {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
}

.resource-card .res-rate.res-balance-link {
  appearance: none;
  border: 0;
  cursor: pointer;
  transition: color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.resource-card .res-rate.res-balance-link:hover {
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 14px rgba(var(--accent-rgb), 0.18);
  transform: translateY(-1px);
}

.resource-card .res-stock-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 4px;
}

.resource-card .res-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 2px;
  margin-top: auto;
  overflow: hidden;
}

.resource-card .res-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 1s linear;
  position: relative;
}

.resource-card[data-resource="ore"] .res-bar-fill {
  background: linear-gradient(90deg, var(--ore-color), rgba(245, 158, 11, 0.6));
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.3);
}
.resource-card[data-resource="helium"] .res-bar-fill {
  background: linear-gradient(90deg, var(--helium-color), rgba(59, 130, 246, 0.6));
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.3);
}
.resource-card[data-resource="qbits"] .res-bar-fill {
  background: linear-gradient(90deg, var(--qbits-color), rgba(139, 92, 246, 0.6));
  box-shadow: 0 0 6px rgba(139, 92, 246, 0.3);
}
.resource-card[data-resource="plasma"] .res-bar-fill {
  background: linear-gradient(90deg, var(--plasma-color), rgba(176, 184, 200, 0.6));
  box-shadow: 0 0 6px rgba(176, 184, 200, 0.3);
}
.resource-card[data-resource="credits"] .res-bar-fill {
  background: linear-gradient(90deg, var(--credits-color), rgba(16, 185, 129, 0.6));
}
.resource-card[data-resource="population"] .res-bar-fill {
  background: linear-gradient(90deg, #0891b2, rgba(6, 182, 212, 0.6));
  box-shadow: 0 0 6px rgba(6, 182, 212, 0.3);
}
.resource-card[data-resource="energy"] .res-bar-fill {
  background: linear-gradient(90deg, var(--energy-color), rgba(234, 179, 8, 0.6));
  box-shadow: 0 0 6px rgba(234, 179, 8, 0.3);
}

/* Clicker effect */
.clickable-res,
.clickable-res * {
  touch-action: manipulation;
}
.clickable-res {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}
.clickable-res:hover {
  transform: scale(1.03);
  box-shadow: 0 0 16px rgba(var(--res-glow-rgb, 255,255,255), 0.35);
  border-color: rgba(var(--res-glow-rgb, 255,255,255), 0.8);
  z-index: 2;
}
.clickable-res:hover::before {
  background: linear-gradient(180deg, rgba(6, 6, 15, 0.3) 0%, rgba(6, 6, 15, 0.7) 60%);
}
.clickable-res:hover::after {
  opacity: 1;
  animation-duration: 1s;
}
.clickable-res:active {
  transform: scale(0.97);
}
.click-floater {
  position: absolute;
  font-size: 0.85rem;
  font-weight: 700;
  font-family: var(--font-mono);
  pointer-events: none;
  z-index: 5;
  animation: clickFloat 1.2s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
@keyframes clickFloat {
  0%   { opacity: 1; transform: translate(-50%, 0) scale(1); }
  15%  { opacity: 1; transform: translate(-50%, -8px) scale(1.15); }
  80%  { opacity: 1; transform: translate(-50%, -55px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -68px) scale(0.95); }
}
.res-particle {
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 9999;
  will-change: left, top, opacity;
}

.res-debt {
  font-size: 0.6rem;
  color: var(--text-dim);
  background: var(--scrim-50);
  padding: 1px 6px;
  border-radius: 4px;
}

.res-rate.positive, .res-amount.positive { color: var(--green); }
[data-resource="energy"] .res-amount.positive,
[data-resource="qbits"] .res-amount.positive { color: #eab308; text-shadow: 0 0 6px rgba(234, 179, 8, 0.3); }
.res-rate.warn, .res-amount.warn {
  color: #eab308;
  text-shadow: 0 0 6px rgba(234, 179, 8, 0.4);
}
[data-resource="energy"] .res-amount.warn,
[data-resource="qbits"] .res-amount.warn {
  color: #ef4444;
  text-shadow: 0 0 6px rgba(239, 68, 68, 0.4);
}
.res-rate.negative, .res-amount.negative {
  color: #ff4444;
  text-shadow: 0 0 6px rgba(255, 68, 68, 0.5);
  animation: negativePulse 1.5s ease-in-out infinite;
}
@keyframes negativePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.res-warning {
  display: inline-block;
  color: var(--amber);
  font-size: 1.1rem;
  margin-left: 6px;
  cursor: help;
  animation: glow-pulse 2s infinite;
  vertical-align: middle;
}

/* --- Idle Clicker Feedback --- */
@keyframes resFloat {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-18px); }
}
.res-float {
  position: absolute;
  top: -2px;
  right: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  pointer-events: none;
  animation: resFloat 1.5s ease-out forwards;
  z-index: 2;
  text-shadow: 0 0 4px currentColor;
}
@keyframes resPulse {
  0%   { transform: scale(1); filter: brightness(1); }
  30%  { transform: scale(1.06); filter: brightness(1.4); }
  100% { transform: scale(1); filter: brightness(1); }
}
.res-amount.res-pulsing {
  animation: resPulse 0.35s ease-out;
}

/* --- Active Tasks --- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.dashboard-shell-free .task-list {
  gap: 0;
}

/* --- Animated radar empty state --- */
.empty-state-tasks {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px 12px;
}
.radar-pulse {
  position: relative;
  width: 48px;
  height: 48px;
}
.radar-dot {
  position: absolute;
  top: 50%; left: 50%;
  width: 6px; height: 6px;
  background: var(--cyan);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px var(--cyan);
}
.radar-ring {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--cyan);
  border-radius: 50%;
  opacity: 0;
  animation: radarPing 2.5s ease-out infinite;
}
.radar-ring.r2 { animation-delay: 1.25s; }
@keyframes radarPing {
  0% { transform: scale(0.3); opacity: 0.8; }
  100% { transform: scale(1.2); opacity: 0; }
}

/* --- Task mini-card ---
   Grid layout: row 1 = [icon | info | timer], row 2 = actions spanning full width.
   This keeps the progress bar + timer on the first row and pushes ALL action
   buttons (Acelerar / Cancelar / qty +- / recall / etc.) BELOW the progress bar
   in a dedicated row, never to the right of it. */
.task-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  align-items: center;
  column-gap: 8px;
  row-gap: 6px;
  padding: 8px 10px 8px 0;
  border: 1px solid rgba(var(--accent-rgb), 0.22);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.10) 0%, rgba(var(--accent-rgb), 0.03) 45%, rgba(8, 14, 22, 0.3) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  transition: background 0.2s, border-color 0.2s;
}
.task-card:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
}
.task-card > .task-card-icon,
.task-card > .fleet-icon {
  grid-row: 1 / span 2;
  grid-column: 1;
  align-self: stretch;
}
.task-card > .task-card-info {
  grid-row: 1;
  grid-column: 2;
  min-width: 0;
}
.task-card > .task-card-timer {
  grid-row: 1;
  grid-column: 3;
}
.task-card > .task-card-actions {
  grid-row: 2;
  grid-column: 2 / span 2;
  width: 100%;
  margin-top: 0;
}
/* Completed cards have no actions row — keep the OK button anchored right */
.task-card > .task-dismiss {
  grid-row: 1;
  grid-column: 3;
}
.task-queue-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.task-queue-counter {
  font-family: var(--font-mono);
  color: var(--text-secondary);
}
.task-queue-counter.queue-full {
  color: #ef4444;
}

.task-card-icon {
  width: 68px;
  align-self: stretch;
  margin: -8px 0;
  border-radius: 7px 0 0 7px;
  object-fit: cover;
  flex-shrink: 0;
  -webkit-mask-image: linear-gradient(90deg, #000 60%, transparent 100%);
  mask-image: linear-gradient(90deg, #000 60%, transparent 100%);
}
.task-card-icon,
.task-card-name-text {
  cursor: pointer;
}

.task-card-qty {
  margin-left: 4px;
  color: var(--accent);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.task-card-progress[data-tap-key] {
  cursor: pointer;
}

.task-card-progress.tap-flash .progress-bar {
  animation: tap-bar-flash 0.35s ease;
}

@keyframes tap-bar-flash {
  0%   { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); }
  30%  { box-shadow: 0 0 8px 2px rgba(34, 211, 238, 0.6); }
  100% { box-shadow: 0 0 0 0 rgba(34, 211, 238, 0); }
}

/* ── Tap-to-accelerate floater ──────────────────────────────── */
.tap-floater {
  position: fixed;
  z-index: 200;
  font-size: 0.8rem;
  font-weight: 700;
  color: #22d3ee;
  text-shadow: 0 0 8px rgba(34, 211, 238, 0.6);
  pointer-events: none;
  transform: translateX(-50%);
  opacity: 1;
  transition: transform 0.5s ease-out, opacity 0.5s ease-out;
}

.tap-floater.tap-float-up {
  transform: translateX(-50%) translateY(-30px);
  opacity: 0;
}

.dashboard-shell-free .task-card-icon {
  width: 56px;
  align-self: stretch;
  margin: -8px 0;
  border-radius: 3px 0 0 3px;
  background: rgba(0, 0, 0, 0.3);
  object-fit: cover;
}
.task-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dashboard-shell-free .task-card-info {
  gap: 5px;
}
.task-card-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-shell-free .task-card-name {
  white-space: normal;
  line-height: 1.35;
  font-size: 0.76rem;
}
/* Shimmer on in-progress / queued task names */
.task-card:not(.completed):not(.empire-alert-card) .task-card-name-text {
  background: linear-gradient(
    90deg,
    var(--text-primary) 0%,
    var(--text-primary) 35%,
    rgba(255, 255, 255, 0.95) 50%,
    var(--text-primary) 65%,
    var(--text-primary) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: task-name-shimmer 3s ease-in-out infinite;
}
@keyframes task-name-shimmer {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.task-card-progress {
  width: 100%;
}
.task-card-progress .progress-bar {
  height: 9px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.4);
}
/* Completed task */
.task-card.completed {
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.06);
}

.dashboard-shell-free .task-card.completed {
  --task-accent: var(--green);
  --task-glow-rgb: 16, 185, 129;
}
.task-card-done {
  font-size: 0.65rem;
  color: var(--green);
  font-weight: 600;
}
.task-card-refund {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 2px;
}
.task-mission-reward-label {
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-gold, #e8c15a);
}
/* Ephemeral mission-reward floater: rises from the OK button on dismiss */
.reward-floater {
  position: fixed;
  z-index: 300;
  display: flex;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: var(--font-mono);
  pointer-events: none;
  text-shadow: 0 0 10px rgba(0, 0, 0, 0.9);
  animation: clickFloat 1.2s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
.reward-floater .task-dismiss-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  white-space: nowrap;
}
.reward-floater svg,
.reward-floater .cost-icon {
  width: 14px;
  height: 14px;
}
.task-card .task-dismiss {
  padding: 4px 12px;
  border-radius: 2px;
  border: 1px solid rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.1);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}
.task-card .task-dismiss:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
}

/* Task action buttons - always rendered below the progress/timer row */
.task-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 0;
}

.dashboard-shell-free .task-card-actions {
  flex-wrap: wrap;
  gap: 6px;
}

/* Hide the whole actions row when it's empty to avoid extra row-gap */
.task-card-actions:empty {
  display: none;
}

.dashboard-shell-free .task-card-actions .btn-speedup-card,
.dashboard-shell-free .task-card-actions .btn-cancel-card {
  flex: 0 0 auto;
  padding: 5px 16px;
}

.task-card-timer {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
  flex-shrink: 0;
  text-align: right;
  min-width: 50px;
}

.dashboard-shell-free .task-card-timer {
  min-width: 74px;
  padding-top: 2px;
}

.task-dismiss {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 4px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.task-dismiss:hover {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--cyan);
  border-color: rgba(var(--accent-rgb), 0.4);
}

/* Queued task timer */
.task-card-timer.queued-timer {
  color: #fbbf24;
  text-shadow: none;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 11.5px;
  padding: 3px 10px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.12);
  min-width: 0;
}
/* Queue deficit / missing resources inside queued task card */
.task-queue-label {
  font-size: 0.55rem;
  font-weight: 700;
  color: #a855f7;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.queue-missing-label {
  color: var(--red, #ef4444);
  margin-right: 2px;
}
.queue-deficit .cost-icon {
  width: 10px;
  height: 10px;
  vertical-align: -1px;
  margin-right: 1px;
}
/* Blocked reason line for queued research */
.queue-blocked-info {
  font-size: 0.65rem;
  line-height: 1.3;
  color: #f59e0b;
  margin: 1px 0;
}
.queue-blocked-reason {
  white-space: nowrap;
}
.queue-blocked-sep {
  color: rgba(255,255,255,0.2);
  margin: 0 3px;
}
/* Queued task buttons: compact, not full-width */
.task-card.queued .task-card-actions .btn-speedup-card,
.task-card.queued .task-card-actions .btn-cancel-card {
  flex: 0 0 auto;
  padding: 4px 16px;
}

/* Queue speedup button (buy resources to start now) */
.btn-queue-speedup,
.btn-ship-queue-speedup {
  font-size: 0.55rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.btn-queue-speedup:hover,
.btn-ship-queue-speedup:hover {
  background: rgba(16, 185, 129, 0.3);
}
.btn-queue-speedup .cost-icon,
.btn-ship-queue-speedup .cost-icon {
  width: 10px;
  height: 10px;
}
/* Queue move buttons */
.btn-queue-move {
  min-width: 36px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(168, 85, 247, 0.3);
  background: rgba(168, 85, 247, 0.08);
  color: #a855f7;
  font-size: 0.65rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-queue-move:hover {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(168, 85, 247, 0.5);
}

/* --- Planet Info --- */
.planet-info-panel .panel-body {
  background: rgba(0, 0, 0, 0.85);
  position: relative;
}

.dashboard-shell-free.planet-info-panel .panel-body {
  background: transparent;
}
.planet-info-grid {
  display: block;
  min-height: 140px;
}

.planet-info-row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: nowrap;
  flex-direction: row;
}

.dashboard-shell-free .planet-info-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 4px 0 2px;
  align-items: center;
}

/* When no tasks, planet at 1/3 and stats centered in 2/3 */
@media (min-width: 900px) {
  .planet-tasks-row:has(.task-list.hidden) .planet-info-row,
  .planet-tasks-row:has(.task-list:empty) .planet-info-row {
    grid-template-columns: 1fr 2fr;
    max-width: 780px;
    margin: 0 auto;
  }
  .planet-tasks-row:has(.task-list.hidden) .planet-visual,
  .planet-tasks-row:has(.task-list:empty) .planet-visual {
    justify-self: center;
    width: 160px;
    height: 160px;
  }
  .planet-tasks-row:has(.task-list.hidden) .planet-gl,
  .planet-tasks-row:has(.task-list:empty) .planet-gl {
    width: 160px;
    height: 160px;
  }
  .planet-tasks-row:has(.task-list.hidden) .planet-stats,
  .planet-tasks-row:has(.task-list:empty) .planet-stats {
    gap: 6px;
  }
}

.planet-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: visible;
  position: relative;
  width: 120px;
  height: 120px;
}

.planet-img {
  width: 100px;
  height: 100px;
  transform: scaleX(-1);
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(var(--accent-rgb), 0.2);
  box-shadow: 0 4px 12px var(--scrim-50);
}

.planet-img--moon {
  width: 200px !important;
  height: 200px !important;
  border-radius: 0 !important;
  border: none !important;
  box-shadow: none !important;
  object-fit: contain;
  background: transparent !important;
}

/* Star light tint on static planet/moon thumbnails via CSS filter */
.planet-visual-star-yellow_dwarf .planet-img  { filter: none; }
.planet-visual-star-red_dwarf .planet-img     { filter: sepia(0.3) hue-rotate(-15deg) saturate(1.3) brightness(0.85); }
.planet-visual-star-orange_giant .planet-img  { filter: sepia(0.25) hue-rotate(5deg) saturate(1.2) brightness(1.05); }
.planet-visual-star-blue_giant .planet-img    { filter: sepia(0.15) hue-rotate(180deg) saturate(0.8) brightness(1.1); }
.planet-visual-star-red_giant .planet-img     { filter: sepia(0.4) hue-rotate(-10deg) saturate(1.5) brightness(0.9); }
.planet-visual-star-white_dwarf .planet-img   { filter: saturate(0.5) brightness(0.9); }
.planet-visual-star-brown_dwarf .planet-img   { filter: sepia(0.5) hue-rotate(-10deg) saturate(0.8) brightness(0.6); }
.planet-visual-star-neutron_star .planet-img  { filter: sepia(0.2) hue-rotate(200deg) saturate(0.7) brightness(1.05); }
.planet-visual-star-black_hole .planet-img    { filter: sepia(0.3) hue-rotate(240deg) saturate(0.6) brightness(0.5); }

.planet-gl {
  position: absolute;
  width: 120px;
  height: 120px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: auto;
  z-index: 0;
}

/* Star section: groups star visual + star stats */
.star-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  margin: calc(-1 * var(--panel-padding));
  margin-right: 0;
}

/* Star display - left side of planet info row */
.star-display {
  width: 100px;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
  align-self: stretch;
  background: transparent;
  border: none !important;
  outline: none !important;
  box-shadow: none !important;
}

.dashboard-shell-free .planet-visual {
  grid-column: 1;
  justify-self: start;
}

.dashboard-shell-free .planet-stats {
  grid-column: 2;
  justify-self: start;
}

.dashboard-shell-free .star-display {
  width: clamp(88px, 10vw, 126px);
  min-height: 168px;
  overflow: visible;
  border-radius: 0;
  background: transparent;
}

.dashboard-shell-free .star-display::after {
  display: none;
}
.star-img {
  position: absolute;
  height: 140%;
  width: auto;
  top: 50%;
  right: -10%;
  transform: translateY(-50%);
  object-fit: cover;
  -webkit-mask-image: radial-gradient(circle at 40% 50%, black 25%, rgba(0,0,0,0.8) 45%, transparent 70%);
  mask-image: radial-gradient(circle at 40% 50%, black 25%, rgba(0,0,0,0.8) 45%, transparent 70%);
}

.dashboard-shell-free .star-img {
  right: -45%;
  height: 132%;
  z-index: 1;
  -webkit-mask-image: radial-gradient(
    ellipse 58% 72% at 38% 50%,
    rgba(0, 0, 0, 1) 20%,
    rgba(0, 0, 0, 0.98) 40%,
    rgba(0, 0, 0, 0.85) 58%,
    rgba(0, 0, 0, 0.45) 75%,
    rgba(0, 0, 0, 0.08) 90%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse 58% 72% at 38% 50%,
    rgba(0, 0, 0, 1) 20%,
    rgba(0, 0, 0, 0.98) 40%,
    rgba(0, 0, 0, 0.85) 58%,
    rgba(0, 0, 0, 0.45) 75%,
    rgba(0, 0, 0, 0.08) 90%,
    transparent 100%
  );
}
.star-stats {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 4px 8px 0;
  white-space: nowrap;
}
.star-stats .stat-label {
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.star-stats .stat-value {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-primary);
}
.star-stats .planet-bonuses {
  justify-content: center;
}

/* Energy/Q-Bits ratio in planet info */
.ratio-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
  filter: drop-shadow(0 0 3px currentColor);
}
.ratio-icon.energy-icon { color: var(--energy-color); }
.ratio-icon.qbits-icon { color: var(--qbits-color); }
.stat-value.ratio-ok, .ratio-ok { color: #eab308; text-shadow: 0 0 6px rgba(234, 179, 8, 0.3); }
.stat-value.ratio-warn, .ratio-warn { color: #ef4444; text-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
.stat-value.ratio-crit, .ratio-crit { color: #ff4444; text-shadow: 0 0 6px rgba(255, 68, 68, 0.5); animation: negativePulse 1.5s ease-in-out infinite; }

.star-count {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--scrim-60);
  padding: 1px 5px;
  border-radius: 4px;
  z-index: 1;
}

.dashboard-shell-free .star-count {
  left: 0;
  z-index: 3;
  background: rgba(3, 6, 14, 0.48);
  backdrop-filter: blur(var(--blur-lg));
  -webkit-backdrop-filter: blur(var(--blur-lg));
}
/* Planet bonuses */
.planet-bonuses {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  margin-top: 0;
}
.stat-value .planet-bonuses { margin-left: 4px; }
.planet-star-bonuses {
  padding: 2px 0 2px 4px;
}
.stat-autofarm {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.planet-bonuses > span {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.68rem;
  font-weight: 700;
  font-family: var(--font-mono);
}
.bonus-icon {
  width: 12px;
  height: 12px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.5;
}
.bonus-pos { color: var(--green); }
.bonus-neg { color: #ff4444; }

@keyframes starPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}

.planet-stats {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  position: relative;
  z-index: 1;
  width: 100%;
  min-width: 0;
}

/* Key/value rows: label left, value right, full width. */
.planet-stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px 16px;
  width: 100%;
  min-width: 0;
}

.planet-stat .stat-label {
  flex: 0 0 auto;
}

.planet-stat .stat-value,
.planet-stat .stat-fields-link,
.planet-stat .stat-star-body {
  flex: 1 1 auto;
  min-width: 0;
  text-align: right;
}

.planet-stat.stat-star {
  align-items: start;
}

.stat-star-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  min-width: 0;
}
.stat-star-body .planet-bonuses {
  margin-left: 0;
  justify-content: flex-end;
}

/* Block rows: label on top, content uses full width below. */
.planet-stat.stat-full:not(.stat-ratios),
.planet-stat.planet-action-row {
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}

/* Modifiers: label left, bonus chips right. */
.planet-stat.stat-modifiers {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  gap: 10px 16px;
}
.planet-stat.stat-modifiers .stat-label {
  flex: 0 0 auto;
}
.planet-stat.stat-modifiers .planet-bonuses {
  flex: 1 1 auto;
  justify-content: flex-end;
  margin-left: auto;
}

/* Energy / Q-bits production: two chips on one row. */
.planet-stat.stat-ratios {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 8px;
  justify-content: stretch;
}
.planet-stat.stat-ratios .ratio-balance-link {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.dashboard-shell-free .planet-stats {
  gap: 6px;
  width: 100%;
  min-width: 0;
}

@media (min-width: 500px) {
  .planet-stats {
    grid-template-columns: 1fr;
  }
  .planet-img {
    width: 120px;
    height: 120px;
  }
  .planet-visual {
    width: 120px;
    height: 120px;
  }
}

.dashboard-shell-free .planet-img {
  transform: none;
  border: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
}

.dashboard-shell-free .planet-gl {
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.38));
}

/* Desktop (>=1024px): stretch planet-stats to full column width. */
@media (min-width: 1024px) {
  /* Distribute task cards in a multi-column grid so PROGRESO ACTUAL
     doesn't stack as a long single-column list when there's plenty of
     horizontal room. Cards keep their own internal layout. */
  .kc-layout-desktop3 .task-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 8px;
  }
  .kc-layout-desktop3 .task-list > .collection-section-label,
  .kc-layout-desktop3 .task-list > .task-queue-header {
    grid-column: 1 / -1;
  }
  .dashboard-shell-free .planet-info-row {
    max-width: none !important;
    margin: 0 !important;
    column-gap: 80px;
  }
  .dashboard-shell-free .planet-visual {
    width: 380px;
    height: 380px;
  }
  .dashboard-shell-free .planet-img {
    width: 360px;
    height: 360px;
  }
  .dashboard-shell-free .planet-gl {
    width: 380px;
    height: 380px;
  }
  .dashboard-shell-free .planet-stats {
    justify-self: stretch !important;
    width: 100%;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .dashboard-shell-free .planet-stats .planet-stat {
    min-width: 0;
  }
  .dashboard-shell-free .planet-stats .stat-ratios {
    justify-content: flex-start;
  }
}

.stat-fields-link {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
  cursor: pointer;
  text-align: right;
  margin-left: auto;
  width: fit-content;
  max-width: 100%;
  transition: color 0.18s ease, text-shadow 0.18s ease;
}
.stat-fields-link:hover {
  color: #fff;
  text-shadow: 0 0 10px rgba(var(--accent-rgb), 0.35);
  box-shadow: none;
  transform: none;
}
.stat-full {
  width: 100%;
}
.stat-span-2 {
  width: 100%;
}
.stat-ratios {
  display: flex;
  flex-direction: row;
  gap: 16px;
  justify-content: center;
}
.ratio-pair {
  display: flex;
  flex-direction: column;
  gap: 1px;
  white-space: nowrap;
}

.ratio-balance-link {
  appearance: none;
  align-items: center;
  text-align: center;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 8px;
  background: rgba(8, 12, 22, 0.55);
  padding: 8px 10px;
  cursor: pointer;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

.ratio-balance-link:hover {
  transform: translateY(-1px);
  border-color: rgba(var(--accent-rgb), 0.28);
  box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.1);
}

.planet-stat .stat-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.planet-stat .stat-value {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.planet-stat .stat-value:not(.ratio-ok):not(.ratio-warn):not(.ratio-crit) {
  color: var(--text-primary);
}

/* Garrison row (ships + defenses + leaders on the planet) */
.stat-garrison {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex !important;
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 5px;
}
.stat-garrison .garrison-label {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.stat-garrison .garrison-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  row-gap: 6px;
  width: 100%;
}
.garrison-groups {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px 18px;
  width: 100%;
}
.garrison-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.garrison-group-icon {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  flex-shrink: 0;
  filter: drop-shadow(0 0 4px currentColor);
  opacity: 0.9;
}
.garrison-group-ships { color: #22d3ee; }
.garrison-group-defenses { color: #60a5fa; }
.garrison-group-leaders { color: #f59e0b; }
.garrison-group-chips {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}
.garrison-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  line-height: 1;
  color: var(--text-primary);
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  background: rgba(8, 12, 22, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.22);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.garrison-chip:hover {
  border-color: rgba(34, 211, 238, 0.5);
  background: rgba(34, 211, 238, 0.08);
  transform: translateY(-1px);
}
.garrison-chip img {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.35);
}
.garrison-chip-name {
  font-size: 0.72rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  white-space: nowrap;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.garrison-chip-qty {
  color: var(--text-primary);
  font-weight: 600;
}
.garrison-group-defenses .garrison-chip:hover {
  border-color: rgba(96, 165, 250, 0.55);
  background: rgba(96, 165, 250, 0.1);
}
.garrison-chip-leader {
  padding-right: 12px;
  border-color: rgba(245, 158, 11, 0.45);
  background: rgba(245, 158, 11, 0.08);
}
.garrison-chip-leader:hover {
  border-color: rgba(245, 158, 11, 0.8);
  background: rgba(245, 158, 11, 0.18);
}
.garrison-chip-leader .garrison-chip-name {
  color: #fcd34d;
  max-width: 100px;
}
.garrison-empty-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px dashed rgba(148, 163, 184, 0.3);
  background: rgba(8, 12, 22, 0.4);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.garrison-empty-chip svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}
.garrison-empty-chip:hover {
  border-color: rgba(0, 240, 255, 0.5);
  color: var(--text-primary);
  background: rgba(0, 240, 255, 0.06);
}
.garrison-threat-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid rgba(239, 68, 68, 0.55);
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  animation: garrisonThreatPulse 1.8s ease-in-out infinite;
}
.garrison-threat-chip svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}
.garrison-threat-chip:hover {
  background: rgba(239, 68, 68, 0.22);
  color: #fff;
}
@keyframes garrisonThreatPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50%      { box-shadow: 0 0 0 5px rgba(239, 68, 68, 0); }
}

/* Planet detail modal (tap planet image to see secondary stats) */
#planet-detail-modal .panel {
  display: flex;
  flex-direction: column;
  max-height: 88vh;
  max-height: 88dvh;
}
.planet-detail-modal-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.planet-detail-visual {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.planet-detail-name {
  font-family: var(--font-display, var(--font-body));
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-align: center;
  margin: -4px 0 0;
  word-break: break-word;
}
.planet-detail-img {
  width: 100%;
  max-height: 26vh;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 4px 20px var(--scrim-60);
}
.planet-detail-img.planet-img--moon {
  width: 160px;
  height: 160px;
  border-radius: 0;
  border: none;
  box-shadow: none;
  object-fit: contain;
}
.planet-detail-visual.planet-visual-star-red_dwarf .planet-detail-img     { filter: sepia(0.3) hue-rotate(-15deg) saturate(1.3) brightness(0.85); }
.planet-detail-visual.planet-visual-star-orange_giant .planet-detail-img  { filter: sepia(0.25) hue-rotate(5deg) saturate(1.2) brightness(1.05); }
.planet-detail-visual.planet-visual-star-blue_giant .planet-detail-img    { filter: sepia(0.15) hue-rotate(180deg) saturate(0.8) brightness(1.1); }
.planet-detail-visual.planet-visual-star-red_giant .planet-detail-img     { filter: sepia(0.4) hue-rotate(-10deg) saturate(1.5) brightness(0.9); }
.planet-detail-visual.planet-visual-star-white_dwarf .planet-detail-img   { filter: saturate(0.5) brightness(0.9); }
.planet-detail-visual.planet-visual-star-brown_dwarf .planet-detail-img   { filter: sepia(0.5) hue-rotate(-10deg) saturate(0.8) brightness(0.6); }
.planet-detail-visual.planet-visual-star-neutron_star .planet-detail-img  { filter: sepia(0.2) hue-rotate(200deg) saturate(0.7) brightness(1.05); }
.planet-detail-visual.planet-visual-star-black_hole .planet-detail-img    { filter: sepia(0.3) hue-rotate(240deg) saturate(0.6) brightness(0.5); }
.planet-detail-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  width: 100%;
}
.planet-detail-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.planet-detail-row .stat-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.planet-detail-row .stat-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--text-primary);
}
/* F2a: the modal hosts the full telemetry ficha as single-column rows */
.planet-detail-stats.planet-stats {
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 10px;
}
.planet-detail-stats.planet-stats .stat-label { font-size: 11.5px; }

.ship-qty-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.ship-qty-btn {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid rgba(34, 211, 238, 0.16);
  background: rgba(8, 20, 34, 0.92);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.ship-qty-value {
  font-size: 0.85rem;
  min-width: 20px;
  text-align: center;
}

/* --- Autofarm toggle --- */
.autofarm-toggle {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 20px;
  background: rgba(8, 12, 22, 0.6);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s, box-shadow 0.2s;
}
.autofarm-toggle:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
}
.autofarm-toggle.is-active {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.1);
  color: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.15);
}
.autofarm-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.3);
  transition: background 0.2s, box-shadow 0.2s;
}
.autofarm-toggle.is-active .autofarm-indicator,
.autofarm-indicator.is-active {
  background: #34d399;
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.6);
}
.autofarm-toggle:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.autofarm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.autofarm-target {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}
.autofarm-shortfall {
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.autofarm-shortfall .cost-icon {
  margin-right: -2px;
}
.autofarm-target.is-building {
  color: #34d399;
}
.autofarm-target.is-assisting {
  color: #60a5fa;
}

/* --- Planet Actions (Terraform, Atmosphere, Genesis Bomb) --- */
.planet-stat.planet-action-row .planet-action-wrap {
  width: 100%;
}
.planet-action-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.planet-action-cost {
  flex: 0 1 auto;
  margin-left: auto;
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
}
.planet-action-cost.confirm-cost {
  margin-left: 0;
  margin-top: 8px;
  justify-content: center;
  width: 100%;
}
.planet-action-temp {
  flex: 0 1 auto;
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  font-size: 0.72rem;
  color: var(--cyan);
  white-space: nowrap;
}
.planet-action-cost-item.cost-missing .kc-res-chip-num,
.planet-action-cost.insufficient .planet-action-cost-item .kc-res-chip-num {
  color: #ef4444;
}
.planet-action-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid rgba(var(--accent-rgb), 0.15);
  border-radius: 3px;
  background: rgba(var(--accent-rgb), 0.06);
  color: var(--cyan);
  cursor: pointer;
  font-size: 0.72rem;
  font-family: var(--font-mono);
  transition: border-color 0.2s, background 0.2s;
}
.planet-action-btn:hover:not(:disabled) {
  border-color: rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.12);
}
.planet-action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.terraform-status {
  font-size: 0.72rem;
  color: var(--cyan);
  font-family: var(--font-mono);
}
.terraform-status.dim {
  color: var(--text-dim);
}

/* --- Atmosphere modal --- */
.atmo-modal-box {
  max-width: 420px;
  width: calc(100vw - 32px);
}
.atmo-modal-title {
  margin: 0 0 4px;
  font-size: 1rem;
  color: var(--text-primary);
}
.atmo-modal-subtitle {
  margin: 0 0 14px;
  font-size: 0.72rem;
  color: var(--text-dim);
}
.atmo-modal-graph-wrap {
  margin-bottom: 12px;
}
.atmo-modal-graph {
  position: relative;
  height: 48px;
  border-radius: 4px;
  background: linear-gradient(90deg, #1e3a5f 0%, #2563eb 22%, #22c55e 35%, #eab308 55%, #ef4444 78%, #7f1d1d 100%);
  border: 1px solid rgba(var(--accent-rgb), 0.2);
  overflow: hidden;
}
.atmo-modal-optimal {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.12);
  border-left: 1px solid rgba(255, 255, 255, 0.25);
  border-right: 1px solid rgba(255, 255, 255, 0.25);
  pointer-events: none;
}
.atmo-modal-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-1px);
  pointer-events: none;
  z-index: 2;
}
.atmo-modal-marker span {
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.55rem;
  white-space: nowrap;
  font-family: var(--font-mono);
}
.atmo-modal-marker.current {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}
.atmo-modal-marker.current span { color: #fff; }
.atmo-modal-marker.target {
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.8);
  width: 3px;
}
.atmo-modal-marker.target span { color: var(--cyan); bottom: auto; top: -16px; }
.atmo-modal-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.58rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  margin-top: 18px;
  padding: 0 2px;
}
.atmo-modal-slider-wrap {
  position: relative;
  margin-top: 10px;
  height: 24px;
}
.atmo-modal-slider-allowed {
  position: absolute;
  left: 0;
  top: 50%;
  height: 4px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: rgba(var(--accent-rgb), 0.35);
  pointer-events: none;
  z-index: 0;
}
.atmo-modal-slider {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0;
  accent-color: var(--cyan);
  background: transparent;
}
.atmo-modal-temps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  font-size: 0.72rem;
}
.atmo-modal-temp-label {
  display: block;
  color: var(--text-dim);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.atmo-modal-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px;
  border-radius: 4px;
  background: rgba(var(--accent-rgb), 0.05);
  border: 1px solid rgba(var(--accent-rgb), 0.12);
}
.atmo-modal-stat {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 8px;
  align-items: center;
  font-size: 0.72rem;
}
.atmo-modal-stat-label {
  color: var(--text-dim);
  grid-column: 1 / -1;
}
.atmo-modal-stat-val.positive { color: #22c55e; }
.atmo-modal-stat-val.negative { color: #ef4444; }
.atmo-modal-stat-delta {
  font-size: 0.68rem;
  justify-self: end;
}
.atmo-modal-stat-delta.positive { color: #22c55e; }
.atmo-modal-stat-delta.negative { color: #ef4444; }
.atmo-modal-cost {
  justify-content: center;
  margin-bottom: 12px;
}
.atmo-modal-actions {
  margin-top: 0;
}

/* --- Planet surface view (rendered in #planet-surface-view, outside grid) --- */
.planet-surface {
  position: relative;
  width: 100%;
  overflow: hidden;
  line-height: 0;
}
.planet-surface img {
  width: 100%;
  height: auto;
  display: block;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.2) 10%, var(--scrim-70) 25%, black 40%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.2) 10%, var(--scrim-70) 25%, black 40%);
  transition: filter 0.5s ease;
}

/* --- Star type LUT - color tint overlay --- */
.planet-surface::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  mix-blend-mode: color;
  opacity: 0;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.2) 10%, var(--scrim-70) 25%, black 40%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.2) 10%, var(--scrim-70) 25%, black 40%);
  transition: opacity 0.5s ease;
}

/* Yellow Dwarf - standard illumination, no tint */

/* Red Dwarf - dim salmon-red, like a perpetual dusk */
.planet-surface.star-red_dwarf::before {
  background: #cc4422;
  opacity: 0.45;
}
.planet-surface.star-red_dwarf img {
  filter: brightness(0.72) saturate(0.8);
}

/* Orange Giant - warm amber, sunset glow */
.planet-surface.star-orange_giant::before {
  background: #ff8833;
  opacity: 0.35;
}
.planet-surface.star-orange_giant img {
  filter: brightness(1.05) saturate(0.9);
}

/* Blue Giant - intense cold blue-white */
.planet-surface.star-blue_giant::before {
  background: #4488ff;
  opacity: 0.4;
}
.planet-surface.star-blue_giant img {
  filter: brightness(1.15) saturate(0.8);
}

/* Red Giant - deep crimson, permanent deep sunset */
.planet-surface.star-red_giant::before {
  background: #cc2200;
  opacity: 0.5;
}
.planet-surface.star-red_giant img {
  filter: brightness(0.78) saturate(0.7);
}

/* White Dwarf - cold moonlit blue-white, dim */
.planet-surface.star-white_dwarf::before {
  background: #aabbff;
  opacity: 0.4;
}
.planet-surface.star-white_dwarf img {
  filter: brightness(0.62) saturate(0.65) contrast(1.1);
}

/* Brown Dwarf - murky twilight, very dim */
.planet-surface.star-brown_dwarf::before {
  background: #664422;
  opacity: 0.55;
}
.planet-surface.star-brown_dwarf img {
  filter: brightness(0.42) saturate(0.55);
}

/* Neutron Star - eerie blue-violet, harsh */
.planet-surface.star-neutron_star::before {
  background: #6688ff;
  opacity: 0.45;
}
.planet-surface.star-neutron_star img {
  filter: brightness(0.68) saturate(0.7) contrast(1.15);
}

/* Black Hole - near darkness, spectral purple from accretion disk */
.planet-surface.star-black_hole::before {
  background: #8844ff;
  opacity: 0.55;
}
.planet-surface.star-black_hole img {
  filter: brightness(0.32) saturate(0.45) contrast(1.2);
}
/* Orbit night-side darkening overlay */
.orbit-night {
  position: absolute;
  inset: 0;
  background: black;
  opacity: var(--orbit-darkness, 0);
  pointer-events: none;
  z-index: 3;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.2) 10%, var(--scrim-70) 25%, black 40%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.2) 10%, var(--scrim-70) 25%, black 40%);
  transition: opacity 0.15s ease;
}
/* Camera overlay: scanlines + vignette */
.planet-surface::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 2px,
      rgba(0, 0, 0, 0.06) 2px,
      rgba(0, 0, 0, 0.06) 4px
    ),
    radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 0, 0.45) 100%);
  z-index: 4;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.2) 10%, var(--scrim-70) 25%, black 40%);
  mask-image: linear-gradient(to bottom, transparent 0%, rgba(0,0,0,0.2) 10%, var(--scrim-70) 25%, black 40%);
}
/* Camera HUD overlay */
.surface-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  font-family: var(--font-mono);
  color: rgba(0, 255, 200, 0.7);
  text-shadow: 0 0 4px rgba(0, 255, 200, 0.3);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
}
/* Corner brackets */
.surface-hud::before,
.surface-hud::after {
  content: '';
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: rgba(0, 255, 200, 0.35);
  border-style: solid;
}
.surface-hud::before {
  top: 12px;
  left: 12px;
  border-width: 1px 0 0 1px;
}
.surface-hud::after {
  bottom: 12px;
  right: 12px;
  border-width: 0 1px 1px 0;
}
.surface-hud-tr,
.surface-hud-bl {
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: rgba(0, 255, 200, 0.35);
  border-style: solid;
}
.surface-hud-tr {
  top: 12px;
  right: 12px;
  border-width: 1px 1px 0 0;
}
.surface-hud-bl {
  bottom: 12px;
  left: 12px;
  border-width: 0 0 1px 1px;
}
/* REC indicator */
.surface-hud-rec {
  position: absolute;
  top: 16px;
  right: 52px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255, 60, 60, 0.85);
  text-shadow: 0 0 6px rgba(255, 60, 60, 0.4);
}
.surface-hud-rec::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 60, 60, 0.9);
  box-shadow: 0 0 6px rgba(255, 60, 60, 0.6);
  animation: recBlink 1.5s ease-in-out infinite;
}
@keyframes recBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}
/* Camera info line */
.surface-hud-info {
  position: absolute;
  bottom: 16px;
  left: 52px;
  font-size: 0.6rem;
  opacity: 0.7;
}
.surface-hud-label {
  position: absolute;
  top: 16px;
  left: 52px;
  right: 100px;
  font-size: 0.6rem;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.surface-hud-epoch {
  position: absolute;
  bottom: 16px;
  right: 52px;
  font-size: 0.6rem;
  opacity: 0.7;
  letter-spacing: 0.04em;
}

/* --- Dashboard Loading Overlay --- */
#screen-empire {
  position: relative;
}


.dashboard-loading-overlay {
  /* Pin to the viewport instead of the dashboard inner area so the panel
     stays centered through the full boot sequence. The previous version
     keyed top/bottom off --banner-offset, --topbar-height, --nav-height
     and --ticker-height. Those vars settle in waves (syncShellMetrics on
     load, ticker.show after state arrives, banner offsets after player
     state lands), which made the overlay visibly jump twice before
     dismissing. Full-viewport pinning + flex centering eliminates the
     dependency on those late-arriving vars. */
  position: fixed;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--panel-padding);
  background: rgba(4, 8, 14, 0.78);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.dashboard-loading-overlay[hidden] {
  display: none !important;
}

.dashboard-loading-panel {
  width: min(420px, 100%);
  padding: 18px 18px 16px;
  border-color: rgba(var(--accent-rgb), 0.18);
  box-shadow:
    0 14px 36px rgba(0, 0, 0, 0.48),
    0 0 32px rgba(var(--accent-rgb), 0.08);
}

.dashboard-loading-title {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  color: #f8fafc;
  margin-bottom: 8px;
}

.dashboard-loading-copy {
  font-size: 0.76rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.dashboard-loading-track {
  position: relative;
  margin-top: 14px;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(var(--accent-rgb), 0.18);
}

.dashboard-loading-bar {
  position: absolute;
  inset: 1px auto 1px -38%;
  width: 38%;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent 0%, rgba(var(--accent-rgb), 0.45) 18%, rgba(var(--accent-rgb), 0.92) 52%, rgba(255, 255, 255, 0.75) 70%, transparent 100%);
  filter: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.35));
  animation: dashboard-loading-slide 1.25s ease-in-out infinite;
}

@keyframes dashboard-loading-slide {
  0% { transform: translateX(0); }
  100% { transform: translateX(360%); }
}

/* --- Fleet Task Card ---
   Mirror the building/research task-card-icon pattern so the ship
   thumbnail bleeds flush against the row's left edge and stretches
   to the full row height (negative vertical margin punches through
   the card's padding). */
.task-card .fleet-icon {
  width: 60px;
  align-self: stretch;
  margin: -8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  border-radius: 3px 0 0 3px;
  overflow: hidden;
  background: rgba(var(--accent-rgb), 0.08);
  flex-shrink: 0;
}
.task-card .fleet-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
}
.task-card-subtitle {
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fleet-recall-btn {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.fleet-recall-btn:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ============================================================
   TECH TREE (Skill Tree)
   ============================================================ */
.tech-tree {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tech-branch {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(13, 13, 31, 0.6);
  border-radius: 3px;
  border: 1px solid rgba(var(--accent-rgb), 0.08);
  padding: 8px;
  min-height: 64px;
}
.tech-branch-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 56px;
  flex-shrink: 0;
}
.tech-branch-icon {
  width: 32px;
  height: 32px;
  border-radius: 2px;
  object-fit: cover;
}
.tech-branch-name {
  font-size: 0.55rem;
  color: var(--branch-color);
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.tech-branch-lvl {
  font-size: 0.6rem;
  color: var(--text-dim);
}

/* Scrollable nodes area */
.tech-nodes-scroll {
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 4px 0;
}
.tech-nodes-scroll::-webkit-scrollbar { display: none; }
.tech-nodes-track {
  display: flex;
  align-items: center;
  gap: 0;
  min-width: max-content;
}

.tech-node-wrapper {
  display: flex;
  align-items: center;
}
.tech-connector {
  width: 16px;
  height: 2px;
  background: rgba(100, 116, 139, 0.3);
  flex-shrink: 0;
}
.tech-connector.completed {
  background: var(--branch-color);
  box-shadow: 0 0 4px var(--branch-color);
}

.tech-node {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid;
  transition: all 0.2s;
  position: relative;
}
.tech-node.completed {
  border-color: var(--branch-color);
  background: color-mix(in srgb, var(--branch-color) 20%, transparent);
  box-shadow: 0 0 6px color-mix(in srgb, var(--branch-color) 40%, transparent);
}
.tech-node.completed .tech-node-level {
  color: var(--branch-color);
  font-weight: 700;
}
.tech-node.available {
  border-color: var(--branch-color);
  background: var(--scrim-40);
  animation: techPulse 2s ease-in-out infinite;
  cursor: pointer;
}
.tech-node.available .tech-node-level { color: var(--branch-color); }
@keyframes techPulse {
  0%, 100% { box-shadow: 0 0 4px transparent; }
  50% { box-shadow: 0 0 12px color-mix(in srgb, var(--branch-color) 50%, transparent); }
}
.tech-node.researching {
  border-color: var(--branch-color);
  background: var(--scrim-40);
  animation: techSpin 3s linear infinite;
}
@keyframes techSpin {
  0% { box-shadow: 0 0 6px var(--branch-color), inset 0 0 6px transparent; }
  50% { box-shadow: 0 0 12px var(--branch-color), inset 0 0 8px color-mix(in srgb, var(--branch-color) 20%, transparent); }
  100% { box-shadow: 0 0 6px var(--branch-color), inset 0 0 6px transparent; }
}
.tech-node.researching .tech-node-level { display: none; }
.tech-node-timer {
  font-size: 0.5rem;
  color: var(--branch-color);
  white-space: nowrap;
}
.tech-node.next-locked {
  border-color: rgba(100, 116, 139, 0.4);
  background: rgba(0, 0, 0, 0.3);
}
.tech-node.next-locked .tech-node-level { color: var(--text-dim); }
.tech-node.locked {
  border-color: rgba(100, 116, 139, 0.2);
  background: rgba(0, 0, 0, 0.2);
  opacity: 0.4;
}
.tech-node.locked .tech-node-level { color: var(--text-dim); }
.tech-node-level {
  font-size: 0.65rem;
  color: var(--text-secondary);
}

/* Action area (right side) */
.tech-branch-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 72px;
  flex-shrink: 0;
}
.research-card .btn-upgrade .btn-label {
  white-space: normal;
  line-height: 1.3;
  font-size: 0.6rem;
  color: var(--text-dim);
}
.tech-cancel-btn {
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.6rem;
  border: 1px solid rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.1);
  color: var(--red);
  cursor: pointer;
}
.tech-cost {
  font-size: 0.6rem;
  color: var(--text-dim);
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
  justify-content: center;
}
.tech-time {
  font-size: 0.55rem;
  color: var(--text-dim);
}
.tech-lock-msg {
  font-size: 0.55rem;
  color: var(--text-dim);
  text-align: center;
}

/* Mobile: stack vertically on very small screens */
@media (max-width: 400px) {
  .tech-branch {
    flex-wrap: wrap;
  }
  .tech-branch-label {
    flex-direction: row;
    gap: 6px;
    min-width: 100%;
    justify-content: flex-start;
  }
  .tech-branch-action {
    min-width: 100%;
    flex-direction: row;
    justify-content: center;
  }
}

/* Trade discount card badge */
.trade-discount-card-badge {
  background: linear-gradient(135deg, #059669, #10b981) !important;
  border-color: rgba(52, 211, 153, 0.6) !important;
}

/* Energy warning */
.res-energy-warn {
  font-size: 11.5px;
  font-weight: 700;
  color: #ff4444;
  text-shadow: 0 0 6px rgba(255, 68, 68, 0.5);
  background: rgba(255, 68, 68, 0.1);
  padding: 1px 6px;
  border-radius: 4px;
  letter-spacing: 0.05em;
}
.res-qbit-warn {
  color: #8b5cf6;
  text-shadow: 0 0 6px rgba(139, 92, 246, 0.5);
  background: rgba(139, 92, 246, 0.1);
}
.res-workforce-warn {
  color: #fbbf24;
  text-shadow: 0 0 6px rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.1);
}
.res-workforce-warn.workforce-critical {
  color: #ff4444;
  text-shadow: 0 0 6px rgba(255, 68, 68, 0.5);
  background: rgba(255, 68, 68, 0.1);
}
.workforce-low { color: #fbbf24; }
.workforce-critical { color: #ff4444; }
.workforce-bonus { color: #06b6d4; }
[data-resource="population"] .res-inline-icon { color: #06b6d4; }
[data-resource="population"] .res-rate { color: #06b6d4; }

/* --- Happiness Badge --- */
[data-resource="population"] .res-label {
  display: flex;
  align-items: center;
}
.happiness-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  margin-left: 4px;
}
.happiness-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* --- Wellbeing Section (Civil Tab) --- */
.wellbeing-section {
  grid-column: 1 / -1;
  padding: 12px 14px;
  margin-bottom: 8px;
}
.wellbeing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
/* Disclosure header (same expandable pattern as the Ciencia PI panel):
   caret + aria-expanded carry the state, colour stays secondary */
.wellbeing-header-toggle { cursor: pointer; }
.wellbeing-header-toggle:focus-visible { outline: 1px solid var(--cyan); outline-offset: 2px; }
.wellbeing-header-toggle[aria-expanded="false"] { margin-bottom: 0; }
.wellbeing-caret {
  display: inline-block;
  width: 0; height: 0; margin-left: 8px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid color-mix(in srgb, currentColor 80%, transparent);
  transition: transform 0.15s ease;
  vertical-align: 2px;
}
.wellbeing-header-toggle[aria-expanded="false"] .wellbeing-caret { transform: rotate(-90deg); }
.wellbeing-factors[hidden] { display: none; }
.wellbeing-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary, #e2e8f0);
}
.wellbeing-score {
  font-size: 1.1rem;
  font-weight: 700;
}
.wellbeing-factors {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.wellbeing-factor {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}
.wellbeing-factor-label {
  color: var(--text-secondary, #94a3b8);
}
.wellbeing-factor-value {
  font-weight: 600;
}
.wellbeing-positive .wellbeing-factor-value {
  color: #22c55e;
}
.wellbeing-negative .wellbeing-factor-value {
  color: #ef4444;
}
.wellbeing-negative {
  background: rgba(239, 68, 68, 0.06);
}
.wellbeing-positive {
  background: rgba(34, 197, 94, 0.04);
}
/* Clickable factor rows reveal a subtle highlight on hover/focus to hint
   that more info is available on click. */
.wellbeing-factor[data-happiness-tip] {
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.wellbeing-factor[data-happiness-tip]:hover,
.wellbeing-factor[data-happiness-tip]:focus-visible {
  background: rgba(0, 240, 255, 0.10);
  box-shadow: inset 0 0 0 1px rgba(0, 240, 255, 0.25);
  outline: none;
}

/* --- Missions Tab --- */
.missions-layout {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Progress bar - full width horizontal */
.mission-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mission-progress-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mission-progress-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}
.mission-progress-count {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--accent, #00f0ff);
  font-weight: 600;
}
.mission-progress-pct {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  margin-left: auto;
}
.mission-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.mission-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #00f0ff, #00d4ff);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.35);
}

/* Current mission - hero card */
.mission-current {
  background-color: rgba(0, 240, 255, 0.04);
  background-size: cover;
  background-position: center;
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: var(--radius-lg, 12px);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
}
.mission-current::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(6, 6, 15, 0.82) 0%, rgba(6, 6, 15, 0.55) 100%);
  z-index: 0;
}
.mission-current-inner {
  position: relative;
  z-index: 1;
}
.mission-current::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent, #00f0ff), transparent);
  z-index: 1;
}
.mission-current-inner {
  display: flex;
  align-items: center;
  gap: 20px;
}
@media (max-width: 420px) {
  .mission-current-inner { flex-direction: column; text-align: center; }
}

/* Step ring - circular badge */
.mission-step-ring {
  width: 56px;
  height: 56px;
  min-width: 56px;
  border-radius: 50%;
  border: 2px solid var(--accent, #00f0ff);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 240, 255, 0.06);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.15), inset 0 0 12px rgba(0, 240, 255, 0.06);
  position: relative;
  animation: ringGlow 3s ease-in-out infinite;
}
@keyframes ringGlow {
  0%, 100% { box-shadow: 0 0 16px rgba(0, 240, 255, 0.15), inset 0 0 12px rgba(0, 240, 255, 0.06); }
  50% { box-shadow: 0 0 24px rgba(0, 240, 255, 0.3), inset 0 0 16px rgba(0, 240, 255, 0.1); }
}
.mission-step-ring-num {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent, #00f0ff);
}
.mission-step-ring-done {
  border-color: #44ff88;
  background: rgba(68, 255, 136, 0.08);
  box-shadow: 0 0 16px rgba(68, 255, 136, 0.15), inset 0 0 12px rgba(68, 255, 136, 0.06);
  animation: none;
}
.mission-step-ring-check {
  font-size: 1.4rem;
  color: #44ff88;
}

.mission-current-body {
  flex: 1;
  min-width: 0;
}
.mission-current-header {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent, #00f0ff);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
@media (max-width: 420px) {
  .mission-current-header { justify-content: center; }
}
.mission-current-pulse {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent, #00f0ff);
  box-shadow: 0 0 6px var(--accent, #00f0ff);
  animation: missionPulse 2s ease-in-out infinite;
}
@keyframes missionPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--accent, #00f0ff); }
  50% { opacity: 0.4; box-shadow: 0 0 2px var(--accent, #00f0ff); }
}
.mission-description {
  font-size: 0.95rem;
  color: var(--text-primary, #e0e0e0);
  margin-bottom: 12px;
  line-height: 1.4;
}

/* Reward chips */
.mission-reward-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
@media (max-width: 420px) {
  .mission-reward-row { justify-content: center; }
}
.mission-reward-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.mission-reward-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: #c0ffd0;
  background: rgba(68, 255, 136, 0.08);
  border: 1px solid rgba(68, 255, 136, 0.15);
  border-radius: 5px;
  padding: 3px 8px;
}
.mission-reward-chip .cost-icon {
  width: 13px;
  height: 13px;
}

/* Go button */
.btn-mission-go {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 24px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #000;
  background: linear-gradient(135deg, #00f0ff, #00c8d4);
  border: none;
  border-radius: 7px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  transition: transform 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 10px rgba(0, 240, 255, 0.25);
}
.btn-mission-go:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 240, 255, 0.4);
}
.btn-mission-go-arrow {
  font-size: 0.85rem;
  transition: transform 0.15s;
}
.btn-mission-go:hover .btn-mission-go-arrow {
  transform: translateX(2px);
}

/* All done */
.mission-all-done .mission-current-header {
  color: #44ff88;
}
.mission-all-done::before {
  background: linear-gradient(90deg, transparent, #44ff88, transparent);
}

/* Completed missions grid */
.mission-history-header {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.mission-history-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #44ff88;
  background: rgba(68, 255, 136, 0.1);
  border-radius: 4px;
  padding: 1px 6px;
}
.mission-history {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}
.mission-history-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(68, 255, 136, 0.03);
  border: 1px solid rgba(68, 255, 136, 0.08);
  transition: background 0.15s, border-color 0.15s;
}
.mission-history-item:hover {
  background: rgba(68, 255, 136, 0.06);
  border-color: rgba(68, 255, 136, 0.2);
}
.mission-step-check {
  font-size: 0.7rem;
  color: #44ff88;
  width: 18px;
  height: 18px;
  min-width: 18px;
  border-radius: 50%;
  background: rgba(68, 255, 136, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
.mission-step-num {
  font-family: var(--font-mono);
  color: rgba(68, 255, 136, 0.6);
  font-size: 0.7rem;
  min-width: 16px;
  flex-shrink: 0;
}
.mission-history-text {
  flex: 1;
  line-height: 1.3;
}

/* ─── Campaign ──────────────────────────────────────────────────── */

.campaign-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  grid-column: 1 / -1;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
}

.campaign-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
  text-align: center;
  padding: 0.2rem 0;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.35);
}

/* ── Chapter Cards ─────────────────────────────────────── */

.campaign-chapter-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.campaign-chapter-card {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  transition: all 0.3s;
  position: relative;
}

.campaign-chapter-card.active {
  border-color: var(--clr-accent, #00f0ff);
  box-shadow: 0 0 15px rgba(0,240,255,0.15);
}

.campaign-chapter-card.completed {
  border-color: rgba(16,185,129,0.35);
}

.campaign-chapter-card.locked {
  opacity: 0.35;
  filter: grayscale(0.6);
}

.campaign-ch-hero {
  width: 100%;
  height: 60px;
  background-size: cover;
  background-position: center;
  opacity: 0.5;
}

.campaign-chapter-card.active .campaign-ch-hero { opacity: 0.7; }
.campaign-chapter-card.completed .campaign-ch-hero { opacity: 0.4; }

.campaign-ch-content {
  padding: 6px 8px 8px;
  text-align: center;
}

.campaign-ch-num {
  font-size: 0.55rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
}

.campaign-ch-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: #e2e8f0;
  line-height: 1.25;
  margin: 2px 0 4px;
}

.campaign-ch-badge {
  font-size: 0.85rem;
}

.campaign-ch-done { color: #10b981; }
.campaign-ch-locked { color: rgba(255,255,255,0.3); font-size: 0.7rem; }

.campaign-ch-progress {
  font-size: 0.6rem;
  color: var(--clr-accent, #00f0ff);
  margin-top: 2px;
}

.campaign-ch-progress-bar {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 4px;
}

.campaign-ch-progress-fill {
  height: 100%;
  background: var(--clr-accent, #00f0ff);
  border-radius: 2px;
}

/* ── Active Chapter Hero Banner ─────────────────────────── */

.campaign-active-chapter {
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  background-size: cover;
  background-position: center;
  min-height: 140px;
}

.campaign-active-overlay {
  background: linear-gradient(135deg, rgba(5,10,25,0.85) 0%, rgba(5,10,25,0.6) 50%, rgba(5,10,25,0.85) 100%);
  padding: 1.2rem 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
  gap: 0.8rem;
}

.campaign-active-top {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.campaign-active-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--clr-accent, #00f0ff);
  opacity: 0.7;
}

.campaign-active-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 10px var(--scrim-50);
}

.campaign-active-subtitle {
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  font-style: italic;
}

.campaign-active-progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.campaign-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
  overflow: hidden;
}

.campaign-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--clr-accent, #00f0ff), #a855f7);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.campaign-progress-label {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.4);
  text-align: right;
}

/* ── Chapter Start Card (not yet begun) ────────────────── */

.campaign-start-card {
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  background-size: cover;
  background-position: center;
  min-height: 280px;
}

.campaign-start-overlay {
  min-height: 280px;
  background: linear-gradient(180deg, rgba(5,10,25,0.4) 0%, rgba(5,10,25,0.75) 50%, rgba(5,10,25,0.95) 100%);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  text-align: center;
  gap: 0.4rem;
}

.campaign-start-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--clr-accent, #00f0ff);
  opacity: 0.7;
}

.campaign-start-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 15px var(--scrim-60);
}

.campaign-start-subtitle {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.5);
  font-style: italic;
  max-width: 400px;
}

.campaign-start-meta {
  font-size: 0.65rem;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.3rem;
}

.campaign-start-btn {
  margin-top: 1rem;
  padding: 0.7rem 2rem;
  background: linear-gradient(135deg, rgba(0,240,255,0.15), rgba(0,240,255,0.25));
  border: 1px solid rgba(0,240,255,0.4);
  border-radius: 8px;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: all 0.3s;
  text-transform: uppercase;
}

.campaign-start-btn:hover {
  background: linear-gradient(135deg, rgba(0,240,255,0.25), rgba(0,240,255,0.4));
  box-shadow: 0 0 25px rgba(0,240,255,0.2);
  border-color: rgba(0,240,255,0.6);
  transform: translateY(-1px);
}

/* ── Chapter Complete Overlay ───────────────────────────── */

.chapter-complete-card {
  max-width: 420px;
  width: 100%;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(16,185,129,0.3);
  box-shadow: 0 0 30px rgba(16,185,129,0.1);
  animation: storySlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.chapter-complete-hero {
  height: 140px;
  background-size: cover;
  background-position: center;
  opacity: 0.5;
}

.chapter-complete-body {
  padding: 1.5rem;
  background: linear-gradient(180deg, rgba(10,18,35,0.97), rgba(5,10,25,0.98));
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.chapter-complete-label {
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: rgba(255,255,255,0.4);
}

.chapter-complete-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
}

.chapter-complete-badge {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: #10b981;
  border: 1px solid rgba(16,185,129,0.3);
  padding: 0.3rem 1rem;
  border-radius: 20px;
  margin: 0.3rem 0;
}

.chapter-complete-btn {
  margin-top: 0.5rem;
  border-color: rgba(16,185,129,0.4) !important;
  background: linear-gradient(135deg, rgba(16,185,129,0.15), rgba(16,185,129,0.25)) !important;
}

.chapter-complete-btn:hover {
  border-color: rgba(16,185,129,0.6) !important;
  box-shadow: 0 0 25px rgba(16,185,129,0.2) !important;
}

/* ── Campaign Story Log / Bitácora ─────────────────────── */

.campaign-log {
  margin-top: 0.5rem;
}

.campaign-log-toggle {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.35);
  padding: 0.5rem 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.campaign-log-count {
  font-size: 0.6rem;
  background: rgba(255,255,255,0.08);
  padding: 1px 6px;
  border-radius: 8px;
}

.campaign-log-entries {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-top: 0.5rem;
}

.campaign-log-entry {
  display: flex;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 10px;
  border-left: 2px solid rgba(255,255,255,0.1);
}

.campaign-log-osei { border-left-color: rgba(16,185,129,0.3); }
.campaign-log-kael { border-left-color: rgba(245,158,11,0.3); }

.campaign-log-unread { border-left-width: 3px; background: rgba(0,240,255,0.04); }
.campaign-log-unread.campaign-log-osei { border-left-color: rgba(16,185,129,0.7); }
.campaign-log-unread.campaign-log-kael { border-left-color: rgba(245,158,11,0.7); }

.campaign-log-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.1);
}

.campaign-log-content {
  flex: 1;
  min-width: 0;
}

.campaign-log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.2rem;
}

.campaign-log-name {
  font-size: 0.7rem;
  font-weight: 600;
}

.campaign-log-time {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.3);
}

.campaign-log-osei .campaign-log-name { color: #10b981; }
.campaign-log-kael .campaign-log-name { color: #f59e0b; }

.campaign-log-text {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.5;
}

/* ── Bitácora Link Button ─────────────────────────────── */

.btn-bitacora-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.5rem 0.8rem;
  margin-top: 0.4rem;
  background: none;
  border: 1px solid rgba(0,240,255,0.12);
  border-radius: 6px;
  color: var(--cyan);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.btn-bitacora-link:hover {
  background: rgba(0,240,255,0.06);
  border-color: rgba(0,240,255,0.3);
}

/* ── Current Mission Card ──────────────────────────────── */

.campaign-mission-card {
  padding: 1rem 1.2rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
}

.campaign-mission-header {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--clr-accent, #00f0ff);
  margin-bottom: 0.4rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.campaign-mission-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--clr-accent, #00f0ff);
  animation: signalPulse 2s ease-in-out infinite;
  flex-shrink: 0;
}

.campaign-mission-title {
  font-size: 1rem;
  font-weight: 600;
  color: #f1f5f9;
  margin-bottom: 0.3rem;
}

.campaign-mission-hint {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.35);
  margin-bottom: 0.5rem;
}

.campaign-mission-hint strong {
  color: var(--clr-accent, #00f0ff);
  font-weight: 600;
}

.campaign-briefing {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  background: rgba(0,240,255,0.03);
  border-left: 2px solid rgba(0,240,255,0.25);
  border-radius: 0 8px 8px 0;
  margin-bottom: 0.6rem;
}

.campaign-briefing-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,240,255,0.3);
}

.campaign-briefing-text {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
  font-style: italic;
  line-height: 1.5;
}

.campaign-done .campaign-mission-header {
  color: #10b981;
  font-size: 1rem;
  text-transform: none;
  letter-spacing: 0;
}

/* ─── Story Overlay ──────────────────────────────────────────────── */

.story-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.75) 0%, rgba(0,0,0,0.92) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: storyFadeIn 0.5s ease;
}

@keyframes storyFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes storySlideUp {
  from { opacity: 0; transform: translateY(30px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes storyGlow {
  0%, 100% { box-shadow: 0 0 20px var(--story-glow), inset 0 0 20px var(--story-glow-inner); }
  50% { box-shadow: 0 0 35px var(--story-glow), inset 0 0 30px var(--story-glow-inner); }
}

@keyframes scanLineMove {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

@keyframes signalPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

@keyframes typeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.story-overlay-content {
  --story-clr: #00f0ff;
  --story-glow: rgba(0,240,255,0.12);
  --story-glow-inner: rgba(0,240,255,0.04);
  max-width: 520px;
  width: 100%;
  background: linear-gradient(165deg, rgba(10,18,35,0.97) 0%, rgba(5,10,25,0.98) 100%);
  border: none;
  border-radius: 12px;
  padding: 0;
  backdrop-filter: blur(30px);
  overflow: hidden;
  position: relative;
  animation: storySlideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1), storyGlow 4s ease-in-out infinite;
}

/* Scan line effect */
.story-overlay-content::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255,255,255,0.008) 2px,
    rgba(255,255,255,0.008) 4px
  );
  pointer-events: none;
  z-index: 1;
}

/* Moving scan line */
.story-overlay-content::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(180deg, transparent, var(--story-glow), transparent);
  animation: scanLineMove 6s linear infinite;
  pointer-events: none;
  z-index: 1;
  opacity: 0.5;
}

.story-overlay-content.story-osei {
  --story-clr: #10b981;
  --story-glow: rgba(16,185,129,0.12);
  --story-glow-inner: rgba(16,185,129,0.04);
  border-color: rgba(16,185,129,0.25);
}

.story-overlay-content.story-kael {
  --story-clr: #f59e0b;
  --story-glow: rgba(245,158,11,0.12);
  --story-glow-inner: rgba(245,158,11,0.04);
  border-color: rgba(245,158,11,0.25);
}

/* Top bar with character color accent */
.story-topbar {
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--story-clr), transparent);
  opacity: 0.7;
}

.story-inner {
  padding: 1.2rem 1.4rem 1.2rem;
  position: relative;
  z-index: 2;
}

.story-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.8rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.story-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  position: relative;
  flex-shrink: 0;
}

/* Pulsing ring around avatar */
.story-avatar::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid var(--story-clr);
  opacity: 0.3;
  animation: signalPulse 2s ease-in-out infinite;
}

img.story-avatar {
  object-fit: cover;
}

.story-avatar-osei {
  background: rgba(16,185,129,0.1);
  color: #10b981;
  border: 1.5px solid rgba(16,185,129,0.4);
  text-shadow: 0 0 10px rgba(16,185,129,0.5);
}

.story-avatar-kael {
  background: rgba(245,158,11,0.1);
  color: #f59e0b;
  border: 1.5px solid rgba(245,158,11,0.4);
  text-shadow: 0 0 10px rgba(245,158,11,0.5);
}

.story-char-info {
  flex: 1;
  min-width: 0;
}

.story-char-name {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--story-clr);
  letter-spacing: 0.03em;
  text-shadow: 0 0 15px var(--story-glow);
}

.story-char-role {
  font-size: 0.6rem;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 2px;
}

.story-signal {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  margin-left: auto;
  flex-shrink: 0;
}

.story-signal-bars {
  display: flex;
  gap: 2px;
  align-items: flex-end;
  height: 12px;
}

.story-signal-bar {
  width: 3px;
  background: var(--story-clr);
  border-radius: 1px;
  opacity: 0.25;
}

.story-signal-bar.active {
  opacity: 0.8;
  box-shadow: 0 0 4px var(--story-glow);
}

.story-text {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.7;
  margin-bottom: 1.2rem;
  animation: typeIn 0.6s ease 0.2s both;
}

.story-transmission {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  margin-bottom: 1.2rem;
  position: relative;
  animation: typeIn 0.6s ease 0.2s both;
}

.story-transmission-header {
  font-size: 0.55rem;
  letter-spacing: 0.18em;
  color: var(--story-clr);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  opacity: 0.6;
}

.story-transmission-text {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.7;
  font-family: var(--font-mono);
  font-weight: 300;
}

.story-continue-btn {
  display: block;
  width: 100%;
  padding: 0.7rem;
  background: linear-gradient(135deg, rgba(255,255,255,0.04), rgba(255,255,255,0.08));
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #e2e8f0;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.3s;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.story-continue-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--story-glow), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.story-continue-btn:hover {
  background: linear-gradient(135deg, rgba(255,255,255,0.06), rgba(255,255,255,0.12));
  border-color: var(--story-clr);
  color: #fff;
  box-shadow: 0 0 15px var(--story-glow);
}

.story-continue-btn:hover::before {
  opacity: 1;
}

/* ─── Chapter Cinematic Intro ────────────────────────────────────── */

.cinematic-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  background: #000;
  overflow: hidden;
  animation: cinematicFadeIn 1s ease;
}

.cinematic-overlay.cinematic-fadeout {
  animation: cinematicFadeOut 0.6s ease forwards;
}

@keyframes cinematicFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cinematicFadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes heroZoom {
  from { transform: scale(1); }
  to { transform: scale(1.15); }
}

.cinematic-stars {
  position: absolute;
  inset: 0;
  z-index: 1;
}

.cinematic-hero {
  position: absolute;
  inset: 0;
  z-index: 2;
  background-size: cover;
  background-position: center;
  opacity: 0.25;
  animation: heroZoom 30s ease-out forwards;
}

.cinematic-gradient {
  position: absolute;
  inset: 0;
  z-index: 3;
  background: linear-gradient(
    180deg,
    rgba(0,0,0,0.3) 0%,
    var(--scrim-50) 30%,
    rgba(0,0,0,0.8) 70%,
    rgba(0,0,0,0.95) 100%
  );
}

.cinematic-content {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

.cinematic-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.35em;
  color: var(--clr-accent, #00f0ff);
  margin-bottom: 1.5rem;
  opacity: 0;
  transition: opacity 1s ease;
}

.cinematic-label.visible {
  opacity: 0.6;
}

.cinematic-text-box {
  max-width: 600px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.cinematic-line {
  font-size: 1rem;
  line-height: 1.8;
  color: rgba(255,255,255,0.85);
  opacity: 0;
  transition: opacity 1.5s ease;
}

.cinematic-line.visible {
  opacity: 1;
}

.cinematic-line.cinematic-quote {
  font-style: italic;
  color: var(--clr-accent, #00f0ff);
  font-size: 1.05rem;
  text-shadow: 0 0 20px rgba(0,240,255,0.3);
}

.cinematic-chapter-title {
  margin-top: 2rem;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #fff;
  text-shadow: 0 0 30px rgba(0,240,255,0.4), 0 0 60px rgba(0,240,255,0.15);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 1.5s ease, transform 1.5s ease;
}

.cinematic-chapter-title.visible {
  opacity: 1;
  transform: scale(1);
}

.cinematic-skip {
  position: absolute;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.4rem 1rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: rgba(255,255,255,0.4);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.3s;
  z-index: 5;
}

.cinematic-skip:hover {
  color: rgba(255,255,255,0.8);
  border-color: rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
}

.cinematic-skip.cinematic-continue {
  color: rgba(255,255,255,0.9);
  border-color: rgba(0,200,255,0.5);
  background: rgba(0,200,255,0.15);
  font-size: 0.8rem;
  padding: 0.5rem 1.5rem;
  animation: cinematic-pulse 2s ease-in-out infinite;
}

@keyframes cinematic-pulse {
  0%, 100% { box-shadow: 0 0 8px rgba(0,200,255,0.2); }
  50% { box-shadow: 0 0 16px rgba(0,200,255,0.4); }
}

@media (max-width: 480px) {
  .cinematic-line { font-size: 0.85rem; }
  .cinematic-chapter-title { font-size: 1.3rem; }
  .cinematic-content { padding: 1.5rem; }
}

/* ── Campaign Checklist ──────────────────────────────── */

.campaign-checklist {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
@media (max-width: 520px) {
  .campaign-checklist { grid-template-columns: 1fr; }
}

.campaign-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.02);
  border: 1px solid transparent;
  flex-wrap: wrap;
}

.campaign-check-item.done {
  opacity: 0.45;
}

.campaign-check-item.satisfied {
  opacity: 0.7;
  background: rgba(68,255,136,0.04);
  border-color: rgba(68,255,136,0.1);
}

.campaign-check-item.pending {
  background: rgba(0,240,255,0.05);
  border-color: rgba(0,240,255,0.2);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.campaign-check-item.pending:hover {
  background: rgba(0,240,255,0.1);
  border-color: rgba(0,240,255,0.35);
}

.campaign-check-icon {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.campaign-check-icon.check {
  background: rgba(68,255,136,0.15);
  color: #44ff88;
}

.campaign-check-icon.dot {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.3);
  font-size: 0.7rem;
}

.campaign-check-item.pending .campaign-check-icon.dot {
  background: rgba(0,240,255,0.15);
  color: var(--clr-accent, #00f0ff);
}

.campaign-check-text {
  flex: 1;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.55);
  line-height: 1.3;
}

.campaign-check-item.pending .campaign-check-text {
  color: #f1f5f9;
  font-weight: 600;
}

.campaign-check-item.done .campaign-check-text {
  text-decoration: line-through;
  text-decoration-color: rgba(68,255,136,0.3);
}

.campaign-check-rewards {
  width: 100%;
  display: flex;
  gap: 4px;
  padding-left: 32px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.campaign-check-rewards .mission-reward-chip {
  font-size: 0.68rem;
  padding: 2px 6px;
}

/* In-progress / queued task indicator on campaign checklist items */
.campaign-check-item.task-in-progress {
  background: rgba(251,191,36,0.06);
  border-color: rgba(251,191,36,0.25);
}
.campaign-check-item.task-in-progress:hover {
  background: rgba(251,191,36,0.12);
  border-color: rgba(251,191,36,0.4);
}

.campaign-check-icon.in-progress {
  background: rgba(251,191,36,0.18);
  color: #fbbf24;
  font-size: 0.7rem;
  animation: campaign-hourglass-spin 2s ease-in-out infinite;
}
@keyframes campaign-hourglass-spin {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(180deg); }
}

.campaign-task-status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  line-height: 1.4;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.campaign-task-status-badge.status-active {
  background: rgba(251,191,36,0.15);
  color: #fbbf24;
  border: 1px solid rgba(251,191,36,0.3);
}
.campaign-task-status-badge.status-queued {
  background: rgba(168,85,247,0.12);
  color: #c084fc;
  border: 1px solid rgba(168,85,247,0.25);
}

/* In-progress banner on the hero mission card */
.mission-task-status-banner {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
  margin: 6px 0 2px;
}
.mission-task-status-banner.status-active {
  background: rgba(251,191,36,0.12);
  color: #fbbf24;
  border: 1px solid rgba(251,191,36,0.25);
}
.mission-task-status-banner.status-queued {
  background: rgba(168,85,247,0.1);
  color: #c084fc;
  border: 1px solid rgba(168,85,247,0.2);
}

.campaign-check-detail {
  padding: 6px 12px 10px 44px;
}

/* ── Active Mission Card ──────────────────────────────── */
/* Layout: card on the left with action button below it, resource boxes
   stacked vertically on the right. The card itself uses .building-card
   and the resource boxes use .resource-card.panel (Planeta tab style). */

.campaign-mission-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 16px;
}

.campaign-mission-top {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 16px;
}

.campaign-mission-card-col {
  flex: 0 0 auto;
  width: 200px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.campaign-mission-card-wrap {
  display: flex;
}

.campaign-mission-card-wrap > .building-card {
  width: 100%;
}

.campaign-mission-cost-col {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-content: start;
}

.campaign-mission-cost-col > .resource-card {
  width: 100%;
  cursor: pointer;
  padding: 10px 10px 8px;
}

.campaign-mission-cost-col > .resource-card .res-amount {
  font-size: 1.4rem;
}

.campaign-mission-cost-col > .resource-card .res-rate {
  font-size: 0.7rem;
}

.campaign-mission-action {
  display: flex;
}

.campaign-mission-btn {
  position: relative;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 10px;
  border: 1px solid rgba(0, 240, 255, 0.4);
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.18), rgba(0, 240, 255, 0.06));
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  overflow: hidden;
  transition: background 0.15s, border-color 0.15s, transform 0.08s, box-shadow 0.15s;
}

.campaign-mission-btn:hover {
  background: linear-gradient(180deg, rgba(0, 240, 255, 0.3), rgba(0, 240, 255, 0.12));
  border-color: #00f0ff;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.3);
}

.campaign-mission-btn:active {
  transform: scale(0.98);
}

.campaign-mission-btn .campaign-mission-btn-label {
  position: relative;
  z-index: 2;
}

/* "Ready to act" state: a quick diagonal light sweep that fires every 3s
   instead of running continuously, plus a tiny breathing scale. */
.campaign-mission-btn.ready {
  border-color: #00f0ff;
  animation: missionBtnReadyScale 3s ease-in-out infinite;
}

.campaign-mission-btn.ready::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(115deg,
    transparent 0%,
    transparent 38%,
    rgba(0, 240, 255, 0.18) 46%,
    rgba(0, 240, 255, 0.55) 50%,
    rgba(0, 240, 255, 0.18) 54%,
    transparent 62%,
    transparent 100%);
  background-size: 240% 240%;
  background-repeat: no-repeat;
  background-position: -130% 0;
  animation: missionBtnSweep 3s linear infinite;
  pointer-events: none;
  z-index: 1;
  mix-blend-mode: screen;
}

/* Quick sweep over the first ~15% of the cycle (~0.45s of 3s) then idle. */
@keyframes missionBtnSweep {
  0%   { background-position: 130% 0; }
  15%  { background-position: -130% 0; }
  100% { background-position: -130% 0; }
}

@keyframes missionBtnReadyScale {
  0%, 20%, 100% { transform: scale(1); }
  8%            { transform: scale(1.018); }
}

.campaign-mission-status {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.campaign-mission-status.status-active {
  background: rgba(251, 191, 36, 0.12);
  color: #fbbf24;
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.campaign-mission-status.status-queued {
  background: rgba(168, 85, 247, 0.1);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.3);
}

/* Missing-resources alert */
.mission-deficit-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 10px;
}
.mission-deficit-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.mission-deficit-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
}
.mission-deficit-row .cost-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.mission-deficit-name {
  flex: 1;
  font-size: 0.85rem;
  color: #f1f5f9;
  text-align: left;
}
.mission-deficit-amt {
  font-size: 0.95rem;
  font-weight: 700;
}
.mission-deficit-hint {
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.65);
  padding: 10px 12px;
  background: rgba(0, 240, 255, 0.06);
  border: 1px solid rgba(0, 240, 255, 0.2);
  border-radius: 6px;
}

/* ─── Orbital cam (under the mission top row) ──────────────── */
.campaign-orbital-cam {
  position: relative;
  width: 100%;
  border-radius: 4px;
  overflow: hidden;
  border-image-source: url('../../assets/ui/hud-frame.webp');
  border-image-slice: 94;
  border-image-width: 7px;
  border-image-repeat: stretch;
  border-style: solid;
  border-width: 7px;
  background: var(--scrim-50);
  aspect-ratio: 21 / 9;
  line-height: 0;
}

/* Specificity bump: .campaign-orbital-cam also carries .planet-surface for
   the star-tint overlays, so without the parent class here `.planet-surface img`
   (width:100%; height:auto) would win and leave a black gap under the image. */
.campaign-orbital-cam .campaign-orbital-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-mask-image: none;
  mask-image: none;
}

.campaign-orbital-cam .campaign-orbital-img-fade {
  opacity: 1;
  transition: opacity 1s ease-out;
  z-index: 2;
}

.campaign-orbital-cam .campaign-orbital-img-fade.campaign-orbital-img-fade-out {
  opacity: 0;
}

.campaign-orbital-cam .surface-hud {
  z-index: 3;
}

@media (max-width: 640px) {
  .campaign-orbital-cam {
    aspect-ratio: 16 / 9;
    border-width: 5px;
  }
}

@media (max-width: 640px) {
  .campaign-mission-top {
    flex-direction: row;
    align-items: flex-start;
    gap: 10px;
  }
  .campaign-mission-card-col {
    width: calc(50% - 5px);
    flex: 0 0 calc(50% - 5px);
  }
  .campaign-mission-cost-col {
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }
  .campaign-mission-cost-col > .resource-card {
    padding: 6px 8px 5px;
  }
  .campaign-mission-cost-col > .resource-card .res-label {
    font-size: 0.65rem;
  }
  .campaign-mission-cost-col > .resource-card .res-amount {
    font-size: 1rem;
  }
  .campaign-mission-cost-col > .resource-card .res-rate {
    font-size: 0.6rem;
  }
  .campaign-mission-btn {
    padding: 10px 12px;
    font-size: 0.78rem;
  }
}

/* Completed missions list (compact strip) */
.campaign-completed-list {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.campaign-completed-header {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.4);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.campaign-completed-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: 9px;
  background: rgba(68, 255, 136, 0.12);
  color: #44ff88;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
}

/* --- Colony hover preview (orbital feed thumbnail) --- */
.kc-d3-colony-preview {
  position: fixed;
  width: 360px;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 1200;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.6));
}
.kc-d3-colony-preview.is-visible {
  opacity: 1;
  transform: translateX(0);
}
.kc-d3-colony-preview-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 6px;
  background: #050912;
  border: 1px solid rgba(0, 255, 200, 0.18);
}
.kc-d3-colony-preview-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 30%;
  display: block;
}
.kc-d3-colony-preview-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0px, transparent 2px, rgba(0,0,0,0.08) 2px, rgba(0,0,0,0.08) 4px),
    radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
}
.kc-d3-colony-preview-cam,
.kc-d3-colony-preview-coords,
.kc-d3-colony-preview-rec {
  position: absolute;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: rgba(0, 255, 200, 0.78);
  text-shadow: 0 0 4px rgba(0, 255, 200, 0.3);
  pointer-events: none;
}
.kc-d3-colony-preview-cam {
  bottom: 8px;
  left: 10px;
}
.kc-d3-colony-preview-coords {
  bottom: 8px;
  right: 10px;
}
.kc-d3-colony-preview-rec {
  top: 8px;
  right: 10px;
  display: flex;
  align-items: center;
  gap: 5px;
  font-weight: 700;
  color: rgba(255, 60, 60, 0.85);
  text-shadow: 0 0 6px rgba(255, 60, 60, 0.4);
}
.kc-d3-colony-preview-rec::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 60, 60, 0.85);
  box-shadow: 0 0 6px rgba(255, 60, 60, 0.6);
  animation: kcD3RecBlink 1.4s infinite;
}
@keyframes kcD3RecBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* P5b: the sticky compact bar is a console readout, not photo cards.
   Flat dark plate, resource-coloured icon, mono number, storage fill
   shown as a luminance tint across the plate (length = how full). */
.resource-compact .resource-card {
  background-image: none;
  background-color: rgba(8, 14, 28, 0.92);
  /* Readout plates stay instrument-sized on wide monitors instead of
     stretching with the column (empty plate + full-width storage line). */
  max-width: 260px;
}
.resource-compact .resource-card::before {
  background: linear-gradient(90deg,
    rgba(var(--res-glow-rgb, 255, 255, 255), 0.16) 0%,
    rgba(var(--res-glow-rgb, 255, 255, 255), 0.10) var(--fill-pct, 0%),
    transparent var(--fill-pct, 0%));
}
.resource-compact .resource-card .res-label .res-inline-icon {
  color: rgb(var(--res-glow-rgb, 255, 255, 255));
}
.resource-compact .resource-card .res-amount,
.resource-compact .resource-card .res-pct {
  background: none;
  padding-left: 0;
}

/* P5b: the energy/q-bits combined box joins the readout styling
   (same flat plate, no photo rows, instrument width). */
.resource-compact .res-combined-box {
  max-width: 260px;
  background: rgba(8, 14, 28, 0.92);
  border-color: rgba(80, 95, 110, 0.35);
}
.resource-compact .res-combined-row[data-resource="energy"],
.resource-compact .res-combined-row[data-resource="qbits"] {
  background-image: none;
}
.resource-compact .res-combined-row .res-amount {
  background: none;
}

/* Construction work shift offer: a framed pill on the colony row, set apart
   from the paid rush button by its dashed frame and wrench glyph so the free
   option is never mistaken for the one that charges credits. */
.task-btn-shift {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  padding: 5px 11px;
  border: 1px dashed rgba(var(--accent-rgb), 0.7);
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.task-btn-shift svg { width: 14px; height: 14px; flex: 0 0 auto; }
.task-btn-shift b { font-family: var(--font-mono); font-weight: 700; }
.task-btn-shift:hover { background: rgba(var(--accent-rgb), 0.2); border-style: solid; }
