:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --text: #1d1a16;
  --muted: #6f675d;
  --border: #e3ddd3;
  --accent: #b3261e;
  --accent-text: #ffffff;
  --win: #2e7d32;
  --radius: 12px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14120f;
    --card: #1e1b17;
    --text: #f1ece4;
    --muted: #a39a8e;
    --border: #332e27;
    --accent: #e5483d;
    --win: #66bb6a;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 16px; }
header { padding: 8px 0 24px; }
.logo { font-weight: 800; font-size: 1.25rem; color: var(--accent); text-decoration: none; letter-spacing: .02em; }
h1 { font-size: clamp(1.8rem, 6vw, 2.8rem); line-height: 1.1; margin: 24px 0 12px; }
h2 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 12px; }
.lead { color: var(--muted); font-size: 1.1rem; margin-bottom: 28px; }
.muted { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 8px; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 6px; }
input {
  flex: 1; min-width: 0; font: inherit; color: inherit;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
}
button {
  font: inherit; font-weight: 600; cursor: pointer;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 16px;
}
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.huge { font-size: 1.3rem; padding: 16px 40px; }

.status { text-align: center; font-weight: 600; min-height: 1.5em; }
.big {
  text-align: center; font-variant-numeric: tabular-nums;
  font-size: clamp(3.5rem, 18vw, 6.5rem); font-weight: 800; line-height: 1.1; margin: 8px 0;
}
.big.one { color: var(--accent); }
.big .of { display: block; font-size: 1rem; font-weight: 500; color: var(--muted); }
.big.pop { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.7); opacity: .3; } to { transform: scale(1); opacity: 1; } }
.controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin-top: 8px; }
.controls input { flex: 0 1 140px; text-align: center; }

.columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.columns .card { margin-bottom: 0; }
@media (max-width: 560px) { .columns { grid-template-columns: 1fr; } }

.players, .rolls { list-style: none; padding: 0; margin: 0; }
.players li, .rolls li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.players li:last-child, .rolls li:last-child { border-bottom: 0; }
.players .turn { font-weight: 700; }
.players .turn::before { content: "▶ "; color: var(--accent); }
.players .offline { color: var(--muted); }
.tag { font-size: .75rem; color: var(--muted); }
.rolls .value { font-variant-numeric: tabular-nums; font-weight: 700; }
.rolls .lost .value { color: var(--accent); }
.rolls { max-height: 320px; overflow-y: auto; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px;
  max-width: calc(100% - 32px);
}

/* Home: mode cards */
.modes { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .modes { grid-template-columns: 1fr; } }
.mode-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  background: var(--card); padding: 20px; border-radius: var(--radius);
}
.mode-card strong { font-size: 1.3rem; }
.mode-card span { font-weight: 400; color: var(--muted); }
.mode-card:hover { border-color: var(--accent); }

/* Game settings bar */
.settings { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: transparent; }
.segmented button.active { background: var(--accent); color: var(--accent-text); }
.start { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--muted); font-size: .9rem; }
.start input { width: 110px; flex: none; }
.share { display: flex; align-items: center; gap: 8px; }

/* Players and rolls */
.add { margin-top: 12px; }
.players li { align-items: center; }
.players li > span:first-child { flex: 1; }
.remove { padding: 2px 8px; font-size: .8rem; color: var(--muted); }
.big.win { color: var(--win); }
.rolls .won .value { color: var(--win); }
.rolls .starter { color: var(--muted); font-style: italic; }

/* `hidden` must win over the display rules on .row, .controls etc. (the "Add player" form showed mid-game). */
[hidden] { display: none !important; }

/* Settings stay readable while a game runs: the chosen mode keeps full colour, the rest fades. */
.segmented button.active:disabled { opacity: 1; cursor: default; }
input:disabled { opacity: .7; cursor: default; }
.controls { margin-top: 20px; }
.status:empty { display: none; }

/* Long Players and Rolls lists scroll inside their card, with room between the scrollbar and the numbers. */
/* The list reaches 12px into the card's padding and pads it back, so names, numbers and the ✕ line up with
   the "Add" button, and a scrollbar lands in the card's padding instead of on top of the numbers. */
.players, .rolls { max-height: 320px; overflow-y: auto; margin-right: -12px; padding-right: 12px; }
