/* Demo intake site: one dark design system for the player page and the admin. */
:root {
  --bg: #0b0e13;
  --surface: #12161d;
  --surface-2: #181d26;
  --surface-3: #1f2530;
  --surface-4: #262d3a;
  --well: #0c1016;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --field-line: #5f6877;
  --text: #e8ebf0;
  --muted: #8b94a3;
  --faint: #5f6877;
  --accent: #4a86e8;
  --accent-2: #6f9ff0;
  --accent-mid: #3b6fd6;
  --accent-deep: #2f63c9;
  --accent-soft: rgba(74, 134, 232, 0.14);
  --ok: #34c37a;
  --ok-soft: rgba(52, 195, 122, 0.14);
  --bad: #ef5a52;
  --bad-soft: rgba(239, 90, 82, 0.14);
  --warn: #f0b35a;
  --warn-soft: rgba(240, 179, 90, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --shadow: 0 12px 32px -20px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.03);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--text); font-size: 15px; line-height: 1.5;
  background: var(--bg);
  background-image: radial-gradient(900px 420px at 50% -120px, rgba(74, 134, 232, 0.18), transparent 70%);
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 28px 16px 56px; }
body.admin .wrap { max-width: 980px; }
.srOnly { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }

/* header */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand .mark {
  width: 34px; height: 34px; border-radius: var(--radius-sm); display: grid; place-items: center; flex: 0 0 auto;
  background: linear-gradient(145deg, var(--accent-mid), var(--accent-deep)); color: #fff; box-shadow: 0 6px 16px -8px rgba(47, 99, 201, 0.9);
}
.brand .mark svg { width: 18px; height: 18px; }
.who { display: none; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); min-width: 0; }
.who.on { display: inline-flex; }
.who .avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: #fff; flex: 0 0 auto;
  background: linear-gradient(145deg, var(--accent-mid), var(--accent-deep));
}
#whoNick { max-width: 55vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 14px; font-size: 18px; font-weight: 600; letter-spacing: -0.015em; }
.cardHead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.cardHead h2 { margin: 0; }
.hint { color: var(--muted); font-size: 13px; }
.eyebrow, th, .tileLabel, .rulesBody h3, .balanceLabel { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
a { color: var(--accent-2); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; text-decoration-color: rgba(111, 159, 240, 0.45); }
a:hover, a:focus-visible { text-decoration-color: currentColor; }
td a { text-decoration: none; }
td a:hover { text-decoration: underline; }
code { background: var(--well); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; font-size: 13px; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
button:focus-visible, a:focus-visible, summary:focus-visible, .linkBtn:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }

/* forms */
label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; margin: 12px 0 6px; }
.hint + label { margin-top: 12px; }
.fieldHint { margin-top: 6px; }
input[type=text], input[type=password] {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--field-line);
  background: var(--well); color: var(--text); font: inherit; font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: var(--muted); }
input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(74, 134, 232, 0.35); }
input[aria-invalid="true"] { border-color: var(--bad); }
button {
  margin: 0; padding: 11px 18px; border-radius: var(--radius-sm); border: 0; cursor: pointer; font: inherit; font-size: 15px; font-weight: 600;
  background: linear-gradient(180deg, var(--accent-mid), var(--accent-deep)); color: #fff; box-shadow: 0 6px 14px -8px rgba(47, 99, 201, 0.9);
  transition: filter .15s, transform .08s, background .15s, color .15s;
}
form > button[type=submit] { margin-top: 14px; }
button:hover { filter: brightness(1.12); }
button:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: default; filter: none; transform: none; }
button.secondary { background: var(--surface-3); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
button.secondary:hover { background: var(--surface-4); filter: none; }
button.small { padding: 7px 12px; font-size: 13px; }
.linkBtn { background: none; border: 0; padding: 0; margin: 0; box-shadow: none; color: var(--accent-2); font: inherit; font-size: 13px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkBtn:hover { filter: none; text-decoration-color: currentColor; }
.tabs { display: flex; width: max-content; max-width: 100%; gap: 2px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 14px; }
.tabs button { margin: 0; padding: 8px 16px; font-size: 14px; font-weight: 500; background: transparent; color: var(--muted); box-shadow: none; border-radius: calc(var(--radius-sm) - 4px); }
.tabs button:hover { color: var(--text); filter: none; }
.tabs button.active { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4); }
.tabs-sm { margin: 0; }
.tabs-sm button { padding: 6px 12px; font-size: 13px; }
.msg { font-size: 14px; }
.msg:not(:empty) { margin-top: 12px; }
.msg.ok, .msg .ok { color: var(--ok); }
.msg.bad, .msg .bad { color: var(--bad); }
.msg.busy { color: var(--muted); }
.formActions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.formActions button { margin: 0; }
.forgot { margin-top: 10px; }

/* balance */
.balanceCard { position: relative; overflow: hidden; }
.balanceCard::after {
  content: ''; position: absolute; inset: -40% -20% auto auto; width: 320px; height: 220px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(74, 134, 232, 0.22), transparent);
}
.balance { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 6px 0 10px; outline: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-2); font-size: 13px; font-weight: 500; }
.balanceMeta { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: 13px; }
.balanceMeta b { color: var(--text); font-weight: 600; }

