:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-alt: #f6f1ff;
    --line: #e6d9ff;
    --line-strong: #d8c5ff;
    --text: #231541;
    --muted: #6d5b95;
    --primary: #6f2ee8;
    --primary-strong: #5a1fc7;
    --primary-soft: #efe7ff;
    --success-bg: #ecfdf3;
    --success-border: #a6f4c5;
    --success-text: #027a48;
    --danger-bg: #fff1f1;
    --danger-border: #ffd5d2;
    --danger-text: #b42318;
    --warning: #b54708;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --shadow: 0 12px 28px #5a1fc712;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
}

body {
    direction: rtl;
    font-family: "Vazirmatn", "Trebuchet MS", sans-serif;
    color: var(--text);
    background: var(--bg);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(circle at 6% 7%, #f3ecff 0, #f3ecff 180px, transparent 180px),
        radial-gradient(circle at 94% 14%, #f8f3ff 0, #f8f3ff 220px, transparent 220px),
        radial-gradient(circle at 72% 88%, #faf6ff 0, #faf6ff 250px, transparent 250px);
}

.site-header,
footer {
    position: relative;
    z-index: 2;
    width: min(1200px, calc(100% - 24px));
    margin: 14px auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow);
}

.site-header {
    position: sticky;
    top: 10px;
    padding: 14px;
}

.brand {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 900;
    color: var(--primary-strong);
}

.top-nav {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
}

.top-nav a {
    text-decoration: none;
    border-radius: 999px;
    border: 1px solid var(--line-strong);
    padding: 8px 14px;
    background: var(--primary-soft);
    color: var(--primary-strong);
    font-size: 0.92rem;
    font-weight: 800;
    transition: 0.2s ease;
}

.top-nav a:hover,
.top-nav a.active {
    color: #ffffff;
    background: var(--primary);
    border-color: var(--primary);
}

.page-shell {
    position: relative;
    z-index: 1;
    width: min(1120px, calc(100% - 24px));
    margin: 24px auto;
}

h2,
.page-title {
    margin: 0 0 16px;
    font-size: 1.95rem;
    text-align: center;
    color: var(--primary-strong);
}

h2::after,
.page-title::after {
    content: "";
    display: block;
    width: 86px;
    height: 5px;
    border-radius: 999px;
    margin: 10px auto 0;
    background: #ccb4ff;
}

.panel,
.login-container,
.admin-sidebar,
.admin-main,
.matches-day,
.subsection,
#standings-table {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.panel {
    padding: 14px;
}

.league-picker-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}

.league-picker {
    width: min(520px, 100%);
    text-align: center;
}

.league-picker h3 {
    margin: 0 0 8px;
    color: var(--muted);
}

.league-current {
    margin: 10px 0 0;
    color: var(--primary-strong);
    font-weight: 700;
}

label {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 0.93rem;
    font-weight: 700;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    background: #fcfaff;
    color: var(--text);
    padding: 10px 11px;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px #6f2ee822;
}

button {
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #ffffff;
    padding: 10px 13px;
    font-weight: 800;
    cursor: pointer;
    transition: 0.18s ease;
}

button:hover {
    background: var(--primary-strong);
    border-color: var(--primary-strong);
}

.btn-danger {
    background: var(--danger-text);
    border-color: var(--danger-text);
}

.btn-danger:hover {
    background: #921f15;
    border-color: #921f15;
}

.btn-warning {
    background: var(--warning);
    border-color: var(--warning);
}

.btn-warning:hover {
    background: #93370d;
    border-color: #93370d;
}

.form-group {
    margin-bottom: 11px;
}

.form-note {
    margin: 3px 0 8px;
    color: var(--muted);
    font-size: 0.91rem;
}

.hidden-field {
    display: none;
}

.login-container {
    width: min(460px, 100%);
    margin: 24px auto;
    padding: 16px;
}

.login-container h2 {
    text-align: right;
    font-size: 1.35rem;
}

.auth-subtitle {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.93rem;
}

.error,
.success,
.message-banner,
.inline-error {
    border-radius: var(--radius-sm);
    padding: 10px;
    margin: 0 0 10px;
    font-size: 0.9rem;
}

