/* UNO Night */
:root {
  --red: #e5322d;
  --yellow: #f5c400;
  --green: #3da14b;
  --blue: #1f6fd0;
  --gold: #f5c400;
  --silver: #b8c0cc;
  --bronze: #d08a4b;
  --radius: 16px;
  --radius-sm: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
:root[data-theme="light"] {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --text: #1b1a17;
  --muted: #6b675e;
  --border: #e3ded2;
  --primary: #1f6fd0;
  --primary-text: #ffffff;
  --primary-soft: #e4effc;
  --danger: #c4281f;
  --shadow: 0 1px 2px rgba(40, 30, 10, .06), 0 6px 20px rgba(40, 30, 10, .06);
  --good: #217a30;
  --bad: #c4281f;
}
:root[data-theme="dark"] {
  --bg: #13141a;
  --surface: #1c1e27;
  --surface-2: #262935;
  --text: #f1efe9;
  --muted: #a4a1b0;
  --border: #323548;
  --primary: #4f8ef7;
  --primary-text: #0b1020;
  --primary-soft: #1f2d4b;
  --danger: #ff6b62;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --good: #5fd170;
  --bad: #ff7a70;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
}
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.1rem); font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 750; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: .25rem 0 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: var(--surface-2); padding: .1em .4em; border-radius: 6px; font-size: .9em; }
pre { white-space: pre-wrap; background: var(--surface-2); padding: .75rem; border-radius: 8px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.good { color: var(--good); font-weight: 700; }
.bad { color: var(--bad); font-weight: 700; }
.inline { display: inline; margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row-gap { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.stack { display: grid; gap: 1rem; }
.narrow { max-width: 560px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 60%, transparent); outline-offset: 2px; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: .05em .45em;
  font: 700 .8em/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  text-align: center;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-width: 3px;
  border-radius: 7px;
}

/* ---------- layout ---------- */
.page { width: min(1160px, 100% - 2rem); margin: 0 auto; padding: 1.5rem 0 4rem; display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.25rem; align-content: start; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 1rem; }
.grid-2 { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .65rem max(1rem, calc((100% - 1160px) / 2));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 850; font-size: 1.15rem; }
.brand:hover { text-decoration: none; }
.brand-cards { position: relative; width: 34px; height: 30px; }
.brand-cards i { position: absolute; top: 2px; width: 16px; height: 24px; border-radius: 4px; border: 2px solid var(--bg); }
.brand-cards i:nth-child(1) { left: 0;   background: var(--red);    transform: rotate(-24deg); }
.brand-cards i:nth-child(2) { left: 6px; background: var(--yellow); transform: rotate(-8deg); }
.brand-cards i:nth-child(3) { left: 12px; background: var(--green);  transform: rotate(8deg); }
.brand-cards i:nth-child(4) { left: 18px; background: var(--blue);   transform: rotate(24deg); }
.nav { display: flex; gap: .25rem; flex: 1; }
.nav a { color: var(--muted); padding: .45rem .8rem; border-radius: 999px; font-weight: 650; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.topbar-actions { display: flex; align-items: center; gap: .5rem; }
.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }

/* ---------- buttons / inputs ---------- */
.btn {
  appearance: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1rem; border-radius: 999px;
  font: 650 .95rem var(--font); color: var(--text);
  background: var(--surface); border: 1px solid var(--border);
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { text-decoration: none; border-color: color-mix(in srgb, var(--text) 30%, var(--border)); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 88%, var(--text)); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-small { padding: .35rem .75rem; font-size: .85rem; }
.btn-block { width: 100%; }
.btn kbd { font-size: .72em; margin-left: .1rem; background: color-mix(in srgb, currentColor 14%, transparent); border-color: color-mix(in srgb, currentColor 25%, transparent); color: inherit; }
.icon-btn {
  display: inline-grid; place-items: center; width: 38px; height: 38px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 999px; font-size: 1rem;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.field { display: grid; gap: .35rem; }
.label { font-weight: 700; font-size: .9rem; }
.input {
  width: 100%; padding: .65rem .8rem; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
.input-small { width: auto; padding: .4rem .6rem; }
select.input { cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
  appearance: none; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  min-width: 2.6rem; padding: .4rem .9rem; border-radius: 999px; font: 700 .9rem var(--font);
  color: var(--muted); background: var(--surface); border: 1px solid var(--border);
}
.chip:hover { text-decoration: none; color: var(--text); }
.chip.is-on, .chip[aria-checked="true"] { background: var(--primary); color: var(--primary-text); border-color: transparent; }

/* ---------- cards / notices ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .9rem; }
.empty { text-align: center; display: grid; gap: .6rem; justify-items: center; padding: 2.5rem 1.25rem; }
.empty-art { font-size: 3rem; }
.notice { padding: .7rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.notice-ok { border-color: color-mix(in srgb, var(--green) 50%, var(--border)); background: color-mix(in srgb, var(--green) 12%, var(--surface)); }
.notice-error { border-color: color-mix(in srgb, var(--red) 55%, var(--border)); background: color-mix(in srgb, var(--red) 12%, var(--surface)); }
.notice-warn { border-color: color-mix(in srgb, var(--yellow) 60%, var(--border)); background: color-mix(in srgb, var(--yellow) 14%, var(--surface)); }
.notice-info { border-color: color-mix(in srgb, var(--blue) 45%, var(--border)); background: color-mix(in srgb, var(--blue) 11%, var(--surface)); }
.resume { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; }
.plain-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--border); }
.plain-list li:first-child { border-top: 0; }

/* ---------- avatars ---------- */
.avatar { width: var(--s, 48px); height: var(--s, 48px); border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-2); }
.avatar-emoji { display: inline-grid; place-items: center; font-size: calc(var(--s, 48px) * .55); line-height: 1; background: var(--c, #3b82f6); box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.player-link { display: inline-flex; align-items: center; gap: .6rem; color: var(--text); font-weight: 650; }
.player-link:hover { text-decoration: none; color: var(--primary); }

/* ---------- dashboard ---------- */
.leader { display: grid; gap: .9rem; position: relative; overflow: hidden; }
.leader::after { content: ""; position: absolute; inset: 0 0 auto auto; width: 140px; height: 140px; background: radial-gradient(circle at 70% 30%, color-mix(in srgb, var(--gold) 28%, transparent), transparent 70%); pointer-events: none; }
.leader-label { font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: .78rem; }
.leader-label .muted { text-transform: none; letter-spacing: 0; font-weight: 600; margin-left: .4rem; }
.leader-body { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.leader-avatars { display: flex; }
.leader-avatars .avatar { border: 3px solid var(--surface); margin-left: -12px; box-shadow: 0 0 0 3px var(--gold); }
.leader-avatars .avatar:first-child { margin-left: 0; }
.leader-name { font-size: 1.6rem; font-weight: 850; letter-spacing: -.02em; }
.crown { margin-left: .35rem; font-size: 1.2rem; }
.leader-empty { display: flex; align-items: center; gap: 1rem; }
.leader-trophy { font-size: 2.4rem; filter: grayscale(1); opacity: .5; }

.tiles { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); min-width: 0; }
.tile-value { font-size: 1.55rem; font-weight: 850; letter-spacing: -.02em; line-height: 1.15; overflow-wrap: anywhere; }
.tile-label { color: var(--muted); font-size: .85rem; margin-top: .2rem; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 750; padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table .rank { color: var(--muted); font-weight: 800; width: 2.2rem; }
.table tbody tr:nth-child(1) .rank { color: var(--gold); }
.table tbody tr:nth-child(2) .rank { color: var(--silver); }
.table tbody tr:nth-child(3) .rank { color: var(--bronze); }
.table-tight td, .table-tight th { padding: .45rem .5rem; }
.is-inactive { opacity: .6; }
.bar-col { min-width: 170px; }
.bar-col .bar { display: inline-block; vertical-align: middle; width: calc(100% - 3rem); }
.bar-num { display: inline-block; width: 2.6rem; text-align: right; }
.bar { display: block; height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue), var(--green)); }
.bar > .pos-fill.pos-1 { background: var(--gold); }
.bar > .pos-fill.pos-2 { background: var(--silver); }
.bar > .pos-fill.pos-3 { background: var(--bronze); }
.bar > .pos-fill.pos-4 { background: var(--muted); }

.recent, .history { list-style: none; margin: 0; padding: 0; display: grid; }
.recent li { display: flex; flex-wrap: wrap; gap: .4rem 1rem; align-items: baseline; padding: .65rem 0; border-top: 1px solid var(--border); }
.recent li:first-child { border-top: 0; }
.recent-when { min-width: 9.5rem; }
.recent-results { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.result-chip { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .65rem .2rem .5rem; border-radius: 999px; font-size: .85rem; background: var(--surface-2); border: 1px solid var(--border); }
.result-chip i { font-style: normal; font-weight: 800; color: var(--good); }
.result-chip .avatar { margin-left: -.25rem; }
.result-chip.pos-1 { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 16%, var(--surface)); }
.result-chip.pos-2 { border-color: var(--silver); }
.result-chip.pos-3 { border-color: var(--bronze); }

.history li { display: grid; gap: .5rem .75rem; grid-template-columns: 1fr auto; padding: .9rem 0; border-top: 1px solid var(--border); align-items: center; }
.history li:first-child { border-top: 0; }
.history-meta { display: grid; }
.history-results { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: .4rem; }
.history-actions { display: flex; gap: .35rem; grid-row: 1; grid-column: 2; }
.pager { display: flex; justify-content: center; align-items: center; gap: 1rem; padding-top: 1rem; }
.edit-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .35rem 0; }

/* ---------- players ---------- */
.player-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.player-card { display: grid; gap: 1rem; align-content: start; }
.player-card-top { display: flex; gap: 1rem; align-items: center; }
.player-card-id { min-width: 0; display: grid; gap: .3rem; }
.player-card h3 a { color: var(--text); }
.hotkey-badge { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--muted); }
.hotkey-badge.is-missing { color: var(--danger); }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0; }
.mini-stats div { background: var(--surface-2); border-radius: var(--radius-sm); padding: .5rem .6rem; }
.mini-stats dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.mini-stats dd { margin: 0; font-size: 1.1rem; font-weight: 800; }
.card-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.inactive-box summary { cursor: pointer; font-weight: 700; }
.profile { display: flex; gap: 1.25rem; align-items: center; }
.dist { list-style: none; margin: 0; padding: 0; display: grid; gap: .55rem; }
.dist li { display: grid; grid-template-columns: 5.5rem 1fr auto auto; gap: .6rem; align-items: center; }
.dist-label { font-weight: 700; font-size: .9rem; }

/* ---------- dialogs ---------- */
dialog.dialog {
  width: min(660px, calc(100vw - 1.5rem)); max-height: calc(100dvh - 1.5rem); overflow: auto;
  padding: 1.4rem; margin: auto;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 22px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .35);
}
dialog.dialog-small { width: min(440px, calc(100vw - 1.5rem)); }
dialog.dialog::backdrop { background: rgba(8, 10, 20, .6); backdrop-filter: blur(3px); }
dialog.dialog[open] { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1.1rem; animation: dlg-in .16s ease-out; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.dialog-title { font-size: 1.35rem; font-weight: 850; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: .5rem; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.pick-grid { display: grid; gap: .6rem; grid-template-columns: repeat(auto-fill, minmax(135px, 1fr)); }
.pick {
  appearance: none; cursor: pointer; position: relative; display: grid; justify-items: center; gap: .35rem;
  padding: .8rem .5rem; color: var(--text); font: inherit;
  background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius);
  transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.pick:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.pick[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-2px); }
.pick[aria-pressed="true"]::after { content: "✓"; position: absolute; top: 6px; right: 9px; font-weight: 900; color: var(--primary); }
.pick-name { font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.avatar-editor { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.avatar-preview { flex: none; }
.avatar-controls { flex: 1; min-width: 240px; display: grid; gap: .75rem; }
.tabs { display: inline-flex; padding: 3px; background: var(--surface-2); border-radius: 999px; justify-self: start; }
.tab { appearance: none; cursor: pointer; border: 0; background: transparent; color: var(--muted); font: 700 .85rem var(--font); padding: .35rem .9rem; border-radius: 999px; }
.tab.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 4px; }
.emoji-opt { appearance: none; cursor: pointer; font-size: 1.4rem; line-height: 1; padding: .35rem 0; background: transparent; border: 2px solid transparent; border-radius: 10px; }
.emoji-opt:hover { background: var(--surface-2); }
.emoji-opt.is-on { border-color: var(--primary); background: var(--primary-soft); }
.swatches { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.swatch { appearance: none; cursor: pointer; width: 28px; height: 28px; border-radius: 50%; background: var(--c); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.swatch.is-on { box-shadow: 0 0 0 3px var(--primary); }

.hotkey-input { display: flex; gap: .5rem; align-items: center; }
.hk-display { cursor: pointer; font-weight: 800; letter-spacing: .04em; text-align: center; max-width: 12rem; caret-color: transparent; }
.hotkey-input.is-listening .hk-display { border-color: var(--primary); background: var(--primary-soft); }
.hk-msg.is-bad { color: var(--danger); font-weight: 650; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 100; left: 50%; bottom: 1.25rem; transform: translateX(-50%); display: grid; gap: .5rem; width: min(480px, calc(100vw - 2rem)); pointer-events: none; }
.toast { padding: .7rem 1rem; border-radius: var(--radius-sm); background: var(--text); color: var(--bg); font-weight: 650; box-shadow: var(--shadow); animation: toast-in .2s ease-out; }
.toast-error { background: var(--red); color: #fff; }
.toast-warn { background: var(--yellow); color: #1b1a17; }
.toast.is-leaving { opacity: 0; transform: translateY(8px); transition: all .3s ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- login / install ---------- */
.auth-body .page { width: 100%; padding: 0; }
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; align-content: center; gap: 1.5rem; padding: 1.5rem; background:
  radial-gradient(900px 500px at 10% 0%, color-mix(in srgb, var(--red) 18%, transparent), transparent 60%),
  radial-gradient(900px 500px at 100% 100%, color-mix(in srgb, var(--blue) 22%, transparent), transparent 60%); }
.auth-card { width: min(420px, 100%); display: grid; gap: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 2rem; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 1.8rem; }
.auth-hero { display: flex; justify-content: center; height: 110px; }
.fan { width: 70px; height: 100px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; font-size: 1.7rem; color: #fff; border: 4px solid #fff; box-shadow: 0 8px 20px rgba(0, 0, 0, .25); margin: 0 -14px; transform-origin: 50% 120%; }
.fan-1 { background: var(--red);    transform: rotate(-24deg); }
.fan-2 { background: var(--blue);   transform: rotate(-8deg); }
.fan-3 { background: var(--green);  transform: rotate(8deg); }
.fan-4 { background: var(--yellow); transform: rotate(24deg); color: #1b1a17; }
.theme-link { justify-self: center; }

/* ---------- scoreboard ---------- */
.play-body .page { width: min(1320px, 100% - 2rem); }
.play { display: grid; gap: 1rem; }
.play-head { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; align-items: flex-end; }
.play-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.play-hint { font-size: 1.05rem; font-weight: 650; padding: .7rem 1rem; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--text); margin: 0; }
.play-grid { display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.board { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
.pcard {
  appearance: none; cursor: pointer; position: relative; display: grid; justify-items: center; align-content: center; gap: .55rem;
  min-height: 220px; padding: 1.2rem .8rem; color: var(--text); font: inherit;
  background: var(--surface); border: 3px dashed var(--border); border-radius: 22px;
  transition: transform .12s ease, border-color .15s ease, background .15s ease, opacity .15s ease;
}
.pcard:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--border)); transform: translateY(-2px); }
.pcard-name { font-size: 1.25rem; font-weight: 850; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard-press { color: var(--muted); font-weight: 650; }
.pcard-press kbd { font-size: 1.1rem; padding: .1em .65em; color: var(--text); }
.pcard-rank { font-size: 2.6rem; font-weight: 900; line-height: 1; letter-spacing: -.03em; }
.pcard-pts { font-weight: 800; color: var(--muted); }
.pcard.is-ranked { border-style: solid; }
.pcard.pos-1 { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 15%, var(--surface)); }
.pcard.pos-1 .pcard-rank { color: var(--gold); }
.pcard.pos-2 { border-color: var(--silver); background: color-mix(in srgb, var(--silver) 14%, var(--surface)); }
.pcard.pos-2 .pcard-rank { color: var(--silver); }
.pcard.pos-3 { border-color: var(--bronze); background: color-mix(in srgb, var(--bronze) 13%, var(--surface)); }
.pcard.pos-3 .pcard-rank { color: var(--bronze); }
.pcard.pos-4 { border-color: var(--border); opacity: .85; }
.pcard.pos-4 .pcard-rank { color: var(--muted); font-size: 2rem; }
.pop { animation: pop .28s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { 0% { transform: scale(.88); } 100% { transform: scale(1); } }
.shake { animation: shake .3s; }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

.side { display: grid; gap: 1rem; }
.panel { display: grid; gap: .75rem; padding: 1rem 1.1rem; }
.panel h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.ranking, .session-list, .legend { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.rank-row, .session-row { display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem; border-radius: var(--radius-sm); background: var(--surface-2); }
.rank-row.is-empty { background: transparent; border: 1px dashed var(--border); }
.rank-pos { width: 2.3rem; font-weight: 850; }
.rank-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 650; }
.rank-pts { font-weight: 850; font-variant-numeric: tabular-nums; }
.rank-row.pos-1 .rank-pos { color: var(--gold); }
.rank-row.pos-2 .rank-pos { color: var(--silver); }
.rank-row.pos-3 .rank-pos { color: var(--bronze); }
.session-row .rank-pos { width: 1.4rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: .6rem; }
.legend-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-sys { padding-top: .4rem; border-top: 1px solid var(--border); }
.legend-sys ~ .legend-sys { border-top: 0; padding-top: 0; }

.result-overlay { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem; background: rgba(8, 10, 20, .7); backdrop-filter: blur(6px); }
.result-overlay[hidden] { display: none; }
.result-card { width: min(520px, 100%); display: grid; gap: 1rem; padding: 1.75rem; background: var(--surface); border: 1px solid var(--border); border-radius: 26px; box-shadow: 0 30px 80px rgba(0, 0, 0, .45); animation: dlg-in .25s cubic-bezier(.2, 1.2, .4, 1); }
.result-eyebrow { text-transform: uppercase; letter-spacing: .12em; font-weight: 800; font-size: .75rem; color: var(--muted); margin: 0; }
.result-card h2 { font-size: 2rem; font-weight: 900; }
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.result-row { display: flex; align-items: center; gap: .8rem; padding: .55rem .8rem; border-radius: 14px; background: var(--surface-2); }
.result-pos { width: 2.8rem; font-weight: 900; font-size: 1.15rem; }
.result-name { flex: 1; font-weight: 750; font-size: 1.1rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-pts { font-size: 1.25rem; font-weight: 900; }
.result-row.pos-1 { background: color-mix(in srgb, var(--gold) 20%, var(--surface)); }
.result-row.pos-1 .result-pos, .result-row.pos-1 .result-pts { color: var(--gold); }
.result-row.pos-2 .result-pos { color: var(--silver); }
.result-row.pos-3 .result-pos { color: var(--bronze); }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .play-grid { grid-template-columns: 1fr; }
  .side { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 720px) {
  .topbar { gap: .5rem; }
  .nav { order: 3; flex: 1 1 100%; overflow-x: auto; }
  .hide-sm { display: none; }
  .bar-col { min-width: 120px; }
  .topbar-actions { margin-left: auto; }
  .brand-name { display: none; }
  .dist li { grid-template-columns: 4.5rem 1fr auto; }
  .dist li .muted { display: none; }
  .profile { flex-direction: column; text-align: center; }
  .pcard { min-height: 180px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
