:root {
    --bg: #eef4e8;
    --ink: #18211f;
    --muted: #67716b;
    --line: #d8e2d0;
    --panel: #ffffff;
    --accent: #126b4f;
    --accent-2: #d6f16a;
    --court: #1f7a55;
    --clay: #d97b3d;
    --warn: #9a5b11;
    --bad: #a33232;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        linear-gradient(90deg, rgba(18,107,79,.08) 1px, transparent 1px) 50% 0 / 118px 118px,
        linear-gradient(0deg, rgba(18,107,79,.07) 1px, transparent 1px) 0 50% / 118px 118px,
        radial-gradient(circle at 92% 8%, rgba(214,241,106,.46) 0 34px, transparent 35px),
        var(--bg);
    -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(18,107,79,.22), rgba(214,241,106,.24)),
        linear-gradient(90deg, transparent 49%, rgba(255,255,255,.55) 49% 51%, transparent 51%),
        var(--bg);
}
.auth-box {
    width: min(460px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: 0 20px 70px rgba(24,33,31,.12);
}
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    padding: 20px;
    background: #111816;
    color: #fff;
    display: flex;
    flex-direction: column;
    gap: 22px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
}
.brand span {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--accent-2);
    color: #101510;
    font-weight: 800;
}
.brand span::after {
    content: "";
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid rgba(16,21,16,.34);
    border-left-color: transparent;
    position: absolute;
}
nav, .side-section { display: grid; gap: 8px; }
nav a, .side-section a {
    padding: 10px 12px;
    border-radius: 8px;
    color: #e8eee8;
}
nav a:hover, .side-section a:hover { background: rgba(255,255,255,.09); }
.side-section small, .account span, .muted { color: var(--muted); }
.account {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid rgba(255,255,255,.14);
    display: grid;
    gap: 4px;
}
.account a { color: var(--accent-2); margin-top: 6px; }
.main {
    margin-left: 260px;
    padding: 28px;
    display: grid;
    gap: 24px;
}
.hero, .page-head {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 18px;
    align-items: end;
    background:
        linear-gradient(90deg, transparent 49%, rgba(255,255,255,.22) 49% 51%, transparent 51%),
        linear-gradient(135deg, #113d31, #176b52);
    color: #fff;
    border-radius: 8px;
    padding: 28px;
}
.hero::before, .page-head::before {
    content: "";
    position: absolute;
    inset: 10px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 6px;
    pointer-events: none;
}
.hero, .page-head, .brand span {
    position: relative;
}
.hero h1, .page-head h1 { margin: 4px 0 8px; font-size: clamp(28px, 4vw, 48px); letter-spacing: 0; }
.hero p { max-width: 760px; color: #d7e1dc; line-height: 1.55; }
.eyebrow {
    margin: 0;
    color: var(--accent-2);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}
.hero-stat {
    min-width: 120px;
    padding: 16px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 8px;
    display: grid;
    gap: 2px;
}
.hero-stat strong { font-size: 34px; }
.hero-stat span { color: #cbd7d0; }
.grid { display: grid; gap: 20px; }
.grid.two { grid-template-columns: minmax(0, 1.25fr) minmax(320px, .75fr); }
.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
h1, h2, h3, p { overflow-wrap: anywhere; }
h2 { margin: 0; font-size: 22px; }
.section-title a, .button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    padding: 9px 12px;
    font-weight: 700;
    cursor: pointer;
}
.button.primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.panel, .rules, .round, .table, .match-list, .player-grid, .league-list {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}
.panel, .rules { padding: 18px; }
.rules p { margin: 0 0 10px; line-height: 1.45; }
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}
.table th, .table td {
    padding: 13px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.table td:nth-child(2), .table th:nth-child(2) { white-space: normal; }
.table tr:last-child td { border-bottom: 0; }
.standings tbody tr:first-child td { background: rgba(214,241,106,.35); font-weight: 800; }
.tag, .badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border-radius: 999px;
    background: #f1e3cf;
    color: var(--warn);
    font-size: 12px;
    font-weight: 800;
}
.round-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.round { padding: 16px; display: grid; gap: 10px; align-content: start; }
.round h3 { margin: 0 0 4px; }
.round h3::before {
    content: "";
    width: 14px;
    height: 14px;
    display: inline-block;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--accent-2);
    box-shadow: inset 5px 0 0 rgba(255,255,255,.35);
}
.match-card, .match-row, .player-card {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}
.match-card.played, .match-card.forfeit { border-left: 5px solid var(--accent); }
.match-card.scheduled { border-left: 5px solid #b9c2bc; }
.match-card small, .match-row span, .match-row em, .player-card span { color: var(--muted); font-style: normal; }
.match-list, .player-grid { padding: 10px; display: grid; gap: 8px; }
.player-grid { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.league-list {
    padding: 10px;
    display: grid;
    gap: 10px;
    align-content: start;
}
.league-card {
    display: grid;
    gap: 8px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfcfa;
}
.league-card strong {
    font-size: 18px;
    line-height: 1.25;
}
.league-card small, .league-card p {
    color: var(--muted);
}
.league-card p {
    margin: 0;
    line-height: 1.45;
}
.check-list {
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
}
.check-list legend {
    padding: 0 6px;
    font-weight: 800;
}
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}
.feature-grid article,
.feature-grid a {
    min-height: 112px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    display: grid;
    gap: 8px;
    align-content: start;
}
.feature-grid article::before,
.feature-grid a::before {
    content: "";
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 35% 35%, #f4ff9b, var(--accent-2));
    box-shadow: inset 7px 0 0 rgba(255,255,255,.32);
}
.feature-grid strong {
    font-size: 16px;
}
.feature-grid span {
    color: var(--muted);
    line-height: 1.42;
}
.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}
.button-row form {
    display: inline-flex;
}
.league-card.unread {
    border-color: var(--accent);
    background: linear-gradient(135deg, rgba(214,241,106,.2), #fff);
}
.public-page {
    padding: 16px;
}
.public-main {
    width: min(1100px, 100%);
    margin: 0 auto;
    display: grid;
    gap: 18px;
}
.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}
.stats div {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    display: grid;
    gap: 4px;
}
.stats strong { font-size: 30px; }
.stats span { color: var(--muted); }
.player-contact {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}
.player-contact div {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    display: grid;
    gap: 4px;
    min-width: 0;
}
.player-contact span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}
.player-contact strong {
    overflow-wrap: anywhere;
}
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 6px; font-weight: 700; }
label.inline {
    display: flex;
    align-items: center;
    gap: 8px;
}
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 48px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
}
input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 18px;
    padding: 0;
    flex: 0 0 auto;
    accent-color: var(--accent);
}
.check-list label.inline,
.mini-form label {
    min-height: 34px;
}
textarea { min-height: 96px; resize: vertical; }
.score-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.player-status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.mini-form {
    display: grid;
    gap: 8px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}
