/* Ma Sói – Dark Fantasy theme. Mobile-first. */
:root {
  color-scheme: dark;
  --black: #000;
  --plum: #150a1e;
  --plum-2: #20112d;
  --plum-3: #2c1840;
  --line: #3e2650;
  --bone: #ece3d3;
  --mist: #a99fb6;
  --blood: #a50e26;
  --blood-hi: #d01d39;
  --blood-deep: #4f0711;
  --violet: #6b35a0;
  --gold: #c9a24a;
  --f-villager: #4cc46a; /* xanh lá */
  --f-wolf: #ec3550; /* đỏ */
  --f-neutral: #a08cf0; /* tím */
  --f-solo: #4a90f0; /* xanh lam */
  --f-unknown: #f0c93c; /* vàng */
  --ok: #62c27f;
  --warn: #e0a83e;
  --font-display: 'Times New Roman', Times, serif;
  --font-mono: 'Times New Roman', Times, serif;
  --font-body: 'Times New Roman', Times, serif;
  --tap: 44px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--black) radial-gradient(ellipse 90% 45% at 50% -8%, rgba(107, 53, 160, .32), transparent 70%) no-repeat fixed;
  color: var(--bone);
  font: 400 17px/1.5 var(--font-body);
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; } /* form controls don't inherit fonts by default */
a { color: var(--gold); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
p { margin: 0; }

.display { font-family: var(--font-display); font-weight: 700; letter-spacing: .01em; }
.page-title { font-size: 2rem; margin: 4px 0 12px; }
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--mist); margin: 24px 0 10px; }
.muted { color: var(--mist); }
.small { font-size: .88rem; }
.center { text-align: center; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1 1 auto; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 16px;
  background: rgba(0, 0, 0, .86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.brand { font: 700 1.6rem/1 var(--font-display); color: var(--bone); text-decoration: none; }
.brand small { font: 500 .85rem var(--font-body); color: var(--mist); margin-left: 6px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; min-width: 0; }
.who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 34vw; font-weight: 500; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); flex: none; }
.conn.off { background: var(--blood-hi); box-shadow: 0 0 0 3px rgba(208, 29, 57, .25); }

.wrap { max-width: 560px; margin: 0 auto; padding: 16px 16px 64px; }
.wrap-wide { max-width: 1280px; margin: 0 auto; padding: 16px 16px 64px; }

