:root {
  color-scheme: dark;
  --bg: #1a1410;
  --ink: #f6eadc;
  --muted: #e0d0c0;
  --faint: #cbbba8;
  --line: rgba(255, 196, 140, 0.2);
  --ember: #e07030;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #140f0c;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

body {
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-areas: "panel stage";
  overflow: hidden;
}

#scene {
  grid-area: stage;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  min-width: 0;
  min-height: 0;
}

#scene:focus { outline: none; }
#scene:focus-visible { outline: 2px solid #ffb15a; outline-offset: -3px; }

#panel {
  grid-area: panel;
  background: var(--bg);
  border-right: 1px solid var(--line);
  padding: 26px 22px 22px;
  overflow: auto;
  min-width: 0;
  min-height: 0;
}

h1 {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 1.85rem;
  letter-spacing: -0.02em;
  margin: 0 0 0.55rem;
}

h2 {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

p { margin: 0 0 0.75rem; }

.point {
  font-family: var(--serif);
  font-style: italic;
  color: #f3dcc6;
}

.read { color: var(--muted); }

.formula {
  font-variant-numeric: tabular-nums;
  color: #ffd7b0;
  margin-bottom: 1rem;
}

.comparison {
  background: rgba(255, 150, 70, 0.08);
  border: 1px solid rgba(255, 176, 110, 0.22);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 0.9rem;
}

.status {
  margin: -0.3rem 0 0.8rem;
  color: #ffd7b0;
}

.status:empty { display: none; }

.roster {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.roster li {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: 10px;
}

.roster li.selected { background: rgba(255, 255, 255, 0.06); }

.roster .pick {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 7px 8px;
  border-radius: 10px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.35);
}

.idcol { display: flex; flex-direction: column; min-width: 0; }

.who { font-weight: 600; }

.tag {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
}

.angle {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  white-space: nowrap;
}

.roster .remove {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
}

.roster .empty {
  color: var(--faint);
  padding: 4px 2px 8px;
}

.slider {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 0.9rem;
  color: var(--muted);
}

.slider input {
  width: 100%;
  accent-color: var(--ember);
}

.toggles {
  display: flex;
  gap: 16px;
  margin-bottom: 1rem;
  color: var(--muted);
}

.toggles label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 1rem;
}

button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  padding: 8px 14px;
}

button:disabled { opacity: 0.4; cursor: default; }

button:focus-visible, input:focus-visible {
  outline: 2px solid #ffb15a;
  outline-offset: 2px;
}

.primary {
  background: var(--ember);
  color: #1d0e08;
  border: 0;
  font-weight: 650;
}

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.hint {
  color: var(--faint);
  font-size: 0.92rem;
  margin: 0;
}

@media (max-width: 840px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr minmax(180px, 42vh);
    grid-template-areas:
      "stage"
      "panel";
  }

  #panel {
    border-right: 0;
    border-top: 1px solid var(--line);
    padding: 16px 16px 18px;
  }

  h1 { font-size: 1.45rem; }
}
