:root {
  --bg: #0d1117;
  --panel: #161b22;
  --line: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #3fb950;
  --danger: #f85149;
  --blue: #58a6ff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #010409;
}

.brand {
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text);
  text-decoration: none;
}
.brand span { color: var(--accent); }

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  margin-left: 18px;
  font-size: 14px;
}
.topbar nav a:hover { color: var(--text); }

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px 64px;
  display: grid;
  gap: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 22px;
}

h1 { margin: 4px 0 12px; font-size: 34px; }
h2 { margin: 0 0 16px; font-size: 16px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }

.label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--muted);
}

.muted { color: var(--muted); }
.small { font-size: 13px; }
a { color: var(--blue); }

/* plancia */
.board { text-align: center; }

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 64px;
  font-weight: 700;
  letter-spacing: 2px;
  margin: 8px 0 16px;
}
.clock.low { color: var(--danger); }
.clock.idle { color: var(--muted); }

.bar {
  height: 8px;
  background: #21262d;
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 1s linear, background-color .3s;
}
.bar-fill.low { background: var(--danger); }

.meta {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 14px;
  color: var(--muted);
}

.order { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.order li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}
.order li.active {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(63, 185, 80, .08);
}
.order .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--line);
}
.order li.active .dot { background: var(--accent); }

/* giocatore */
.player { text-align: center; }
.turn-state { font-size: 18px; margin: 0 0 4px; }
.turn-state.yours { color: var(--accent); font-weight: 600; }
.turn-state.waiting { color: var(--muted); }

button {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #21262d;
  color: var(--text);
  padding: 10px 18px;
}
button:hover:not(:disabled) { border-color: var(--muted); }
button:disabled { opacity: .4; cursor: not-allowed; }

button.big {
  width: 100%;
  padding: 26px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  background: var(--accent);
  border-color: var(--accent);
  color: #04150a;
}
button.big:disabled { background: #21262d; color: var(--muted); border-color: var(--line); }

button.primary { background: var(--accent); border-color: var(--accent); color: #04150a; font-weight: 600; }
button.danger { color: var(--danger); border-color: #5a1d1d; }

/* admin */
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.field { display: grid; gap: 6px; flex: 1 1 200px; margin-bottom: 14px; }
.field[hidden] { display: none; }
.field span { font-size: 13px; color: var(--muted); }

input, select {
  font: inherit;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #0d1117;
  color: var(--text);
  width: 100%;
}
input:focus, select:focus { outline: 2px solid var(--blue); outline-offset: -1px; }

.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions form { margin: 0; }

.status-line { margin: 0 0 16px; }
.on { color: var(--accent); }
.off { color: var(--muted); }

.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.links li { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.links code { color: var(--muted); font-size: 12px; }

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

.flash {
  background: rgba(88, 166, 255, .12);
  border: 1px solid rgba(88, 166, 255, .4);
  color: var(--blue);
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
}

/* statistiche OpenRouter */
.stats-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.stats-head h2 { margin: 0; }
.stats-day { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.stats-total {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.stats-sum {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.stats-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.stats-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  font-weight: 600;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--line);
}
.stats-table td { padding: 9px 8px; border-bottom: 1px solid #21262d; }
.stats-table tr:last-child td { border-bottom: 0; }
.stats-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.stats-table .rank { width: 32px; color: var(--muted); font-variant-numeric: tabular-nums; }
.stats-table .name { overflow-wrap: anywhere; }
.stats-table .eur { font-weight: 600; }
.stats-table tr.top .rank { color: var(--accent); font-weight: 700; }
.stats-table tr.top .name { color: var(--accent); }

.stats-error { margin: 12px 0 0; font-size: 12px; color: var(--danger); }