/* ---------- buttons & inputs ---------- */
.btn, .icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--plum-2); color: var(--bone);
  font: 500 1rem var(--font-body); text-decoration: none;
  cursor: pointer; user-select: none; touch-action: manipulation;
}
.btn:hover:not(:disabled), .icon-btn:hover:not(:disabled) { border-color: var(--violet); background: var(--plum-3); }
.btn:disabled, .icon-btn:disabled { opacity: .42; cursor: not-allowed; }
.btn-primary { background: var(--blood); border-color: var(--blood-hi); font-weight: 700; }
.btn-primary:hover:not(:disabled) { background: var(--blood-hi); border-color: #ff5a72; }
.btn-danger { background: transparent; border-color: var(--blood); color: #ff8d9d; }
.btn-danger:hover:not(:disabled) { background: var(--blood-deep); border-color: var(--blood-hi); }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .92rem; }
.btn-xl { min-height: 60px; width: 100%; font-size: 1.25rem; border-radius: 12px; }
.icon-btn { padding: 0 8px; background: transparent; border-color: transparent; white-space: nowrap; }
.brand { white-space: nowrap; }
@media (max-width: 420px) {
  .topbar { padding: 6px 10px; gap: 6px; }
  .topbar-right { gap: 2px; }
  .brand small { display: none; }
  .who { max-width: 26vw; font-size: .92rem; }
}
.btn.is-on { background: var(--violet); border-color: var(--violet); }

.input {
  width: 100%; min-height: var(--tap); padding: 8px 12px;
  background: var(--plum); color: var(--bone);
  border: 1px solid var(--line); border-radius: 8px;
  font: 400 1rem var(--font-body);
}
.input:focus { border-color: var(--violet); outline: none; box-shadow: 0 0 0 3px rgba(107, 53, 160, .35); }
textarea.input { min-height: 110px; resize: vertical; }
select.input { appearance: auto; }
.field { display: grid; gap: 4px; }
.field > span, .field > .field-title { font-size: .92rem; color: var(--mist); }
.fields { display: grid; gap: 12px; }
@media (min-width: 640px) { .fields.two { grid-template-columns: 1fr 1fr; } }

/* ---------- chips & badges ---------- */
.fchip, .badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 9px; border-radius: 999px;
  font-size: .8rem; font-weight: 700; line-height: 1.6; white-space: nowrap;
  border: 1px solid currentColor;
}
.fchip.f-villager { color: var(--f-villager); }
.fchip.f-wolf { color: var(--f-wolf); }
.fchip.f-neutral { color: var(--f-neutral); }
.fchip.f-solo { color: var(--f-solo); }
.fchip.f-unknown { color: var(--f-unknown); }
.badge { border-color: transparent; background: var(--plum-3); color: var(--bone); }
.badge-ok { background: rgba(98, 194, 127, .16); color: var(--ok); }
.badge-bad { background: rgba(208, 29, 57, .2); color: #ff8d9d; }
.badge-warn { background: rgba(224, 168, 62, .16); color: var(--warn); }
.badge-info { background: rgba(107, 53, 160, .3); color: #d4bff2; }
.badge-gold { background: rgba(201, 162, 74, .18); color: var(--gold); }
.badge-dead { background: var(--blood-deep); color: #ffb3bf; }

/* ---------- banners & notices ---------- */
.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 14px; margin: 10px 0;
  border-radius: 10px; border-left: 4px solid var(--violet);
  background: var(--plum-2);
}
.banner > .grow { flex: 1 1 200px; }
.banner-warn { border-left-color: var(--warn); }
.banner-ok { border-left-color: var(--ok); }
.banner-dead { border-left-color: var(--blood-hi); background: var(--blood-deep); }

.notice { text-align: center; padding: 32px 8px; }
.notice h2 { font-size: 2rem; margin: 20px 0 8px; }
.notice p { max-width: 36ch; margin: 0 auto; color: var(--mist); }
.notice-art { width: 120px; margin: 0 auto; transform: rotate(-6deg); }
.notice .actions { margin-top: 20px; display: grid; gap: 10px; justify-items: center; }

/* ---------- role card (the signature element) ---------- */
.rcard {
  --fc: var(--mist);
  position: relative;
  display: flex; flex-direction: column;
  width: 100%; max-width: 340px; margin: 0 auto;
  border-radius: 16px; overflow: hidden;
  background: linear-gradient(180deg, var(--plum-2), #0a0510);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 4px #000, 0 0 0 5px color-mix(in srgb, var(--fc) 55%, transparent), 0 18px 48px rgba(0, 0, 0, .7);
}
.rcard.f-villager, .cat-item.f-villager, .pcard.f-villager, .codex .f-villager { --fc: var(--f-villager); }
.rcard.f-wolf, .cat-item.f-wolf, .pcard.f-wolf, .codex .f-wolf { --fc: var(--f-wolf); }
.rcard.f-neutral, .cat-item.f-neutral, .pcard.f-neutral, .codex .f-neutral { --fc: var(--f-neutral); }
.rcard.f-solo, .cat-item.f-solo, .pcard.f-solo, .codex .f-solo { --fc: var(--f-solo); }
.rcard.f-unknown, .cat-item.f-unknown, .pcard.f-unknown, .codex .f-unknown { --fc: var(--f-unknown); }
.rcard-art { aspect-ratio: 5 / 4; background: #07030b; overflow: hidden; }
.rcard-art img { width: 100%; height: 100%; object-fit: cover; }
.rcard-body { padding: 14px 16px 18px; text-align: center; border-top: 1px solid color-mix(in srgb, var(--fc) 40%, transparent); }
.rcard-name { font: 700 2.1rem/1.05 var(--font-display); color: var(--bone); margin-bottom: 8px; }
.rcard-name { overflow-wrap: anywhere; }
.rcard-desc { margin-top: 10px; color: var(--mist); text-align: left; white-space: pre-line; max-width: 60ch; max-height: 40vh; overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; }
.rcard.compact .rcard-name { font-size: 1.5rem; }
.rcard.is-dead { filter: grayscale(.85) brightness(.55); }
.rcard.is-dead::after {
  content: 'Đã chết';
  position: absolute; top: 34%; left: 50%; transform: translate(-50%, -50%) rotate(-12deg);
  padding: 4px 18px; border: 3px solid var(--blood-hi); border-radius: 6px;
  font: 700 2rem var(--font-display); color: #ff6b80; background: rgba(0, 0, 0, .55);
}

.ph-art { width: 100%; height: 100%; display: grid; place-items: center; color: var(--fc, var(--mist));
  background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--fc, var(--violet)) 18%, transparent), transparent 62%), #07030b; }
.ph-art svg { width: 58%; height: 58%; }

.card-back {
  position: relative; width: 100%; aspect-ratio: 5 / 7; border-radius: 14px; overflow: hidden;
  display: grid; place-items: center;
  border: 1px solid #5a2a3a;
  box-shadow: 0 0 0 3px #000, 0 0 0 4px var(--blood-deep), 0 12px 32px rgba(0, 0, 0, .7);
  background:
    radial-gradient(circle at 50% 46%, rgba(208, 29, 57, .35), transparent 38%),
    repeating-linear-gradient(45deg, rgba(107, 53, 160, .22) 0 2px, transparent 2px 12px),
    repeating-linear-gradient(-45deg, rgba(107, 53, 160, .22) 0 2px, transparent 2px 12px),
    linear-gradient(160deg, #2a0f2f, #0b0410 70%);
}
.card-back svg { width: 46%; color: var(--blood-hi); filter: drop-shadow(0 0 12px rgba(208, 29, 57, .6)); }
.card-back .cb-label { position: absolute; bottom: 10%; left: 0; right: 0; text-align: center; font-weight: 700; color: var(--bone); }

.card-toggle { display: block; width: 100%; max-width: 340px; margin: 0 auto; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; text-align: inherit; border-radius: 16px; }
.card-toggle .card-back { max-width: 340px; margin: 0 auto; }

/* ---------- reveal overlay ---------- */
.reveal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center; align-content: center; gap: 18px;
  background: rgba(0, 0, 0, .9);
  cursor: pointer;
  animation: fade-in .2s ease-out;
}
.reveal-stage { position: relative; width: min(72vw, 300px); aspect-ratio: 5 / 7; perspective: 1200px; }
.rv-back { position: absolute; inset: 0; }
.reveal.shuffling .rv-b0 { animation: shuffle-l .45s ease-in-out infinite alternate; }
.reveal.shuffling .rv-b1 { animation: shuffle-r .45s ease-in-out .15s infinite alternate; }
.reveal.shuffling .rv-b2 { animation: shuffle-l .45s ease-in-out .3s infinite alternate; }
.rv-flip { position: absolute; inset: 0; }
.rv-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3, .7, .2, 1); }
.reveal.flipped .rv-inner { transform: rotateY(180deg); }
.rv-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; align-items: center; }
.rv-backface { transform: rotateY(180deg); }
.rv-backface .rcard-desc { display: none; }
.reveal-hint { color: var(--mist); font-size: .9rem; }
@keyframes shuffle-l { from { transform: translateX(-38%) rotate(-9deg); } to { transform: translateX(12%) rotate(4deg); } }
@keyframes shuffle-r { from { transform: translateX(38%) rotate(9deg); } to { transform: translateX(-12%) rotate(-4deg); } }
@keyframes fade-in { from { opacity: 0; } }

