/* Core theme */
:root {
  --bg: #000;
  --fg: #e0e0e0;
  --muted: #9aa0aa;
  --accent: #00ffff;
  --accent-soft: rgba(0, 255, 255, 0.15);
  --rail: #111;
  --rail-border: #333;
  --card: #05060a;
  --card-border: #222;
  --danger: #ff4f4f;
  --success: #7bff7b;
  --shadow-soft: 0 0 30px rgba(0, 255, 255, 0.15);
  --radius-lg: 14px;
  --radius-sm: 8px;
  --transition-fast: 0.15s ease-out;
  --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #050815 0, #000 40%, #000 100%);
  color: var(--fg);
  font-family: var(--font-main);
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

header {
  padding: 16px 6vw 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

header .title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

header h1 {
  font-size: 1.4rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 0;
}

header p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.planner-select {
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.75);
  color: var(--fg);
  padding: 6px 12px;
  font-size: 0.85rem;
  min-width: 120px;
  outline: none;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast), background var(--transition-fast);
}

.planner-select:focus {
  border-color: rgba(0, 255, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.9);
}

.nav-link {
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: rgba(0, 0, 0, 0.6);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
}

.nav-link span {
  font-size: 0.9rem;
}

main {
  padding: 0 6vw 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto 16px;
  position: relative;
}

/* Day rail */
.day-rail {
  margin: 4px 0 20px;
  padding: 10px 0 12px;
}

.rail-label {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 6px;
  column-gap: 8px;
}

.rail-label .rail-left {
  text-align: left;
}

.rail-label .rail-center {
  text-align: center;
}

.rail-label .rail-right {
  text-align: right;
}

.rail-track {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: var(--rail);
  border: 1px solid var(--rail-border);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
}

.rail-percent {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 0 6px rgba(0, 255, 255, 0.15);
}

.rail-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(0, 255, 255, 0.2),
    rgba(0, 255, 255, 0.9),
    rgba(0, 255, 255, 0.2)
  );
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.4s ease-out;
}

.rail-marker {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 22px;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.9);
  transform: translate(-50%, -50%);
}

.rail-meta {
  margin-top: 4px;
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
}

.reset-strip {
  padding: 6px 6vw 0;
  display: flex;
  justify-content: flex-end;
}

.reset-main-wrapper {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
}
.reset-strip .reset-main-wrapper {
  margin-top: 0;
}

.reset-main-button {
  padding: 8px 18px;
  border-radius: 999px;
  border: 1px solid rgba(0, 255, 255, 0.35);
  background: rgba(0, 15, 25, 0.75);
  color: var(--accent);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.12);
  transition: color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease,
    transform 0.12s ease;
}

.reset-main-button:hover {
  border-color: rgba(0, 255, 255, 0.55);
  color: #fff;
  box-shadow: 0 0 16px rgba(0, 255, 255, 0.25);
  transform: translateY(-1px);
}

.reset-main-button.game-over-ready {
  border-color: rgba(255, 79, 79, 0.8);
  color: var(--danger);
  box-shadow: 0 0 18px rgba(255, 79, 79, 0.35);
  background: rgba(40, 0, 0, 0.55);
}

/* Layout */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 18px;
}

/* Locked tier visual treatment */
.tier-locked {
  filter: blur(2px) brightness(0.5);
  opacity: 0.4;
  position: relative;
}

.tier-locked::after {
  content: "LOCKED";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.6);
}

/* Machine lock styling */
.machine-pill.locked {
  filter: blur(2px);
  opacity: 0.35;
}

.machine-pill.locked-machine {
  filter: blur(1.4px) brightness(0.5);
  opacity: 0.6;
  position: relative;
}

.machine-pill.locked-machine::after {
  content: "Locked";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(0, 0, 0, 0.55);
  border-radius: inherit;
  border: 1px dashed rgba(0, 255, 255, 0.35);
}

.machine-pill.unlocked-machine {
  filter: none;
  opacity: 1;
}

.machine-pill.unlocked {
  filter: none;
  opacity: 1;
}

