:root {
  --bg: #0f1115;
  --bg-soft: #161a21;
  --card: #1b2029;
  --line: #2a313d;
  --text: #e7ebf2;
  --muted: #97a1b2;
  --accent: #6ea8fe;
  --silence: #4ade80;
  --snitch: #f87171;
  --warn: #fbbf24;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 15% -10%, #1d2634 0%, transparent 60%),
    radial-gradient(700px 400px at 110% 10%, #241d2c 0%, transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  display: flex;
  flex-direction: column;
}

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 .5rem; letter-spacing: -.02em; }
h2 { font-size: 1.1rem; margin: 0 0 .9rem; letter-spacing: -.01em; }
p  { margin: 0 0 1rem; }
a  { color: var(--accent); }

.muted  { color: var(--muted); }
.small  { font-size: .82rem; }
.strong { font-weight: 650; }
.mono, .code { font-family: var(--mono); font-size: .88rem; }
.is-hidden { display: none !important; }
.inline { display: inline; }

.code {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: .12rem .4rem;
  white-space: nowrap;
}

.link-strong { font-weight: 600; text-decoration: none; }
.link-strong:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- layout */

.shell {
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding: 1.75rem 1.15rem 3rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.15rem;
}
.shell--narrow { max-width: 560px; justify-content: center; }