/* ---------- player: login, draw, catalog ---------- */
.login h1 { font: 700 3.4rem/1 var(--font-display); text-align: center; margin: 24px 0 4px; }
.login .lead { text-align: center; color: var(--mist); margin-bottom: 24px; }
.login section { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgba(21, 10, 30, .8); }
.login section + section { margin-top: 16px; }
.login h2 { font-size: 1.1rem; margin-bottom: 10px; }
.pick-list { display: grid; gap: 6px; }
.pick-list:empty { display: none; }
.pick { justify-content: flex-start; font-size: 1.1rem; }
.emoji-row { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-btn { width: 44px; height: 44px; border: 1px solid transparent; border-radius: 8px; background: var(--plum); font-size: 1.4rem; cursor: pointer; }
.emoji-btn:hover, .emoji-btn.is-on { border-color: var(--violet); }
.emoji-input { font-size: 1.4rem; width: 76px; flex: 0 0 76px; text-align: center; }
.row > .grow { flex: 1 1 140px; min-width: 0; }

.draw-box { margin: 18px 0 8px; display: grid; gap: 6px; text-align: center; }
.catalog { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.cat-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: start;
  padding: 10px; border-radius: 10px; background: var(--plum); border: 1px solid var(--line);
  border-left: 3px solid var(--fc, var(--line));
}
.cat-item.is-out { opacity: .55; }
.cat-thumb { width: 64px; aspect-ratio: 4 / 5; border-radius: 6px; overflow: hidden; background: #07030b; }
.cat-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cat-head { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cat-name { font: 700 1.25rem/1.1 var(--font-display); }
.cat-stock { font-size: .9rem; color: var(--mist); }
.cat-item.is-out .cat-stock { color: #ff8d9d; font-weight: 700; }
.cat-info { min-width: 0; }
.cat-name { overflow-wrap: anywhere; }
.cat-info details { margin-top: 4px; font-size: .92rem; color: var(--mist); }
.cat-info details p { white-space: pre-line; max-height: 40vh; overflow-y: auto; }
.cat-info summary { cursor: pointer; min-height: 28px; }
.catalog-wrap { margin-top: 24px; }

/* roles: one column per faction (4 on desktop, 2 on phone) */
.fcols { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 560px) { .fcols { grid-template-columns: 1fr 1fr; gap: 8px; } }
.fcol-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; margin: 0 0 8px; padding-bottom: 6px; border-bottom: 2px solid var(--fc, var(--line)); }
.fcol.f-villager { --fc: var(--f-villager); } .fcol.f-wolf { --fc: var(--f-wolf); } .fcol.f-neutral { --fc: var(--f-neutral); }
.fcol.f-solo { --fc: var(--f-solo); } .fcol.f-unknown { --fc: var(--f-unknown); }
.fcol .cat-item { grid-template-columns: 44px 1fr; gap: 8px; padding: 8px; }
.fcol .cat-item > .btn { grid-column: 1 / -1; }
.fcol .cat-thumb { width: 44px; }
.fcol .cat-info { display: grid; gap: 2px; }
.fcol .cat-name { font-size: 1.05rem; }
.fcol .cat-stock { font-size: .8rem; }
.wrap-wide > section > .draw-box, .wrap-wide > section > .banner { max-width: 560px; margin-inline: auto; }

/* 3 secret-digit boxes */
/* login: boxes span the same width as the name field so the edges line up */
.pin-boxes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: min(100%, 260px); }
.login .pin-boxes { width: 100%; }
/* in-game code screen: boxes + button as one centred block */
.pin-form { width: min(100%, 280px); margin-inline: auto; }
.pin-form .pin-boxes, .pin-form .btn { width: 100%; }
.pin-box { width: 100%; height: 56px; padding: 0; text-align: center; font: 700 1.6rem var(--font-mono); }
.catalog-wrap > summary { cursor: pointer; font-weight: 700; color: var(--mist); padding: 10px 0; }

.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hist li { padding: 10px 12px; border-radius: 10px; background: var(--plum); border: 1px solid var(--line); display: grid; gap: 4px; }
.hist .h-title { font-weight: 700; }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 80; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(92vw, 420px); display: grid; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; padding: 12px 16px; border-radius: 10px;
  background: var(--plum-3); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .6);
  animation: toast-in .2s ease-out;
}
.toast-error { border-color: var(--blood-hi); background: #2a0710; }
.toast-warn { border-color: var(--warn); }
.toast-ok { border-color: var(--ok); }
.toast-alert { border: 2px solid var(--blood-hi); background: #2a0710; font-weight: 700; font-size: 1.05rem; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- modal ---------- */
dialog.modal {
  width: min(94vw, 560px); max-height: 90vh; padding: 0;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--plum); color: var(--bone);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .8);
}
dialog.modal.wide { width: min(96vw, 980px); }
dialog.modal::backdrop { background: rgba(0, 0, 0, .75); }
.modal-inner { display: flex; flex-direction: column; max-height: 90vh; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.modal-head h2 { font: 700 1.6rem var(--font-display); flex: 1; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-actions { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }

/* ---------- GM ---------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; padding: 0 16px; border-bottom: 1px solid var(--line); background: rgba(0, 0, 0, .6); }
.tab { min-height: var(--tap); padding: 0 14px; border: 0; border-bottom: 3px solid transparent; background: none; color: var(--mist); font: 700 1rem var(--font-body); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--bone); border-bottom-color: var(--blood-hi); }
.tab-ico { margin-right: 8px; }
/* GM: tabs as a left sidebar on wide screens; a scrollable top row on phones. */
@media (min-width: 900px) {
  .gm-layout { display: flex; align-items: flex-start; }
  .gm-layout > .tabs {
    position: sticky; top: var(--topbar-h, 61px); flex: 0 0 210px; height: calc(100vh - var(--topbar-h, 61px));
    flex-direction: column; gap: 4px; padding: 14px 10px; overflow: hidden auto;
    border-bottom: 0; border-right: 1px solid var(--line);
  }
  .gm-layout > .tabs .tab { display: flex; align-items: center; text-align: left; padding: 0 12px; border-bottom: 0; border-left: 3px solid transparent; border-radius: 0 10px 10px 0; }
  .gm-layout > .tabs .tab:hover { color: var(--bone); background: var(--plum-2); }
  .gm-layout > .tabs .tab[aria-selected="true"] { border-left-color: var(--blood-hi); background: color-mix(in srgb, var(--blood-hi) 14%, transparent); }
  .gm-layout > main { flex: 1; min-width: 0; }
}

.dash-head { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 12px; }
.dash-head h2 { font: 700 2rem var(--font-display); }
.dash-head .row { margin-left: auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); gap: 8px; margin: 0 0 12px; }
.stat { padding: 8px 10px; border-radius: 10px; background: var(--plum); border: 1px solid var(--line); }
.stat b { display: block; font-size: 1.5rem; line-height: 1.1; }
.stat span { font-size: .85rem; color: var(--mist); }
.stat.f-villager b { color: var(--f-villager); }
.stat.f-wolf b { color: var(--f-wolf); }
.stat.f-neutral b { color: var(--f-neutral); }
.stat.f-unknown b { color: var(--f-unknown); }
.stat.f-solo b { color: var(--f-solo); }
.stock { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.stock .badge.out { background: var(--blood-deep); color: #ffb3bf; }
.fields > * { min-width: 0; } /* let wide children (5-column role picker) scroll inside, not widen the page */
/* Roles grouped by faction (create screen + game screen) */
.faction-tbl th { width: 1%; color: var(--fc); background: color-mix(in srgb, var(--fc) 10%, var(--plum-2)); border-left: 3px solid var(--fc); }
.faction-tbl td.num { width: 1%; color: var(--fc); font-weight: 700; }
.faction-roles { display: flex; flex-wrap: wrap; gap: 6px; }
.faction-tbl thead th { width: auto; color: var(--mist); background: var(--plum-2); border-left: 0; }
.faction-tbl tfoot th, .faction-tbl tfoot td { color: var(--bone); font-weight: 700; background: var(--plum-2); border-left: 0; border-top: 1px solid var(--line); }
.faction-roles .badge.out { background: var(--blood-deep); color: #ffb3bf; }

.panels { display: grid; gap: 12px; margin-bottom: 12px; }
@media (min-width: 900px) { .panels { grid-template-columns: 1fr 1fr; } }
.panel { padding: 12px; border-radius: 12px; background: var(--plum); border: 1px solid var(--line); }
.panel:empty { display: none; }
.panel h3 { font-size: 1.05rem; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.panel.hot { border-color: var(--blood-hi); }
.panel-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--line); }
.panel-row:first-of-type { border-top: 0; }
.panel-row .grow { min-width: 140px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.toolbar .input { width: auto; flex: 1 1 160px; }
.toolbar select.input { flex: 0 1 180px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { min-height: var(--tap); padding: 0 12px; border: 0; background: transparent; color: var(--mist); font: 500 .95rem var(--font-body); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--violet); color: var(--bone); }

/* GM cards grouped in one column per faction, tinted with the faction colour */
.members.fgroups { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); align-items: start; }
.fgroup { --fc: var(--line); display: grid; gap: 10px; padding: 10px; border-radius: 12px;
  border-top: 3px solid var(--fc); background: color-mix(in srgb, var(--fc) 9%, transparent); }
.fgroup.f-villager { --fc: var(--f-villager); } .fgroup.f-wolf { --fc: var(--f-wolf); } .fgroup.f-neutral { --fc: var(--f-neutral); }
.fgroup.f-solo { --fc: var(--f-solo); } .fgroup.f-unknown { --fc: var(--f-unknown); }
.fgroup-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin: 0; }
/* Dân Làng is the biggest faction: twice as wide, cards in 2 columns (not on narrow screens) */
@media (min-width: 760px) {
  .fgroup.f-villager { grid-column: span 2; grid-template-columns: 1fr 1fr; }
  .fgroup.f-villager > .fgroup-head { grid-column: 1 / -1; }
}
.pcard {
  --fc: var(--line);
  position: relative; padding: 12px; border-radius: 12px;
  background: var(--plum); border: 1px solid var(--line); border-top: 3px solid var(--fc);
  display: grid; gap: 8px; align-content: start;
}
.pcard-top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.pcard-emoji { font-size: 2rem; line-height: 1; }
.pcard-label { font-weight: 700; overflow-wrap: anywhere; }
.pcard-role { font: 700 1.3rem/1.1 var(--font-display); }
.pcard.is-dead { background: #0b060f; }
.pcard.is-dead > :not(.actions):not(.pcard-badge) { opacity: .4; filter: grayscale(1); }
.pcard-badge { position: absolute; top: 10px; right: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.actions .btn { min-height: 38px; padding: 0 10px; font-size: .9rem; }

.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .95rem; }
.tbl th, .tbl td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { color: var(--mist); font-weight: 700; background: var(--plum-2); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.is-dead td:not(:last-child) { opacity: .45; }
.tbl td.num, .tbl th.num { text-align: right; }

.cfg-list { display: grid; gap: 6px; }
.cfg-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; background: var(--plum-2); }
.cfg-row.on { outline: 1px solid var(--violet); }
.cfg-name { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cfg-name b { font: 700 1.15rem var(--font-display); }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 40px; height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--plum); color: var(--bone); font-size: 1.2rem; cursor: pointer; }
.qty button:disabled { opacity: .35; }
.qty output { min-width: 2ch; text-align: center; font-weight: 700; font-size: 1.1rem; }
.cfg-board { display: grid; grid-template-columns: repeat(5, minmax(200px, 1fr)); gap: 10px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.cfg-col { min-width: 0; padding: 8px; border: 1px solid color-mix(in srgb, var(--fc) 40%, transparent); border-radius: 12px; background: color-mix(in srgb, var(--fc) 6%, transparent); }
.cfg-col-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 8px; padding-bottom: 6px; border-bottom: 1px solid color-mix(in srgb, var(--fc) 45%, transparent); }
.cfg-col-head span { color: var(--fc); font: 700 1.1rem var(--font-display); }
.cfg-col-head small { color: var(--mist); margin-left: auto; }
.cfg-board .cfg-name b { font-size: 1rem; }
.cfg-board .qty button { width: 32px; height: 32px; }
.cfg-total { position: sticky; bottom: 0; padding: 10px 0; background: var(--plum); }

.role-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.role-tile { display: grid; gap: 8px; align-content: start; }
.role-tile .rcard-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.role-tile .rcard { box-shadow: 0 0 0 3px #000, 0 0 0 4px color-mix(in srgb, var(--fc) 50%, transparent); }

/* Role codex (GM → Role): faction sidebar + one grid per faction. Phone: sidebar becomes a chip row. */
.codex { display: grid; gap: 18px; margin-top: 14px; }
.codex-side { display: grid; gap: 10px; align-content: start; }
.codex-nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.codex-nav-item {
  --fc: var(--bone);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex: none;
  min-height: var(--tap); padding: 0 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--plum-2); color: var(--fc); font: 700 .95rem var(--font-body); cursor: pointer;
}
.codex-nav-item b { color: var(--mist); font-weight: 700; }
.codex-nav-item.on { background: color-mix(in srgb, var(--fc) 18%, var(--plum-2)); border-color: var(--fc); }
.codex-sec + .codex-sec { margin-top: 28px; }
.codex-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; padding-bottom: 6px; border-bottom: 1px solid color-mix(in srgb, var(--fc) 45%, transparent); }
.codex-head .display { color: var(--fc); font-size: 1.6rem; }
.codex-head small { color: var(--mist); }
.codex .role-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.codex-tile { padding: 0; border: 0; background: none; color: inherit; text-align: inherit; cursor: pointer; border-radius: 14px; transition: transform .15s; }
.codex-tile:hover { transform: translateY(-3px); }
.codex-tile .rcard { height: 100%; }
/* Drive card images are 3:2 with the portrait in the left 40% and rules text on the right: show only the portrait. */
.codex-tile .rcard-art { aspect-ratio: 3 / 4; position: relative; overflow: hidden; }
/* card PNG = art on its left half (3:4) + rules text on the right: 200% width shows exactly the art */
.codex-tile .rcard-art img { position: absolute; left: 0; top: 50%; width: 200%; max-width: none; height: auto; transform: translateY(-50%); object-fit: initial; }
.codex-tile .rcard-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .9rem; line-height: 1.45; }
.codex-tile .rcard-name { font-size: 1.05rem; }
.codex-facets { display: grid; gap: 12px; }
.codex-facet { display: grid; gap: 6px; }
.codex-facet-title { color: var(--mist); font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.codex-facet-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn {
  min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--plum-2); color: var(--bone); font: 600 .85rem var(--font-body); cursor: pointer;
}
.chip-btn.on { background: color-mix(in srgb, var(--gold) 20%, var(--plum-2)); border-color: var(--gold); color: var(--gold); }
.meta-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; margin-top: 6px; }
.meta-chips .badge { font-size: .72rem; font-weight: 600; }
.codex-detail { max-width: 340px; margin: 0 auto; }
.codex-detail .rcard-desc { white-space: pre-line; max-height: 40vh; overflow: auto; text-align: left; }
@media (min-width: 900px) {
  .codex { grid-template-columns: 220px 1fr; }
  .codex-side { position: sticky; top: 12px; }
  .codex-nav { flex-direction: column; overflow: visible; }
}
@media (prefers-reduced-motion: reduce) { .codex-tile { transition: none; } .codex-tile:hover { transform: none; } }

