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

:root {
    --unmsm-primary: #8B4545;
    --unmsm-primary-dark: #6b3535;
    --unmsm-primary-soft: rgba(139, 69, 69, 0.1);
    --unmsm-border: #d4c4c0;
    --bg-main: #FAF8F5;
    --text-dark: #2d2323;
    --error-bg: #fee;
    --error-text: #c33;
    --success-bg: #efe;
    --success-text: #2d8a3a;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-main);
    background-image:
        repeating-radial-gradient(
            circle at 0 0,
            transparent 0,
            rgba(139, 69, 69, 0.03) 1px,
            transparent 2px,
            transparent 20px
        ),
        repeating-radial-gradient(
            circle at 100% 100%,
            transparent 0,
            rgba(139, 69, 69, 0.02) 1px,
            transparent 2px,
            transparent 20px
        );
    background-attachment: fixed;
    min-height: 100vh;
    padding: 20px;
    color: var(--text-dark);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.header {
    text-align: center;
    margin-bottom: 30px;
}

.header-logo {
    width: 100%;
    max-width: 600px;
    height: auto;
    margin: 0 auto;
    display: block;
}

.login-button {
    text-align: center;
    margin-bottom: 40px;
}

.login-button button {
    background: linear-gradient(135deg, var(--unmsm-primary) 0%, var(--unmsm-primary-dark) 100%);
    color: white;
    border: none;
    padding: 16px 40px;
    font-size: 1.2em;
    font-weight: 600;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(139, 69, 69, 0.3);
}

.login-button button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 69, 69, 0.4);
}

.login-section {
    max-width: 500px;
    margin: 0 auto 40px auto;
    display: none;
    animation: slideDown 0.4s ease-out;
}

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

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-section h1 {
    color: var(--unmsm-primary);
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8em;
}

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

.form-group label {
    display: block;
    color: var(--unmsm-primary);
    margin-bottom: 8px;
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--unmsm-border);
    border-radius: 8px;
    font-size: 1em;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.95);
}

.form-group input:focus {
    outline: none;
    border-color: var(--unmsm-primary);
    box-shadow: 0 0 0 3px rgba(139, 69, 69, 0.1);
}

.btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--unmsm-primary) 0%, var(--unmsm-primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(139, 69, 69, 0.3);
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 69, 69, 0.4);
}

.btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.mode-note {
    color: var(--unmsm-primary);
    font-size: 0.92em;
    line-height: 1.45;
    margin-top: 12px;
    text-align: center;
}

.error-message,
.success-message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
    line-height: 1.4;
}

.error-message {
    background: var(--error-bg);
    color: var(--error-text);
    border-left: 4px solid var(--error-text);
}

.success-message {
    background: var(--success-bg);
    color: var(--success-text);
    border-left: 4px solid var(--success-text);
}

.scoreboard-section {
    padding: 20px 0;
}

.ranking-card {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid rgba(139, 69, 69, 0.18);
    border-radius: 16px;
    box-shadow: 0 10px 28px rgba(139, 69, 69, 0.12);
    overflow: hidden;
    margin-top: 20px;
}

.ranking-card-header {
    background: linear-gradient(135deg, rgba(139, 69, 69, 0.08) 0%, rgba(139, 69, 69, 0.02) 100%);
    border-bottom: 1px solid rgba(139, 69, 69, 0.18);
    padding: 0;
}

.ranking-title {
    color: var(--unmsm-primary);
    text-align: center;
    font-size: 1.8em;
    font-weight: 700;
    padding: 26px 20px 18px 20px;
    margin: 0;
}

.score-tabs {
    display: flex;
    width: 100%;
    border-top: 1px solid rgba(139, 69, 69, 0.12);
    background: rgba(250, 248, 245, 0.8);
}

.tab-button {
    flex: 1;
    border: none;
    border-right: 1px solid rgba(139, 69, 69, 0.16);
    background: transparent;
    color: var(--unmsm-primary);
    padding: 17px 18px;
    font-size: 1em;
    font-weight: 800;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
    position: relative;
    letter-spacing: 0.2px;
}

.tab-button:last-child {
    border-right: none;
}

.tab-button:hover {
    background: rgba(139, 69, 69, 0.07);
}

.tab-button.active {
    background: white;
    color: var(--unmsm-primary-dark);
    box-shadow: inset 0 4px 0 var(--unmsm-primary);
}

