:root {
    --bg: #f4f6f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f0f4f8;
    --accent: #0d9488;
    --accent-dim: #0f766e;
    --gold: #b8860b;
    --silver: #6b7280;
    --bronze: #a0522d;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #dc2626;
    --success: #16a34a;
    --radius: 12px;
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    background-image:
        radial-gradient(ellipse at 20% 0%, rgba(13, 148, 136, 0.06) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(59, 130, 246, 0.05) 0%, transparent 50%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
}

.container {
    width: 100%;
    max-width: none;
    min-height: 100vh;
    min-height: 100dvh;
    margin: 0;
    padding: 16px 28px 24px;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 12px;
    padding-top: 4px;
    flex-shrink: 0;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #2563eb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

nav {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

nav a, .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    cursor: pointer;
}

nav a:hover, .btn:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
}

nav a.active, .btn-primary {
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
    font-weight: 600;
}

nav a.active:hover, .btn-primary:hover {
    background: var(--accent-dim);
    border-color: var(--accent-dim);
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
    flex-shrink: 0;
}

.grid-2-compact {
    gap: 12px;
    margin-bottom: 12px;
}

.card-compact {
    padding: 12px 16px;
}

.card-rules-bar {
    margin-bottom: 12px;
    padding: 10px 16px;
}

.rules-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
    overflow-x: auto;
    font-size: 0.82rem;
    color: var(--text);
    scrollbar-width: thin;
    white-space: nowrap;
}

.rules-bar-label {
    font-weight: 700;
    color: var(--accent-dim);
    flex-shrink: 0;
}

.rules-bar-item {
    flex-shrink: 0;
    color: var(--text-muted);
}

.rules-bar-item strong {
    color: var(--text);
    font-weight: 600;
}

.rules-bar-divider {
    width: 1px;
    height: 18px;
    background: var(--border);
    flex-shrink: 0;
}

.rules-bar-mult {
    color: var(--text-muted);
}

.rules-bar-max {
    font-weight: 700;
    color: var(--accent-dim);
}

.card-standings {
    margin-bottom: 12px;
}

.card-compact h2 {
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.card-compact .confidence {
    font-size: 0.75rem;
    padding: 2px 8px;
    margin-top: 2px;
}

.card-compact .prediction-reason {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 0.78rem;
    line-height: 1.35;
}

.card-compact .rules-table {
    font-size: 0.78rem;
}

.card-compact .rules-table th,
.card-compact .rules-table td {
    padding: 4px 8px;
}

.rules-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}

.rules-max-inline {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-dim);
}

@media (max-width: 768px) {
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 12px 14px 16px;
    }
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: var(--shadow);
}

.card-fill {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.card-fill .table-wrap {
    flex: 1;
    overflow: auto;
}

.card h2 {
    font-size: 1.1rem;
    margin-bottom: 14px;
    color: var(--accent-dim);
}

.podium {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
    min-height: 130px;
}

.podium-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    max-width: 130px;
}

.podium-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    margin-bottom: 6px;
    gap: 2px;
}

.podium-player:hover .podium-name {
    color: var(--accent-dim);
}

.podium-medal {
    font-size: 1.2rem;
    line-height: 1;
}

.podium-name {
    font-weight: 700;
    font-size: 0.82rem;
    line-height: 1.2;
    transition: color 0.15s;
}

.podium-points {
    font-size: 0.72rem;
    color: var(--accent-dim);
    font-weight: 600;
}

