:root {
  --bg-0: #07131b;
  --bg-1: #0e2330;
  --bg-2: #173a49;
  --ink: #e9f0e8;
  --muted: #96b7b7;
  --line: rgba(196, 230, 223, 0.12);
  --panel: rgba(8, 22, 30, 0.78);
  --panel-strong: rgba(9, 27, 37, 0.9);
  --dew: #72f1d4;
  --rumor: #ffc66d;
  --residue: #a6f28e;
  --memory: #ff927c;
  --wave-silence: #9bbaff;
  --wave-blight: #8fef7d;
  --wave-mirror: #d6e1ff;
  --wave-drought: #ff9a63;
  --wave-shear: #ff6480;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  --radius: 22px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Trebuchet MS", "Gill Sans", "Avenir Next", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(118, 241, 212, 0.08), transparent 28%),
    radial-gradient(circle at top right, rgba(255, 198, 109, 0.08), transparent 26%),
    radial-gradient(circle at bottom center, rgba(143, 239, 125, 0.07), transparent 30%),
    linear-gradient(155deg, var(--bg-0), var(--bg-1) 50%, var(--bg-2));
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    radial-gradient(circle at 70% 65%, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    radial-gradient(circle at 55% 15%, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 220px 220px, 280px 280px, 180px 180px;
  mix-blend-mode: screen;
}

.app-shell {
  width: min(1520px, calc(100% - 24px));
  margin: 0 auto;
  padding: 16px 0 28px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(240px, 1.1fr) minmax(360px, 1.3fr) auto;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.brand-block,
.status-strip,
.action-strip,
.panel,
.board-frame {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(16, 39, 49, 0.85), rgba(9, 21, 29, 0.86));
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.brand-block,
.status-strip,
.action-strip,
.panel {
  border-radius: var(--radius);
}

.brand-block {
  padding: 18px 20px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand-block h1 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: clamp(2rem, 2.5vw, 3.25rem);
  line-height: 0.96;
}

.tagline {
  margin: 10px 0 0;
  max-width: 36ch;
  color: var(--muted);
}

.status-strip {
  padding: 14px 16px;
  display: grid;
  gap: 14px;
}

.phase-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px 16px;
  align-items: center;
}

.phase-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(115, 184, 255, 0.12);
  color: #bbd5ff;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.phase-card strong {
  font-size: 1rem;
}

.phase-meter {
  grid-column: 1 / -1;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.phase-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--dew), var(--rumor));
  box-shadow: 0 0 20px rgba(114, 241, 212, 0.35);
  transition: width 120ms linear;
}

.phase-timer {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.resource-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.resource-card {
  padding: 10px 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 2px;
}

.resource-card span {
  color: var(--muted);
  font-size: 0.8rem;
}

.resource-card strong {
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.resource-card.dew strong {
  color: var(--dew);
}

.resource-card.rumor strong {
  color: var(--rumor);
}

.resource-card.residue strong {
  color: var(--residue);
}

.resource-card.memory strong {
  color: var(--memory);
}

.action-strip {
  padding: 14px;
  display: grid;
  gap: 10px;
  align-content: center;
  min-width: 188px;
}

.action-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  padding: 12px 14px;
  font: inherit;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.action-button:hover,
.action-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(114, 241, 212, 0.4);
  background: rgba(114, 241, 212, 0.09);
  outline: none;
}

.action-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.action-button.accent {
  background: linear-gradient(120deg, rgba(255, 146, 124, 0.2), rgba(114, 241, 212, 0.14));
}

.action-button.subtle {
  color: var(--muted);
}

.main-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(340px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.board-panel {
  min-width: 0;
}

.board-frame {
  position: relative;
  padding: 12px;
  border-radius: 30px;
  min-height: clamp(440px, 76vh, 980px);
  overflow: hidden;
}

.board-frame::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 45%, rgba(114, 241, 212, 0.08), transparent 34%),
    radial-gradient(circle at 50% 55%, rgba(255, 198, 109, 0.05), transparent 40%);
  opacity: 0.8;
  pointer-events: none;
}

#boardCanvas {
  width: 100%;
  height: 100%;
  min-height: clamp(420px, 74vh, 940px);
  display: block;
  border-radius: 22px;
  touch-action: none;
}

.board-overlay {
  position: absolute;
  inset: 12px;
  pointer-events: none;
}

.hint-pill {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(8, 20, 28, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  transition: opacity 220ms ease;
}

.toast-stack {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  gap: 10px;
  width: min(340px, 40vw);
}

.toast {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(9, 22, 29, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  transform: translateY(0);
  opacity: 1;
  transition:
    opacity 260ms ease,
    transform 260ms ease;
}

.toast.leaving {
  opacity: 0;
  transform: translateY(-6px);
}

.toast strong {
  display: block;
  margin-bottom: 4px;
}

.side-panel {
  display: grid;
  gap: 16px;
}

.panel {
  padding: 14px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 12px;
}

.panel-heading h2 {
  margin: 0;
  font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-size: 1.2rem;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

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

.piece-card {
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  display: grid;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.piece-card:hover,
.piece-card:focus-visible,
.piece-card.selected {
  transform: translateY(-1px);
  border-color: rgba(114, 241, 212, 0.44);
  background: rgba(114, 241, 212, 0.09);
  outline: none;
}

.piece-card.locked {
  opacity: 0.45;
  cursor: default;
}

.piece-card .piece-name {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  font-weight: 700;
}

.piece-swatch {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  box-shadow: 0 0 18px currentColor;
}

.piece-card .piece-role,
.piece-card .piece-cost {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.forecast-list,
.discoveries-list,
.legacy-list,
.objective-content {
  display: grid;
  gap: 10px;
}

.forecast-card,
.discovery-card,
.legacy-card,
.inspect-card,
.empty-state {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
}

.inspect-card.completed {
  border-color: rgba(114, 241, 212, 0.32);
  background: rgba(114, 241, 212, 0.08);
}

.forecast-card.active {
  border-color: rgba(255, 198, 109, 0.35);
  background: rgba(255, 198, 109, 0.08);
}

.forecast-top,
.inspect-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.forecast-top strong,
.inspect-top strong {
  font-size: 0.96rem;
}

.forecast-meta,
.discovery-card p,
.legacy-card p,
.inspect-card p,
.empty-state {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.wave-badge,
.inspect-badge {
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
}

.inspect-content {
  display: grid;
  gap: 10px;
}

.inspect-stats,
.inspect-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.inspect-chip {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 0.76rem;
}

.legacy-card button {
  margin-top: 10px;
  width: 100%;
}

.mutation-choice {
  border-color: rgba(255, 124, 184, 0.24);
  background: linear-gradient(180deg, rgba(255, 124, 184, 0.09), rgba(124, 224, 255, 0.07));
}

.objective-card {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  padding: 12px;
}

.objective-kicker {
  color: var(--muted);
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.objective-card strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 4px;
}

.objective-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

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

.objective-metric {
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  padding: 10px;
}

.objective-metric span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  margin-bottom: 4px;
}

.objective-metric strong {
  font-size: 0.96rem;
}

.empty-state {
  text-align: center;
}

@media (max-width: 1160px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .action-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .main-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100%, calc(100% - 12px));
    padding-top: 10px;
  }

  .status-strip .resource-strip,
  .action-strip,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .board-frame {
    padding: 8px;
    min-height: 54vh;
  }

  #boardCanvas {
    min-height: 54vh;
  }

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

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

  .hint-pill {
    font-size: 0.8rem;
    right: 12px;
    left: 12px;
    text-align: center;
  }

  .toast-stack {
    width: calc(100% - 24px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
