:root {
  color-scheme: dark;
  --bg: #141719;
  --panel: #1c2225;
  --text: #e0e2df;
  --muted: #8d9393;
  --accent: #bc5b48;
  --gold: #d4b78c;
  --line: #343b3e;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 20% 0, #722e221a, transparent 55%), var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
main { max-width: 900px; margin: auto; padding: calc(20px + var(--tg-content-safe-area-inset-top, 0px)) 20px calc(96px + env(safe-area-inset-bottom)); }
header, .section-heading, .match-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.brand { display: flex; align-items: center; gap: 14px; font-size: 11px; font-weight: 500; letter-spacing: 1.6px; text-transform: uppercase; }
.brand::before { content: ""; width: 3px; height: 16px; background: var(--accent); }
.brand small { color: var(--muted); font-size: 9px; letter-spacing: 2px; }
button { font: inherit; color: var(--text); cursor: pointer; }
button:disabled { opacity: .4; }
button:focus-visible, a:focus-visible, summary:focus-visible, .bracket-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#refresh { width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: var(--muted); font-size: 24px; }
#refresh:hover { color: var(--text); }
h1 { margin: 24px 0; font: 400 clamp(26px, 5vw, 32px)/1.2 Georgia, "Times New Roman", serif; letter-spacing: .04em; text-transform: uppercase; }
h2 { margin: 0; font-size: 13px; font-weight: 500; }
.muted { color: var(--muted); font-size: 11px; }
#feedback { margin-top: 12px; color: var(--muted); font-size: 12px; }
#feedback:empty { display: none; }
#feedback.error { color: var(--tg-theme-destructive-text-color, #e5aaa9); }
.tabs { display: flex; gap: 28px; border-bottom: 1px solid var(--line); }
.tabs button { position: relative; padding: 0 0 12px; background: transparent; border: 0; color: var(--muted); font-size: 13px; }
.tabs button { min-height: 40px; }
.tabs button[aria-selected="true"] { color: #e6d1bd; }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--accent); }
.bracket-controls { display: flex; justify-content: flex-end; margin: 14px 0 8px; }
.small-button { padding: 4px 0 4px 10px; border: 0; background: transparent; color: var(--muted); font-size: 11px; }
.bracket-scroll { overflow: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.bracket-canvas { position: relative; transform-origin: top left; }
.lane-divider { position: absolute; height: 1px; background: linear-gradient(90deg, #633e33, #343b3e55); }
.bracket-canvas svg { position: absolute; inset: 0; pointer-events: none; }
.bracket-canvas path { fill: none; stroke: #838a8a; stroke-width: 1.25; opacity: .75; }
.lane-label, .round-label, .bracket-card { position: absolute; }
.lane-label { color: #c2aea0; font-size: 10px; font-weight: 500; letter-spacing: 1.1px; text-transform: uppercase; }
.round-label { width: 184px; color: var(--muted); font-size: 10px; }
.bracket-card { width: 184px; height: 68px; background: linear-gradient(120deg, #252b2e, #1b2124); color: var(--text); border: 1px solid #404649; border-radius: 0; box-shadow: 0 2px 7px #0002; }
.bracket-card.live, .bracket-card.live_or_delayed { border-left: 2px solid var(--accent); }
.team-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; height: 33px; padding-left: 8px; font-size: 12px; }
.team-row:first-child { border-bottom: 1px solid #ffffff0c; }
.team-name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-row strong { display: grid; place-items: center; align-self: stretch; flex: 0 0 28px; border-left: 1px solid #ffffff0c; font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums; }
.team-logo { width: 18px; height: 18px; flex: 0 0 18px; object-fit: contain; }
.team-logo[src*="/spirit-"], .team-logo[src*="/liquid-"] { filter: brightness(0) invert(.85); }
.team-mark { display: grid; place-items: center; width: 18px; height: 18px; flex: 0 0 18px; color: #a1a9b8; font-size: 8px; font-weight: 500; }
.finished .team-row:not(.winner), .team-row.unknown { color: var(--muted); }
.team-row.winner { font-weight: 600; }
.team-row.winner strong { color: var(--gold); }
.live-badge { position: absolute; right: 6px; top: -14px; color: var(--accent); font-size: 8px; letter-spacing: .8px; }
.section-heading { margin: 24px 0 16px; }
.schedule-day > summary { cursor: pointer; list-style: none; min-height: 36px; }
.schedule-day > summary::-webkit-details-marker { display: none; }
.day-meta { display: flex; align-items: center; gap: 14px; }
.day-chevron { width: 7px; height: 7px; border-right: 1px solid var(--muted); border-bottom: 1px solid var(--muted); transform: rotate(-45deg); margin-right: 3px; }
.schedule-day[open] .day-chevron { transform: rotate(45deg); }
.match { padding: 15px 0; border-bottom: 1px solid var(--line); }
.match-top { margin-bottom: 8px; color: var(--muted); font-size: 10px; }
.schedule-teams { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; font-size: 13px; }
.schedule-teams span:last-child { text-align: right; }
.schedule-team { display: flex; align-items: center; gap: 7px; min-width: 0; }
.schedule-team:last-child { justify-content: flex-end; }
.schedule-teams strong { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }
.empty { padding: 28px 0; color: var(--muted); font-size: 12px; }
.bottom-nav { position: fixed; z-index: 5; bottom: 0; left: 50%; transform: translateX(-50%); width: min(100%, 900px); display: grid; grid-template-columns: repeat(4, 1fr); padding: 0 16px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: var(--bg); }
.bottom-nav a { position: relative; padding: 20px 0; text-align: center; text-decoration: none; color: var(--muted); font-size: 12px; }
.bottom-nav a[aria-current="page"] { color: #e6d1bd; }
.bottom-nav a[aria-current="page"]::before { content: ""; position: absolute; left: 16px; right: 16px; top: -1px; height: 2px; background: var(--accent); }
.profile-identity { display: flex; align-items: center; gap: 18px; padding: 10px 0 28px; border-bottom: 1px solid var(--line); }
.profile-avatar { display: grid; place-items: center; flex: 0 0 56px; height: 56px; border: 1px solid #60483d; background: var(--panel); color: var(--gold); font: 20px Georgia, serif; }
.profile-details { min-width: 0; }
.profile-details h2 { font-size: 18px; overflow-wrap: anywhere; }
.profile-details p { margin: 4px 0 0; overflow-wrap: anywhere; }
.profile-username { color: var(--muted); font-size: 12px; }
.profile-section { padding: 24px 0; border-bottom: 1px solid var(--line); }
.profile-section > h2 { margin-bottom: 18px; color: #c2aea0; font-size: 11px; letter-spacing: 1.1px; text-transform: uppercase; }
.profile-row + .profile-row { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line); }
.profile-row .section-heading, .transaction .section-heading { align-items: flex-start; margin: 0 0 6px; }
.profile-row h3 { margin: 0; font-size: 14px; font-weight: 500; }
.profile-row p { margin: 4px 0 0; overflow-wrap: anywhere; }
.profile-note, #profile-feedback { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
#profile-feedback:empty { display: none; }
.plan-status { flex-shrink: 0; color: var(--muted); font-size: 11px; }
.plan-status.active { color: var(--gold); }
.balance-value { margin: 0; font-size: 30px; font-weight: 400; font-variant-numeric: tabular-nums; }
.profile-link, .back-link { display: inline-block; color: #e6d1bd; font-size: 12px; text-decoration: none; }
.profile-link { margin-top: 20px; padding: 5px 0; }
.back-link { margin-top: 24px; }
.transaction { padding: 18px 0; border-bottom: 1px solid var(--line); }
.transaction h2 { min-width: 0; overflow-wrap: anywhere; }
.transaction-amount { flex-shrink: 0; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.prediction-tournament { margin: 24px 0 12px; color: #c2aea0; font-size: 14px; }
.prediction-intro { margin-top: 22px; }
#predictions-feedback, #current-predictions-feedback { color: var(--muted); font-size: 12px; margin-top: 16px; }
#predictions-feedback:empty, #current-predictions-feedback:empty { display: none; }
.prediction-card { --prediction-tint: transparent; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--line); background: linear-gradient(to top, var(--prediction-tint), transparent 72%), linear-gradient(120deg, #252b2e88, #1b212466); }
.prediction-card.prediction-correct { --prediction-tint: #638b693d; }
.prediction-card.prediction-incorrect { --prediction-tint: #a65f5d3d; }
.prediction-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 12px; margin: 0 0 6px; color: var(--muted); font-size: 11px; }
.prediction-match-link { padding: 4px 0; margin: -4px 0; color: #e6d1bd; text-decoration: none; white-space: nowrap; font-variant-numeric: tabular-nums; }
.prediction-match-link:hover { text-decoration: underline; }
.prediction-team { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 6px; }
.prediction-team strong { flex-shrink: 0; font-size: 20px; font-weight: 500; font-variant-numeric: tabular-nums; color: #e6d1bd; }
.prediction-team .schedule-team { flex: 1; }
.prediction-team .schedule-team:last-child { justify-content: flex-start; }
.probability-bar { height: 4px; margin: 10px 0 8px; background: #A65F5D; overflow: hidden; }
.probability-bar span { display: block; height: 100%; background: #638B69; }
.prediction-confidence { margin: 0; font-size: 12px; color: #c2aea0; }
.prediction-published, .prediction-expiry { margin: 8px 0 0; font-size: 10px; color: var(--muted); }
.prediction-footer { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 3px 12px; }
.prediction-footer p { margin: 0; }
.prediction-footer .prediction-confidence { font-size: 11px; }
.prediction-message { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13px; }
.prediction-waiting { margin: 14px 0 2px; color: var(--muted); font-size: 12px; }
.history-more { margin-top: 22px; width: 100%; padding: 12px; background: transparent; border: 1px solid var(--line); }
@media(max-width: 420px) { main { padding-left: 16px; padding-right: 16px; } }

.prediction-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 18px 0 14px; }
.prediction-stat { padding: 16px 12px; border: 1px solid var(--line); background: var(--panel); min-width: 0; }
.prediction-stat h3 { margin: 0 0 10px; color: #c2aea0; font-size: 11px; font-weight: 500; }
.winrate-value { display: block; font-size: clamp(24px, 5.5vw, 34px); line-height: 1.2; font-weight: 500; color: #a4bd9f; font-variant-numeric: tabular-nums; }
.winrate-count, .winrate-pending { margin: 8px 0 0; font-size: 11px; color: var(--muted); }
.winrate-pending { margin-top: 4px; font-size: 10px; }
.prediction-rules { margin-bottom: 22px; font-size: 11px; }
@media(max-width: 420px) { .prediction-stats { gap: 7px; } .prediction-stat { padding: 12px 8px; } .winrate-count { font-size: 10px; } }

.view-date { margin: 20px 0; color: var(--muted); font-size: 12px; }
.today-predictions { padding: 16px; border: 1px solid var(--line); background: var(--panel); }
.today-predictions > h2 { margin-bottom: 14px; color: #c2aea0; font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
.state-title { margin: 0; color: var(--text); font-size: 14px; font-weight: 500; }
.today-predictions .profile-link, #current-predictions-content > .profile-link { margin-top: 12px; }
.today-section { margin-top: 28px; }
.today-section > h2 { color: #c2aea0; }
.match-live { color: var(--gold); }
.today-completed, .schedule-archive { margin-top: 24px; border-top: 1px solid var(--line); }
.schedule-archive > .schedule-day { margin-left: 12px; }
.view-links { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 24px; }
.view-links a { padding: 8px 0; color: #e6d1bd; font-size: 12px; text-decoration: none; }
#current-predictions-content > .state-title { margin-top: 28px; }
