@import url('https://fonts.googleapis.com/css2?family=Albert+Sans:ital,wght@0,100..900;1,100..900&family=Montserrat:ital,wght@0,100..900;1,100..900&display=swap');

body {
    margin: 0;
    font-family: "Albert Sans", sans-serif;
    background: url('../img/bg1.png') no-repeat center center fixed;
    position: relative;
    /* --- MODIFIED RULES --- */
    min-height: 100vh; /* Changed to 100vh */
    letter-spacing: -.5px;
    display: flex; /* Added */
    flex-direction: column; /* Added */
}

.bgIcon1 {
    position: fixed;
    bottom: -60%;
    left: -20%;
    /* --- MODIFIED RULE --- */
    opacity: 0.4; /* Moved from inline HTML style */
    z-index: -99;
    /* Added size and max-size for better scaling */
    width: 70vh;
    height: 70vh;
    max-width: 1000px;
    max-height: 1000px;
}

.bgIcon2 {
    position: fixed;
    top: -90%;
    right: -24%;
    /* --- MODIFIED RULE --- */
    opacity: 0.2; /* Moved from inline HTML style */
    z-index: -99;
    width: auto;
    /* Made height relative to viewport and capped it */
    height: 150vh;
    max-height: 2000px;
}

.bgIcon3 {
    position: fixed;
    bottom: -18%;
    right: -6%;
    /* --- MODIFIED RULE --- */
    opacity: 0.4; /* Moved from inline HTML style */
    z-index: -99;
    width: auto;
    /* Made height relative to viewport and capped it */
    height: 40vh;
    max-height: 700px;
}

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

.bgIcon1,
.bgIcon2,
.bgIcon3 {
    transform-origin: center center;
    will-change: transform;
    animation: spin 30s linear infinite;
}

.bgIcon1 { animation-duration: 105s; }
.bgIcon2 { animation-duration: 160s; }
.bgIcon3 { animation-duration: 98s; }

