:root {
  --bg: #15131a;
  --card: #1f1c26;
  --line: #34303f;
  --text: #ece8f3;
  --muted: #9a93a8;
  --accent: #e0b25a;
  --danger: #e26d6d;
  /* The five mana colours: W U B R G */
  --mana: linear-gradient(90deg, #f3e9c6, #4a8fd8, #7a6a8e, #d8573f, #3f9a5b);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(circle at 50% -20%, #2b2536, var(--bg) 60%) fixed;
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 3rem 1.25rem 2rem;
}

header { margin-bottom: 2rem; }
.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
h1 { margin: 0.2rem 0 0.5rem; font-size: 2.4rem; line-height: 1.1; }
h2 { font-size: 1.1rem; margin: 2.5rem 0 0.75rem; }
.lead { margin: 0; color: var(--muted); }

/* Progress */
.progress {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.5rem;
}
.numbers { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 0.9rem; }
.total { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.goal { color: var(--muted); font-size: 1.1rem; }

.bar {
  display: flex;
  height: 28px;
  border-radius: 999px;
  background: #2a2633;
  overflow: hidden;
}
.fill {
  width: 0;
  height: 100%;
  background: var(--mana);
  background-size: 640px 100%; /* keep the colours put while the bar grows */
  transition: width 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.bar.done .fill { box-shadow: 0 0 24px #e0b25a88; }
/* Owed but not yet paid: a hatched stretch right after the paid part. */
.bar .open {
  width: 0;
  height: 100%;
  background: repeating-linear-gradient(-45deg, #4a4358 0 6px, #3a3446 6px 12px);
  transition: width 1.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.status { margin: 0.75rem 0 0; color: var(--muted); }

/* Per-person table */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.55rem 0.4rem; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 0.85rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.owes { color: var(--accent); font-weight: 600; }
.empty, .hint { color: var(--muted); }
.hint { font-size: 0.85rem; margin-top: -0.25rem; }

/* Rounds */
.round {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
}
.round-head { display: flex; flex-wrap: wrap; gap: 0.25rem 0.6rem; align-items: baseline; margin-bottom: 0.6rem; }
.round-head .label { color: var(--accent); }
.round-head .meta { color: var(--muted); font-size: 0.85rem; margin-left: auto; }
.players { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.player {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 500;
}
.player.paid { background: #23402c; border-color: #3f9a5b; color: #cfeedd; }
.player.open { background: transparent; border-style: dashed; border-color: #5a5368; color: var(--muted); }
button.player { cursor: pointer; }
.player-wrap { display: inline-flex; align-items: center; }
.player-wrap .player { border-radius: 999px 0 0 999px; }
button.remove {
  background: none;
  border: 1px solid var(--line);
  border-left: none;
  border-radius: 0 999px 999px 0;
  color: var(--muted);
  padding: 0.25rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 400;
}
.round-admin { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; margin-top: 0.75rem; }
.add-player { display: flex; gap: 0.35rem; }
.add-player input { width: 11rem; padding: 0.3rem 0.55rem; }
.add-player button { padding: 0.3rem 0.7rem; }

/* New round form */
form#new-round { display: grid; gap: 0.75rem; }
form#new-round label { display: grid; gap: 0.25rem; color: var(--muted); font-size: 0.85rem; }
form#new-round .row { display: grid; grid-template-columns: auto 1fr 7rem; gap: 0.5rem; }
@media (max-width: 560px) {
  form#new-round .row { grid-template-columns: 1fr 1fr; }
  form#new-round .grow { grid-column: 1 / -1; grid-row: 2; }
}
form#new-round > button { justify-self: start; }
.chips-input {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #17151d;
  cursor: text;
}
.chips-input input { border: none; background: none; flex: 1; min-width: 8rem; padding: 0.2rem 0.3rem; }
.chips-input input:focus { outline: none; }
.chips-input:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  background: #2a2633;
  color: var(--text);
  border-radius: 999px;
  padding: 0.15rem 0.2rem 0.15rem 0.6rem;
  font-size: 0.9rem;
}
.chip button { background: none; border: none; color: var(--muted); padding: 0 0.35rem; font-weight: 400; }

/* Controls */
input, button {
  font: inherit;
  color: inherit;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #17151d;
  padding: 0.5rem 0.65rem;
  min-width: 0;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button { cursor: pointer; background: var(--accent); color: #1b1610; border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; padding: 0; color: var(--muted); font-weight: 400; text-decoration: underline; }
button.link.danger { color: var(--danger); }
/* Pills and chip buttons override the generic button look above. */
button.player.paid { background: #23402c; border-color: #3f9a5b; color: #cfeedd; }
button.player.open { background: transparent; border-color: #5a5368; color: var(--muted); }

.error { color: var(--danger); font-size: 0.9rem; }

footer { margin-top: 3rem; display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; font-size: 0.9rem; }
footer form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

[hidden] { display: none !important; }