.alert {
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fff;
}
.alert.ok { border-color: #8cc99f; color: #176b37; }
.alert.bad { border-color: #dea3a3; color: var(--bad); }
code { background: #eef2ee; padding: 2px 5px; border-radius: 4px; }

@media (max-width: 900px) {
    body {
        padding-bottom: calc(76px + env(safe-area-inset-bottom));
    }
    .sidebar {
        position: sticky;
        top: 0;
        z-index: 20;
        width: 100%;
        min-height: 0;
        padding: 10px 12px;
        border-bottom: 1px solid rgba(255,255,255,.12);
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 8px 12px;
    }
    .brand {
        min-width: 0;
        font-size: 16px;
    }
    .brand span {
        width: 34px;
        height: 34px;
    }
    .brand strong {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .sidebar nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 30;
        grid-column: 1 / -1;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 76px;
        gap: 0;
        padding: 7px max(8px, env(safe-area-inset-left)) calc(7px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
        background: #111816;
        border-top: 1px solid rgba(255,255,255,.12);
        box-shadow: 0 -12px 34px rgba(16,21,16,.18);
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
    .sidebar nav a {
        min-height: 58px;
        padding: 7px 4px 5px;
        border-radius: 8px;
        display: grid;
        place-items: center;
        align-content: center;
        gap: 3px;
        color: #edf4ef;
        font-size: 11px;
        font-weight: 800;
        line-height: 1.1;
        text-align: center;
    }
    .sidebar nav a::before {
        content: "";
        width: 22px;
        height: 22px;
        display: block;
        border-radius: 8px;
        background: rgba(214,241,106,.18);
        color: var(--accent-2);
        font-size: 17px;
        line-height: 22px;
    }
    .sidebar nav a:nth-child(1)::before { content: "⌂"; }
    .sidebar nav a:nth-child(2)::before { content: "B"; font-weight: 900; }
    .sidebar nav a:nth-child(3)::before { content: "#"; font-weight: 900; }
    .sidebar nav a:nth-child(4)::before { content: "●"; }
    .sidebar nav a:nth-child(5)::before { content: "T"; font-weight: 900; }
    .sidebar nav a:nth-child(6)::before { content: "◷"; }
    .sidebar nav a:nth-child(7)::before { content: "!"; font-weight: 900; }
    .sidebar nav a:nth-child(8)::before { content: "T"; font-weight: 900; }
    .sidebar nav a:nth-child(9)::before { content: "€"; font-weight: 900; }
    .sidebar nav a:nth-child(10)::before { content: "⚙"; }
    .side-section {
        display: none;
    }
    .account {
        margin: 0;
        padding: 0;
        border: 0;
        justify-items: end;
        gap: 0;
        font-size: 12px;
    }
    .account strong {
        max-width: 128px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .account a {
        margin: 2px 0 0;
        min-height: 28px;
        display: inline-flex;
        align-items: center;
    }
    .main {
        margin-left: 0;
        padding: 12px;
        gap: 16px;
    }
    .hero, .page-head, .grid.two, .stats, .player-contact {
        grid-template-columns: 1fr;
    }
    .hero, .page-head {
        padding: 18px;
        gap: 12px;
    }
    .hero h1, .page-head h1 {
        margin: 4px 0 6px;
        font-size: 28px;
        line-height: 1.05;
    }
    .hero p {
        margin: 0;
        font-size: 15px;
        line-height: 1.45;
    }
    .hero-stat {
        min-width: 0;
        grid-template-columns: auto 1fr;
        align-items: baseline;
        padding: 12px;
    }
    .hero-stat strong {
        font-size: 26px;
    }
    h2 {
        font-size: 19px;
    }
    .section-title {
        margin: 2px 0 8px;
    }
    .section-title a, .button {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    .panel, .rules, .round, .match-list, .player-grid, .league-list {
        border-radius: 8px;
    }
    .round-grid, .player-status-grid {
        grid-template-columns: 1fr;
    }
    .round {
        padding: 14px;
    }
    .match-card, .match-row, .player-card, .league-card {
        min-height: 58px;
        padding: 13px;
        gap: 5px;
    }
    .match-card span, .match-row strong {
        font-size: 16px;
        line-height: 1.28;
    }
    .stats {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stats div {
        padding: 14px;
    }
    .stats strong {
        font-size: 26px;
    }
    .auth-page {
        align-items: start;
        padding: 18px 12px;
    }
    .auth-box {
        margin-top: 8vh;
        padding: 22px;
    }
}

@media (max-width: 560px) {
    .main {
        padding: 10px;
    }
    .hero, .page-head {
        margin-inline: -2px;
    }
    .page-head .badge {
        justify-self: start;
    }
    .table.standings {
        display: grid;
        gap: 8px;
        border: 0;
        background: transparent;
        overflow: visible;
    }
    .table.standings thead {
        display: none;
    }
    .table.standings tbody {
        display: grid;
        gap: 8px;
    }
    .table.standings tr {
        display: grid;
        grid-template-columns: 42px 1fr auto;
        grid-template-areas:
            "pos player points"
            "pos wl diff"
            "pos games diff";
        gap: 5px 10px;
        align-items: center;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
        box-shadow: 0 1px 0 rgba(24,33,31,.03);
    }
    .table.standings tbody tr:first-child {
        border-color: #bddc44;
        background: linear-gradient(135deg, rgba(214,241,106,.38), #fff);
    }
    .table.standings tbody tr:first-child td {
        background: transparent;
    }
    .table.standings td {
        display: block;
        padding: 0;
        border: 0;
        white-space: normal;
    }
    .table.standings td:nth-child(1) {
        grid-area: pos;
        width: 34px;
        height: 34px;
        display: grid;
        place-items: center;
        border-radius: 8px;
        background: #17231f;
        color: #fff;
        font-weight: 900;
    }
    .table.standings td:nth-child(2) {
        grid-area: player;
        min-width: 0;
        font-size: 17px;
        font-weight: 900;
    }
    .table.standings td:nth-child(3) {
        grid-area: wl;
        color: var(--muted);
        font-weight: 800;
    }
    .table.standings td:nth-child(3)::before {
        content: "Pob/Por ";
        color: var(--muted);
        font-weight: 700;
    }
    .table.standings td:nth-child(4) {
        grid-area: points;
        justify-self: end;
        min-width: 52px;
        min-height: 38px;
        display: grid;
        place-items: center;
        border-radius: 8px;
        background: var(--accent);
        color: #fff;
        font-size: 19px;
        font-weight: 900;
    }
    .table.standings td:nth-child(4)::after {
        content: " bod";
        font-size: 11px;
        font-weight: 700;
        margin-left: 2px;
    }
    .table.standings td:nth-child(5) {
        grid-area: games;
        color: var(--muted);
    }
    .table.standings td:nth-child(5)::before {
        content: "Gemovi ";
        font-weight: 700;
    }
    .table.standings td:nth-child(6) {
        grid-area: diff;
        justify-self: end;
        color: var(--muted);
        font-weight: 800;
    }
    .table.standings td:nth-child(6)::before {
        content: "Razlika ";
        font-weight: 700;
    }
    .tag {
        margin-top: 4px;
        vertical-align: middle;
    }
    .score-inputs {
        grid-template-columns: 1fr;
    }
    .table:not(.standings) {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 380px) {
    .sidebar nav a {
        font-size: 10px;
    }
    .hero h1, .page-head h1 {
        font-size: 25px;
    }
    .table.standings tr {
        grid-template-columns: 36px 1fr;
        grid-template-areas:
            "pos player"
            "pos points"
            "pos wl"
            "pos games"
            "pos diff";
    }
    .table.standings td:nth-child(4),
    .table.standings td:nth-child(6) {
        justify-self: start;
    }
}