.machine-tag.unlocked {
  border-color: rgba(0, 255, 255, 0.7);
  color: var(--muted); /* keeps text calm instead of bright cyan */
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.card {
  background: linear-gradient(145deg, #05060a 0, #050816 60%, #05060a 100%);
  border-radius: var(--radius-lg);
  padding: 14px 16px 16px;
  border: 1px solid var(--card-border);
  box-shadow: 0 0 18px rgba(0, 0, 0, 0.7);
}
/* Shared card header row */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.log-panel {
  margin-top: 14px;
}

.log-panel-title {
  margin: 0 0 6px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.card h2 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin: 0 0 10px;
}

.card small {
  font-size: 0.75rem;
  color: var(--muted);
}

.status-panel {
  margin: 10px 0 6px;
  padding: 8px 14px;
  border: 1px solid rgba(0, 255, 255, 0.25);
  border-radius: 999px;
  background: rgba(5, 10, 20, 0.65);
  min-height: 36px;
  display: flex;
  flex-direction: row;
  align-items: center;
  font-size: 0.78rem;
  overflow: hidden;
}

.status-panel span {
  display: block;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-panel.status-neutral {
  color: var(--muted);
}

.status-panel.status-anomaly {
  border-color: rgba(0, 255, 255, 0.6);
  color: var(--accent);
  background: rgba(0, 30, 40, 0.6);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.2);
}

.status-panel.status-corruption-danger {
  border-color: rgba(255, 93, 255, 0.65);
  color: #ff5dff;
  background: rgba(40, 0, 40, 0.55);
  box-shadow: 0 0 14px rgba(255, 93, 255, 0.35);
}

.status-panel.status-corruption-stable {
  border-color: rgba(35, 241, 255, 0.5);
  color: #23f1ff;
  background: rgba(5, 35, 35, 0.55);
  box-shadow: 0 0 12px rgba(35, 241, 255, 0.25);
}

.status-panel.status-gameover {
  border-color: rgba(255, 99, 99, 0.7);
  color: #ff9c9c;
  background: rgba(40, 10, 10, 0.65);
  box-shadow: 0 0 14px rgba(255, 90, 90, 0.35);
}

.core-status-message {
  margin: 0;
  font-size: 0.78rem;
  color: var(--accent);
  letter-spacing: 0.02em;
  text-shadow: 0 0 8px rgba(0, 255, 255, 0.35);
  display: block;
}

.core-status-message.anomaly-active {
  color: #a0f2ff;
  animation: anomalyPulse 1.4s ease-in-out infinite;
}

.core-status-message.anomaly-resolved {
  color: var(--muted);
  text-shadow: none;
}

@keyframes anomalyPulse {
  0% {
    opacity: 0.55;
    transform: translateY(0);
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.35);
  }
  50% {
    opacity: 1;
    transform: translateY(-1px);
    text-shadow: 0 0 12px rgba(0, 255, 255, 0.6);
  }
  100% {
    opacity: 0.55;
    transform: translateY(0);
    text-shadow: 0 0 6px rgba(0, 255, 255, 0.35);
  }
}

.dev-panel {
  position: absolute;
  top: 150px;
  left: max(12px, calc(6vw - 260px));
  width: 230px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(0, 255, 255, 0.4);
  background: rgba(5, 10, 20, 0.85);
  box-shadow: 0 0 14px rgba(0, 255, 255, 0.25);
  font-size: 0.72rem;
  font-family: "Fira Code", "Consolas", monospace;
  color: rgba(255, 255, 255, 0.8);
  z-index: 5;
  display: block;
}

.dev-box {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 255, 255, 0.3);
  background: rgba(5, 10, 18, 0.7);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.15);
  padding: 10px 12px;
  margin-top: 12px;
  max-height: 220px;
  overflow: auto;
  font-family: "Fira Code", "Consolas", monospace;
  font-size: 0.76rem;
  color: #b8d4dd;
}

.dev-box.hidden {
  display: none;
}

.dev-box-header {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: #63e6ff;
  margin-bottom: 6px;
}

.dev-box-body {
  white-space: pre-wrap;
  line-height: 1.4;
}

