:root {
  --page-bg: #0c0d10;
  --page-bg-accent: rgba(115, 140, 196, 0.14);
  --panel: rgba(15, 18, 24, 0.92);
  --panel-strong: rgba(10, 13, 18, 0.96);
  --panel-soft: rgba(255, 255, 255, 0.04);
  --ink: #eef2f7;
  --muted: #9ca6b7;
  --line: rgba(154, 163, 184, 0.16);
  --line-strong: rgba(154, 163, 184, 0.28);
  --accent: #c7d2fe;
  --accent-strong: #e2e8ff;
  --accent-soft: rgba(199, 210, 254, 0.16);
  --success: #b0e8c4;
  --danger: #f3b5b0;
  --shadow: 0 22px 58px rgba(0, 0, 0, 0.36);
  --radius: 0.35rem;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --serif: Iowan Old Style, Palatino Linotype, Book Antiqua, Georgia, Times New Roman, serif;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  font-family: var(--serif);
  background:
    radial-gradient(circle at top left, var(--page-bg-accent), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 22%),
    var(--page-bg);
}

a {
  color: inherit;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

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

.wrap {
  min-height: 100vh;
  padding: 18px 18px 54px;
}

.skip-link {
  position: absolute;
  left: -9999px;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
  background: var(--panel-strong);
  padding: 0.7rem 0.9rem;
  border-radius: 0.3rem;
  z-index: 20;
}

.site-header {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding-top: 3.2rem;
}

.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  background: linear-gradient(180deg, rgba(12, 13, 15, 0.96), rgba(12, 13, 15, 0.9));
  border-bottom: 2px solid var(--line);
  backdrop-filter: saturate(120%) blur(6px);
}

.topbar-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.65rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--accent);
  text-decoration: none;
}

.brand:hover,
.brand:focus-visible {
  color: var(--accent-strong);
}

.ecosystem-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.ecosystem-nav a,
.ecosystem-nav .active,
.fcc-econav-more > summary {
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1;
  padding: 0.35rem 0.45rem;
  border-radius: 0.2rem;
  border: 2px solid transparent;
}

.ecosystem-nav a,
.fcc-econav-more > summary {
  color: var(--muted);
  text-decoration: none;
}

.ecosystem-nav a:hover,
.ecosystem-nav a:focus-visible,
.fcc-econav-more > summary:hover,
.fcc-econav-more > summary:focus-visible {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.ecosystem-nav .active {
  color: #eafff1;
  border-color: rgba(145, 220, 173, 0.52);
  background: linear-gradient(180deg, rgba(31, 129, 74, 0.32), rgba(16, 72, 40, 0.4));
}

.fcc-econav-more {
  position: relative;
}

.fcc-econav-more > summary {
  list-style: none;
  cursor: pointer;
}

.fcc-econav-more > summary::-webkit-details-marker {
  display: none;
}

.fcc-econav-more-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 10rem;
  display: none;
  flex-direction: column;
  gap: 0.32rem;
  padding: 0.55rem;
  border-radius: 0.3rem;
  border: 2px solid var(--line-strong);
  background: rgba(8, 10, 14, 0.98);
  box-shadow: 0 18px 34px rgba(0, 0, 0, 0.45);
}

.fcc-econav-more[open] .fcc-econav-more-menu {
  display: flex;
}

.fcc-econav-more-menu span,
.fcc-econav-more-menu a {
  padding: 0.38rem 0.45rem;
  border-radius: 0.2rem;
  font-family: var(--mono);
  font-size: 0.84rem;
  text-decoration: none;
}

.fcc-econav-more-menu span {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}

.shell {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1.4rem 0 0;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.8fr);
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}

.hero-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 0.42rem;
  color: var(--muted);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.75rem, 6vw, 4.9rem);
  line-height: 0.93;
  letter-spacing: -0.03em;
}

.hero-text,
.hero-summary {
  margin: 0.9rem 0 0;
  max-width: 38rem;
  color: var(--muted);
  line-height: 1.62;
  font-size: 1.03rem;
}

.hero-summary strong {
  color: var(--ink);
  font-weight: 700;
}

.card {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 26%),
    var(--panel);
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 1rem;
  display: grid;
  gap: 0.8rem;
}