.error,
.inline-error {
    color: var(--danger-text);
    background: var(--danger-bg);
    border: 1px solid var(--danger-border);
}

.success,
.message-banner {
    color: var(--success-text);
    background: var(--success-bg);
    border: 1px solid var(--success-border);
}

#standings-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}

#standings-table th,
#standings-table td {
    padding: 11px 8px;
    text-align: center;
    border-bottom: 1px solid #f1e9ff;
    font-size: 0.93rem;
}

#standings-table th {
    background: var(--surface-alt);
    color: var(--primary-strong);
    font-weight: 900;
}

#standings-table tr:last-child td {
    border-bottom: 0;
}

#standings-table tbody tr:hover {
    background: #faf6ff;
}

.empty-state {
    text-align: center;
    border: 1px dashed var(--line);
    border-radius: var(--radius-md);
    color: var(--muted);
    padding: 16px;
}

.filter-menu {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

#matches-list {
    display: grid;
    gap: 12px;
}

.day-header {
    margin: 0;
    padding: 12px 14px;
    background: var(--surface-alt);
    color: var(--primary-strong);
    border-bottom: 1px solid var(--line);
}

.matches-container {
    padding: 10px;
    display: grid;
    gap: 8px;
}

.match-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fdfbff;
    padding: 10px;
}

.match-card.completed {
    border-color: #ceb5ff;
}

.match-content {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: center;
}

.team {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.team-name {
    font-weight: 800;
}

.team-label,
.match-status {
    color: var(--muted);
    font-size: 0.84rem;
}

.match-score {
    text-align: center;
}

.score,
.vs {
    min-width: 84px;
    display: inline-block;
    color: var(--primary-strong);
    font-weight: 900;
}

.match-status {
    margin-top: 6px;
    text-align: center;
}

.admin-container {
    position: relative;
    z-index: 1;
    width: min(1200px, calc(100% - 24px));
    margin: 20px auto;
    display: grid;
    grid-template-columns: 250px 1fr;
    gap: 12px;
}

.admin-sidebar,
.admin-main {
    padding: 12px;
}

.admin-sidebar {
    align-self: start;
    position: sticky;
    top: 108px;
}

.sidebar-header h3 {
    margin: 0 0 10px;
    color: var(--primary-strong);
}

.sidebar-nav {
    display: grid;
    gap: 7px;
}

.sidebar-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 7px;
    border: 1px solid var(--line-strong);
    border-radius: 11px;
    background: var(--surface-alt);
    color: var(--primary-strong);
    padding: 9px;
    font-weight: 800;
}

.sidebar-btn.active,
.sidebar-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.section-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.section-header h2 {
    margin: 0;
    text-align: right;
    font-size: 1.35rem;
}

.section-header p {
    margin: 5px 0 0;
    color: var(--muted);
}

.section-content {
    display: grid;
    gap: 12px;
}

.subsection {
    padding: 12px;
}

.subsection h3 {
    margin: 0 0 10px;
    color: var(--primary-strong);
}

.admin-form {
    display: grid;
    gap: 6px;
}

.teams-grid {
    display: grid;
    gap: 6px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.team-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fcfaff;
}

.team-checkbox input {
    width: auto;
    margin: 0;
}

.checkmark {
    display: none;
}

footer {
    margin-top: 20px;
    padding: 12px;
    text-align: center;
    color: var(--muted);
}

footer p {
    margin: 0;
}

footer a {
    color: var(--primary-strong);
    font-weight: 800;
    text-decoration: none;
}

@media (max-width: 980px) {
    .admin-container {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
    }

    .sidebar-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .sidebar-btn {
        justify-content: center;
    }
}

@media (max-width: 760px) {
    .brand {
        font-size: 1.2rem;
    }

    h2,
    .page-title {
        font-size: 1.55rem;
    }

    .filter-menu {
        grid-template-columns: 1fr;
    }

    #standings-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .match-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .team {
        align-items: center;
    }

    .sidebar-nav {
        grid-template-columns: 1fr;
    }
}