.dev-panel.dev-hidden {
  display: none;
}

.dev-panel-header {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.68rem;
  color: var(--accent);
  border-bottom: 1px solid rgba(0, 255, 255, 0.35);
  padding-bottom: 4px;
}

.dev-panel pre {
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.3;
}

@media (max-width: 900px) {
  .dev-panel {
    position: static;
    width: 100%;
    margin-bottom: 12px;
  }
}
/* ============================
   Tier Hint – Forge System Tips
   ============================ */

.tier-hints {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(0, 20, 30, 0.25); /* subtle cyan-black tint */
  border: 1px solid rgba(0, 255, 255, 0.12);
  box-shadow: inset 0 0 14px rgba(0, 255, 255, 0.15);
}

.tier-hints p {
  font-family: var(--font-main);
  font-size: 0.78rem;
  color: var(--muted);
  margin: 6px 0;
  padding-left: 8px;
  border-left: 2px solid rgba(0, 255, 255, 0.35);
  line-height: 1.45;
  letter-spacing: 0.02em;
}

/* Resource pills */
.resources {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 12px;
}

@media (max-width: 800px) {
  .resources {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.res-pill {
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  padding: 8px 9px;
  background: radial-gradient(circle at top left, #0a1018, #05060a);
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
}
.res-pill.corruption-hot {
  border-color: rgba(255, 93, 255, 0.8);
  box-shadow: 0 0 12px rgba(255, 93, 255, 0.5),
    0 0 22px rgba(255, 40, 120, 0.45);
}
.res-pill.corruption-hot::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  pointer-events: none;
  background: radial-gradient(
    circle at top,
    rgba(255, 93, 255, 0.18),
    transparent 60%
  );
  opacity: 0;
  animation: corruptionSizzle 1.8s ease-in-out infinite;
  mix-blend-mode: screen;
}

.res-pill.celebrate {
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.7);
  border-color: rgba(0, 255, 255, 0.9);
}

/* Locked resource tiers (blur/overlay until unlocked) */
.res-pill.tier-locked {
  filter: blur(2px);
  opacity: 0.35;
  position: relative;
  pointer-events: none;
}

.res-pill.tier-locked::after {
  content: "LOCKED";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #d0d0d0;
  background: rgba(0, 0, 0, 0.72);
  border-radius: inherit;
  pointer-events: none;
}

.res-pill.tier-locked.unlock-interactive {
  pointer-events: auto;
}

.res-pill.tier-locked.unlock-interactive::after {
  background: rgba(0, 0, 0, 0.55);
  color: #a6b1c5;
}

.res-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--muted);
}

.res-label span.key {
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.res-label span.badge {
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid rgba(0, 255, 255, 0.4);
  color: var(--accent);
  font-size: 0.7rem;
}

.res-value {
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
}

.res-value strong {
  color: var(--accent);
}

.res-rate {
  font-size: 0.7rem;
  color: var(--muted);
}

.res-storage-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  font-size: 0.7rem;
}

.res-storage-tier {
  color: var(--muted);
  flex: 1;
}

.res-storage-upgrade {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  font-size: 0.7rem;
  border-color: rgba(0, 255, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.15);
}

.res-unlock {
  margin-top: 4px;
}

.res-unlock button {
  width: 100%;
}

.resource-bar {
  margin-top: auto;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
  display: flex;
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.35);
  flex: 0 0 auto;
}

.resource-bar-safe,
.resource-bar-corrupt {
  height: 100%;
  width: 0%;
  transition: width 0.18s ease;
}

.resource-bar-safe {
  background: linear-gradient(
    90deg,
    rgba(123, 255, 123, 0.35),
    rgba(123, 255, 123, 0.85)
  );
}

.resource-bar-corrupt {
  background: linear-gradient(
    90deg,
    rgba(255, 79, 79, 0.45),
    rgba(255, 79, 79, 0.9)
  );
}

@keyframes corruptionSizzle {
  0% {
    opacity: 0.15;
    transform: scale(0.98);
    filter: blur(0px);
  }
  50% {
    opacity: 0.45;
    transform: scale(1.02);
    filter: blur(1px);
  }
  100% {
    opacity: 0.15;
    transform: scale(0.98);
    filter: blur(0px);
  }
}

#toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 320px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0, 255, 255, 0.4);
  background: rgba(5, 10, 20, 0.94);
  box-shadow: 0 0 14px rgba(0, 255, 255, 0.25), 0 0 24px rgba(0, 0, 0, 0.8);
  font-size: 0.78rem;
  color: var(--fg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-6px);
  animation: toastIn 0.2s ease-out forwards;
}

.toast-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
}

.toast-body {
  font-size: 0.76rem;
  color: var(--muted);
}

.toast-storage {
  border-color: rgba(123, 255, 123, 0.6);
  box-shadow: 0 0 16px rgba(123, 255, 123, 0.35), 0 0 24px rgba(0, 0, 0, 0.85);
}

@keyframes toastIn {
  0% {
    opacity: 0;
    transform: translateY(-6px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast.toast-out {
  animation: toastOut 0.25s ease-in forwards;
}

@keyframes toastOut {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.seismo-subtitle {
  display: block;
  font-size: 0.74rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.seismo-card {
  transition: box-shadow 0.25s ease, border-color 0.25s ease;
}

.seismo-card.mode-high {
  border-color: rgba(0, 255, 255, 0.6);
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.4);
}

.seismo-card.mode-low {
  border-color: rgba(255, 200, 80, 0.7);
  box-shadow: 0 0 18px rgba(255, 200, 80, 0.35);
}

.seismo-card.mode-neutral {
  border-color: var(--card-border);
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.7);
}

.seismo-tag {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 255, 255, 0.4);
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.seismo-canvas-wrap {
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: radial-gradient(circle at top, #08101a, #040509);
  border: 1px solid rgba(0, 255, 255, 0.25);
  box-shadow: inset 0 0 16px rgba(0, 255, 255, 0.12);
  overflow: hidden;
}

#anomaly-seismograph {
  display: block;
  width: 100%;
  height: 80px;
}

.seismo-footer {
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.76rem;
  color: var(--muted);
}

.seismo-label {
  opacity: 0.9;
}

.seismo-value {
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

/* Actions & buttons */
.actions-block {
  margin-top: 4px;
  border-top: 1px dashed rgba(120, 130, 140, 0.5);
  padding-top: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.action-label {
  font-size: 0.75rem;
  color: var(--muted);
}

button {
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.6);
  color: var(--fg);
  padding: 6px 11px;
  font-size: 0.8rem;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast),
    box-shadow var(--transition-fast), opacity var(--transition-fast);
  white-space: nowrap;
}

button span.hotkey {
  opacity: 0.7;
  font-size: 0.7rem;
}

button.primary {
  border-color: rgba(0, 255, 255, 0.8);
  box-shadow: 0 0 14px rgba(0, 255, 255, 0.25);
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(90deg, #041f24, #062a32);
  transform: translateY(-1px);
}

button.secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

.forge-meta,
.epoch-meta,
.auto-meta {
  font-size: 0.72rem;
  color: var(--muted);
}

.forge-meta span.ready,
.epoch-meta span.ready {
  color: var(--success);
}

.anomaly-indicator {
  display: none;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 255, 255, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--accent);
  background: rgba(0, 20, 30, 0.25);
  box-shadow: inset 0 0 12px rgba(0, 255, 255, 0.12);
}

/* Corruption panel (compact, subtle) */
.corruption-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  width: 100%;
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  position: relative;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
#corruption-panel {
  display: none;
}
.corruption-panel.corruption-panel-active {
  background: rgba(0, 10, 15, 0.85);
  border: 1px solid rgba(0, 255, 255, 0.4);
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.25),
    0 0 14px rgba(0, 255, 255, 0.35);
}
.corruption-panel.corruption-panel-danger {
  --corruption-ring-inner-opacity: 0.25;
  --corruption-ring-outer-opacity: 0.15;
}
.corruption-panel.corruption-panel-danger::before,
.corruption-panel.corruption-panel-danger::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transform-origin: center;
}
.corruption-panel.corruption-panel-danger::before {
  border: 1px solid rgba(255, 93, 255, 0.6);
  box-shadow: 0 0 16px rgba(255, 93, 255, 0.5);
  opacity: var(--corruption-ring-inner-opacity, 0.2);
  animation: corruptionRingPulseInner 2.3s ease-in-out infinite;
}
.corruption-panel.corruption-panel-danger::after {
  inset: -9px;
  border: 1px solid rgba(255, 93, 255, 0.35);
  box-shadow: 0 0 24px rgba(255, 93, 255, 0.35);
  opacity: var(--corruption-ring-outer-opacity, 0.12);
  animation: corruptionRingPulseOuter 2.3s ease-in-out infinite;
}
@keyframes corruptionRingPulseInner {
  0% {
    opacity: 0;
    transform: scale(0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.96);
  }
}
@keyframes corruptionRingPulseOuter {
  0% {
    opacity: 0;
    transform: scale(0.92);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  100% {
    opacity: 0;
    transform: scale(0.92);
  }
}
.corruption-panel.corruption-panel-danger.corruption-severity-low {
  --corruption-ring-inner-opacity: 0.25;
  --corruption-ring-outer-opacity: 0.12;
}
.corruption-panel.corruption-panel-danger.corruption-severity-medium {
  --corruption-ring-inner-opacity: 0.45;
  --corruption-ring-outer-opacity: 0.25;
}
.corruption-panel.corruption-panel-danger.corruption-severity-high {
  --corruption-ring-inner-opacity: 0.7;
  --corruption-ring-outer-opacity: 0.4;
}
.corruption-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.72rem;
}
.corruption-rail {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  border: 1px solid rgba(0, 255, 255, 0.15);
  overflow: hidden;
}
.corruption-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(
    90deg,
    rgba(255, 160, 0, 0.12),
    rgba(255, 80, 80, 0.18)
  );
  box-shadow: 0 0 12px rgba(255, 120, 80, 0.18);
  transition: width 0.25s ease, background 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
}
.corruption-noise {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.55;
  mix-blend-mode: screen;
  pointer-events: none;
}
.corruption-percent {
  min-width: 36px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Severity bands */
.corruption-fill.corruption-low {
  background: linear-gradient(
    90deg,
    rgba(0, 255, 255, 0.18),
    rgba(0, 240, 255, 0.28)
  );
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.25);
}
.corruption-fill.corruption-medium {
  background: linear-gradient(
    90deg,
    rgba(255, 200, 80, 0.25),
    rgba(255, 140, 60, 0.32)
  );
  box-shadow: 0 0 18px rgba(255, 160, 60, 0.28);
}
.corruption-fill.corruption-high {
  background: linear-gradient(
    90deg,
    rgba(255, 90, 90, 0.32),
    rgba(255, 40, 40, 0.45)
  );
  box-shadow: 0 0 22px rgba(255, 60, 36, 0.35);
}