.tab-button.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 2px;
    background: white;
}

.ranking-card-body {
    padding: 24px 26px 28px 26px;
}

.score-panel {
    display: none;
    animation: slideDown 0.25s ease-out;
}

.score-panel.active {
    display: block;
}

.score-panel-title {
    color: var(--unmsm-primary);
    text-align: left;
    margin: 0 0 18px 0;
    font-size: 1.25em;
    font-weight: 800;
    letter-spacing: 0.1px;
}

.balance-note {
    color: rgba(107, 53, 53, 0.78);
    border-top: 1px solid rgba(139, 69, 69, 0.16);
    margin: 18px 0 0 0;
    padding: 12px 4px 0 4px;
    font-size: 0.82em;
    line-height: 1.45;
    text-align: center;
}

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    border-radius: 10px;
}

.scoreboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    min-width: 760px;
}

.team-col-position {
    width: 10%;
}

.team-col-group {
    width: 34%;
}

.team-col-solved {
    width: 22%;
}

.team-col-score {
    width: 18%;
}

.team-col-activity {
    width: 16%;
}

.participant-col-position {
    width: 8%;
}

.participant-col-group {
    width: 24%;
}

.participant-col-student {
    width: 28%;
}

.participant-col-solved {
    width: 16%;
}

.participant-col-score {
    width: 12%;
}

.participant-col-activity {
    width: 12%;
}

.scoreboard-table thead {
    background: linear-gradient(135deg, var(--unmsm-primary) 0%, var(--unmsm-primary-dark) 100%);
    color: white;
}

.scoreboard-table th {
    padding: 16px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scoreboard-table th:first-child {
    border-top-left-radius: 10px;
}

.scoreboard-table th:last-child {
    border-top-right-radius: 10px;
}

.scoreboard-table td {
    padding: 14px 15px;
    border-bottom: 1px solid rgba(139, 69, 69, 0.2);
    background: rgba(255, 255, 255, 0.9);
    vertical-align: middle;
}

.scoreboard-table tbody tr {
    transition: all 0.3s;
}

.scoreboard-table tbody tr:hover td {
    background: rgba(139, 69, 69, 0.08);
}

.scoreboard-table tbody tr:last-child td {
    border-bottom: none;
}

.scoreboard-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 10px;
}

.scoreboard-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 10px;
}

.rank {
    font-weight: bold;
    color: var(--unmsm-primary);
    font-size: 1.1em;
    text-align: center;
}

.rank-1 {
    color: #FFD700;
    font-size: 1.3em;
    text-shadow: 0 0 5px rgba(255, 215, 0, 0.5);
}

.rank-2 {
    color: #C0C0C0;
    font-size: 1.2em;
    text-shadow: 0 0 5px rgba(192, 192, 192, 0.5);
}

.rank-3 {
    color: #CD7F32;
    font-size: 1.2em;
    text-shadow: 0 0 5px rgba(205, 127, 50, 0.5);
}

.score {
    font-weight: bold;
    color: var(--unmsm-primary);
    font-size: 1.1em;
}

.official-score {
    font-weight: 900;
    color: var(--unmsm-primary-dark);
    font-size: 1.08em;
}

.loading {
    text-align: center;
    color: var(--unmsm-primary);
    padding: 30px;
    font-size: 1.1em;
}

.is-hidden {
    display: none !important;
}

@media (max-width: 768px) {
    body {
        padding: 14px;
    }

    .header-logo {
        max-width: 400px;
    }

    .login-button {
        margin-bottom: 28px;
    }

    .login-button button {
        padding: 14px 30px;
        font-size: 1.1em;
    }

    .scoreboard-section h2,
    .login-section h1 {
        font-size: 1.5em;
    }

    .scoreboard-table {
        font-size: 0.85em;
    }

    .scoreboard-table th,
    .scoreboard-table td {
        padding: 10px 8px;
    }

    .ranking-card-body {
        padding: 18px 14px 22px 14px;
    }

    .ranking-title {
        font-size: 1.45em;
        padding: 22px 14px 16px 14px;
    }

    .score-tabs {
        flex-direction: column;
    }

    .tab-button {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid rgba(139, 69, 69, 0.16);
    }

    .tab-button:last-child {
        border-bottom: none;
    }

    .tab-button.active {
        box-shadow: inset 4px 0 0 var(--unmsm-primary);
    }
}