/* upload */
.drop {
  display: block; position: relative; border: 2px dashed var(--field-line); border-radius: var(--radius-sm); padding: 28px 20px; text-align: center; color: var(--muted); cursor: pointer;
  transition: border-color .15s, background .15s, opacity .15s; margin: 0;
}
.drop > * { pointer-events: none; }
.drop:hover { border-color: rgba(74, 134, 232, 0.7); background: rgba(74, 134, 232, 0.05); }
.drop:focus-within { border-color: var(--accent); outline: 2px solid var(--accent-2); outline-offset: 2px; }
.drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.drop.disabled { opacity: .55; pointer-events: none; cursor: default; }
.drop input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.drop .icon { width: 40px; height: 40px; margin: 0 auto 10px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-2); }
.drop .icon svg { width: 20px; height: 20px; }
.drop strong { color: var(--text); font-weight: 600; font-size: 15px; display: block; margin-bottom: 4px; }
.drop .hint { display: block; }
@media (hover: none) { .drop .dnd { display: none; } }
.uploadList { margin-top: 12px; display: grid; gap: 6px; }
.uploadList:empty { margin-top: 0; }
.uploadList .row { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; padding: 8px 10px; border-radius: var(--radius-xs); background: var(--surface-2); }
.uploadList .row > div { min-width: 0; overflow-wrap: anywhere; }
.uploadList .row .st { flex: 0 0 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 700; margin-top: 1px; }
.uploadList .row.ok .st { background: var(--ok-soft); color: var(--ok); }
.uploadList .row.bad .st { background: var(--bad-soft); color: var(--bad); }
.uploadList .row.warn .st { background: var(--warn-soft); color: var(--warn); }
.uploadList .row.busy .st { border: 2px solid var(--line-strong); border-top-color: var(--accent-2); animation: spin .8s linear infinite; }
.uploadList .row .name { font-weight: 500; }
.uploadList .row .txt { color: var(--muted); }
.uploadList .row.ok .txt { color: var(--ok); }
.uploadList .row.bad .txt { color: var(--bad); }
.uploadList .row.warn .txt { color: var(--warn); }
.uploadList .row.total { background: transparent; padding-top: 4px; font-weight: 600; }
.uploadList .row.total .st { visibility: hidden; }
@keyframes spin { to { transform: rotate(360deg); } }

/* tables */
.tableWrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; overflow-wrap: anywhere; }
th { white-space: nowrap; }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
td { transition: background .12s; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.035); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; color: var(--muted); }
td .sub { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--surface-3); color: var(--muted); }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.paid { background: var(--ok-soft); color: var(--ok); }
.pill.unpaid { background: var(--warn-soft); color: var(--warn); }
.pill.rej { background: var(--bad-soft); color: var(--bad); }
.empty { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 4px 0 2px; }
.empty svg { width: 18px; height: 18px; color: var(--faint); flex: 0 0 auto; }