/* Log */
.smelt-log {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px dashed rgba(120, 130, 140, 0.5);
  font-size: 0.72rem;
  color: var(--muted);
  max-height: 260px;
  overflow-y: auto;
  overflow-x: hidden;
}

.smelt-log-line {
  opacity: 0.85;
}

.smelt-log-line + .smelt-log-line {
  margin-top: 2px;
}

.smelt-log-line span.highlight {
  color: var(--accent);
}

.smelt-log-line span.success {
  color: var(--success);
}
.smelt-log-line span.corruption-magenta {
  color: #ff5dff;
}
.smelt-log-line span.corrupt-up {
  color: #ff5dff;
  font-weight: 600;
}
.smelt-log-line span.corrupt-down {
  color: #23f1ff;
  font-weight: 600;
}

.smelt-log-line span.game-over {
  color: var(--danger);
  font-weight: 600;
}

.smelt-log-line span.danger {
  color: var(--danger);
}

.smelt-log-line span.crit {
  color: #ffd966;
}

/* Upgrades */
.upgrades-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.upgrade {
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  padding: 7px 9px;
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) auto;
  gap: 6px;
  background: radial-gradient(circle at top left, #070b10, #05060a);
}

.upgrade-header {
  font-size: 0.82rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.upgrade-header strong {
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.76rem;
  color: var(--accent);
}

.upgrade-header span.desc {
  color: var(--muted);
  font-size: 0.75rem;
}

.upgrade-meta {
  font-size: 0.7rem;
  color: var(--muted);
}

.upgrade-meta span.cost {
  color: var(--accent);
}

.upgrade-meta span.level {
  color: var(--success);
}

.upgrade-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

/* Machines */
.machine-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

@media (max-width: 700px) {
  .machine-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.machine-pill {
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  padding: 7px 9px;
  background: radial-gradient(circle at top left, #060812, #05060a);
  font-size: 0.78rem;
  position: relative;
}

/* Blur / hide machines until unlocked */
.machine-pill.locked {
  filter: blur(2px);
  opacity: 0.35;
  pointer-events: none;
}

.machine-pill.locked::after {
  content: "LOCKED";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #d0d0d0;
  background: rgba(0, 0, 0, 0.72);
  border-radius: inherit;
}

/* Tooltips for locked machines */
.machine-pill {
  position: relative; /* anchor tooltips to the pill */
}

.lock-tooltip {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translate(-50%, 8px);
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.9);
  border: 1px solid var(--card-border);
  font-size: 0.7rem;
  color: var(--muted);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast), transform var(--transition-fast);
  z-index: 5;
}

/* Only show on hover while locked */
.machine-pill.locked:hover .lock-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Once unlocked, hide tooltip entirely */
.machine-pill.unlocked .lock-tooltip {
  display: none;
}

.machine-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.machine-name {
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

/* Status-style tags */
.machine-tag {
  font-size: 0.7rem;
  border-radius: 999px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--muted);
}

.machine-tag.unlocked {
  color: var(--success);
  font-weight: 500;
}

.machine-tag.unlocked::before {
  content: "✔ ";
  color: var(--success);
}

.machine-tag.locked {
  color: #777;
}

/* Machine body */
.machine-body {
  display: flex;
  gap: 4px;
  align-items: baseline;
}

.machine-resource-label {
  color: var(--muted);
}

.machine-resource-value {
  color: var(--accent);
}

/* Footer */
footer {
  padding: 10px 6vw 14px;
  border-top: 1px solid #111;
  font-size: 0.75rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.save-status {
  font-size: 0.72rem;
  opacity: 0.8;
}

.save-status span {
  color: var(--accent);
}

.danger-link {
  color: var(--danger);
  cursor: pointer;
  text-decoration: underline;
}

.danger-link.game-over-ready {
  text-shadow: 0 0 8px rgba(255, 79, 79, 0.5);
}

/* Core action buttons: consistent cyan ring */
#btn-press,
#btn-forge,
#btn-epoch {
  position: relative;
  border-radius: 999px;
  box-sizing: border-box;
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.25),
    0 0 12px rgba(0, 255, 255, 0.45);
  transition: box-shadow 0.18s ease, transform 0.12s ease, opacity 0.12s ease;
}

