:root {
    --bg: #0b1020;
    --card: #0f172a;
    --primary: #7c83ff;
    --success: #22c55e;
    --danger: #f87171;
    --warning: #f59e0b;
    --text: #f8fafc;
    --muted: #94a3b8;
    --ring: rgba(124, 131, 255, 0.35);
}
*,
*::before,
*::after {
    box-sizing: border-box;
}
body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle at top, #202b50 0%, #0b1120 48%, #05070f 100%);
    color: var(--text);
    margin: 0;
    padding: 24px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
a {
    color: inherit;
}
.container {
    max-width: 1100px;
    margin: auto;
    text-align: center;
}
.page-shell {
    max-width: 1200px;
}
.card {
    background: linear-gradient(160deg, rgba(16, 24, 39, 0.96), rgba(10, 15, 30, 0.9));
    padding: 28px;
    border-radius: 20px;
    margin-bottom: 22px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    box-shadow: 0 24px 50px rgba(8, 12, 24, 0.45);
    backdrop-filter: blur(12px);
}
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
}
.btn {
    border: none;
    padding: 14px 24px;
    border-radius: 14px;
    cursor: pointer;
    font-weight: 700;
    transition: 0.25s;
    font-size: 1rem;
    letter-spacing: 0.3px;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.25);
}
.btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}
.btn:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}
.btn-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-admin { background: linear-gradient(135deg, #6d77ff, #8b5cf6); color: white; }
.btn-score {
    background: rgba(36, 36, 43, 0.9);
    color: white;
    border: 1px solid rgba(148, 163, 184, 0.2);
    font-size: 1.4rem;
}
.btn-score.active {
    background: var(--primary);
    border-color: #fff;
    box-shadow: 0 0 22px rgba(124, 131, 255, 0.5);
}
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warn { background: var(--warning); color: #1f2937; }
.btn-secondary { background: #2b2b34; color: white; }
.pair-card {
    background: rgba(30, 41, 59, 0.72);
    padding: 18px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border: 1px solid transparent;
    transition: 0.2s;
    gap: 16px;
}
.pair-card.active { border-color: rgba(124, 131, 255, 0.6); box-shadow: 0 12px 30px rgba(99, 102, 241, 0.25); }
.ranking-card { padding: 10px; }
.ranking-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 18px 24px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
    font-size: 2rem;
}
.ranking-row:last-child { border-bottom: none; }
.ranking-rank { font-weight: 800; color: var(--primary); min-width: 120px; text-align: left; }
.ranking-name { flex: 1; text-align: left; }
.ranking-score { font-weight: 900; min-width: 120px; text-align: right; }
.ranking-empty { padding: 40px; font-size: 1.5rem; opacity: 0.7; }
.tab-bar { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 20px 0; }
.tab-button {
    background: rgba(30, 41, 59, 0.8);
    color: var(--text);
    border: 1px solid rgba(148, 163, 184, 0.2);
    padding: 12px 22px;
    border-radius: 999px;
    cursor: pointer;
    font-weight: 700;
    transition: 0.2s ease;
}
.tab-button.active { background: var(--primary); border-color: var(--primary); color: white; box-shadow: 0 12px 24px rgba(99, 102, 241, 0.3); }
.tab-content { display: none; }
.tab-content.active { display: block; }
.action-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.input-row { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.input-row input {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.75);
    color: var(--text);
    min-width: 220px;
}
.input-row select {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    background: rgba(15, 23, 42, 0.75);
    color: var(--text);
    min-width: 220px;
}
.input-row select option {
    color: #0f172a;
    background: #f8fafc;
}
.helper-text {
    display: block;
    margin-top: 6px;
    font-size: 0.85rem;
    color: var(--muted);
}
.output-dir-row label { flex: 1 1 240px; }
.output-dir-actions { display: flex; gap: 10px; align-items: center; }
.output-dir-actions .btn { white-space: nowrap; }
.input-row input:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
}
.score-grid { grid-template-columns: repeat(2, 1fr); gap: 15px; }
.score-grid button {
    min-height: 64px;
}
.page-header { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-title { text-align: left; flex: 1; min-width: 260px; }
.page-title h1 { font-size: 2.8rem; margin: 0 0 8px; }
.eyebrow { text-transform: uppercase; font-size: 0.8rem; letter-spacing: 2px; color: var(--muted); }
.subtitle { color: var(--muted); margin: 0; }
.control-card { min-width: 280px; }
.control-row { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.control-row label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; color: var(--muted); }
.control-row select { padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(148, 163, 184, 0.2); background: rgba(15, 23, 42, 0.75); color: var(--text); }
.item-title { font-weight: 700; font-size: 1.1rem; }
.item-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-badge { background: rgba(124, 131, 255, 0.2); color: #c7d2fe; border: 1px solid rgba(124, 131, 255, 0.6); padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.5px; }
.handler-card { flex-direction: column; align-items: stretch; gap: 14px; }
.handler-meta { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; }
.handler-total { font-size: 1rem; color: var(--muted); }
.pair-scores { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.score-chip { background: rgba(15, 23, 42, 0.65); border-radius: 12px; padding: 10px 12px; display: flex; align-items: center; justify-content: space-between; border: 1px solid rgba(148, 163, 184, 0.2); }
.score-name { font-size: 0.95rem; color: var(--muted); }
.score-value { font-size: 1.2rem; font-weight: 800; color: var(--text); }
.handler-actions { justify-content: flex-start; }
.handler-footer { text-align: center; }

.hero-title {
    font-size: clamp(2.4rem, 4vw, 4rem);
    margin-bottom: 12px;
    text-shadow: 0 0 30px rgba(124, 131, 255, 0.4);
}
.hero-subtitle {
    margin: 0 0 24px;
    color: var(--muted);
}
.hero-card {
    padding: 32px;
    border-radius: 26px;
}
.leaderboard-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-top: 40px;
}
.leaderboard-score {
    font-size: clamp(3rem, 6vw, 7rem);
    font-weight: 900;
}
.leaderboard-total {
    margin-top: 50px;
    font-size: clamp(2.4rem, 5vw, 5rem);
    background: linear-gradient(135deg, rgba(124, 131, 255, 0.95), rgba(59, 130, 246, 0.9));
    padding: 18px 32px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: min(520px, 100%);
    gap: 12px;
    box-shadow: 0 20px 40px rgba(59, 130, 246, 0.35);
}
.judge-shell h1 {
    margin-bottom: 32px;
}
.judge-actions {
    margin-top: 40px;
}

/* Leaderboard Animations */
.score-pop { animation: pop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); color: var(--success); }
    100% { transform: scale(1); }
}

@media (min-width: 768px) and (orientation: landscape) {
    .score-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    body {
        padding: 18px;
    }
    .page-header {
        flex-direction: column;
    }
    .pair-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .action-row {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 700px) {
    .ranking-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        font-size: 1.4rem;
    }
    .ranking-rank,
    .ranking-score {
        min-width: 0;
    }
    .score-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
    .score-grid button {
        font-size: 1.1rem;
        padding: 12px;
        min-height: 54px;
    }
    .leaderboard-total {
        width: 100%;
    }
}

@media (max-width: 480px) {
    body {
        padding: 14px;
    }
    .btn {
        width: 100%;
    }
    .grid {
        grid-template-columns: 1fr;
    }
    .input-row {
        width: 100%;
    }
    .input-row input {
        width: 100%;
        min-width: 0;
    }
}