.hero-panel-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1rem;
  align-items: start;
}

.game-surface-card,
.sidebar-card,
.instructions-card {
  overflow: hidden;
}

.game-surface-header,
.panel-section {
  padding: 1rem 1rem 0;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 0.85rem;
}

.panel-section {
  flex-direction: column;
  align-items: stretch;
}

.panel-heading,
.game-surface-header h2 {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.2;
}

.panel-copy,
.game-surface-copy {
  margin: 0.3rem 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.state-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.24rem 0.7rem;
  border-radius: 999px;
  border: 2px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.state-pill.is-good {
  color: #ecfff3;
  border-color: rgba(145, 220, 173, 0.55);
  background: rgba(33, 101, 63, 0.32);
}

.state-pill.is-warn {
  color: #fff7da;
  border-color: rgba(222, 187, 98, 0.52);
  background: rgba(99, 74, 27, 0.34);
}

.state-pill.is-danger {
  color: #fff0ee;
  border-color: rgba(226, 143, 136, 0.5);
  background: rgba(112, 39, 34, 0.35);
}

.canvas-shell {
  padding: 1rem;
  display: grid;
  gap: 0.85rem;
}

.canvas-frame {
  position: relative;
  overflow: hidden;
  border-radius: calc(var(--radius) - 0.05rem);
  border: 2px solid rgba(255, 255, 255, 0.08);
  background: var(--panel-strong);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
}

.canvas-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-grid {
  padding: 1rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem;
}

.stat {
  min-height: 5rem;
  padding: 0.68rem 0.72rem;
  border-radius: 0.35rem;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.stat-value {
  display: block;
  margin-top: 0.26rem;
  font-size: 1.38rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-meta {
  display: block;
  margin-top: 0.28rem;
  color: var(--muted);
  font-size: 0.83rem;
}

.button-stack,
.button-row,
.tool-cluster {
  display: grid;
  gap: 0.6rem;
}

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

button,
.button-link {
  min-height: 2.8rem;
  border-radius: 0.35rem;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: #11141b;
  cursor: pointer;
  padding: 0.6rem 0.85rem;
  transition: transform 140ms ease, background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button:hover:not(:disabled),
.button-link:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

button:active:not(:disabled),
.button-link:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

button.ghost,
.button-link.ghost {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
}

button.ghost:hover:not(:disabled),
.button-link.ghost:hover {
  border-color: var(--accent);
  background: rgba(199, 210, 254, 0.08);
  color: var(--accent-strong);
}

button.toggle-on {
  border-color: rgba(145, 220, 173, 0.52);
  background: rgba(33, 101, 63, 0.32);
  color: #edfdf2;
}

button.toggle-off {
  border-color: rgba(226, 143, 136, 0.5);
  background: rgba(112, 39, 34, 0.24);
  color: #fff1ef;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.instructions-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.instructions-card {
  padding: 1rem;
}

.instruction-list {
  margin: 0.85rem 0 0;
  padding-left: 1.1rem;
  color: var(--muted);
  line-height: 1.7;
}

.instruction-list strong {
  color: var(--ink);
}

.footer-note {
  margin: 1rem 0 0;
  padding: 0.95rem 1rem;
  color: var(--muted);
  text-align: center;
}

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

@media (max-width: 980px) {
  .hero,
  .game-layout,
  .instructions-grid {
    grid-template-columns: 1fr;
  }

  .game-layout {
    gap: 0.9rem;
  }

  .sidebar-card {
    order: 2;
  }
}

@media (max-width: 720px) {
  .wrap {
    padding-inline: 14px;
    padding-bottom: 28px;
  }

  .topbar-content {
    padding-inline: 0.95rem;
    align-items: flex-start;
  }

  .brand {
    font-size: 1.18rem;
  }

  .shell {
    padding-top: 1rem;
  }

  .hero h1 {
    font-size: clamp(2.35rem, 10vw, 3.4rem);
  }

  .status-grid,
  .button-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .topbar-content {
    flex-direction: column;
  }

  .ecosystem-nav {
    justify-content: flex-start;
  }

  .status-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

  .canvas-shell,
  .status-grid,
  .hero-panel,
  .instructions-card {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
  }
}
