:root {
  --bg: #1a1c21;
  --panel: #24262e;
  --text: #e6e8ed;
  --dim: #949aa6;
  --button: #383d47;
  --button-hover: #4d5261;
  --blue: #3d78e6;
  --red: #e04540;
  --hilite: #ffd940;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  justify-content: flex-end;
  padding: 10px 16px;
}
a { color: #8fb4ff; }

.dim { color: var(--dim); font-weight: normal; }

main {
  flex: 1;
  display: flex;
  gap: 16px;
  padding: 0 16px 16px;
  min-height: 0;
}

#board-wrap { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; }
#board { width: 100%; height: 100%; max-height: calc(100vh - 70px); user-select: none; -webkit-user-select: none; touch-action: manipulation; }

#panel {
  width: 330px;
  flex-shrink: 0;
  background: var(--panel);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-self: flex-start;
}
#panel section { display: flex; flex-direction: column; gap: 12px; }
#panel section[hidden] { display: none; }
#panel h2 { margin: 0; font-size: 18px; }
#panel p { margin: 0; }

#rules { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#rules legend { font-weight: 600; padding: 0; margin-bottom: 6px; }
#rules label { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-radius: 6px; background: var(--button); cursor: pointer; }
#rules label:has(input:checked) { outline: 2px solid #8fb4ff; outline-offset: -2px; }
#rules label > span { display: flex; flex-direction: column; }
#rules input { margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.visits-row { display: flex; gap: 8px; align-items: center; }
#visits-slider { flex: 1; min-width: 0; accent-color: #8fb4ff; }
#visits { width: 5.5em; font: inherit; color: var(--text); background: var(--button); border: 0; border-radius: 6px; padding: 6px 8px; }
#roll { min-height: 0; color: var(--hilite); }
#roll:empty { display: none; }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice { display: flex; flex-direction: column; align-items: flex-start; padding: 12px 14px; border-left: 6px solid; }
.choice strong { font-size: 17px; }
.choice span { color: var(--dim); }
.choice.blue { border-left-color: var(--blue); }
.choice.red { border-left-color: var(--red); }

#status { font-size: 19px; font-weight: 600; min-height: 1.45em; }
#status.blue { color: #7aa5f5; }
#status.red { color: #f07a76; }
#substatus { min-height: 1.45em; margin-top: -8px; }

#score { border-collapse: collapse; width: 100%; }
#score th { text-align: left; width: 50px; }
#score td, #score th { padding: 2px 4px 2px 0; white-space: nowrap; }
#score tr.blue th { color: #7aa5f5; }
#score tr.red th { color: #f07a76; }
#score td:nth-child(2) { color: var(--dim); }

.buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.buttons button { flex: 1; }

button {
  font: inherit;
  color: var(--text);
  background: var(--button);
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--button-hover); }
button:disabled { opacity: 0.4; cursor: default; }
button[aria-pressed="true"] { outline: 2px solid var(--hilite); outline-offset: -2px; }
button.primary { outline: 2px solid #8fb4ff; outline-offset: -2px; }

.check { display: flex; gap: 8px; align-items: center; color: var(--dim); cursor: pointer; }

#help summary { cursor: pointer; color: var(--dim); }
#help ul { padding-left: 18px; margin: 8px 0 0; color: var(--dim); }
#help li { margin-bottom: 4px; }

#info { font-size: 12px; }

/* board */
.cell { cursor: default; }
.cell.clickable { cursor: pointer; }
.cell text { font-weight: 600; pointer-events: none; }
.overlay { pointer-events: none; }

@media (max-width: 760px) {
  main { flex-direction: column; padding: 0 16px 16px; }
  #panel { width: 100%; }
  #board { max-height: 62vh; }
  #board-wrap { flex: none; }
}
