:root {
  --bg: #0e0f11;
  --surface: #17191c;
  --surface-2: #1f2226;
  --border: #2a2e34;
  --text: #ebe8e3;
  --muted: #8f96a0;
  --accent: #d6a548;
  --accent-ink: #1a1408;
  --town: #e04b51;
  --mafia: #9aa4b2;
  --sheriff: #f2c94c;
  --don: #b78cf0;
  --citizen: #e9777b;
  --ok: #4fb57d;
  --warn: #e7a23b;
  --danger: #e04b51;
  --track: #2a2e34;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--font);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.02rem; }
h4 { font-size: .9rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); font-weight: normal; }
.small { font-size: .85rem; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem max(16px, calc((100vw - 1180px) / 2));
  background: rgba(14, 15, 17, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { color: var(--text); font-size: 1.1rem; white-space: nowrap; }
.brand b { color: var(--accent); }
.brand:hover { text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: .5rem; }
.logo { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; }
nav { display: flex; gap: .25rem; overflow-x: auto; }
nav a { color: var(--muted); padding: .4rem .75rem; border-radius: 8px; white-space: nowrap; }
nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
nav a.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px 0 var(--accent); }

main { max-width: 1180px; margin: 0 auto; padding: 1.25rem 16px 4rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; margin: 1.25rem 0 .75rem; }
.card .section-head { margin-top: 0; }
.section-title { margin: 1.75rem 0 .75rem; }
.back { display: inline-block; font-size: .85rem; margin-bottom: .25rem; }
.row { display: flex; align-items: center; }
.gap { gap: .5rem; }
.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: 1rem; margin: 1rem 0; }
.grid-2 > .card { margin: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}
.empty, .hero { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.hero h1 { color: var(--text); font-size: 2rem; }
.hero p { max-width: 520px; margin: .5rem auto 1.5rem; }
.hero .row { justify-content: center; }
.callout { background: rgba(214, 165, 72, .08); border: 1px solid rgba(214, 165, 72, .35); border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; }
.demo-banner { background: var(--accent); color: var(--accent-ink); text-align: center; padding: .45rem 16px; font-size: .9rem; }
.demo-banner a { color: var(--accent-ink); text-decoration: underline; font-weight: 600; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .5rem .95rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: #3a3f47; text-decoration: none; background: #262a2f; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.on { border-color: var(--accent); color: var(--accent); }
.btn.danger { background: transparent; border-color: rgba(224, 75, 81, .5); color: var(--danger); }
.btn.danger:hover { background: rgba(224, 75, 81, .12); }
.danger-text { color: var(--danger) !important; }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .45rem .6rem;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(214, 165, 72, .5); outline-offset: 0; border-color: var(--accent); }
input[type="date"] { color-scheme: dark; }
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
.field.inline { flex-direction: row; align-items: center; gap: .4rem; }
.field.block { margin-top: 1rem; }
.num-input { width: 4.5rem; }
.filter { width: 100%; margin-bottom: .75rem; }
.quick-add { margin: .5rem 0 .75rem; }
.quick-add input { flex: 1 1 160px; max-width: 240px; }
.settings { display: grid; gap: .75rem; }
.settings input { max-width: 120px; }

/* ---------- chips ---------- */
.chip {
  display: inline-block;
  padding: .1rem .5rem;
  border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  white-space: nowrap;
}
.chip.muted { color: var(--muted); font-weight: 500; }
.chip.warn { color: var(--warn); border-color: rgba(231, 162, 59, .4); }
.chip.win { color: var(--ok); border-color: rgba(79, 181, 125, .45); }
.chip.loss { color: var(--muted); }
.chip.team-town, .chip.role-citizen { color: var(--town); border-color: rgba(224, 75, 81, .45); background: rgba(224, 75, 81, .08); }
.chip.team-mafia, .chip.role-mafia { color: var(--mafia); border-color: rgba(154, 164, 178, .45); background: rgba(154, 164, 178, .08); }
.chip.role-sheriff { color: var(--sheriff); border-color: rgba(242, 201, 76, .45); background: rgba(242, 201, 76, .08); }
.chip.role-don { color: var(--don); border-color: rgba(183, 140, 240, .45); background: rgba(183, 140, 240, .08); }
.chip.mismatch { outline: 2px dashed var(--warn); outline-offset: 1px; }

/* ---------- bars ---------- */
.bar { display: inline-block; height: 8px; width: 100%; min-width: 50px; background: var(--track); border-radius: 4px; overflow: hidden; vertical-align: middle; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar.accent > span { background: var(--accent); }
.bar.role-citizen > span { background: var(--citizen); }
.bar.role-sheriff > span { background: var(--sheriff); }
.bar.role-mafia > span { background: var(--mafia); }
.bar.role-don > span { background: var(--don); }
.bar-row { display: grid; grid-template-columns: minmax(80px, 130px) 1fr auto; align-items: center; gap: .65rem; padding: .25rem 0; }
.bar-row .num { font-variant-numeric: tabular-nums; font-size: .9rem; min-width: 80px; text-align: right; }
.bar-row a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- dashboard ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; display: flex; flex-direction: column; }
.kpi-val { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-lbl { color: var(--muted); font-size: .85rem; }
.town-text { color: var(--town); }
.mafia-text { color: var(--mafia); }
.split { display: flex; height: 26px; border-radius: 8px; overflow: hidden; margin-top: .75rem; font-size: .8rem; font-weight: 600; }
.split span { display: flex; align-items: center; padding: 0 .6rem; white-space: nowrap; }
.split-town { background: var(--town); color: #fff; }
.split-mafia { background: #3a414b; color: #e6e9ee; justify-content: flex-end; }

.titles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .75rem; }
.title-card { display: flex; gap: .8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.title-card:first-child { border-color: rgba(214, 165, 72, .6); background: linear-gradient(135deg, rgba(214, 165, 72, .12), var(--surface) 60%); }
.title-icon { font-size: 1.7rem; line-height: 1; }
.title-name { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.title-holder { display: block; font-size: 1.15rem; font-weight: 700; color: var(--text); }
.title-detail { font-size: .9rem; color: var(--accent); }
.title-desc { font-size: .8rem; color: var(--muted); margin-top: .15rem; }
.empty-title { opacity: .6; }
.empty-title .title-detail { color: var(--muted); }
.role-leaders { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.role-block h4 { margin-bottom: .3rem; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover, th.sorted { color: var(--text); }
td.wr { min-width: 130px; }
td.wr .bar { width: 60px; margin-left: .35rem; }
td.rolecell { color: var(--muted); }
td.actions { text-align: right; }

/* ---------- games ---------- */
.game-list { display: flex; flex-direction: column; gap: .4rem; }
.game-row { display: flex; align-items: center; gap: .8rem; padding: .6rem .8rem; border-radius: 8px; background: var(--surface-2); color: var(--text); flex-wrap: wrap; }
.game-row:hover { text-decoration: none; background: #262a2f; }
.gnum { font-weight: 700; color: var(--accent); min-width: 2rem; }
.gdate { font-size: .9rem; }

table.seats select { width: 100%; min-width: 150px; }
table.seats .seatno { font-weight: 700; color: var(--accent); width: 2rem; }
table.seats tr.dead td { opacity: .55; }
table.seats tr.dead td.fate { opacity: 1; color: var(--muted); }
.fate .alive { color: var(--ok); }
.fouls { width: 4rem; }
.fouls.warnf { border-color: var(--warn); color: var(--warn); }
select.bad { border-color: var(--danger); }
.role-select.role-citizen { color: var(--citizen); }
.role-select.role-sheriff { color: var(--sheriff); }
.role-select.role-mafia { color: var(--mafia); }
.role-select.role-don { color: var(--don); }
.role-select option { color: var(--text); }
.role-count { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .5rem; }
.warnings { margin: .25rem 0 .75rem; padding-left: 1.2rem; color: var(--warn); font-size: .88rem; }

.round { padding: 0; overflow: hidden; }
.round-head { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1.1rem; border-bottom: 1px solid var(--border); }
.round-head h3 { margin: 0; }
.phase { padding: .9rem 1.1rem; }
.phase.day { background: linear-gradient(180deg, rgba(214, 165, 72, .05), transparent); }
.phase.night { background: rgba(0, 0, 0, .25); border-top: 1px solid var(--border); }
.votes { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: .35rem .9rem; }
.vote-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .4rem; }
.vote-row .voter { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.vote-row .arrow { color: var(--muted); }
.vote-row select { width: 100%; }
.tally { display: flex; flex-wrap: wrap; gap: .35rem; margin: .75rem 0; }
.picks { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; margin: .4rem 0; }
.picks .lbl, .alive-list .lbl { font-size: .85rem; color: var(--muted); margin-right: .25rem; }
.pick { display: inline-flex; align-items: center; gap: .3rem; padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); font-size: .85rem; cursor: pointer; user-select: none; }
.pick input { margin: 0; accent-color: var(--danger); }
.pick.on { border-color: var(--danger); background: rgba(224, 75, 81, .15); }
details summary { cursor: pointer; color: var(--muted); font-size: .85rem; margin-top: .4rem; }
.night-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .75rem; }
.night-grid .field .chip { align-self: flex-start; margin-top: .2rem; }
.add-round { margin-bottom: 1.25rem; }

.result .alive-list { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-bottom: .75rem; }
.alive-chip { display: inline-flex; gap: .35rem; align-items: center; padding: .2rem .55rem; border-radius: 8px; background: var(--surface-2); font-size: .88rem; }
.hint { background: rgba(79, 181, 125, .1); border: 1px solid rgba(79, 181, 125, .35); border-radius: 8px; padding: .5rem .75rem; display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { font: inherit; padding: .55rem 1rem; background: var(--surface-2); color: var(--muted); border: 0; border-right: 1px solid var(--border); cursor: pointer; }
.seg button:last-child { border-right: 0; }
.seg button.on { color: var(--text); background: #2c3036; font-weight: 600; }
.seg button.seg-town.on { background: var(--town); color: #fff; }
.seg button.seg-mafia.on { background: #3a414b; color: #fff; }

.facts { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #2c3036; color: var(--text); border: 1px solid var(--border);
  padding: .55rem 1rem; border-radius: 10px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 50;
  max-width: calc(100vw - 32px);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 640px) {
  .topbar { gap: .75rem; }
  h1 { font-size: 1.3rem; }
  .kpi-val { font-size: 1.4rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .votes { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr auto; }
}

/* ---------- v2: nominations, nights, live mode ---------- */
.demo-banner.subtle { background: var(--surface-2); color: var(--muted); border-bottom: 1px solid var(--border); }
.vote-text { max-width: 640px; margin: .25rem 0 .6rem; }
.vote-text textarea { width: 100%; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .95rem; line-height: 1.5; }
.vote-errors { color: var(--warn); font-size: .85rem; margin-top: .25rem; }
.noms { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .5rem; }
.nom-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) 5rem auto; gap: .4rem; align-items: center; max-width: 640px; }
.nom-row select { width: 100%; }
.nom-row.ro { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; font-size: .92rem; }
.nom-row .arrow { color: var(--muted); }
.nom-votes { color: var(--muted); font-variant-numeric: tabular-nums; }
.votes-input { width: 100%; }
.night-ro { font-size: .92rem; }
.night-ro .lbl { color: var(--muted); }
.hide-ro { display: none; }
td.pos, .kpi-val.pos, span.pos { color: var(--ok); }
td.neg, .kpi-val.neg, span.neg { color: var(--danger); }
.notes { white-space: pre-wrap; color: var(--muted); }
@media (max-width: 640px) {
  .nom-row { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); }
  .nom-row .votes-input { grid-column: 1 / 2; }
}
:root { --doctor: #4fb57d; --maniac: #e8894a; }
.chip.role-doctor { color: var(--doctor); border-color: rgba(79, 181, 125, .45); background: rgba(79, 181, 125, .08); }
.chip.role-maniac { color: var(--maniac); border-color: rgba(232, 137, 74, .45); background: rgba(232, 137, 74, .08); }
.bar.role-doctor > span { background: var(--doctor); }
.bar.role-maniac > span { background: var(--maniac); }
.role-select.role-doctor { color: var(--doctor); }
.role-select.role-maniac { color: var(--maniac); }
.nom-row.ro { max-width: 520px; }

/* ---------- v3: login, admin ---------- */
.topbar .spacer { flex: 1; }
.auth { display: flex; align-items: center; gap: .5rem; white-space: nowrap; }
.auth .who { font-size: .9rem; }
.btn.tg { background: #2aabee; border-color: #2aabee; color: #fff; font-weight: 600; }
.btn.tg:hover { filter: brightness(1.08); background: #2aabee; }
.chip.admin { color: var(--accent); border-color: rgba(214, 165, 72, .5); }
.save-state { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.save-state.saving { color: var(--warn); }
.save-state.saved { color: var(--ok); }
.save-state.error { color: var(--danger); font-weight: 600; }
.pick.on-ok { border-color: var(--ok); background: rgba(79, 181, 125, .15); }
tr.editing td { background: var(--surface-2); }
.edit-player .field input { min-width: 160px; }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; row-gap: .4rem; }
  .topbar nav { order: 3; width: 100%; }
}

/* ---------- v4: unsaved changes bar ---------- */
.savebar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: rgba(23, 25, 28, .97); border-top: 2px solid var(--warn); box-shadow: 0 -6px 24px rgba(0, 0, 0, .4); }
.savebar-inner { max-width: 1180px; margin: 0 auto; padding: .7rem 16px; display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.savebar .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 4px rgba(231, 162, 59, .2); }
.savebar .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }
.savebar .spacer { flex: 1; }
body:has(.savebar) main { padding-bottom: 7rem; }
body:has(.savebar) #toast { bottom: 84px; }

.backup-list { margin-top: .75rem; }
.grid-2 > .card.wide { grid-column: 1 / -1; }
.grid-2.cols-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }

/* ---------- v5: bot page ---------- */
.mt { margin-top: 1rem; }
.warn-text { color: var(--warn); }
#botText, .post-edit { width: 100%; margin: .6rem 0; font: inherit; }
.post .post-head { margin-bottom: .5rem; }
.post-text { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: .7rem .9rem; margin-bottom: .6rem; font-size: .95rem; }
.post.deleted { opacity: .55; }

/* DD/MM/YYYY date field with a native picker behind the 📅 button */
.date-field { position: relative; display: inline-flex; align-items: center; gap: 4px; }
.date-field input[type=text] { width: 8.5em; }
.date-field .date-pick { background: none; border: 0; cursor: pointer; font-size: 1.1em; padding: 4px; line-height: 1; }
.date-field .date-native { position: absolute; right: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; border: 0; padding: 0; }

/* Bot page: commands preview, templates row, tabs */
.cmd-list { display: grid; gap: .35rem; margin: .5rem 0 .8rem; }
.cmd { display: flex; gap: .6rem; align-items: baseline; text-align: left; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .7rem; cursor: pointer; font: inherit; }
.cmd code { color: var(--accent); font-weight: 600; min-width: 5.5em; }
.cmd.on { border-color: var(--accent); }
.tg-preview { margin-top: .7rem; }
.tg-bubble { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; padding: .7rem .9rem; font-size: .95rem; line-height: 1.45; overflow-wrap: anywhere; }
.tpl-row { margin-top: .7rem; align-items: center; }
.tpl-row .lbl { color: var(--muted); font-size: .85rem; }
.tabs { display: flex; gap: .3rem; align-items: center; margin: 1.75rem 0 .75rem; border-bottom: 1px solid var(--border); }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); font: inherit; font-weight: 600; padding: .55rem .9rem; cursor: pointer; margin-bottom: -1px; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); }
.tab-empty { display: flex; gap: 1rem; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.tab-empty p { margin: 0; }
.icon-btn { font-size: 1.15rem; line-height: 1; padding-left: .7rem; padding-right: .7rem; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--surface-2); }

/* Avatars */
.ava { display: block; flex: none; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.ava-lg { width: 96px; height: 96px; }
.ava-hat { display: flex; align-items: center; justify-content: center; overflow: hidden; color: var(--muted); border: 1px solid var(--border); }
.ava-hat svg { width: 78%; height: 78%; }
.ava-icon { overflow: hidden; background: #f1eee8; box-shadow: 0 0 0 1px var(--border); }
.ava-icon img { display: block; width: 100%; height: 100%; }
a.who-cell, .who-cell > a { display: flex; align-items: center; gap: 8px; }
.player-head { display: flex; align-items: center; gap: 16px; }
.player-head h1 { margin: 2px 0 6px; }
.player-photo .ava { box-shadow: 0 0 0 2px var(--accent); }
.photo-actions { margin-top: 4px; }
.my-details form .field input { min-width: 180px; }

/* Modal (photo crop) */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; width: 100%; max-width: 330px; display: flex; flex-direction: column; gap: 10px; }
.modal-box h3 { margin: 0; }
canvas.crop { width: 280px; height: 280px; max-width: 100%; align-self: center; border-radius: 50%; touch-action: none; cursor: grab; background: var(--bg); }
canvas.crop:active { cursor: grabbing; }

@media (max-width: 640px) {
  .player-head { gap: 12px; }
  .ava-lg { width: 72px; height: 72px; }
  .my-details form .field input { min-width: 0; width: 100%; }
}

/* Language switch (UA / EN) */
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-switch button { background: none; border: 0; color: var(--muted); font: inherit; font-size: .8rem; font-weight: 600; padding: .3rem .55rem; cursor: pointer; }
.lang-switch button:hover { color: var(--text); }
.lang-switch button.on { background: var(--surface-2); color: var(--accent); }

/* Compare page */
.cmp-head { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); grid-template-areas: "a swap b" "ta . tb"; gap: 12px; align-items: stretch; margin-bottom: .5rem; }
.cmp-card-a { grid-area: a; } .cmp-card-b { grid-area: b; } .cmp-swap { grid-area: swap; }
.cmp-titles-a { grid-area: ta; } .cmp-titles-b { grid-area: tb; }
.cmp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; text-align: center; }
.cmp-select { width: 100%; }
.cmp-who { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--text); font-weight: 600; }
.cmp-big { font-size: 1.4rem; }
.cmp-titles { display: flex; flex-wrap: wrap; justify-content: center; align-content: flex-start; gap: 4px; min-width: 0; }
.cmp-titles .chip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-swap { align-self: center; font-size: 1.2rem; }
.cmp-lead { text-align: center; margin: .25rem 0 1rem; }
.cmp-table { width: 100%; table-layout: fixed; }
.cmp-table th[scope="row"] { text-align: left; font-weight: 500; color: var(--muted); font-size: .9rem; text-transform: none; letter-spacing: 0; white-space: normal; }
.cmp-table thead th:not(:first-child), .cmp-table td { text-align: center; }
.cmp-table td.better { color: var(--ok); font-weight: 700; background: rgba(79, 181, 125, .08); }
@media (max-width: 640px) {
  .cmp-head { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "a b" "ta tb" "swap swap"; row-gap: 8px; }
  .cmp-swap { justify-self: center; }
  .cmp-card { padding: 10px; }
  .cmp-big { font-size: 1.15rem; }
  .cmp-table th[scope="row"] { width: 40%; }
}

/* Footer */
.site-foot { max-width: 1180px; margin: 2rem auto 0; padding: 1.2rem 16px 2rem; display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--border); }
.site-foot a { color: var(--muted); }
.site-foot a:hover { color: var(--text); }
.intro { color: var(--muted); max-width: 70ch; margin: -.25rem 0 1.2rem; }
.about { max-width: 760px; }
.about h2 { margin-top: 1.4rem; }
.about ul { padding-left: 1.2rem; }
.about li { margin: .3rem 0; }
.about .roles-list { list-style: none; padding: 0; display: grid; gap: .45rem; }
.about .roles-list li { display: flex; gap: .6rem; align-items: baseline; }
.about .roles-list .chip { flex: none; min-width: 5.5rem; text-align: center; }

/* Phone menu: burger button + side panel (login on top, then the menu items) */
.auth .who { display: inline-flex; align-items: center; gap: .45rem; }
.auth .who .ava { width: 26px; height: 26px; }
.menu-btn, .drawer-close { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: .3rem; cursor: pointer; line-height: 0; }
.menu-btn:hover, .drawer-close:hover { background: var(--surface-2); }
.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .55); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(320px, 86vw); background: var(--surface); border-left: 1px solid var(--border); display: flex; flex-direction: column; overflow-y: auto; animation: drawer-in .18s ease-out; }
.drawer[hidden], .drawer-backdrop[hidden] { display: none; }
@keyframes drawer-in { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: flex-start; gap: .75rem; padding: 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.drawer-head .drawer-close { display: block; margin-left: auto; }
.drawer-auth { display: flex; flex-direction: column; align-items: flex-start; gap: .6rem; min-width: 0; }
.drawer-auth .who { display: flex; align-items: center; gap: .5rem; font-weight: 600; }
.drawer-auth .who .ava { width: 36px; height: 36px; }
.drawer-nav { display: flex; flex-direction: column; padding: 8px; }
.drawer-nav a { color: var(--text); padding: .8rem .9rem; border-radius: 8px; font-size: 1.02rem; }
.drawer-nav a:hover { background: var(--surface-2); text-decoration: none; }
.drawer-nav a.active { background: var(--surface-2); box-shadow: inset 3px 0 0 var(--accent); }
body.menu-open { overflow: hidden; }
@media (max-width: 760px) {
  .topbar { flex-wrap: nowrap; }
  .topbar nav, .topbar .auth { display: none; }
  .menu-btn { display: block; }
}

/* Scrollbars: dark, but clearly visible (wide tables like the leaderboard scroll sideways) */
:root { color-scheme: dark; }   /* dark default scrollbars and form controls everywhere */
.table-wrap { scrollbar-width: thin; scrollbar-color: #5a616b var(--surface-2); padding-bottom: 2px; }
.table-wrap:hover { scrollbar-color: var(--accent) var(--surface-2); }
@supports not (scrollbar-color: auto) {   /* Safari */
  .table-wrap::-webkit-scrollbar { height: 10px; }
  .table-wrap::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 5px; }
  .table-wrap::-webkit-scrollbar-thumb { background: #5a616b; border-radius: 5px; border: 2px solid var(--surface-2); }
  .table-wrap:hover::-webkit-scrollbar-thumb { background: var(--accent); }
}
