:root {
  color-scheme: light;
  --ink: #18212b;
  --muted: #5f6b76;
  --line: #d7dee3;
  --paper: #f7f6f1;
  --panel: #ffffff;
  --mint: #23a984;
  --blue: #2d67c8;
  --amber: #d89028;
  --red: #cb4b45;
  --violet: #6f5cc2;
  --shadow: 0 18px 55px rgba(24, 33, 43, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 4vw, 42px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(10px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--mint), var(--blue));
  font-size: 0.82rem;
  letter-spacing: 0;
}

.navlinks {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 0.94rem;
}

.navlinks a:hover {
  color: var(--ink);
}

.language {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.language button {
  border: 0;
  background: transparent;
  padding: 8px 11px;
  cursor: pointer;
  color: var(--muted);
}

.language button.active {
  background: var(--ink);
  color: #fff;
}

main {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto;
}

.hero {
  min-height: 320px;
  padding: 50px 0 30px;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 0.7fr);
  gap: 28px;
  align-items: end;
}

.eyebrow {
  color: var(--blue);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
}

h1 {
  margin: 10px 0 14px;
  max-width: 760px;
  font-size: clamp(2.1rem, 5vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.hero p:not(.eyebrow) {
  max-width: 720px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.6;
}

.hero-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.hero-stat {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.hero-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.hero-stat strong {
  display: block;
  margin-top: 8px;
  font-size: 1.8rem;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding-bottom: 40px;
}

.controls,
.game-area {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.controls {
  padding: 18px;
  position: sticky;
  top: 86px;
}

.controls h2 {
  margin: 0 0 16px;
  font-size: 1.15rem;
}

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

input[type="range"],
select {
  grid-column: 1 / -1;
  width: 100%;
}

select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
}

output {
  color: var(--ink);
  font-weight: 800;
}

.budget {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  background: #f4faf7;
}

.budget strong {
  color: var(--mint);
  font-size: 1.35rem;
}

.toolbox {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 14px 0;
}

.tool,
.primary,
.secondary,
.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.tool {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  padding: 8px;
}

.tool-icon {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #eef2f4;
  font-size: 0.78rem;
  font-weight: 900;
}

.tool.active {
  border-color: var(--blue);
  background: #eef5ff;
}

.primary {
  width: 100%;
  border: 0;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  margin-top: 6px;
}

.secondary {
  padding: 9px 12px;
}

.secondary:hover,
.tab:hover,
.tool:hover {
  border-color: #9aa7b1;
}

.game-area {
  min-height: 642px;
  overflow: hidden;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  padding: 8px 14px;
  white-space: nowrap;
}

.tab.active {
  background: var(--ink);
  color: #fff;
}

.view {
  display: none;
  padding: 16px;
}

.view.active {
  display: block;
}

.board-wrap {
  display: grid;
  gap: 12px;
}

#board {
  width: 100%;
  max-width: 850px;
  aspect-ratio: 3 / 2;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
  cursor: crosshair;
}

.legend {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.legend-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--muted);
  background: #fff;
  font-size: 0.9rem;
}

.legend-swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}

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

.metric {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}

.metric span {
  color: var(--muted);
  font-size: 0.88rem;
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 2rem;
}

.meter {
  height: 9px;
  border-radius: 999px;
  background: #e5ebef;
  overflow: hidden;
  margin-top: 12px;
}

.meter div {
  height: 100%;
  background: var(--mint);
}

.wave-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.wave {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfbf8;
}

.wave strong {
  display: block;
  margin-bottom: 8px;
}

.brief-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.brief-text {
  margin: 0;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfbf8;
  color: var(--ink);
  line-height: 1.55;
  min-height: 360px;
}

.event-log {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 20px;
}

.event-log li {
  border-bottom: 1px solid var(--line);
  padding: 0 0 9px;
  color: var(--muted);
}

footer {
  width: min(1180px, calc(100vw - 28px));
  margin: 0 auto 28px;
  color: var(--muted);
  font-size: 0.9rem;
}

.doc .doc-wrap {
  width: min(840px, calc(100vw - 28px));
  padding: 46px 0;
}

.doc-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: clamp(22px, 5vw, 42px);
  box-shadow: var(--shadow);
}

.doc-block h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
}

.doc-block h2 {
  margin-top: 28px;
}

.doc-block p {
  color: var(--muted);
  line-height: 1.7;
}

.hidden {
  display: none;
}

@media (max-width: 920px) {
  .topbar {
    flex-wrap: wrap;
  }

  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
  }

  .score-grid,
  .legend,
  .wave-strip {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 580px) {
  main,
  footer {
    width: min(100% - 18px, 1180px);
  }

  .navlinks {
    order: 3;
    width: 100%;
    justify-content: space-between;
  }

  .hero {
    padding-top: 28px;
  }

  .hero-panel,
  .score-grid,
  .legend,
  .wave-strip {
    grid-template-columns: 1fr;
  }

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