:root {
  --bg: #0b0910;
  --sidebar: #100d17;
  --panel: #15111d;
  --surface: #1b1525;
  --border: #2c2438;
  --strong: #f7f2ff;
  --muted: #b1a5c2;
  --purple: #b785ff;
  --accent: #8248ea;
  --green: #74e0ad;
  --red: #ffa9bd;
  --sidebar-width: 230px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-synthesis: none;
  background: var(--bg);
  color: var(--strong);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 320px; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--purple); outline-offset: 3px; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
.icon-library { display: none; }
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.sidebar { display: flex; flex-direction: column; position: sticky; top: 0; align-self: start; height: 100vh; padding: 25px 17px 14px; background: var(--sidebar); border-right: 1px solid var(--border); }
.brand { display: flex; gap: 11px; align-items: center; padding: 0 6px; }
.brand img { display: block; }
.brand strong { font-size: 19px; font-weight: 900; white-space: nowrap; line-height: 1; letter-spacing: -.04em; }
.brand-accent { color: var(--purple); }
.brand small { display: block; color: var(--muted); font-size: 13px; line-height: 1.45; }
.navigation { display: grid; gap: 5px; margin-top: 42px; }
.navigation a { display: flex; align-items: center; gap: 11px; min-height: 44px; padding: 0 12px; border: 1px solid transparent; border-radius: 9px; color: var(--muted); font-size: 14px; font-weight: 640; }
.navigation a:hover { background: var(--surface); color: var(--strong); }
.navigation a[aria-current="page"] { border-color: #432e5e; color: #e4cdff; background: #271938; }
.navigation a[aria-current="page"] .icon { color: var(--purple); }
.sidebar-foot { margin-top: auto; }
.discord-status { width: 100%; border: 1px solid var(--border); border-radius: 11px; background: #17121f; color: var(--strong); padding: 9px; display: flex; gap: 8px; align-items: center; text-align: left; }
.discord-status:hover { border-color: #624185; }
.status-symbol { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: #2b1b40; color: var(--purple); }
.discord-status strong, .discord-status small { display: block; }
.discord-status strong { font-size: 14px; }
.discord-status small { color: var(--muted); font-size: 12px; }
.status-light { flex: none; width: 7px; height: 7px; margin-left: auto; background: #806d96; border-radius: 50%; }
.status-light.live { background: var(--green); box-shadow: 0 0 9px #74e0ad55; }
.signature { display: block; margin-top: 13px; color: #a18eb5; font-size: 13px; text-align: right; }

.topbar { min-height: 71px; padding: 10px 30px; display: flex; align-items: center; justify-content: space-between; gap: 15px; border-bottom: 1px solid var(--border); background: #100d16; }
.breadcrumbs, .top-actions { display: flex; align-items: center; gap: 12px; }
.breadcrumbs { color: var(--muted); font-size: 14px; }
.breadcrumbs strong { color: var(--strong); font-weight: 700; }
.breadcrumb-divider { color: #685876; }
.main-shell { min-width: 0; }
main { width: 100%; max-width: 1480px; margin-inline: auto; padding: 24px 30px 0; }

.button { display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 41px; padding: 8px 14px; border: 1px solid transparent; border-radius: 8px; font-size: 14px; font-weight: 700; line-height: 1.2; color: var(--strong); white-space: nowrap; }
.button .icon { width: 17px; height: 17px; }
.button.primary { background: #8245e8; border-color: #a574ef; color: #fff; box-shadow: inset 0 1px #fff2, 0 6px 16px #09001538; }
.button.primary:hover { background: #9359f0; }
.button.secondary { background: #21182c; border-color: #3f3050; }
.button.secondary:hover, .button.glass:hover { border-color: #8b62ba; background: #33213e; }
.button.glass { border-color: #695481; background: #161023ab; backdrop-filter: blur(6px); }
.button.subtle { background: transparent; color: #d1b9f2; }
.button.subtle:hover { background: var(--surface); }
.button.danger { background: #58243a; border-color: #88445d; color: #fff; }
.button.danger:hover { background: #78334d; }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--border); border-radius: 7px; background: transparent; color: var(--muted); }
.icon-button:hover { border-color: #74549b; color: var(--strong); }
.icon-button.danger:hover { border-color: #a46077; color: var(--red); }
.icon-button .icon { width: 17px; height: 17px; }

.hero { min-height: 280px; display: flex; align-items: center; isolation: isolate; position: relative; overflow: hidden; border: 1px solid #493262; border-radius: 15px; background: #180e28; }
.hero::before, .hero::after { content: ''; position: absolute; inset: 0; z-index: -1; }
.hero::before { background: url('/pavuna-hero.webp') right center / auto 132% no-repeat, radial-gradient(ellipse at 78% 25%, #311755 0%, #180d24 65%); }
.hero::after { background: linear-gradient(90deg, #130b20 0%, #170d25 23%, #1a102de8 40%, #18102545 66%, #190c2955 100%), linear-gradient(0deg, #160d27ba, transparent 72%); }
.hero-content { padding: 28px 34px 30px; }
.hero-kicker { margin: 0 0 9px; color: #d8b5ff; font-size: 13px; font-weight: 800; letter-spacing: .18em; }
.hero h1 { margin: 0; font-family: Impact, 'Arial Narrow', sans-serif; font-size: clamp(48px, 7vw, 84px); font-weight: 800; line-height: .98; letter-spacing: .015em; text-transform: uppercase; overflow-wrap: anywhere; }
.hero h1 em { font-style: normal; color: #c183ff; }
.hero-meta { display: flex; gap: 8px; align-items: center; margin-top: 17px; color: #e1d3f3; font-size: 15px; }
.hero-meta .icon { width: 17px; height: 17px; color: #c58fff; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 20px; }
.mode-notice { margin-top: 16px; padding: 12px 14px; border: 1px solid #614285; border-radius: 8px; background: #241733; color: #ebd9ff; font-size: 14px; }
.mode-notice.error { color: #ffe1e8; border-color: #65374c; background: #2e1725; }
.loading { color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 19px; }
.stat { display: flex; align-items: center; gap: 12px; min-height: 85px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px; background: var(--panel); }
.stat-icon { width: 41px; height: 41px; display: grid; place-items: center; flex: none; color: var(--purple); border-radius: 9px; background: #2c1d40; }
.stat-icon.gold { color: #e9c16d; background: #382d22; }
.stat span:not(.stat-icon) { display: block; }
.stat-label { color: var(--muted); font-size: 14px; }
.stat-value { margin-top: 3px; font-size: 21px; line-height: 1.1; font-weight: 810; overflow-wrap: anywhere; }
.stat-value.word { font-size: 17px; }

.panel { margin-top: 19px; overflow: hidden; border: 1px solid var(--border); border-radius: 13px; background: var(--panel); }
.panel-content { padding: 19px; }
.panel-heading { display: flex; gap: 14px; align-items: center; justify-content: space-between; padding: 17px 19px; }
.panel-heading h2, .section-title { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 780; letter-spacing: -.03em; }
.panel-heading h2 .icon { vertical-align: -2px; margin-right: 4px; color: var(--purple); }
.panel-heading p { margin: 5px 0 0; color: var(--muted); font-size: 14px; }
.panel-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.main-foot { padding: 17px 3px; text-align: right; color: #a18eb5; font-size: 13px; }
.empty { margin: 0; padding: 22px 19px; border-top: 1px solid var(--border); color: var(--muted); }

.bracket-scroll { overflow-x: auto; scrollbar-color: #5e477a #181221; }
.bracket-rounds { display: flex; width: max-content; min-width: 100%; min-height: 170px; padding: 13px 19px 20px; border-top: 1px solid var(--border); background: radial-gradient(ellipse at 25% 0%, #22153270, transparent 72%), #130f1a; }
.bracket-round { display: flex; flex-direction: column; flex: 1 0 180px; width: 180px; }
.bracket-round + .bracket-round { margin-left: 23px; }
.bracket-round h3 { margin: 0 0 10px; font-size: 14px; font-weight: 770; color: #dec7f7; }
.round-matches { display: flex; flex-direction: column; flex: 1; justify-content: space-around; gap: 9px; }
.match-card { position: relative; padding: 4px; border: 1px solid #362b45; border-radius: 9px; background: #1c1626; }
.match-card:not(.last)::after { position: absolute; content: ''; top: 50%; right: -22px; width: 21px; border-top: 1px solid #684c87; }
.match-card.pending { border-style: dashed; }
.match-team { width: 100%; min-height: 34px; padding: 6px 8px; display: flex; gap: 8px; align-items: center; color: var(--strong); border: 1px solid transparent; border-radius: 6px; background: transparent; text-align: left; font-size: 14px; line-height: 1.2; overflow-wrap: anywhere; }
button.match-team:hover { background: #36224c; border-color: #66448c; }
.match-team + .match-team { border-top-color: #342843; }
.match-team.placeholder { color: #ac9abf; }
.match-team.winner { color: #e2ffd9; background: #26322a; }
.match-team .icon { margin-left: auto; width: 13px; height: 13px; }
.team-mark { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #a477e0; }
.match-team.placeholder .team-mark { background: #65536f; }
.match-team.winner .team-mark { background: var(--green); }
.match-heading { display: flex; min-height: 22px; align-items: center; gap: 6px; padding: 1px 8px 4px; color: #b6a1cb; font-size: 12px; }
.match-heading a { text-decoration: underline; text-underline-offset: 2px; }
.match-heading a:hover { color: var(--strong); }

.team-list { border-top: 1px solid var(--border); }
.team-row { min-height: 66px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(110px, .55fr) auto; align-items: center; gap: 12px; padding: 10px 19px; }
.team-row + .team-row { border-top: 1px solid var(--border); }
.team-identity { min-width: 0; display: flex; align-items: center; gap: 10px; }
.team-identity strong { overflow-wrap: anywhere; }
.team-avatar { display: grid; place-items: center; flex: none; width: 34px; min-height: 34px; border-radius: 8px; color: #e9d7ff; background: #38234f; font-size: 12px; font-weight: 800; }
.team-discord { color: var(--muted); font-size: 14px; }
.team-discord a { text-decoration: underline; text-underline-offset: 2px; }
.team-actions { display: flex; gap: 7px; }

.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.settings-grid .panel { margin-top: 0; }
.settings-grid .panel-content { border-top: 1px solid var(--border); }
.settings-stack { margin-top: 19px; }
.settings-stack h2 { margin-bottom: 12px; }
.settings-info { margin: 0 0 14px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.settings-info code { padding: 3px 5px; border-radius: 4px; background: #292039; color: #ead9ff; }
.field { display: grid; gap: 7px; margin: 0 0 13px; font-size: 14px; font-weight: 690; }
.field input, .field select { width: 100%; min-height: 43px; border: 1px solid #49395a; border-radius: 8px; background: #120d1b; color: var(--strong); padding: 8px 10px; font-size: 16px; font-weight: 400; }
.field select { appearance: none; padding-right: 31px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23b99ad3' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }

dialog { width: min(92vw, 510px); max-height: 90vh; padding: 0; border: 1px solid #624680; border-radius: 14px; color: var(--strong); background: #1b1426; box-shadow: 0 18px 70px #0009; }
dialog.wide { width: min(92vw, 970px); }
dialog.poster-dialog { width: min(88vw, 550px); }
dialog::backdrop { background: #09060dd2; backdrop-filter: blur(4px); }
.dialog-frame { padding: 17px; }
.dialog-frame header { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 13px; }
.dialog-frame h2 { margin: 0; font-size: 22px; font-weight: 800; }
.dialog-frame p { color: var(--muted); margin: 0 0 14px; line-height: 1.55; }
.dialog-frame p.form-error { color: var(--red); font-size: 14px; margin-top: 10px; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 13px; }
.dialog-image { display: block; max-width: 100%; max-height: 70vh; margin-inline: auto; border-radius: 6px; object-fit: contain; }
.team-picker { max-height: min(37vh, 290px); padding: 7px; overflow-y: auto; border: 1px solid #49395a; border-radius: 8px; }
.team-picker label { padding: 8px; display: flex; align-items: center; gap: 8px; border-radius: 4px; }
.team-picker label:hover { background: #332344; }
.team-picker input { width: 16px; height: 16px; accent-color: #9356f4; }
.toast { position: fixed; z-index: 10; right: 20px; bottom: 20px; max-width: min(460px, calc(100vw - 40px)); padding: 13px 15px; border: 1px solid #66468a; border-radius: 9px; background: #2a1d3b; color: #f7ecff; box-shadow: 0 7px 34px #0009; }
.toast.error { border-color: #82445e; background: #3c2130; color: #ffe7ed; }

@media (max-width: 1030px) {
  :root { --sidebar-width: 190px; }
  .sidebar { padding-inline: 13px; }
  .topbar, main { padding-inline: 21px; }
  .hero::before { background-position: right 24% center; }
  .stat { gap: 8px; }
}

@media (max-width: 760px) {
  .shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 11px 12px 0; border-right: 0; border-bottom: 1px solid var(--border); }
  .brand { padding-left: 3px; }
  .brand img { width: 37px; height: 37px; }
  .navigation { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; margin-top: 10px; }
  .navigation a { justify-content: center; gap: 5px; min-height: 43px; padding: 5px 1px; border-bottom: 0; border-radius: 6px 6px 0 0; font-size: 13px; }
  .navigation a .icon { width: 16px; height: 16px; }
  .sidebar-foot { display: none; }
  .topbar, main { padding-inline: 13px; }
  .topbar { min-height: 58px; background: transparent; }
  .top-actions { gap: 4px; }
  main { padding-top: 15px; }
  .hero { min-height: 240px; }
  .hero::before { background-position: right 31% center; }
  .hero::after { background: linear-gradient(90deg, #130b20 0%, #170d25e8 25%, #1a102dc4 44%, #18102550 100%), linear-gradient(0deg, #160d2790, transparent 65%); }
  .hero-content { padding: 22px 16px; }
  .stats { gap: 7px; }
  .stat { padding: 9px; }
  .stat-icon { width: 33px; height: 33px; }
  .stat-icon .icon { width: 17px; height: 17px; }
  .stat-label { font-size: 13px; }
  .stat-value.word { font-size: 14px; }
  .panel-heading { flex-wrap: wrap; padding: 14px; }
  .bracket-rounds { padding-inline: 14px; }
  .panel-content { padding: 14px; }
}

@media (max-width: 470px) {
  .navigation a { flex-direction: column; min-height: 48px; }
  .topbar .breadcrumbs > span { display: none; }
  .topbar .button { padding-inline: 8px; font-size: 13px; }
  .hero h1 { font-size: 47px; }
  .hero-kicker { font-size: 11px; }
  .hero-meta { font-size: 14px; }
  .stat { flex-direction: column; align-items: flex-start; }
  .team-row { grid-template-columns: minmax(0, 1fr) auto; gap: 7px; padding-inline: 12px; }
  .team-discord { grid-row: 2; padding-left: 44px; }
  .team-actions { grid-column: 2; grid-row: 1 / span 2; }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: no-preference) {
  .button, .navigation a, .icon-button { transition: background-color .16s ease, border-color .16s ease; }
}
