/* Public pages of the tournament app (docs/SERVER_IMPLEMENTATION_PLAN_FA.md §4). Mobile first,
   RTL, the app's gold accent and neutrals, Dana; light and dark follow the device. */

@font-face { font-family: Dana; font-weight: 400; font-display: swap; src: url(../fonts/dana-fanum-regular.woff2) format("woff2"); }
@font-face { font-family: Dana; font-weight: 500; font-display: swap; src: url(../fonts/dana-fanum-medium.woff2) format("woff2"); }
@font-face { font-family: Dana; font-weight: 600; font-display: swap; src: url(../fonts/dana-fanum-demibold.woff2) format("woff2"); }
@font-face { font-family: Dana; font-weight: 700; font-display: swap; src: url(../fonts/dana-fanum-bold.woff2) format("woff2"); }

:root {
    --bg: #F6F7F3;
    --surface: #FFFFFF;
    --surface-2: #F1F4F0;
    --text: #1C211E;
    --muted: #5B645F;
    --line: #E3E8E2;
    --line-strong: #C4CCC6;
    --accent: #FFB300;
    --on-accent: #1C1B1F;
    --accent-ink: #946300;
    --accent-soft: #FFF4D6;
    --radius: 16px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0F1413;
        --surface: #161C1B;
        --surface-2: #1E2926;
        --text: #DDE7E3;
        --muted: #A3B3AE;
        --line: #2A3633;
        --line-strong: #3E504C;
        --accent-ink: #FFC940;
        --accent-soft: #3A2E0A;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 15px/1.65 Dana, Tahoma, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button { font: inherit; color: inherit; }
[dir="auto"] { unicode-bidi: plaintext; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }

.page { max-width: 960px; margin: 0 auto; padding: 10px 10px 8px; }
.page.narrow { max-width: 520px; padding-top: 48px; }
.page.doc { max-width: 760px; }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}

.muted { color: var(--muted); }

.ic { width: 22px; height: 22px; fill: currentColor; flex: none; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--surface-2);
    color: var(--text);
    cursor: pointer;
    flex: none;
}
.icon-btn:hover { background: var(--accent-soft); }
.icon-btn:active { transform: scale(.94); }

/* Header: trophy, name, sport · mode, last update, share. */
.hero {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}
.hero-row { display: flex; align-items: center; gap: 12px; }
.trophy {
    display: grid;
    place-items: center;
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: var(--accent-soft);
    flex: none;
}
.trophy img { width: 40px; height: 40px; }
.trophy-off img { filter: grayscale(1); opacity: .55; }
.hero-text { flex: 1; min-width: 0; }
.hero h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 700;
    line-height: 1.45;
    overflow-wrap: anywhere;
}
.sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.updated {
    margin: 12px 0 0;
    padding-top: 10px;
    border-top: 1px dashed var(--line);
    color: var(--muted);
    font-size: 12px;
}
.share-btn .ic-done { display: none; }
.share-btn.done .ic-share { display: none; }
.share-btn.done .ic-done { display: block; color: var(--accent-ink); }

/* Stage chips: one per stage, scrolling sideways. */
.chips {
    display: flex;
    gap: 8px;
    margin: 12px -10px 0;
    padding: 0 10px 2px;
    overflow-x: auto;
    scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
    flex: none;
    padding: 6px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }

.stage { margin-top: 12px; }
.stage-title { margin: 20px 4px 8px; font-size: 16px; font-weight: 700; }

/* Tabs: icons with a gold bar under the open one, as in the app. */
.tabs {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 12px;
    overflow: hidden;
}
.tab {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 4px 9px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}
.tab.on { color: var(--text); font-weight: 700; }
.tab.on .ic { fill: var(--accent); }
.tab.on::after {
    content: "";
    position: absolute;
    inset: auto 22% 0;
    height: 3px;
    border-radius: 3px 3px 0 0;
    background: var(--accent);
}

/* Without script every stage and panel shows in order; with it, one at a time. */
.js .stage, .js .panel { display: none; }
.js .stage.on, .js .panel.on { display: block; }
.js .stage-title { display: none; }

.sec-title {
    margin: 0;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--accent-ink);
    font-size: 15px;
    font-weight: 700;
}