.podium-block {
    width: 100%;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.podium-rank {
    font-size: 1.1rem;
    font-weight: 800;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.podium-1 .podium-block {
    height: 72px;
    background: linear-gradient(180deg, #f5d442, var(--gold));
}

.podium-2 .podium-block {
    height: 52px;
    background: linear-gradient(180deg, #e8eaed, var(--silver));
}

.podium-3 .podium-block {
    height: 38px;
    background: linear-gradient(180deg, #e8a87c, var(--bronze));
}

.podium-1 .podium-name {
    font-size: 0.9rem;
}

.card-compact .podium {
    min-height: 150px;
    gap: 12px;
    margin-top: 8px;
}

.card-compact .podium-slot {
    max-width: 140px;
}

.card-compact .podium-1 .podium-block { height: 80px; }
.card-compact .podium-2 .podium-block { height: 58px; }
.card-compact .podium-3 .podium-block { height: 42px; }

.card-compact .podium-medal { font-size: 1.35rem; }
.card-compact .podium-name { font-size: 0.9rem; }
.card-compact .podium-1 .podium-name { font-size: 1rem; }
.card-compact .podium-points { font-size: 0.8rem; }
.card-compact .podium-rank { font-size: 1.3rem; }
.card-compact .podium-player { margin-bottom: 8px; gap: 4px; }

.podium-full {
    overflow-x: auto;
    justify-content: flex-start;
    gap: 8px;
    min-height: 150px;
    padding-bottom: 6px;
    scrollbar-width: thin;
}

.podium-full .podium-slot {
    flex: 0 0 auto;
    min-width: 76px;
    max-width: 92px;
}

.podium-full .podium-player {
    margin-bottom: 6px;
    gap: 3px;
}

.podium-full .podium-medal {
    font-size: 1rem;
    min-height: 1.2rem;
}

.podium-full .podium-name {
    font-size: 0.78rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-full .podium-1 .podium-name {
    font-size: 0.85rem;
}

.podium-full .podium-points {
    font-size: 0.7rem;
}

.podium-full .podium-rank {
    font-size: 1rem;
}

.podium-other .podium-block {
    background: linear-gradient(180deg, #e2e8f0, #94a3b8);
}

.podium-other .podium-medal {
    font-size: 0.72rem;
    font-weight: 800;
    color: var(--text-muted);
}

.confidence {
    font-size: 0.85rem;
    padding: 3px 10px;
    border-radius: 20px;
    display: inline-block;
    margin-top: 4px;
}

.confidence-high { background: #dcfce7; color: var(--success); }
.confidence-medium { background: #fef9c3; color: #a16207; }
.confidence-low { background: #fee2e2; color: var(--danger); }

.rules-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.rules-table th, .rules-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.rules-table th {
    color: var(--text-muted);
    font-weight: 500;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.leaderboard {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard th {
    text-align: left;
    padding: 14px 18px;
    color: var(--text-muted);
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--border);
    background: #f8fafc;
}

.leaderboard td {
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 1.05rem;
}

.leaderboard tr:hover td {
    background: var(--bg-card-hover);
}

.leaderboard tr.leader td {
    background: #ecfdf5;
}

.rank {
    font-weight: 700;
    font-size: 1.4rem;
    width: 48px;
}

.rank-1 { color: var(--gold); }
.rank-2 { color: var(--silver); }
.rank-3 { color: var(--bronze); }

.points {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-dim);
}

.points-sub {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.picks-mini {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pick-chip {
    font-size: 0.95rem;
    padding: 4px 10px;
    border-radius: 6px;
    background: #f1f5f9;
    border: 1px solid var(--border);
    white-space: nowrap;
    color: var(--text);
}

.pick-chip .mult {
    color: var(--accent-dim);
    font-weight: 600;
}

.pick-chip-active {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

.pick-chip-active .mult {
    color: #64748b;
}

.pick-chip-scored {
    background: #dcfce7;
    border-color: #86efac;
    color: #166534;
}

.pick-chip-scored .mult {
    color: #15803d;
}

.pick-chip-zero {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #991b1b;
}

.pick-chip-zero .mult {
    color: #b91c1c;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-gold { background: #fef9c3; color: #a16207; }
.badge-silver { background: #f1f5f9; color: #475569; }
.badge-bronze { background: #ffedd5; color: #c2410c; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-active { background: #ccfbf1; color: #0f766e; }
.badge-out { background: #fee2e2; color: #b91c1c; }

.can-win { color: var(--success); }
.cannot-win { color: var(--danger); }

.update-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-muted);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.flash-msg {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.flash-success { background: #dcfce7; border: 1px solid #86efac; color: #15803d; }
.flash-error { background: #fee2e2; border: 1px solid #fca5a5; color: #b91c1c; }

/* Player detail */
.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.breakdown-table th, .breakdown-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.breakdown-table th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--accent-dim);
    text-decoration: none;
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.back-link:hover { text-decoration: underline; }

/* Admin */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.form-group select, .form-group input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    font-size: 0.9rem;
}

.form-group select:focus, .form-group input[type="password"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.update-bar-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.admin-card {
    min-height: 0;
}

.admin-hint {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-bottom: 16px;
}

.team-stages-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.team-stages-head {
    display: grid;
    grid-template-columns: minmax(160px, 280px) 1fr;
    gap: 16px;
    padding: 0 16px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.team-stages-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
    overflow-y: auto;
    padding-right: 4px;
}

.team-stage-row {
    display: grid;
    grid-template-columns: minmax(160px, 280px) 1fr;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.team-stage-row:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.team-stage-name {
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
    word-break: break-word;
}

.team-stage-select {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #ffffff;
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    appearance: auto;
}

.team-stage-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.admin-actions {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .team-stages-head {
        display: none;
    }

    .team-stage-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .team-stage-name {
        font-size: 0.85rem;
        color: var(--text-muted);
    }
}

.login-box {
    max-width: 400px;
    margin: 60px auto;
}

code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85em;
    color: var(--text);
}