.pick-rows { display: grid; gap: 4px; max-height: 240px; overflow: auto; margin-top: 8px; }
.pick-row { display: flex; align-items: center; gap: 10px; min-height: var(--tap); padding: 0 10px; border-radius: 8px; background: var(--plum-2); cursor: pointer; }
.pick-row input { width: 20px; height: 20px; accent-color: var(--blood-hi); }
.pick-row.disabled { opacity: .5; cursor: not-allowed; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 12px; }
.kv dt { color: var(--mist); }
.kv dd { margin: 0; }
.sync { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.events { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; font-size: .93rem; }
.events li { display: grid; grid-template-columns: 5.5em 1fr; gap: 8px; }
.events time { color: var(--mist); }
.gm-login { max-width: 380px; margin: 48px auto; padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--plum); }
.gm-login h1 { font: 700 2.4rem var(--font-display); margin-bottom: 14px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Typography system (design doc): Cinzel headings with 0.05em tracking, JetBrains Mono for numbers. */
.display, .brand, .rcard-name, .login h1, .gm-login h1, .cat-name, .modal-head h2, .dash-head h2, .pcard-role, .cfg-name b { letter-spacing: .05em; }
.stat b, .codex-nav-item b, .codex-head small, .qty output, .tbl td.num, .cat-stock, .cfg-total b { font-family: var(--font-mono); }

/* GM → Xếp hạng (from the Sheet's Profile tab) */
.podium { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 0 0 14px; }
.podium-card { --pc: var(--gold); display: grid; justify-items: center; gap: 2px; padding: 14px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--pc) 55%, transparent); background: color-mix(in srgb, var(--pc) 10%, var(--plum)); color: var(--bone); font: inherit; }
.podium-card.r2 { --pc: #c0c6d0; }
.podium-card.r3 { --pc: #c98a4a; }
.podium-card:hover { transform: translateY(-2px); }
.podium-rank { color: var(--pc); font: 700 1.1rem var(--font-display); }
.podium-emoji { font-size: 2.4rem; line-height: 1.2; }
.podium-name { font: 700 1.2rem var(--font-display); text-align: center; }
.podium-pts { color: var(--pc); font-weight: 700; font-size: 1.1rem; }
.th-sort { all: unset; cursor: pointer; }
.th-sort.on { color: var(--bone); }
.th-sort:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td, .tbl tr.clickable:focus-visible td { background: var(--plum-2); }
.board-emoji { font-size: 1.2rem; }
.board-pts { font-weight: 700; }
@media (prefers-reduced-motion: reduce) { .podium-card:hover { transform: none; } }

/* GM → Thống kê role (one player's roles, from the Sheet's History tab) */
.rs-head { display: flex; align-items: center; gap: 14px; margin: 4px 0 12px; }
.rs-emoji { font-size: 3rem; line-height: 1; }
.rs-name { font-size: 2rem; margin: 0 0 4px; }
.rs-grid { display: grid; gap: 12px; margin-bottom: 14px; }
@media (min-width: 900px) { .rs-grid { grid-template-columns: 3fr 2fr; } }
.rs-hls { display: grid; gap: 10px; }
.rs-hl { display: grid; gap: 2px; padding: 8px 10px; border-radius: 10px; background: var(--plum-2); }
.rs-hl b { font: 700 1.1rem var(--font-display); }
.rs-bar { height: 6px; margin-top: 6px; border-radius: 3px; background: var(--plum-2); overflow: hidden; min-width: 60px; }
.rs-bar i { display: block; height: 100%; background: var(--fc, var(--gold)); border-radius: 3px; }
.rs-cell { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.rs-cell .rs-bar { flex: 1; max-width: 160px; margin: 0; }
.rs-roles td:first-child { white-space: nowrap; }

/* handbook popup: iframe fills the dialog, no footer */
dialog.modal.sotay .modal-body { padding: 0; overflow: hidden; }
dialog.modal.sotay .modal-actions { display: none; }
dialog.modal.sotay .modal-head { padding: 8px 12px 8px 18px; }
.sotay-frame { display: block; width: 100%; height: calc(90vh - 58px); border: 0; background: #fcfbf8; }

/* ---------- leaderboard: podium + ranked list (GM "Xếp hạng", players' "BXH") ---------- */
:root { --m1: #e9c25a; --m1-lo: #b8902c; --m2: #d3d6de; --m2-lo: #9097a6; --m3: #d9925a; --m3-lo: #a3612f; }
.pod { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 10px; max-width: 620px; margin: 8px auto 18px; }
.pod-col { --mc: var(--violet); --mc-lo: var(--plum-3); display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0;
  background: none; border: 0; padding: 0; color: var(--bone); font: inherit; cursor: pointer; }
.pod-col.m1 { --mc: var(--m1); --mc-lo: var(--m1-lo); }
.pod-col.m2 { --mc: var(--m2); --mc-lo: var(--m2-lo); }
.pod-col.m3 { --mc: var(--m3); --mc-lo: var(--m3-lo); }
.pod-ava { position: relative; display: grid; place-items: center; width: 72px; height: 72px; border-radius: 50%;
  background: var(--plum-3); border: 3px solid var(--mc); box-shadow: 0 0 0 3px var(--plum), 0 0 18px color-mix(in srgb, var(--mc) 45%, transparent); }
.pod-col.s1 .pod-ava { width: 88px; height: 88px; }
.pod-emoji { font-size: 2.2rem; line-height: 1; }
.pod-col.s1 .pod-emoji { font-size: 2.7rem; }
.pod-medal { position: absolute; right: -4px; bottom: -4px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--mc); color: #1a1020; font: 700 .85rem var(--font-body); border: 2px solid var(--plum); }
.pod-name { max-width: 100%; margin-top: 6px; font: 700 1.05rem var(--font-display); text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-pts { color: var(--mc); font-weight: 700; font-size: .95rem; }
.pod-block { width: 100%; margin-top: 6px; display: grid; place-items: center; border-radius: 10px 10px 0 0;
  background: linear-gradient(135deg, var(--mc), var(--mc-lo)); color: #1a1020; font: 700 1.9rem var(--font-display);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35); }
.pod-block small { font-size: .9rem; opacity: .7; margin-right: 1px; }
.pod-col.s1 .pod-block { height: 120px; }
.pod-col.s2 .pod-block { height: 88px; }
.pod-col.s3 .pod-block { height: 66px; }
.pod-col:hover .pod-ava, .pod-col:focus-visible .pod-ava { transform: translateY(-2px); }
.pod-ava { transition: transform .15s; }

.rk { list-style: none; margin: 0 auto; padding: 0; max-width: 620px; }
.rk-row { border-bottom: 1px solid var(--line); }
.rk-btn { width: 100%; display: grid; grid-template-columns: 40px 44px 1fr auto; align-items: center; gap: 10px; padding: 9px 6px;
  background: none; border: 0; color: var(--bone); font: inherit; text-align: left; }
button.rk-btn { cursor: pointer; }
button.rk-btn:hover { background: var(--plum-2); }
.rk-place { justify-self: center; color: var(--mist); font-weight: 700; }
.rk-ava { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--plum-3); border: 1px solid var(--line); font-size: 1.3rem; }
.rk-main { min-width: 0; display: flex; flex-direction: column; }
.rk-main b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-main small { color: var(--mist); font-size: .82rem; }
.rk-you { margin-left: 6px; padding: 1px 6px; border-radius: 999px; background: var(--violet); color: var(--bone); font: 700 .7rem var(--font-body); vertical-align: middle; }
.rk-pts { text-align: right; color: var(--bone); font-weight: 700; font-size: 1.1rem; }
.rk-pts small { display: block; color: var(--mist); font-weight: 400; font-size: .72rem; }
.rk-me-card { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 0 auto 14px; padding: 8px 14px; max-width: 620px;
  border: 1px solid var(--violet); border-radius: 12px; background: var(--plum-2); }
@media (max-width: 480px) {
  .pod { gap: 6px; }
  .pod-ava { width: 56px; height: 56px; }
  .pod-col.s1 .pod-ava { width: 68px; height: 68px; }
  .pod-emoji { font-size: 1.7rem; }
  .pod-col.s1 .pod-emoji { font-size: 2.1rem; }
  .pod-name { font-size: .92rem; }
  .pod-col.s1 .pod-block { height: 92px; }
  .pod-col.s2 .pod-block { height: 68px; }
  .pod-col.s3 .pod-block { height: 52px; }
  .rk-btn { grid-template-columns: 30px 38px 1fr auto; gap: 8px; }
  .rk-ava { width: 36px; height: 36px; font-size: 1.15rem; }
}
/* narrow phones: topbar shortcuts collapse to their icon */
@media (max-width: 420px) { .topbar .lbl { display: none; } }

/* rank colour bands (players' list + GM table): 1–3 gold, 4–10 silver, 11–20 blue, the rest plain */
.tier-gold { --tc: var(--m1); }
.tier-silver { --tc: var(--m2); }
.tier-blue { --tc: #4a90f0; }
[class*="tier-"] .rk-place { display: inline-grid; place-items: center; min-width: 28px; height: 28px; padding: 0 6px; border-radius: 999px;
  background: var(--tc); color: #1a1020; font-weight: 700; }
.tier-blue .rk-place { color: #fff; }
.rk-row[class*="tier-"] .rk-btn { box-shadow: inset 3px 0 0 var(--tc); background: color-mix(in srgb, var(--tc) 8%, transparent); }
.rk-row[class*="tier-"] .rk-pts { color: var(--tc); }
.board-tbl tr[class*="tier-"] td { background: color-mix(in srgb, var(--tc) 8%, transparent); }
.board-tbl tr[class*="tier-"] td:first-child { box-shadow: inset 3px 0 0 var(--tc); }
.board-tbl tr[class*="tier-"] .board-pts { color: var(--tc); }
.rk-row.is-me .rk-btn { background: color-mix(in srgb, var(--violet) 28%, transparent); border-radius: 10px; }

/* GM ranking toolbar: big search box with its controls on the same row, centred on its height (wraps on narrow screens) */
.board-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 8px 0 14px; }
.board-search { flex: 1 1 420px; width: auto; min-height: calc(var(--tap) + 20px); font-size: 1.1rem; } /* +10px above and below the usual input */
.board-meta { display: flex; flex-direction: column; justify-content: center; gap: 6px; white-space: nowrap; } /* filter on top, Sheet date below */

/* trophy next to top-3 names */
.cup { display: inline-block; width: 1.15em; height: 1.15em; margin-left: 6px; vertical-align: -0.18em; }
.cup svg { width: 100%; height: 100%; fill: currentColor; stroke: rgba(0, 0, 0, .45); stroke-width: .6; filter: drop-shadow(0 0 3px color-mix(in srgb, currentColor 55%, transparent)); }
.cup.c1 { color: var(--m1); }
.cup.c2 { color: var(--m2); }
.cup.c3 { color: var(--m3); }
/* podium: trophy beside the name; the name truncates, the trophy never does */
.pod-title { display: flex; align-items: center; justify-content: center; max-width: 100%; margin-top: 6px; }
.pod-title .pod-name { margin-top: 0; min-width: 0; }
.pod-title .cup { flex: none; width: 1.3em; height: 1.3em; }

/* ---------- league poster (winter season board): wooden frame, snowy night banner, top 20 in two tables ---------- */
.poster {
  --wood: #6b4423; --wood-hi: #a8733f; --night: #0b1830; --night-2: #16305a; --ice: #cfe6ff; --gold-txt: #ffd77a;
  position: relative; margin: 6px 0 16px; padding: 14px 14px 16px; border-radius: 16px; overflow: hidden; color: #f4f1ea;
  border: 6px solid var(--wood);
  background:
    radial-gradient(2px 2px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 30% 8%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 48% 22%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 66% 6%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 76% 30%, #fff 50%, transparent 51%), radial-gradient(2px 2px at 6% 40%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 94% 44%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 40% 36%, #fff 50%, transparent 51%),
    linear-gradient(180deg, var(--night-2), var(--night) 38%, #08111f);
  box-shadow: 0 0 0 2px var(--wood-hi), inset 0 0 0 2px rgba(255, 255, 255, .06), 0 12px 36px rgba(0, 0, 0, .6);
}
.poster::before { /* falling snow */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: .35;
  background-image: radial-gradient(1.6px 1.6px at 20px 30px, #fff 50%, transparent 51%), radial-gradient(1.2px 1.2px at 70px 90px, #fff 50%, transparent 51%),
    radial-gradient(1.4px 1.4px at 130px 50px, #fff 50%, transparent 51%);
  background-size: 160px 120px;
}
@media (prefers-reduced-motion: no-preference) { .poster::before { animation: pst-snow 18s linear infinite; } }
@keyframes pst-snow { to { background-position: 40px 240px, -30px 240px, 20px 240px; } }
.poster > * { position: relative; z-index: 1; }
.poster::after { /* moon, behind the text */
  content: ''; position: absolute; top: 16px; right: 22px; width: 46px; height: 46px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle at 38% 38%, #fffbe8, #f4e2a0 60%, #d6b45a); box-shadow: 0 0 26px 8px rgba(255, 236, 170, .3); opacity: .9; }

.pst-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; margin-bottom: 12px; }
.pst-logo { display: grid; place-items: center; width: 74px; height: 74px; border-radius: 50%; text-align: center; line-height: 1;
  background: radial-gradient(circle at 50% 35%, #3b2a1a, #1c120a); border: 3px solid var(--gold-txt); box-shadow: 0 0 14px rgba(255, 215, 122, .45); }
.pst-logo span { font-size: 2rem; }
.pst-logo small { margin-top: -10px; font: 700 .7rem var(--font-display); color: var(--gold-txt); letter-spacing: .04em; }
.pst-titles { text-align: center; min-width: 0; }
.pst-title { margin: 0; font: 800 clamp(1.25rem, 3.6vw, 2.3rem)/1.05 var(--font-display); letter-spacing: .03em; text-transform: uppercase;
  background: linear-gradient(180deg, #fff3c4, var(--gold-txt) 45%, #c98a2b); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #4a2a0c) drop-shadow(0 0 10px rgba(255, 200, 90, .35)); }
.pst-season { display: inline-block; margin: 8px 0 2px; padding: 3px 18px; border-radius: 6px; font: 700 clamp(.78rem, 1.8vw, 1rem) var(--font-display);
  letter-spacing: .05em; text-transform: uppercase; color: var(--ice); background: linear-gradient(180deg, #1f4b85, #12305a); border: 1px solid #6da3e8; }
.pst-months { margin: 2px 0 0; font-size: .85rem; color: var(--ice); opacity: .85; }
.pst-date { align-self: end; padding: 5px 12px; border-radius: 999px; font: 700 .95rem var(--font-display); color: #2a1606;
  background: linear-gradient(180deg, #ffe6a3, #e0a93a); border: 2px solid var(--wood); white-space: nowrap; }

.pst-tables { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pst-tbl { width: 100%; border-collapse: separate; border-spacing: 0 3px; font-size: .92rem; }
.pst-tbl th { padding: 6px 4px; font: 700 .72rem var(--font-body); text-transform: uppercase; letter-spacing: .03em; color: var(--gold-txt);
  background: linear-gradient(180deg, #3a2412, #24160b); border-top: 1px solid var(--wood-hi); border-bottom: 1px solid var(--wood-hi); }
.pst-tbl th:first-child { border-left: 1px solid var(--wood-hi); border-radius: 6px 0 0 6px; }
.pst-tbl th:last-child { border-right: 1px solid var(--wood-hi); border-radius: 0 6px 6px 0; }
.pst-tbl td { padding: 5px 4px; text-align: center; background: rgba(9, 22, 44, .82); }
.pst-tbl td:first-child { border-radius: 6px 0 0 6px; }
.pst-tbl td:last-child { border-radius: 0 6px 6px 0; }
.pst-tbl .c-name { text-align: left; font-weight: 700; max-width: 9em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pst-tbl .c-name .cup { width: 1em; height: 1em; margin-left: 4px; }
.pst-tbl .c-emoji { font-size: 1.1rem; }
.pst-tbl .c-points { font-weight: 800; color: var(--gold-txt); }
.pst-tbl tr[class*="tier-"] td { background: color-mix(in srgb, var(--tc) 18%, rgba(9, 22, 44, .9)); }
.pst-tbl tr[class*="tier-"] td:first-child { box-shadow: inset 3px 0 0 var(--tc); }
.pst-tbl tr[class*="tier-"] .c-points { color: var(--tc); }
.pst-tbl tr.is-me td { background: color-mix(in srgb, var(--violet) 55%, rgba(9, 22, 44, .9)); }
.pst-tbl tr:not([class*="tier-"]) .rk-place { color: var(--ice); } /* tier badges keep their dark text */

@media (max-width: 760px) {
  .pst-tables { grid-template-columns: 1fr; }
  .pst-head { grid-template-columns: auto 1fr; }
  .pst-date { grid-column: 1 / -1; justify-self: center; }
}
@media (max-width: 480px) {
  .poster { padding: 10px 8px 12px; border-width: 4px; }
  .pst-logo { width: 56px; height: 56px; }
  .pst-logo span { font-size: 1.5rem; }
  .pst-tbl .opt, .pst-tbl .c-emoji { display: none; }   /* Bonus / AFK / Emoji hidden on phones so the rest fits */
  .pst-tbl { font-size: .8rem; }
  .pst-tbl th { font-size: .62rem; padding: 5px 2px; }
  .pst-tbl td { padding: 4px 2px; }
  .pst-tbl .c-name { max-width: 7.5em; }
  .pst-tbl .rk-place { min-width: 24px; height: 24px; padding: 0 4px; }
  .poster::after { top: 8px; right: 10px; width: 26px; height: 26px; box-shadow: 0 0 14px 4px rgba(255, 236, 170, .3); }
  dialog.modal.board-modal .modal-body { padding: 10px 8px; }
}
dialog.modal.board-modal { width: min(98vw, 1120px); }
