:root {
  --bg: #0e0f13;
  --panel: #181a21;
  --panel-2: #21242d;
  --line: #2c303b;
  --text: #f3f4f7;
  --muted: #9097a6;
  --accent: #ffb400;
  --accent-ink: #1a1300;
  --danger: #ff5a5f;
  --ok: #2fcb71;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

button, input, select { font: inherit; color: inherit; }

button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  touch-action: manipulation;
}
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.4; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 700; }
button.danger { color: var(--danger); }
button.icon { min-width: 44px; padding: 8px; }

input, select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 44px;
  min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 64px; }

header.bar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); z-index: 5;
}
.brand { font-weight: 800; letter-spacing: -0.02em; text-decoration: none; color: var(--text); }
.code { font: 700 15px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.18em; padding: 6px 10px; border-radius: 8px; background: var(--panel-2); }
.status { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.dot.on { background: var(--ok); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 600; }

/* turno */
.turn { display: grid; gap: 4px; }
.turn .label { color: var(--muted); font-size: 14px; }
.turn .name { font-size: clamp(34px, 11vw, 56px); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; overflow-wrap: anywhere; }
.turn .meta { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.dice { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.die { width: 46px; height: 46px; border-radius: 10px; background: #fff; color: #111; display: grid; place-items: center; font-weight: 800; font-size: 22px; }
.dice .sum { font-weight: 700; font-size: 20px; }
.dice .who { color: var(--muted); font-size: 13px; }
.badge { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 12px; padding: 3px 8px; border-radius: 99px; }

.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 16px; }
.actions .wide { grid-column: 1 / -1; min-height: 56px; font-size: 18px; }

/* giocatori */
ul.players { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.player { display: grid; grid-template-columns: 6px 1fr auto; gap: 12px; align-items: center; background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 10px 0; overflow: hidden; }
.player.current { border-color: var(--accent); }
.player.off { opacity: 0.55; }
.player .swatch { align-self: stretch; border-radius: 0 4px 4px 0; }
.player .who { min-width: 0; }
.player .pname { font-weight: 700; font-size: 17px; background: none; border: 0; padding: 0; min-height: 0; text-align: left; overflow-wrap: anywhere; }
.player .tags { font-size: 12px; color: var(--muted); }
.player .score { display: flex; align-items: center; gap: 6px; }
.player .score b { min-width: 34px; text-align: center; font-size: 20px; font-variant-numeric: tabular-nums; }
.player .tools { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.player .tools button { min-height: 36px; padding: 6px 10px; font-size: 13px; }
.player details { grid-column: 2 / -1; }
.player summary { font-size: 13px; color: var(--muted); cursor: pointer; padding: 4px 0; }

form.add { display: flex; gap: 8px; margin-top: 12px; }
form.add input { flex: 1; }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.row button { flex: 1; }

/* impostazioni */
.settings { display: grid; gap: 12px; }
.settings label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.settings .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

ol.log { list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--muted); display: grid; gap: 4px; }
ol.log time { font-variant-numeric: tabular-nums; margin-right: 8px; opacity: 0.7; }

.empty { color: var(--muted); text-align: center; padding: 12px 0; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--danger); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; max-width: calc(100vw - 32px); z-index: 10; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; width: min(420px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h3 { margin: 0 0 12px; }
dialog .choices { display: grid; gap: 8px; }
dialog .choices button { text-align: left; font-weight: 700; display: flex; align-items: center; gap: 10px; }
dialog .choices i { width: 12px; height: 12px; border-radius: 50%; flex: none; }

/* home */
.home { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.home .card { width: min(420px, 100%); text-align: center; }
.home h1 { font-size: 56px; letter-spacing: -0.04em; margin: 0; }
.home p { color: var(--muted); margin: 8px 0 28px; }
.home form { display: flex; gap: 8px; }
.home input { flex: 1; text-transform: uppercase; text-align: center; letter-spacing: 0.3em; font: 700 22px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.home .or { margin: 20px 0; color: var(--muted); font-size: 13px; }
.home .full { width: 100%; }
.home .error { color: var(--danger); min-height: 1.4em; margin-top: 12px; font-size: 14px; }
