:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-glow: rgba(79, 70, 229, 0.3);
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.65);
    --text-main: #f8fafc;
    --text-soft: #cbd5e1;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-border-hover: rgba(255, 255, 255, 0.14);
    --glass-highlight: rgba(255, 255, 255, 0.04);
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --accent-blue: #60a5fa;
    --accent-purple: #c084fc;
    --accent-green: #4ADE80;
    --radius: 1rem;
    --radius-sm: 0.6rem;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4), 0 1px 4px rgba(0, 0, 0, 0.2);
    --shadow-btn: 0 4px 14px rgba(79, 70, 229, 0.35);
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: linear-gradient(150deg, #0b1120 0%, #13113a 30%, #1a1040 60%, #0f172a 100%);
    color: var(--text-main);
    min-height: 100vh;
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
}

body::before {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(79, 70, 229, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(192, 132, 252, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(96, 165, 250, 0.04) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

.container {
    position: relative;
    z-index: 1;
    max-width: 840px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

/* ─── Header ─── */
header {
    text-align: center;
    margin-bottom: 2.25rem;
}

header h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #60a5fa 0%, #a78bfa 40%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.35rem;
}

header .subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 400;
}

/* ─── Navigation ─── */
.nav-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.45rem 1rem;
    border-radius: 2rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid transparent;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all var(--transition);
}

.nav-link:hover {
    color: var(--text-soft);
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--glass-border);
}

.nav-link.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 12px var(--primary-glow);
}

.nav-group {
    font-size: 0.65rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0.2rem;
}

.nav-sep {
    width: 1px;
    height: 20px;
    background: var(--glass-border);
    margin: 0 0.3rem;
}

/* ─── Glass Card ─── */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-card);
    margin-bottom: 1.25rem;
    transition: border-color var(--transition);
}

.glass-card:hover {
    border-color: var(--glass-border-hover);
}

/* ─── Form ─── */
.form-group { margin-bottom: 1.1rem; }

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    color: var(--text-soft);
    font-size: 0.875rem;
    letter-spacing: 0.01em;
}

input[type="text"],
input[type="number"] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.925rem;
    font-family: inherit;
    transition: all var(--transition);
}

input[type="text"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

input::placeholder { color: var(--text-dim); }

/* ─── Group Header ─── */
.group-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 1rem;
    margin-top: 1.4rem;
    margin-bottom: 0.3rem;
    border-radius: var(--radius-sm);
    background: rgba(147, 197, 253, 0.06);
    border: 1px solid rgba(147, 197, 253, 0.1);
}

.group-header span {
    font-weight: 700;
    color: #93c5fd;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.group-header .group-bar {
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, rgba(147, 197, 253, 0.2), transparent);
}

/* ─── Match Card ─── */
.match-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    margin-bottom: 0.7rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
    transition: all var(--transition);
}

