:root {
  --ink: #172033;
  --muted: #687386;
  --panel: #fffdf8;
  --line: #d8d1c0;
  --paper: #f5edda;
  --accent: #0f766e;
  --blue: #2364aa;
  --gold: #c08a22;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(192, 138, 34, 0.16), transparent 38%),
    #f5f1e9;
  font-family: Arial, Helvetica, sans-serif;
}

.game {
  display: grid;
  gap: 16px;
  min-height: 100vh;
  padding: 22px;
}

header,
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

header {
  justify-content: space-between;
}

.header-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 46px);
  line-height: 1;
}

#contextLabel {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

button,
textarea {
  border-radius: 8px;
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  padding: 10px 14px;
  color: white;
  background: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

button:disabled {
  background: #9aa4b2;
  cursor: not-allowed;
}

.setup-panel {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

textarea {
  width: 100%;
  border: 1px solid var(--line);
  padding: 10px;
  color: var(--ink);
  background: white;
  resize: vertical;
}

.table {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(260px, 340px);
  gap: 16px;
  min-height: 0;
}

.ladder-card,
.status-card,
.results-card {
  border: 1px solid rgba(23, 32, 51, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.94);
  box-shadow: 0 10px 24px rgba(23, 32, 51, 0.08);
}

.ladder-card {
  display: grid;
  grid-template-rows: auto minmax(340px, 1fr) auto;
  gap: 10px;
  padding: 14px;
  min-height: 560px;
}

.labels {
  display: grid;
  gap: 8px;
}

.label-button,
.outcome-label {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 7px;
  color: var(--ink);
  background: var(--paper);
  font-size: 13px;
  font-weight: 900;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.label-button {
  cursor: pointer;
}

.label-button.active {
  color: white;
  background: var(--accent);
}

.outcome-label.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(192, 138, 34, 0.22);
}

.ladder {
  width: 100%;
  min-height: 340px;
  border: 2px solid #8a7555;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.52), transparent 70%),
    #ead9b9;
}

.ladder line {
  stroke: #5b4631;
  stroke-width: 0.7;
  stroke-linecap: round;
}

.ladder .bar {
  stroke: var(--blue);
  stroke-width: 0.9;
}

.ladder .path {
  fill: none;
  stroke: #d92d20;
  stroke-width: 1.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.side-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-height: 0;
}

.status-card,
.results-card {
  padding: 14px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

#status {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
}

.results-card {
  overflow: auto;
}

.results-card ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
}

@media (max-width: 860px) {
  .setup-panel,
  .table {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .game {
    padding: 14px;
  }

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

  .ladder-card {
    min-height: 460px;
  }
}