.card {
  background: linear-gradient(180deg, rgba(255,255,255,.028), transparent), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card--center { text-align: center; }

.row { display: flex; gap: 1rem; align-items: flex-start; }
.row--between { justify-content: space-between; flex-wrap: wrap; }

.footer {
  text-align: center;
  color: #5c6577;
  font-size: .78rem;
  padding: 1.25rem;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 .45rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.card--center .eyebrow { justify-content: center; }

.lede { color: #c3cbd9; }

.glyph { font-size: 2.6rem; line-height: 1; margin-bottom: .6rem; }
.glyph--sm { font-size: 1.9rem; }

/* ----------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .85rem 1.15rem;
  background: rgba(12, 15, 20, .75);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar__brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar__nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .9rem;
  flex-wrap: wrap;
}
.topbar__nav a { color: var(--muted); text-decoration: none; }
.topbar__nav a:hover { color: var(--text); }
.topbar__user {
  color: var(--muted);
  border-left: 1px solid var(--line);
  padding-left: 1rem;
}

/* ----------------------------------------------------------------- forms */

.field { display: block; margin-bottom: 1.15rem; }
.field__label {
  display: block;
  font-size: .84rem;
  font-weight: 620;
  margin-bottom: .4rem;
  color: #cfd6e2;
}
.field__row { display: flex; gap: .5rem; align-items: stretch; }
.field__row > input { flex: 1; min-width: 0; }
.field__hint { font-size: .78rem; color: var(--muted); margin: .4rem 0 0; }
.field__hint--center { text-align: center; }

input[type="text"], input[type="password"], textarea {
  width: 100%;
  padding: .7rem .85rem;
  font: inherit;
  color: var(--text);
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; }

input:focus, textarea:focus, button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(110, 168, 254, .2);
}
input[readonly] { color: var(--muted); }

.form-grid { display: block; }

/* --------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .68rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: #232a35;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .06s;
}
.btn:hover  { background: #2b3340; }
.btn:active { transform: translateY(1px); }

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1220;
}
.btn--primary:hover { background: #86b8ff; }

.btn--ghost  { background: transparent; }
.btn--ghost:hover { background: #232a35; }
.btn--warn   { border-color: #6b5316; color: var(--warn); }
.btn--danger { border-color: #6d2b2b; color: #fca5a5; }
.btn--block  { width: 100%; }
.btn--sm     { padding: .42rem .75rem; font-size: .85rem; }
.btn--icon   { padding: .6rem .8rem; font-size: 1.05rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

.controls { display: flex; flex-wrap: wrap; gap: .6rem; }

/* --------------------------------------------------------------- choices */

.choices { border: 0; margin: 0 0 1.35rem; padding: 0; display: grid; gap: .7rem; }
.choices legend { padding: 0; margin-bottom: .5rem; }

.choice { position: relative; display: block; cursor: pointer; }
.choice input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.choice__body {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "icon title" "icon desc";
  gap: .1rem .85rem;
  align-items: center;
  padding: 1rem 1.1rem;
  background: var(--bg-soft);
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s, transform .06s;
}
.choice:hover .choice__body { background: #1c222c; }
.choice__icon  { grid-area: icon; font-size: 1.7rem; }
.choice__title { grid-area: title; font-weight: 680; }
.choice__desc  { grid-area: desc; font-size: .84rem; color: var(--muted); }

.choice input:focus-visible + .choice__body {
  box-shadow: 0 0 0 3px rgba(110, 168, 254, .25);
}
.choice--silence input:checked + .choice__body {
  border-color: var(--silence);
  background: rgba(74, 222, 128, .1);
}
.choice--snitch input:checked + .choice__body {
  border-color: var(--snitch);
  background: rgba(248, 113, 113, .1);
}

/* --------------------------------------------------------------- results */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: .8rem;
  margin-bottom: 1.1rem;
}
.stat {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  text-align: center;
}
.stat__value {
  display: block;
  font-size: 2rem;
  font-weight: 720;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.stat__label {
  font-size: .78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.stat--silence .stat__value { color: var(--silence); }
.stat--snitch  .stat__value { color: var(--snitch); }

.bar {
  display: flex;
  height: 13px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}
/* Width is driven by --pct, which the scripts set with style.setProperty().
   Setting a custom property that way is not an inline style attribute, so it
   does not trip `style-src 'self'` in the CSP. Defaults to 0 so a bar with no
   data renders empty rather than full. */
.bar__seg {
  width: var(--pct, 0%);
  transition: width .45s cubic-bezier(.4, 0, .2, 1);
}
.bar__seg--silence { background: var(--silence); }
.bar__seg--snitch  { background: var(--snitch); }

.results { margin-top: 1.6rem; text-align: left; }
.results__title { text-align: center; }

.tally {
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  flex-wrap: wrap;
  margin-top: .9rem;
}
.tally__item { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.tally__dot { width: 10px; height: 10px; border-radius: 50%; }
.tally__dot--silence { background: var(--silence); }
.tally__dot--snitch  { background: var(--snitch); }
.tally__label { color: var(--muted); }
.tally__value { font-weight: 700; font-variant-numeric: tabular-nums; }

.waiting {
  margin-top: 1.4rem;
  font-size: .87rem;
  color: var(--muted);
  border-top: 1px dashed var(--line);
  padding-top: 1.1rem;
}

/* --------------------------------------------------------------- verdict */

.verdict {
  margin-top: 1.5rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
  text-align: center;
}
.verdict__headline {
  font-size: 1.5rem;
  letter-spacing: -.02em;
  margin: .2rem 0 .8rem;
}

.verdict-card {
  border-color: rgba(251, 191, 36, .35);
  background:
    linear-gradient(180deg, rgba(251, 191, 36, .06), transparent 60%),
    var(--card);
}

/* Big single number shown to a player: their own damage. */
.damage {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: .1rem;
  padding: 1rem 2.2rem;
  margin: .4rem 0 1rem;
  border: 1px solid rgba(248, 113, 113, .4);
  background: rgba(248, 113, 113, .1);
  border-radius: var(--radius);
}
.damage__value {
  font-size: 3.2rem;
  font-weight: 780;
  line-height: 1;
  color: var(--snitch);
  font-variant-numeric: tabular-nums;
}
.damage--none .damage__value { color: var(--silence); }
.damage--none {
  border-color: rgba(74, 222, 128, .4);
  background: rgba(74, 222, 128, .1);
}
.damage__label {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--muted);
}

.damage-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .8rem;
  margin-top: 1.1rem;
}
.damage-split__item {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: .9rem 1rem;
  text-align: center;
}
.damage-split__value {
  display: block;
  font-size: 2rem;
  font-weight: 720;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}
.damage-split__item--silence .damage-split__value { color: var(--silence); }
.damage-split__item--snitch  .damage-split__value { color: var(--snitch); }
.damage-split__label {
  font-size: .74rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ----------------------------------------------------------------- table */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td {
  text-align: left;
  padding: .6rem .7rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table th {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 650;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table tbody tr.is-new { animation: flash 1.1s ease-out; }

@keyframes flash {
  from { background: rgba(110, 168, 254, .22); }
  to   { background: transparent; }
}

.empty { padding: 1rem .2rem 0; font-size: .88rem; }
.flush { margin: 0; }

/* --------------------------------------------------------- badges, misc. */

.badge {
  display: inline-block;
  padding: .16rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border: 1px solid transparent;
}
.badge--open    { color: var(--silence); border-color: rgba(74,222,128,.4);  background: rgba(74,222,128,.1); }
.badge--closed  { color: var(--muted);   border-color: var(--line);          background: var(--bg-soft); }
.badge--silence { color: var(--silence); border-color: rgba(74,222,128,.4);  background: rgba(74,222,128,.1); }
.badge--snitch  { color: var(--snitch);  border-color: rgba(248,113,113,.4); background: rgba(248,113,113,.1); }

.pill {
  display: inline-block;
  min-width: 1.5rem;
  padding: .05rem .45rem;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: .78rem;
  color: var(--muted);
  text-align: center;
}

.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  margin-bottom: 1.1rem;
  font-size: .9rem;
}
.alert--error { color: #fecaca; border-color: rgba(248,113,113,.45); background: rgba(248,113,113,.12); }
.alert--ok    { color: #bbf7d0; border-color: rgba(74,222,128,.45);  background: rgba(74,222,128,.1); }
.alert--warn  { color: #fde68a; border-color: rgba(251,191,36,.45);  background: rgba(251,191,36,.1); }

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transition: background .2s;
}
.live-dot.is-live { background: var(--silence); animation: pulse 2s infinite; }
.live-dot.is-down { background: var(--snitch); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

/* ----------------------------------------------------------------- share */

.share { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.share__main { flex: 1; min-width: 260px; }
.share__qr {
  border-radius: var(--radius-sm);
  background: #fff;
  padding: 6px;
  flex-shrink: 0;
}

@media (max-width: 560px) {
  .card { padding: 1.15rem; }
  h1 { font-size: 1.35rem; }
  .topbar__user { display: none; }
  .controls .btn { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