.match-card:hover {
    border-color: var(--glass-border-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.match-card.played {
    opacity: 0.75;
    border-color: rgba(16, 185, 129, 0.2);
}

.match-card.played:hover { opacity: 0.85; }

.match-time {
    text-align: center;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.match-time .time-icon { font-size: 0.9rem; }

.match-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.team {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.3;
}

.team-home { text-align: right; padding-right: 0.8rem; }
.team-away { text-align: left; padding-left: 0.8rem; }

.team-code {
    display: block;
    font-size: 0.7rem;
    color: var(--text-dim);
    font-weight: 400;
    margin-top: 0.1rem;
}

.team-flag {
    font-size: 1.2rem;
    vertical-align: -1px;
}

.score-box {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.score-input {
    width: 52px !important;
    height: 46px;
    text-align: center;
    font-size: 1.15rem !important;
    font-weight: 700;
    padding: 0 !important;
    border-radius: var(--radius-sm) !important;
    background: rgba(15, 23, 42, 0.7) !important;
    transition: all var(--transition);
}

.score-input:focus {
    border-color: var(--accent-blue) !important;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2) !important;
}

.score-display {
    font-size: 1.3rem;
    font-weight: 800;
    min-width: 1.6em;
    text-align: center;
    color: var(--text-main);
}

.score-vs {
    color: var(--text-dim);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.match-venue {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-dim);
    margin-top: 0.4rem;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    background: var(--primary);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.6rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.95rem;
    font-family: inherit;
    letter-spacing: 0.01em;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-btn);
}

.btn:active { transform: translateY(0); }

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-lg { width: 100%; padding: 0.85rem 1.6rem; font-size: 1rem; }

.btn-sm {
    padding: 0.4rem 0.9rem;
    font-size: 0.8rem;
    border-radius: 0.4rem;
}

.btn-success { background: var(--success); }
.btn-success:hover { background: #059669; box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35); }

.btn-outline {
    background: transparent;
    border: 1px solid var(--glass-border);
    color: var(--text-muted);
}
.btn-outline:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-soft);
    border-color: var(--glass-border-hover);
    box-shadow: none;
}

/* ─── Loader ─── */
.loader {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(255, 255, 255, 0.08);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

.loader-sm {
    width: 18px;
    height: 18px;
    border-width: 2px;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Toast ─── */
.toast {
    visibility: hidden;
    opacity: 0;
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--success);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 0.65rem;
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
    z-index: 1000;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.toast.show {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: var(--danger);
    box-shadow: 0 8px 24px rgba(239, 68, 68, 0.3);
}

/* ─── Leaderboard Table ─── */
.lb-table {
    width: 100%;
    border-collapse: collapse;
}

.lb-table thead th {
    padding: 0.8rem 0.7rem;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #93c5fd;
    border-bottom: 2px solid var(--glass-border);
}

.lb-table tbody td {
    padding: 0.8rem 0.7rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--glass-border);
    vertical-align: middle;
}

.lb-table tbody tr {
    transition: background var(--transition);
}

.lb-table tbody tr:hover {
    background: var(--glass-highlight);
}

.lb-table .rank-cell {
    font-weight: 700;
    font-size: 1rem;
    text-align: center;
    width: 3rem;
}

.lb-table .rank-1 { color: #fbbf24; font-size: 1.5rem; }
.lb-table .rank-2 { color: #94a3b8; font-size: 1.4rem; }
.lb-table .rank-3 { color: #d97706; font-size: 1.3rem; }

.lb-table .name-cell {
    font-weight: 600;
    color: var(--text-main);
}

.lb-table .stat-cell {
    text-align: center;
    color: var(--text-muted);
}

.lb-table .points-cell {
    text-align: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--accent-green);
}

/* ─── Admin Panel ─── */
.admin-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition);
}

.admin-toggle:hover { color: var(--text-soft); }

.admin-panel {
    display: none;
    margin-top: 1.25rem;
}

.admin-panel.open { display: block; }

.admin-panel h3 {
    color: #93c5fd;
    font-size: 0.9rem;
    margin-bottom: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.admin-panel .hint {
    color: var(--text-muted);
    font-size: 0.78rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.admin-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    font-size: 0.83rem;
}

.admin-row:last-child { border-bottom: none; }

.admin-row .match-label {
    flex: 1;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.admin-row input[type="number"] {
    width: 48px !important;
    padding: 0.35rem 0.3rem !important;
    text-align: center;
    font-size: 0.85rem !important;
}

.admin-row .score-sep {
    color: var(--text-dim);
    font-weight: 600;
}

.admin-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.25rem;
}

#calc-result {
    margin-top: 0.75rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
}

/* ─── Empty State ─── */
.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
}

.empty-state .empty-icon {
    font-size: 3rem;
    margin-bottom: 0.8rem;
    opacity: 0.7;
}

.empty-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .container { padding: 1.25rem 0.6rem 3rem; }
    header h1 { font-size: 1.65rem; }
    header .subtitle { font-size: 0.85rem; }
    .glass-card { padding: 1rem; }
    .match-card { padding: 0.8rem 0.9rem; }

    .match-row {
        flex-direction: column;
        gap: 0.5rem;
    }

    .team-home, .team-away {
        text-align: center;
        padding: 0;
    }

    .team-home { order: 1; }
    .score-box { order: 2; }
    .team-away { order: 3; }

    .lb-table thead th,
    .lb-table tbody td {
        padding: 0.55rem 0.35rem;
        font-size: 0.78rem;
    }
    .lb-table .points-cell { font-size: 0.9rem; }

    .admin-row {
        flex-wrap: wrap;
        gap: 0.3rem;
    }
    .admin-row .match-label {
        flex: 1 1 100%;
        font-size: 0.78rem;
    }
}

/* ─── Scrollable table wrapper ─── */
.scroll-wrap {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    -webkit-overflow-scrolling: touch;
}