/* Slight lift + stronger glow on hover when usable */
#btn-press:not(:disabled):hover,
#btn-forge:not(:disabled):hover,
#btn-epoch:not(:disabled):hover {
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.4), 0 0 18px rgba(0, 255, 255, 0.85);
  transform: translateY(-1px);
}

/* Subtle dim when disabled */
#btn-press:disabled,
#btn-forge:disabled,
#btn-epoch:disabled {
  opacity: 0.45;
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.18), 0 0 6px rgba(0, 255, 255, 0.25);
  transform: none;
}

/* Dust Reserve UI removed — related inputs and indicators deprecated */

/* ==========================================
   THE FORGE SCROLLBAR (dark + cyan glow)
   ========================================== */

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: #00c8ff #0b0f14;
}

/* Chrome, Edge, Safari */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: #0b0f14; /* same as UI background */
}

::-webkit-scrollbar-thumb {
  background: #003d52; /* dark cyan */
  border-radius: 4px;
  border: 1px solid #00c8ff; /* cyan outline */
}

::-webkit-scrollbar-thumb:hover {
  background: #00c8ff; /* cyan on hover */
  box-shadow: 0 0 6px #00c8ff; /* glow, matches buttons */
}

/* =====================================================
   REMOVE NUMBER INPUT SPINNER ARROWS (ALL BROWSERS)
   ===================================================== */

