:root {
  --bg: #111317; --panel: #191c22; --card: #20242c; --line: #2e333d;
  --text: #ece8de; --muted: #9a9ca3; --accent: #d9a441; --danger: #c4483c;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
h1 { font: 600 22px/1.2 Georgia, "Times New Roman", serif; margin: 0 0 4px; letter-spacing: .01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: #ff8a7a; min-height: 1.2em; }

input, select, button {
  font: inherit; color: var(--text); background: #14171c; border: 1px solid var(--line);
  border-radius: 6px; padding: 6px 8px; min-width: 0;
}
input[type=color] { padding: 2px; width: 44px; height: 34px; }
button { background: #2a2f39; cursor: pointer; }
button:hover { border-color: var(--accent); }
button.on { background: var(--accent); color: #1a1408; border-color: var(--accent); }
button.danger { color: #ffb4aa; }
button.danger:hover { border-color: var(--danger); }
.num { width: 64px; }
.grow { flex: 1; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.block { display: block; margin: 6px 0; }
.block input { width: 100%; }

.center { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 10px 0; }
.card.narrow { width: min(340px, 100%); display: grid; gap: 10px; }
.card.wide { width: min(640px, 100%); }
.card section { margin-top: 18px; }
.games { list-style: none; padding: 0; margin: 0; }
.games li { padding: 8px 0; border-bottom: 1px solid var(--line); }
summary { cursor: pointer; font-weight: 600; }

#game { display: grid; grid-template-columns: 1fr 360px; height: 100vh; }
#view { width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
#side { background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; padding: 12px 14px 24px; }
#side header { margin-bottom: 6px; }
.back { font-size: 12px; text-decoration: none; }
.players { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { border-left: 4px solid var(--c); background: #14171c; padding: 2px 8px; border-radius: 4px; font-size: 12px; }
.unit { border-left: 4px solid var(--c); }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 8px 0; }
.stats label { display: grid; font-size: 11px; color: var(--muted); text-align: center; }
.stats input { text-align: center; padding: 4px; }
.distance { color: var(--accent); min-height: 1.2em; font-weight: 600; }
.upload { position: relative; overflow: hidden; display: inline-block; padding: 6px 10px; border: 1px dashed var(--line); border-radius: 6px; cursor: pointer; }
.upload .file { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.roll { padding: 6px 0; border-top: 1px solid var(--line); opacity: .7; }
.roll.latest { opacity: 1; }
.faces { display: flex; flex-wrap: wrap; gap: 3px; margin: 4px 0; }
.die { width: 24px; height: 24px; display: grid; place-items: center; border-radius: 5px; background: #ece8de; color: #1a1a1a; font-weight: 700; font-size: 13px; }
.die.dmax { background: var(--accent); }
.die.done { background: #6a2b26; color: #fff; }
.help { font-size: 12px; margin-top: 16px; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #2a2f39; border: 1px solid var(--line); padding: 8px 14px; border-radius: 8px; z-index: 10; }
body.offline #side header::after { content: "Reconnecting…"; display: block; color: #ff8a7a; font-size: 12px; margin-top: 4px; }

@media (max-width: 800px) {
  #game { grid-template-columns: 1fr; grid-template-rows: 55vh 1fr; }
  #side { border-left: 0; border-top: 1px solid var(--line); }
}
