:root {
  color-scheme: light;
  --ink: #20201d;
  --muted: #676058;
  --paper: #f7f3ea;
  --panel: #fffaf0;
  --line: #d8ccba;
  --accent: #c24b2d;
  --accent-2: #246c78;
  --accent-3: #6e7f37;
  --dark: #27241f;
  --shadow: 0 18px 45px rgba(41, 35, 25, .12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(194, 75, 45, .07) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(36, 108, 120, .06) 0 1px, transparent 1px 100%),
    var(--paper);
  background-size: 38px 38px;
  color: var(--ink);
}

button, select, input { font: inherit; }

button {
  border: 0;
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(16px, 3vw, 42px);
  background: rgba(247, 243, 234, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 850;
}

.mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--dark);
  color: #ffe9c5;
  font-size: .85rem;
}

.nav {
  display: flex;
  align-items: center;
  gap: 13px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: .95rem;
}

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

.lang {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff8ec;
}

.lang button {
  min-width: 38px;
  padding: 7px 8px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.lang button.active {
  background: var(--dark);
  color: #fff5df;
}

main { padding-bottom: 54px; }

.intro {
  min-height: calc(84vh - 67px);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, .75fr);
  gap: clamp(24px, 6vw, 72px);
  align-items: center;
  padding: clamp(28px, 5vw, 76px) clamp(16px, 5vw, 72px) 28px;
}

.intro-copy {
  max-width: 820px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-2);
  text-transform: uppercase;
  font-weight: 900;
  letter-spacing: 0;
  font-size: .8rem;
}

h1, h2, h3, p { overflow-wrap: anywhere; }

h1 {
  margin: 0;
  max-width: 900px;
  font-size: clamp(2.7rem, 8vw, 6.3rem);
  line-height: .95;
  letter-spacing: 0;
}

.intro p:not(.eyebrow) {
  max-width: 680px;
  margin: 22px 0 0;
  color: #4f493f;
  font-size: clamp(1.05rem, 2vw, 1.32rem);
  line-height: 1.55;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.primary, .secondary, .small {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 850;
}

.primary {
  background: var(--accent);
  color: #fffaf0;
  box-shadow: 0 10px 24px rgba(194, 75, 45, .24);
}

.secondary, .small {
  background: #fff7e9;
  color: var(--dark);
  border: 1px solid var(--line);
}

.small { min-height: 36px; padding: 0 12px; }

.score-preview {
  display: grid;
  gap: 12px;
}

.score-preview div {
  min-height: 118px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .8);
  box-shadow: var(--shadow);
}

.score-preview span {
  color: var(--muted);
  font-weight: 800;
}

.score-preview strong {
  display: block;
  margin-top: 8px;
  font-size: 3.4rem;
  line-height: 1;
}

.game-shell {
  width: min(1500px, calc(100% - 28px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 285px minmax(360px, 1fr) 280px;
  gap: 14px;
  align-items: stretch;
}

.panel, .board-wrap, .brief-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 240, .92);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1.16rem;
}

.field {
  display: grid;
  gap: 7px;
  margin: 0 0 12px;
}

.field span {
  color: var(--muted);
  font-size: .88rem;
  font-weight: 850;
}

select {
  width: 100%;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.tool {
  display: grid;
  min-height: 70px;
  gap: 4px;
  place-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
}

.tool span { font-size: 1.25rem; }
.tool b { font-size: .84rem; }
.tool.active {
  border-color: var(--accent-2);
  outline: 3px solid rgba(36, 108, 120, .15);
}

.budget, .meterbar {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.budget div, .meterbar div {
  padding: 10px;
  border-radius: 8px;
  background: #f2ead9;
}

.budget span, .meterbar span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 850;
}

.budget strong, .meterbar strong {
  display: block;
  margin-top: 2px;
  font-size: 1.35rem;
}

.stacked { display: grid; }

.board-wrap {
  min-width: 0;
  padding: 14px;
}

.meterbar {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 12px;
}

#court {
  width: 100%;
  aspect-ratio: 960 / 620;
  display: block;
  border: 1px solid #cfc2ad;
  border-radius: 8px;
  background: #fdf7e8;
}

.rounds {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.round {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fffdf8;
  font-weight: 850;
}

.round.active {
  background: var(--dark);
  color: #fff5df;
}

.live {
  display: flex;
  flex-direction: column;
}

#statusText {
  margin: 0 0 10px;
  color: #4e4539;
  line-height: 1.45;
}

#eventLog {
  padding-left: 20px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

#eventLog li { margin-bottom: 8px; }

.brief {
  width: min(1180px, calc(100% - 28px));
  margin: 42px auto 0;
  display: grid;
  grid-template-columns: minmax(260px, .8fr) minmax(320px, 1.2fr);
  gap: 20px;
  align-items: start;
}

.brief h2 {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.4rem);
  line-height: 1;
}

.brief p:not(.eyebrow) {
  color: var(--muted);
  line-height: 1.55;
}

.brief-card {
  padding: 16px;
}

pre {
  min-height: 260px;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #352f27;
  font-size: .94rem;
  line-height: 1.48;
}

footer {
  padding: 26px 16px 42px;
  text-align: center;
  color: var(--muted);
}

.doc {
  background: var(--paper);
}

.doc-page {
  width: min(860px, calc(100% - 28px));
  margin: 0 auto;
  padding: 42px 0 70px;
}

.doc-page a { color: var(--accent-2); font-weight: 850; }
.doc-page h1 { font-size: clamp(2.3rem, 7vw, 4.6rem); }
.doc-page h2 { margin-top: 32px; }
.doc-page p { color: var(--muted); line-height: 1.65; }

@media (max-width: 1120px) {
  .game-shell { grid-template-columns: 300px minmax(0, 1fr); }
  .live { grid-column: 1 / -1; }
}

@media (max-width: 820px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .nav { justify-content: flex-start; }
  .intro, .brief, .game-shell { grid-template-columns: 1fr; }
  .intro { min-height: auto; }
  .meterbar { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 520px) {
  .tool-grid, .budget, .meterbar, .rounds { grid-template-columns: 1fr; }
  h1 { font-size: 2.55rem; }
  .primary, .secondary { width: 100%; }
}