/* Chrome, Edge, Safari */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Firefox */
input[type="number"] {
  -moz-appearance: textfield;
}
/* Dust Reserve UI removed — related inputs and indicators deprecated */

@media (max-width: 600px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

.footer-center {
  text-align: center;
}

.footer-center .save-status {
  margin-bottom: 4px;
}

/* Footer override for centered layout */
footer {
  display: block !important;
  text-align: center !important;
  width: 100%;
}

.footer-actions {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* To Do: Task Quadrants layout & components */

.add-card {
  margin-bottom: 16px;
}

.add-card h2 {
  margin-bottom: 6px;
}

.add-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.add-form input[type="text"] {
  min-width: 160px;
  flex: 1 1 190px;
}

.add-form input,
.add-form select {
  border-radius: 999px;
  border: 1px solid var(--card-border);
  padding: 6px 10px;
  font-size: 0.85rem;
  background: rgba(0, 0, 0, 0.75);
  color: var(--fg);
  outline: none;
  transition: border-color var(--transition-fast),
    box-shadow var(--transition-fast), background var(--transition-fast);
}

.add-form input::placeholder {
  color: var(--muted);
}

.add-form input:focus,
.add-form select:focus {
  border-color: rgba(0, 255, 255, 0.8);
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.5);
  background: rgba(0, 0, 0, 0.9);
}

.btn-primary {
  border-radius: 999px;
  border: 1px solid rgba(0, 255, 255, 0.8);
  background: rgba(0, 0, 0, 0.8);
  color: #ffffff;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: background var(--transition-fast),
    transform var(--transition-fast), box-shadow var(--transition-fast),
    border-color var(--transition-fast), color var(--transition-fast);
  box-shadow: 0 0 14px rgba(0, 255, 255, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(90deg, #041f24, #062a32);
  transform: translateY(-1px);
  border-color: rgba(0, 255, 255, 1);
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.6);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.3);
}

.btn-ghost {
  border-color: var(--card-border);
  background: rgba(0, 0, 0, 0.6);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.6);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  border-color: rgba(0, 255, 255, 0.5);
  box-shadow: 0 0 12px rgba(0, 255, 255, 0.35);
}

.btn-compact {
  padding: 6px 12px;
  font-size: 0.78rem;
}

/* 4-quadrant grid */
.quadrant-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: minmax(260px, auto);
  gap: 18px;
  margin-top: 4px;
}

@media (max-width: 900px) {
  .quadrant-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-auto-rows: auto;
  }
}

.quadrant {
  padding: 12px 12px 10px;
  display: flex;
  flex-direction: column;
  min-height: 220px;
}

.quadrant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
  gap: 6px;
}

.quadrant-title {
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.quadrant-title span.count {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.75rem;
  margin-left: 6px;
}

.quadrant-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--muted);
}

.quadrant-controls label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.quadrant-controls input[type="checkbox"] {
  margin: 0;
  accent-color: var(--accent);
}

.quadrant-body {
  flex: 1;
  overflow-y: auto;
  padding-top: 4px;
  padding-bottom: 4px;
  margin-right: 2px;
}

/* Pinned vs date-sorted divider */
.section-divider {
  text-align: center;
  margin: 4px 0 6px;
  position: relative;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.section-divider::before,
.section-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: rgba(0, 255, 255, 0.2);
}

.section-divider::before {
  left: 0;
}

.section-divider::after {
  right: 0;
}

/* Task cards */

.task-card {
  background: radial-gradient(circle at top left, #070b10, #05060a);
  border-radius: var(--radius-sm);
  border: 1px solid var(--card-border);
  padding: 6px 8px 6px 8px;
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.7);
  transition: box-shadow var(--transition-fast),
    transform var(--transition-fast), border-color var(--transition-fast),
    background var(--transition-fast);
}