/* details / spoilers */
details.rules { padding: 0; }
details.rules summary, .tableView summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 10px; user-select: none; }
details.rules summary::-webkit-details-marker, .tableView summary::-webkit-details-marker { display: none; }
details.rules summary::before, .tableView summary::before { content: ''; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; margin-left: 2px; flex: 0 0 auto; }
details.rules[open] summary::before, .tableView[open] summary::before { transform: rotate(45deg); }
details.rules summary { padding: 15px 20px; font-size: 16px; font-weight: 600; }
details.rules summary:hover, .tableView summary:hover { color: var(--accent-2); }
.rulesBody { padding: 0 20px 18px; font-size: 14px; line-height: 1.55; }
.rulesBody h3 { margin: 16px 0 8px; }
.rulesBody h3:first-child { margin-top: 2px; }
.rulesBody ul { margin: 0; padding: 0; list-style: none; }
.rulesBody li { position: relative; padding-left: 18px; margin: 5px 0; }
.rulesBody li::before { content: ''; position: absolute; left: 3px; top: 9px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); opacity: .8; }
.rulesBody code { overflow-wrap: anywhere; word-break: break-all; }
.tableView { margin-top: 10px; }
.tableView summary { padding: 8px 0; font-size: 13px; font-weight: 500; color: var(--muted); }

/* footer */
footer.links { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; display: grid; gap: 8px; }
footer.links div { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
footer.links svg { width: 18px; height: 18px; color: var(--faint); flex: 0 0 auto; }
footer.links a { color: var(--accent-2); min-width: 0; overflow-wrap: anywhere; }

/* admin: summary chips, password block, stats */
.summaryRow { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.summaryRow .chip { background: var(--surface-3); color: var(--muted); }
.summaryRow .chip b { color: var(--text); }
.pwBlock { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius-xs); background: var(--ok-soft); margin-bottom: 12px; }
.pwBlock .hint { flex-basis: 100%; }
code.pw { background: var(--well); padding: 4px 9px; border-radius: 6px; font-size: 14px; color: var(--warn); user-select: all; letter-spacing: .04em; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tileValue { font-size: 30px; font-weight: 700; margin-top: 4px; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.chartWrap { position: relative; }
.chart { width: 100%; height: 240px; display: block; }
.chart .grid { stroke: rgba(255, 255, 255, 0.07); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--accent); transition: fill .12s; }
.chart .bar.hot { fill: var(--accent-2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .lbl { fill: var(--text); font-size: 11px; text-anchor: middle; font-weight: 600; }
.chart .note { fill: var(--muted); font-size: 13px; text-anchor: middle; }
#viewStats[aria-busy] .tiles, #viewStats[aria-busy] .chart { opacity: .5; }
.tip { position: absolute; pointer-events: none; background: var(--well); border: 1px solid var(--line-strong); border-radius: var(--radius-xs); padding: 6px 10px; font-size: 13px; white-space: nowrap; z-index: 2; box-shadow: 0 8px 20px -10px rgba(0, 0, 0, 0.8); }
.tip strong { font-size: 15px; }

@media (max-width: 600px) {
  /* the player's demo list becomes stacked cards (player page only: the admin has its own #demos table) */
  body:not(.admin) #demos thead { display: none; }
  body:not(.admin) #demos tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  body:not(.admin) #demos tr:last-child { border-bottom: 0; }
  body:not(.admin) #demos td { display: block; border: 0; padding: 0; min-width: 0; }
  body:not(.admin) #demos td:nth-child(2) { grid-column: 1; grid-row: 1 / span 2; }
  body:not(.admin) #demos td.num { grid-column: 2; grid-row: 1; }
  body:not(.admin) #demos td:nth-child(4) { grid-column: 2; grid-row: 2; text-align: right; }
  body:not(.admin) #demos td.nowrap { grid-column: 1 / span 2; grid-row: 3; font-size: 12px; }
  body:not(.admin) #demos tbody tr:hover td { background: transparent; }
  /* admin tables: sticky first column, hide the least important one */
  #users th:first-child, #users td:first-child, #members th:first-child, #members td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; white-space: nowrap; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; overflow-wrap: normal; }
  #users th:nth-child(6), #users td:nth-child(6) { display: none; }
  .wrap { padding: 18px 14px 44px; }
  .card { padding: 16px; border-radius: 12px; }
  details.rules summary { padding: 14px 16px; }
  .rulesBody { padding: 0 16px 16px; }
  .balance { font-size: 36px; }
  .tiles { grid-template-columns: 1fr; }
  th, td { padding: 8px 6px; font-size: 13px; }
  .tabs { width: 100%; }
  .tabs button { flex: 1; padding: 8px 10px; }
  .tabs-sm { width: auto; }
  .tabs-sm button { flex: 0 0 auto; }
  .drop { padding: 22px 14px; }
  .formActions { flex-direction: column; align-items: stretch; }
  .formActions button { width: 100%; }
  .formActions .hint { text-align: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .uploadList .row.busy .st { border-top-color: var(--line-strong); }
}