/* Standings: rank and name stay put while the numbers scroll. */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.st { width: max-content; min-width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.st th, .st td {
    padding: 9px 5px;
    text-align: center;
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}
.st th { color: var(--muted); font-size: 12px; font-weight: 500; padding-top: 10px; padding-bottom: 8px; }
.st tbody tr:last-child td { border-bottom: 0; }
.st .c-rk { position: sticky; right: 0; z-index: 1; width: 40px; min-width: 40px; padding-right: 8px; padding-left: 2px; }
/* The name column takes the room the numbers leave; the table scrolls only when it must. */
.st .c-nm {
    position: sticky;
    right: 40px;
    z-index: 1;
    width: 100%;
    text-align: right;
    box-shadow: inset 1px 0 0 var(--line);
}
.st .nm { display: block; min-width: 64px; max-width: 26vw; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
/* Points stay in sight on the left edge while the middle columns scroll. */
.st .c-pt {
    position: sticky;
    left: 0;
    z-index: 1;
    font-weight: 700;
    font-size: 15px;
    padding-left: 12px;
    padding-right: 8px;
    box-shadow: inset -1px 0 0 var(--line);
}
.st .c-pt sup { color: var(--accent-ink); font-size: 11px; }
.rk {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--surface-2);
    font-size: 13px;
    font-weight: 700;
}
.st .l { display: none; }
.note-line { margin: 0; padding: 10px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }

/* Matches: side one on the right, the result in the middle, side two on the left. */
.matches { list-style: none; margin: 0; padding: 0; }
.matches > li { border-bottom: 1px solid var(--line); }
.matches > li:last-child { border-bottom: 0; }
.m {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 4px 10px;
    padding: 12px 14px;
}
.side { font-size: 14.5px; overflow-wrap: anywhere; line-height: 1.5; }
.side.one { text-align: right; }
.side.two { text-align: left; }
.side.win { font-weight: 700; }
.res { min-width: 64px; text-align: center; }
.sc {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 10px;
    border-radius: 8px;
    background: var(--surface-2);
    font-size: 15px;
}
.sc i { font-style: normal; color: var(--muted); }
.pend { color: var(--muted); font-size: 18px; }
.lbl { display: inline-block; padding: 2px 8px; border-radius: 8px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.det { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.5; }
.matches .note { padding: 10px 16px; color: var(--muted); font-size: 13px; }

/* Bracket: the app's board in its own scrolling frame. */
.bk-tools { display: flex; justify-content: flex-end; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); }
.bk-tools .icon-btn { width: 36px; height: 36px; }
.bk-scroll { overflow: auto; direction: ltr; max-height: 78vh; -webkit-overflow-scrolling: touch; }
.bk { display: block; font-family: Dana, Tahoma, sans-serif; }
.bk text { fill: var(--text); font-size: 15px; }
.bk text.w { font-weight: 700; }
.bk text.m { fill: var(--muted); }
.bk .cp { fill: var(--muted); font-size: 13px; }
.bk .lb { fill: var(--muted); font-weight: 600; }
.bk .lb-s { fill: var(--accent-ink); font-size: 16px; font-weight: 700; }
.bk .bx { fill: var(--surface); stroke: var(--line-strong); stroke-width: 1; }
.bk .dv { stroke: var(--line); stroke-width: 1; }
.bk .ln { fill: none; stroke: var(--line-strong); stroke-width: 1.2; }
.bk .ln-d { stroke: var(--text); stroke-opacity: .7; stroke-width: 1.8; }

/* Empty stage, unavailable page, placeholder home. */
.empty, .state { padding: 32px 20px; text-align: center; }
.empty p { margin: 8px 0 0; color: var(--muted); }
.empty-ic { width: 40px; height: 40px; fill: var(--line-strong); }
.state .trophy { margin: 0 auto 12px; width: 72px; height: 72px; border-radius: 20px; }
.state h1 { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.state p { margin: 4px 0 0; }

/* Privacy and terms. */
.prose { padding: 20px; }
.prose h1 { margin: 0; font-size: 21px; font-weight: 700; }
.prose h2 { margin: 24px 0 6px; font-size: 16px; font-weight: 700; }
.prose p, .prose ul { margin: 8px 0; line-height: 1.95; }
.prose ul { padding-right: 20px; padding-left: 0; }
.prose li { margin-bottom: 6px; }
.prose a { color: var(--accent-ink); }

.foot { padding: 20px 16px 32px; text-align: center; color: var(--muted); font-size: 12.5px; }
.foot a { text-decoration: none; }
.foot a:hover { text-decoration: underline; }
.foot .made strong { color: var(--text); font-weight: 600; }
.foot .brand-logo { width: 20px; height: 20px; vertical-align: -5px; }
.home-logo { display: block; width: 112px; height: 112px; margin: 4px auto 12px; }
.foot-links { margin-top: 6px; display: flex; justify-content: center; gap: 8px; }

@media (min-width: 600px) {
    .st .s { display: none; }
    .st .l { display: inline; }
    .st .nm { max-width: 260px; }
}

@media (min-width: 768px) {
    .page { padding: 24px 20px 8px; }
    .hero { padding: 20px 24px; }
    .hero h1 { font-size: 23px; }
    .trophy { width: 64px; height: 64px; }
    .trophy img { width: 46px; height: 46px; }
    .chips { margin-left: 0; margin-right: 0; padding: 0; }
    .m { padding: 12px 20px; }
    .st tbody tr:hover td { background: var(--surface-2); }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}
