:root {
  color-scheme: dark;
  --bg: #0d1f16;
  --card: #15301f;
  --card-2: #1c3d28;
  --line: #2a5238;
  --text: #eef6f0;
  --muted: #9fbca8;
  --accent: #3ddc84;
  --accent-ink: #062611;
  --star: #ffc93c;
  --star-off: #3a5a45;
  --danger: #ff6b6b;
  --gold: #ffd54a;
  --silver: #cfd8dc;
  --bronze: #e0995e;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: 0.85rem; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.brand { font-weight: 800; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill {
  font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 4px 10px; border-radius: 999px; background: var(--card-2); color: var(--accent); white-space: nowrap;
}

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 80px; }
main.wide { max-width: 1100px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px; margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 1.1rem; }
.card h3 { margin: 0 0 8px; font-size: 1rem; }

label { display: block; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=url], input[type=number] {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 1rem;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); font: inherit; font-weight: 700;
  cursor: pointer; text-decoration: none;
}
button:hover, .btn:hover { filter: brightness(1.15); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.danger { color: var(--danger); }
button.block { width: 100%; margin-top: 16px; }
button:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* goals/assists steppers */
.counters { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.counter { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.counter .label { color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.counter .val { font-size: 2rem; font-weight: 800; margin: 2px 0; }
.counter .stepper { display: flex; gap: 8px; justify-content: center; }
.counter .stepper button { width: 44px; height: 44px; padding: 0; font-size: 1.3rem; }

/* star voting */
.vote-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.vote-row:last-child { border-bottom: 0; }
.vote-row .who { min-width: 0; }
.vote-row .who .name { font-weight: 700; overflow-wrap: anywhere; }
.stars { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.stars button {
  background: none; border: 0; padding: 4px 2px; font-size: 1.7rem; line-height: 1;
  color: var(--star-off); cursor: pointer;
}
.stars button.on { color: var(--star); }
.stars button.zero {
  font-size: 0.8rem; font-weight: 800; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); color: var(--muted); margin-right: 4px; padding: 0;
}
.stars button.zero.on { background: var(--card-2); color: var(--text); border-color: var(--muted); }
.stars.unset button.zero { opacity: 0.6; }

.player-list { list-style: none; padding: 0; margin: 0; }
.player-list li { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.player-list li:last-child { border-bottom: 0; }
.tag { font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--card-2); color: var(--muted); }
.tag.you { color: var(--accent); }

/* ranking */
.rank-item {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.rank-item:last-child { border-bottom: 0; }
.rank-num { font-size: 1.4rem; font-weight: 800; text-align: center; color: var(--muted); }
.rank-item.r1 .rank-num { color: var(--gold); }
.rank-item.r2 .rank-num { color: var(--silver); }
.rank-item.r3 .rank-num { color: var(--bronze); }
.rank-name { font-weight: 800; font-size: 1.05rem; overflow-wrap: anywhere; }
.rank-meta { color: var(--muted); font-size: 0.85rem; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.rank-score { text-align: right; }
.rank-score .big { font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.rank-score .lbl { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.dist { display: flex; gap: 3px; align-items: flex-end; height: 28px; margin-top: 8px; }
.dist div { flex: 1; max-width: 22px; background: var(--star); border-radius: 3px 3px 0 0; min-height: 2px; opacity: 0.85; position: relative; }
.dist-labels { display: flex; gap: 3px; font-size: 0.65rem; color: var(--muted); }
.dist-labels span { flex: 1; max-width: 22px; text-align: center; }

/* host */
.host-grid { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
@media (max-width: 860px) { .host-grid { grid-template-columns: 1fr; } }
.qr { background: #fff; border-radius: 12px; padding: 12px; }
.qr img { display: block; width: 100%; height: auto; }
.join-url { font-family: ui-monospace, monospace; font-size: 1rem; word-break: break-all; margin-top: 10px; text-align: center; }
.phase-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.phase-btns button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.stat-line { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; margin-top: 10px; }
.stat-line b { color: var(--text); }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-weight: 700; z-index: 20; max-width: calc(100% - 32px); text-align: center;
}
.toast.err { background: var(--danger); color: #fff; }
.hero { font-size: 3rem; text-align: center; margin: 10px 0; }

/* name picker */
select {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font: inherit; font-size: 1rem;
}
select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* local game timer */
.timer-display {
  font-size: clamp(3.5rem, 20vw, 6rem); font-weight: 800; line-height: 1.1; margin: 4px 0 14px;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.timer-display.ending { color: var(--star); }
.timer-display.done { color: var(--danger); animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* goals & assists table */
.legend { display: flex; gap: 14px; margin: 6px 0 2px; }
.stat-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 6px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.stat-row:last-of-type { border-bottom: 0; }
.stat-name { font-weight: 700; overflow-wrap: anywhere; }
.mini { display: flex; align-items: center; gap: 3px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.mini .ic { font-size: 0.85rem; padding: 0 2px; }
.mini button { width: 34px; height: 34px; padding: 0; font-size: 1.15rem; border-radius: 8px; }
.mini b { min-width: 22px; text-align: center; font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.stat-row .x { width: 30px; height: 30px; padding: 0; font-size: 0.8rem; background: none; border-color: transparent; color: var(--muted); }
.stat-row .x:hover { color: var(--danger); }
@media (max-width: 400px) {
  .stat-row { grid-template-columns: auto auto 1fr; }
  .stat-name { grid-column: 1 / 3; }
  .stat-row .x { grid-column: 3; grid-row: 1; justify-self: end; }
}