.main-header {
    display: flex;
    align-items: center;
    gap: clamp(12px, 2.5vw, 18px);
    margin-top: clamp(12px, 4vw, 32px);
    margin-bottom: clamp(10px, 2.5vw, 15px);
    
    /* --- MODIFIED RULES --- */
    /* Removed margin-left and replaced with centered layout to match the tally-card */
    width: clamp(300px, 90vw, 1920px); /* Match tally-card width */
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box; 
    /* Match tally-card's inline padding for perfect alignment */
    /* --- MODIFIED RULE (Fixed typo) --- */
    padding-left: clamp(16px, 6vw, 32px); 
    padding-right: clamp(16px, 6vw, 32px);
}
.main-header img {
    width: clamp(48px, 9vw, 100px);
    height: clamp(48px, 9vw, 100px);
    object-fit: contain;
}
.main-title {
    font-family: "Albert Sans", sans-serif;
    font-size: clamp(1.8rem, 5.5vw, 5rem);
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: clamp(-1px, -0.8vw, -3px);
    color: #444;
    margin-bottom: 0;
    transition: font-size 0.2s ease, line-height 0.2s ease;
}
.subtitle {
    font-size: clamp(0.85rem, 2.4vw, 1rem);
    color: #444;
    margin-top: clamp(-6px, -0.8vw, -15px);
    margin-left: clamp(2px, 0.6vw, 4px);
    font-weight: 600;
    line-height: 1.3;
    transition: font-size 0.2s ease, line-height 0.2s ease;
}
.top-buttons {
    position: absolute;
    top: clamp(8px, 2vw, 16px);
    right: clamp(8px, 2vw, 16px);
    display: flex;
    gap: clamp(4px, 1.2vw, 8px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.1);
    /* padding: clamp(4px, 1.2vw, 8px) clamp(6px, 1.5vw, 12px); */
    padding: 2px;
    border: 1px solid #e0e0e0;
    height: auto;
    align-items: center;
    width: auto;
    max-width: clamp(220px, 35vw, 420px);
    z-index: 5;
}
.top-btn {
    background: none;
    border: none;
    border-radius: 8px;
    padding: 0 clamp(10px, 2vw, 15px);
    font-size: clamp(0.9rem, 1.6vw, 1.3rem);
    font-weight: 900;
    color: #222;
    cursor: pointer;
    height: clamp(32px, 3vw, 40px);
    transition: background 0.2s, color 0.2s, font-size 0.2s ease;
    margin: 0;
    outline: none;
    box-shadow: none;
    font-family: "Albert Sans", sans-serif;
    white-space: nowrap;
}
.top-btn.active {
    background: #e0e0e0;
    color: #222;
}
.top-btn:not(.active):hover {
    background: #f5f5f5;
    color: #222;
}
.tally-card {
    position: relative;
    z-index: 1;
    width: clamp(300px, 90vw, 1920px);
    min-height: clamp(480px, 80vh, 1000px);
    margin: 0 auto clamp(48px, 6vw, 96px) auto;
    background-color: rgba(255, 255, 255, 0.95);
    border: 1px solid #DBDBDB;
    border-radius: 16px;
    box-sizing: border-box; /* include padding in width to avoid side cut-off */
    padding: clamp(72px, 10vw, 96px) clamp(16px, 4vw, 32px) clamp(24px, 5vw, 32px);
    /* Ensure a bit more breathing room on very small screens */
    padding-inline: clamp(16px, 6vw, 32px);
    box-shadow: 0px 0px 1px 1px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* prevent content from overlapping edges */
    /* --- ADDED RULE --- */
    /* Allows card to grow and fill space on mobile */
    flex-grow: 1; 
}
.tally-table {
    width: 100%;
    border-collapse: collapse;
    font-size: clamp(0.9rem, 1.6vw, 1.1rem);
}
.tally-table th, .tally-table td {
    padding: clamp(8px, 1.2vw, 12px) clamp(6px, 1vw, 8px);
    text-align: left;
    word-break: break-word;
}
.tally-table th {
    font-family: 'Montserrat', sans-serif;
    font-size: clamp(0.95rem, 1.5vw, 1.1rem);
    font-weight: 700;
    color: #222;
    background: none;
    border-bottom: 2px solid #eee;
}
.tally-table th.gold { color: #FFD700; text-align: center; white-space: nowrap; font-size: clamp(0.85rem, 1.4vw, 1.05rem); }
.tally-table th.silver { color: #B0B0B0; text-align: center; white-space: nowrap; font-size: clamp(0.85rem, 1.4vw, 1.05rem); }
.tally-table th.bronze { color: #C9894B; text-align: center; white-space: nowrap; font-size: clamp(0.85rem, 1.4vw, 1.05rem); }

/* --- MODIFIED RULES --- */
/* Removed the color property from these table cells */
.tally-table td.gold { font-weight: 700; text-align: center;}
.tally-table td.silver { font-weight: 700; text-align: center;}
.tally-table td.bronze { font-weight: 700; text-align: center;}
/* --- END MODIFIED RULES --- */

.tally-table tr {
    border-bottom: 1px solid #f3f3f3;
}
.tally-table tr:last-child {
    border-bottom: none;
}
.dept-logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    object-fit: cover;
    background: #eee;
}

/* --- ADDED RULES for Medal Circles --- */
.medal-count {
    display: inline-block;
    width: 32px;
    height: 32px;
    line-height: 34px; /* Adjusted for vertical centering */
    border-radius: 50%;
    font-weight: 700;
    font-size: 0.9em;
    color: #fff; /* Default text color (white for silver/bronze) */
    background-color: #ccc; /* Fallback */
    text-align: center;
    vertical-align: middle;
    text-shadow: 0 1px 1px rgba(0,0,0,0.18);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.tally-table td.gold .medal-count {
    background-color: #FFD700;
    border: 1px solid #fff2a5;
    color: #554800; 
}
.tally-table td.silver .medal-count {
    background-color: #B0B0B0;
    border: 1px solid #ffffff;
}
.tally-table td.bronze .medal-count {
    background-color: #C9894B;
    border: 1px solid #fdb368;
}
/* --- END ADDED RULES --- */

.dept-name {
    font-weight: 500;
    color: #222;
}
/* --- MODIFIED RULES (Added .tally-table for specificity) --- */
/* Hide the acronym version by default */
.tally-table .dept-name.acronym {
    display: none;
}
/* Show the full-name version by default */
.tally-table .dept-name.full-name {
    display: inline;
}
/* --- END MODIFIED RULES --- */

.tally-table th.total, .tally-table td.total {
    font-weight: 700;
    color: #222;
    text-align: center;
    white-space: nowrap;
}
.tally-table th, .tally-table td {
    border-right: 1px solid #eee;
}
.tally-table th:last-child, .tally-table td:last-child {
    border-right: none;
}

/* Horizontal scroll wrapper for wide tables */
.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-scroll .tally-table,
.table-scroll .department-events-table {
    min-width: 650px; /* allow scroll when viewport is narrow */
}
footer,
.footer {
    position: fixed;
    bottom: 18px;
    left: 0;
    width: 100%;
    text-align: center;
    z-index: 2;
    /* --- MODIFIED RULE --- */
    font-size: clamp(0.9rem, 1.8vw, 1.2rem); /* Made footer font responsive */
    letter-spacing: -0.5px; /* Adjusted letter-spacing */
    color: #222;
    background: none;
}
.ub-logo {
    vertical-align: middle;
    /* --- MODIFIED RULES --- */
    height: 1.2em; /* Scales with parent font size */
    width: auto; /* Maintains aspect ratio */
    margin: 0 4px;
    /* --- ADDED RULE --- */
    flex-shrink: 0; /* Prevents footer from shrinking */
}


@media (max-width: 900px) {
    /* Removed rules that conflicted with new centered header */
    .tally-card { max-width: 99vw; } /* This tightens margin, kept it */
    .top-buttons { right: 8px; }
}

/* Small devices: tighten spacing and adjust title line-height */
@media (max-width: 768px) {
    .main-title { line-height: 1.1; }
    .subtitle { line-height: 1.25; }

    /* --- ADDED RULES --- */
    /* Tighten up card padding and buttons for tablets */
    .tally-card {
        padding-top: clamp(50px, 8vw, 72px); 
    }
    .top-btn {
        font-size: clamp(0.85rem, 2vw, 1.1rem);
        height: clamp(30px, 5vw, 36px);
    }
}

@media (max-width: 480px) {
    .main-title { font-size: clamp(1.6rem, 8vw, 2.2rem); line-height: 1.15; }
    .main-header img { width: clamp(40px, 12vw, 60px); height: clamp(40px, 12vw, 60px); }

    /* --- ADDED/MODIFIED RULES FOR MOBILE --- */
    .main-header, .tally-card {
        width: 92vw; /* Use viewport width directly */
        box-sizing: border-box;
    }
    .main-header {
        padding-left: 3vw;
        padding-right: 3vw;
        gap: 10px;
    }
    .tally-card {
        padding-inline: 3vw;
        padding-top: 45px; /* Reduced top padding for buttons */
        min-height: 0; /* Let content define height */
        margin-bottom: 0; /* Footer will handle spacing */
        /* --- MODIFIED RULE --- */
        flex-grow: 1; /* Explicitly set for mobile override */
    }

    /* Make buttons smaller to fit */
    .top-buttons {
        top: 6px;
        right: 6px;
        padding: 2px; 
        gap: 2px;
    }
    .top-btn {
        font-size: 0.7rem; 
        font-weight: 700;
        height: 24px; 
        padding: 0 6px; 
    }

    /* Adjust table for small screens */
    .tally-table {
        font-size: 0.85rem; /* Reduce base font in table */
    }
    .tally-table th, .tally-table td {
        padding: 8px 6px; /* simplify padding */
    }
    .dept-logo {
        width: 28px;
        height: 28px;
    }
    .table-scroll .tally-table,
    .table-scroll .department-events-table {
        min-width: 500px; /* Reduce min-width for better scrolling */
    }

    /* --- ADDED RULES for Mobile Medal Circles --- */
    .medal-count {
        width: 22px;
        height: 22px;
        line-height: 24px; 
        font-size: 0.7em;
    }
    /* --- END ADDED RULES --- */

    /* Un-fix the footer */
    footer, .footer {
        position: relative;
        bottom: auto;
        left: auto;
        margin-top: 24px;
        margin-bottom: 24px;
        font-size: 0.8rem;
    }
    .ub-logo {
        height: 1.1em;
    }

    /* --- MODIFIED RULES FOR ACRONYM (Added .tally-table for specificity) --- */
    /* On mobile, hide the full name */
    .tally-table .dept-name.full-name {
        display: none;
    }
    /* On mobile, show the acronym */
    .tally-table .dept-name.acronym {
        display: inline;
    }
    /* --- END MODIFIED RULES --- */

    
    
    /* Top-Right Element (was .bgIcon2) */
    .bgIcon2 {
        top: -12%;
        right: -40%;
        width: 100vw;
        height: 100vw;
        max-width: 500px;
        max-height: 500px;
    }

    /* Bottom-Left Element (was .bgIcon1) */
    .bgIcon1 {
        top: auto; /* Unset */
        bottom: -20%;
        left: -35%;
        width: 80vw;
        height: 80vw;
        max-width: 400px;
        max-height: 400px;
    }

    /* Bottom-Right Element (was .bgIcon3) */
    .bgIcon3 {
        bottom: 5%;
        right: -15%;
        width: 50vw;
        height: 50vw;
        max-width: 200px;
        max-height: 200px;
    }
}