:root {
  --bg: #0f1220;
  --card: #1a1f35;
  --card2: #232a47;
  --line: #2e3658;
  --text: #e9ecf5;
  --muted: #9aa3bf;
  --gold: #e8b64c;
  --violet: #8b6cff;
  --ok: #39c487;
  --bad: #ff5d6c;
  --r: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) 0 calc(72px + env(safe-area-inset-bottom)); }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.05rem; margin: 24px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
a { color: var(--gold); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 10px; }
.card.link { display: block; color: inherit; text-decoration: none; }
.card.active { border-color: var(--violet); }
.card.reported { border-color: var(--gold); }
.row { display: flex; gap: 8px; align-items: center; }
.row.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

.badge { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--card2); color: var(--muted); }
.badge.live { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.badge.gold { background: color-mix(in srgb, var(--gold) 20%, transparent); color: var(--gold); }

button, .btn {
  font: inherit; border: 0; border-radius: 10px; padding: 12px 16px; cursor: pointer;
  background: var(--violet); color: #fff; font-weight: 600; text-decoration: none; display: inline-block; text-align: center;
  min-height: 44px;
}
button.secondary, .btn.secondary { background: var(--card2); color: var(--text); }
button.ok { background: var(--ok); color: #062014; }
button.bad { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
button.block, .btn.block { width: 100%; }
button:disabled { opacity: .4; cursor: default; }
button.pick { background: var(--card2); color: var(--text); flex: 1; }
button.pick.on { background: var(--gold); color: #1d1500; }

label { display: block; margin: 12px 0 4px; color: var(--muted); font-size: .9rem; }
input, select {
  font: inherit; width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card2); color: var(--text);
}
input[type=checkbox], input[type=radio] { width: auto; }
.check { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 6px 0; background: var(--card2); border-radius: 10px; color: var(--text); font-size: 1rem; }
.mode { display: block; padding: 12px; margin: 6px 0; background: var(--card2); border: 2px solid transparent; border-radius: 10px; cursor: pointer; color: var(--text); font-size: 1rem; }
.mode:has(input:checked) { border-color: var(--gold); }
.mode input { display: none; }
.error { color: var(--bad); min-height: 1.4em; margin-top: 8px; }

.vs { font-size: 1.15rem; font-weight: 600; }
.vs .x { color: var(--muted); font-weight: 400; margin: 0 6px; }
.crown::before { content: "👑 "; }
.champion { text-align: center; padding: 24px 14px; border-color: var(--gold); }
.champion .name { font-size: 1.8rem; font-weight: 700; color: var(--gold); }

table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: .8rem; }
th:nth-child(2), td:nth-child(2) { text-align: left; }
td:first-child, th:first-child { text-align: left; color: var(--muted); width: 2em; }
tr.me td { color: var(--gold); }

nav#nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 4px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: #0b0e1a; border-top: 1px solid var(--line);
}
nav#nav a, nav#nav button { flex: 1; text-align: center; padding: 10px; border-radius: 10px; color: var(--text); text-decoration: none; background: transparent; font-weight: 500; }
nav#nav a.on { background: var(--card2); color: var(--gold); }

dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: var(--r); width: min(560px, 94vw); padding: 16px; }
dialog::backdrop { background: rgb(0 0 0 / .6); }
.game { padding: 10px 0; border-bottom: 1px solid var(--line); }
.score { font-size: 2rem; font-weight: 700; text-align: center; margin: 8px 0; font-variant-numeric: tabular-nums; }

/* Life points */
.lp { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.lp .side { background: var(--card); border: 2px solid var(--line); border-radius: var(--r); padding: 12px; text-align: center; }
.lp .side.low { border-color: var(--bad); }
.lp .pts { font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.lp .side input { text-align: center; background: transparent; border: 0; padding: 4px; color: var(--muted); }
.entry { font-size: 2rem; text-align: center; font-variant-numeric: tabular-nums; margin: 12px 0 6px; min-height: 1.3em; }
.pad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pad button { background: var(--card2); color: var(--text); padding: 14px 0; font-size: 1.15rem; }
.dice { font-size: 3rem; text-align: center; min-height: 1.4em; }
.dice.roll { animation: roll .6s ease-out; }
.dice.flip { animation: flip .6s ease-out; }
.dice.landed { animation: land .25s ease-out; color: var(--gold); }
@keyframes roll {
  0% { transform: translateY(0) rotate(0); }
  30% { transform: translateY(-18px) rotate(240deg); }
  60% { transform: translateY(0) rotate(480deg); }
  80% { transform: translateY(-6px) rotate(660deg); }
  100% { transform: translateY(0) rotate(720deg); }
}
@keyframes flip {
  0% { transform: translateY(0) rotateX(0); }
  50% { transform: translateY(-28px) rotateX(900deg); }
  100% { transform: translateY(0) rotateX(1800deg); }
}
@keyframes land {
  0% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
/* Reduced motion: no spinning, but still a visible pulse so the click registers. */
@media (prefers-reduced-motion: reduce) {
  .dice.roll, .dice.flip { animation: pulse .6s ease-in-out; }
  .dice.landed { animation: none; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}