.task-card:hover {
  border-color: rgba(0, 255, 255, 0.4);
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.25);
  transform: translateY(-1px);
}

.task-card.completed {
  background: rgba(5, 5, 10, 0.7);
  border-style: dashed;
  border-color: rgba(154, 160, 170, 0.5);
  box-shadow: none;
}

.pinned-card {
  border-color: rgba(255, 93, 255, 0.75);
  box-shadow: 0 0 12px rgba(255, 93, 255, 0.35), 0 0 18px rgba(0, 0, 0, 0.6);
}

.pinned-card:hover {
  box-shadow: 0 0 16px rgba(255, 93, 255, 0.5), 0 0 22px rgba(0, 0, 0, 0.7);
}

.task-header {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.task-checkbox {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.task-checkbox input[type="checkbox"] {
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}

.task-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.task-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
}

.task-title {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-title.completed {
  text-decoration: line-through;
  color: var(--muted);
}

.task-badges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 55%;
}

.badge {
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.6);
}

.badge-date {
  border-color: rgba(154, 160, 170, 0.8);
  color: var(--muted);
}

.badge-overdue {
  border-color: rgba(255, 79, 79, 0.8);
  color: var(--danger);
  box-shadow: 0 0 8px rgba(255, 79, 79, 0.5);
}

.badge-today {
  border-color: rgba(255, 200, 80, 0.9);
  color: #ffd966;
}

.badge-soon {
  border-color: rgba(0, 200, 255, 0.8);
  color: var(--accent);
}

.task-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 2px;
}

.task-meta-row select {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.85);
  color: var(--fg);
  outline: none;
}

.task-meta-row select:focus {
  border-color: rgba(0, 255, 255, 0.7);
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.4);
}

.task-meta-row input[type="date"] {
  font-size: 0.75rem;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.85);
  color: var(--fg);
  outline: none;
}

.task-meta-row input[type="date"]:focus {
  border-color: rgba(0, 255, 255, 0.7);
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.4);
}

.task-meta-row input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
}

.task-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.icon-btn {
  border: 1px solid var(--card-border);
  background: rgba(0, 0, 0, 0.8);
  border-radius: 999px;
  padding: 2px 6px;
  font-size: 0.7rem;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  transition: background var(--transition-fast),
    border-color var(--transition-fast), transform var(--transition-fast),
    box-shadow var(--transition-fast), color var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(0, 255, 255, 0.7);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.35);
  transform: translateY(-0.5px);
}

.icon-btn:active {
  transform: translateY(0);
  box-shadow: none;
}

.icon-pin.active {
  background: rgba(0, 255, 255, 0.2);
  color: var(--accent);
  border-color: rgba(0, 255, 255, 0.8);
  box-shadow: 0 0 10px rgba(0, 255, 255, 0.4);
}

.task-card.completed .task-controls .icon-btn {
  opacity: 0.35;
  pointer-events: none;
}

.task-notes-toggle {
  font-size: 0.7rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  margin-left: 24px;
}

.task-notes {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(0, 255, 255, 0.2);
  margin-left: 24px;
}

.task-notes textarea {
  width: 100%;
  min-height: 40px;
  resize: vertical;
  font-size: 0.8rem;
  font-family: var(--font-main);
  border-radius: 6px;
  border: 1px solid var(--card-border);
  padding: 4px 6px;
  background: rgba(0, 0, 0, 0.8);
  color: var(--fg);
}

.task-notes textarea:focus {
  outline: none;
  border-color: rgba(0, 255, 255, 0.7);
  box-shadow: 0 0 0 1px rgba(0, 255, 255, 0.35);
}

.task-footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 2px;
  font-size: 0.7rem;
  color: var(--muted);
}

.task-footer-row .hint {
  font-style: italic;
}

.task-footer-row .stamp {
  font-variant-numeric: tabular-nums;
}

.task-delete-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 0;
  text-decoration: underline;
  margin-left: 4px;
}

.task-delete-btn:hover {
  color: var(--danger);
  text-shadow: 0 0 6px rgba(255, 79, 79, 0.5);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
