:root {
    --navy: #09275b;
    --blue: #1875c9;
    --sky: #73ccef;
    --paper: #ffffff;
    --line: #d7e0e8;
    --gold: #ffc428;
    --shadow: 0 10px 24px rgba(19, 68, 106, 0.18);
    color-scheme: light;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    background: var(--sky);
    color: var(--navy);
    font-family: "Montserrat", Arial, sans-serif;
    letter-spacing: 0;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -3;
    background: #78c9ed url("assets/landscape-background.jpg") center bottom / cover no-repeat;
}

.page-shell {
    width: min(1050px, calc(100% - 32px));
    margin: 12px auto 24px;
}

.site-header,
.ranking-panel {
    background: rgba(255, 255, 255, 0.96);
    box-shadow: var(--shadow);
}

.site-header {
    min-height: 102px;
    padding: 16px 28px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 22px;
    min-width: 0;
    color: var(--navy);
    text-decoration: none;
    font-family: "Montserrat", Arial, sans-serif;
}

.brand > img { width: 118px; height: 66px; object-fit: contain; }
.brand-title {
    min-height: 72px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: clamp(1.5rem, 4vw, 2.75rem);
    font-weight: 900;
    white-space: nowrap;
}
.title-trophy {
    flex: 0 0 auto;
    width: 68px;
    height: 68px;
    object-fit: contain;
    mix-blend-mode: multiply;
    pointer-events: none;
}

.teacher-button {
    display: block;
    flex: 0 0 auto;
    width: 125px;
    aspect-ratio: 1338 / 405;
    background: url("assets/teacher-access-default.png?v=2") center / contain no-repeat;
    text-decoration: none;
}

.teacher-button:hover,
.teacher-button:focus-visible { background-image: url("assets/teacher-access-hover.png?v=2"); }
.teacher-button:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }

.news-ticker {
    min-height: 42px;
    margin-top: 12px;
    display: flex;
    align-items: stretch;
    overflow: hidden;
    border: 2px solid rgba(255, 196, 40, .95);
    border-radius: 9px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 5px 14px rgba(19, 68, 106, .16);
}

.ticker-label {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    padding: 0 17px;
    display: grid;
    place-items: center;
    background: var(--navy);
    color: white;
    font-size: .76rem;
    font-weight: 900;
    text-transform: uppercase;
}

.ticker-window {
    min-width: 0;
    display: flex;
    align-items: center;
    overflow: hidden;
    flex: 1;
}

.ticker-track {
    width: max-content;
    display: flex;
    gap: 72px;
    padding-left: 72px;
    color: var(--navy);
    font-size: .92rem;
    font-weight: 800;
    white-space: nowrap;
    animation: ticker-scroll 17s linear infinite;
    will-change: transform;
}

.ticker-track span { flex: 0 0 auto; }
.news-ticker:hover .ticker-track,
.news-ticker:focus-within .ticker-track { animation-play-state: paused; }

@keyframes ticker-scroll {
    to { transform: translateX(calc(-50% - 36px)); }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

main { display: grid; gap: 14px; margin-top: 18px; }

.leader-spotlight { min-height: 0; }
.leader-spotlight[hidden] { display: none; }
.leader-card,
.dual-leader-card {
    border-radius: 14px;
    background: rgba(255,255,255,0.96);
    box-shadow: 0 0 0 4px #ffd54b, 0 0 20px 6px rgba(255, 213, 75, .88), 0 12px 30px rgba(85, 74, 16, .28);
    overflow: hidden;
}

.leader-card {
    position: relative;
    min-height: 290px;
    isolation: isolate;
    background: color-mix(in srgb, var(--team) 15%, #fff7e5);
}
.leader-card::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: color-mix(in srgb, var(--team) 9%, transparent);
    pointer-events: none;
}
.leader-card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    background: linear-gradient(90deg, rgba(255,255,255,.76) 0%, rgba(255,255,255,.5) 52%, rgba(255,255,255,0) 76%);
    pointer-events: none;
}

.leader-identity {
    position: relative;
    z-index: 2;
    width: 69%;
    min-height: 290px;
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    align-items: center;
}
.leader-identity > img { width: 100%; height: 256px; padding: 12px 18px; object-fit: contain; filter: drop-shadow(0 8px 8px rgba(7,26,56,.22)); }
.leader-copy { min-width: 0; padding: 24px 24px 24px 6px; }
.leader-ribbon { display: inline-block; padding: 8px 18px; background: var(--team, #c92d42); color: white; font-weight: 900; text-transform: uppercase; clip-path: polygon(0 0,100% 0,94% 50%,100% 100%,0 100%); }
.leader-copy h2 { margin: 15px 0 8px; font-size: clamp(1.7rem, 3.2vw, 2.6rem); line-height: 1.05; }
.leader-score { display: flex; align-items: center; gap: 12px; color: var(--team); font-size: 1.55rem; }
.leader-score > span { color: var(--gold); font-size: 2rem; }
.leader-scene { position: absolute; inset: 0; z-index: 0; background-color: #fff1e6; background-position: center; background-size: cover; background-repeat: no-repeat; }
.leader-copy .progress-wrap { width: min(100%, 470px); margin-top: 18px; }

.progress-wrap { display: flex; align-items: center; gap: 14px; min-width: 0; margin-top: 20px; }
.progress-track { height: 24px; border: 2px solid #c6d0d9; border-radius: 7px; background: #eef1f4; overflow: hidden; flex: 1; min-width: 80px; }
.progress-fill { display: block; width: var(--progress); height: 100%; background: var(--team); box-shadow: inset 0 -4px rgba(0,0,0,.12); transition: width .6s ease; }
.progress-label { font-weight: 900; white-space: nowrap; }

.shared-lead-label { padding: 9px 18px; background: #d6a400; color: white; text-align: center; font-weight: 900; text-transform: uppercase; }
.dual-leader-grid { display: grid; grid-template-columns: 1fr 1fr; }
.dual-leader-team { min-width: 0; padding: 18px 22px; display: grid; grid-template-columns: 125px minmax(0,1fr); gap: 18px; align-items: center; background: color-mix(in srgb, var(--team) 7%, white); }
.dual-leader-team + .dual-leader-team { border-left: 2px solid #e0c34d; }
.dual-leader-team > img { width: 115px; height: 164px; object-fit: contain; filter: drop-shadow(0 6px 6px rgba(7,26,56,.2)); }
.dual-team-copy { min-width: 0; }
.dual-team-copy h2 { margin: 0 0 5px; font-size: 1.65rem; line-height: 1.08; }
.dual-team-copy > strong { color: var(--team); font-size: 1.2rem; }
.dual-team-copy > strong span { color: var(--gold); }
.dual-team-copy .progress-wrap { display: block; margin-top: 14px; }
.dual-team-copy .progress-label { display: block; margin-top: 5px; font-size: .72rem; }

.ranking-panel { border-radius: 14px; overflow: hidden; }
.ranking-row {
    min-height: 92px;
    padding: 9px 22px;
    display: grid;
    grid-template-columns: 52px 72px 140px minmax(180px, 1fr) 88px 32px;
    gap: 16px;
    align-items: center;
    border-left: 7px solid var(--team);
    border-bottom: 1px solid var(--line);
}
.ranking-row:last-child { border-bottom: 0; }
.rank-number { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: color-mix(in srgb, var(--team) 15%, white); font-size: 1.35rem; font-weight: 900; }
.row-crest { width: 66px; height: 78px; object-fit: contain; filter: drop-shadow(0 3px 3px rgba(0,0,0,.2)); }
.row-name { font-size: 1.35rem; }
.ranking-row .progress-wrap { margin: 0; }
.row-score { text-align: right; font-size: 1.35rem; white-space: nowrap; }
.row-score span { font-size: .72rem; }
.row-star { color: var(--team); font-size: 2.2rem; line-height: 1; }

.loading { margin: 0; min-height: 280px; display: grid; place-items: center; background: white; border-radius: 14px; font-weight: 900; }
.error-message { margin: 0; padding: 14px 20px; color: #a31f32; font-weight: 800; }

@media (max-width: 820px) {
    .page-shell { width: min(100% - 20px, 680px); }
    .site-header { min-height: 76px; padding: 11px 14px; border-radius: 12px; }
    .brand { gap: 10px; }
    .brand > img { width: 62px; height: 46px; }
    .brand-title { min-height: 52px; gap: 7px; font-size: 1.15rem; white-space: normal; }
    .title-trophy { width: 44px; height: 44px; }
    .teacher-button { width: 95px; }
    .leader-card { min-height: 240px; }
    .leader-identity { width: 72%; min-height: 240px; grid-template-columns: 130px minmax(0,1fr); }
    .leader-identity > img { height: 210px; padding: 10px 14px; }
    .leader-copy { padding: 18px 14px 18px 0; }
    .leader-copy h2 { font-size: 1.75rem; }
    .dual-leader-team { grid-template-columns: 88px minmax(0,1fr); padding: 14px; gap: 11px; }
    .dual-leader-team > img { width: 82px; height: 126px; }
    .dual-team-copy h2 { font-size: 1.25rem; }
    .ranking-row { grid-template-columns: 42px 58px minmax(90px,1fr) 78px 24px; gap: 10px; min-height: 80px; padding: 8px 12px; }
    .ranking-row .progress-wrap { grid-column: 3 / -1; grid-row: 2; }
    .ranking-row { grid-template-rows: 48px 18px; }
    .rank-number { width: 36px; height: 36px; }
    .row-crest { width: 54px; height: 66px; grid-row: span 2; }
    .row-name { font-size: 1.05rem; }
    .row-score { font-size: 1.05rem; }
    .row-star { font-size: 1.7rem; }
    .progress-track { height: 18px; }
}

@media (max-width: 520px) {
    body::before { background-position: 32% bottom; }
    .page-shell { width: calc(100% - 12px); margin-top: 6px; }
    .site-header { gap: 8px; }
    .brand > img { width: 46px; }
    .brand-title { min-height: 44px; gap: 4px; font-size: .82rem; }
    .title-trophy { width: 30px; height: 30px; }
    .teacher-button { width: 66px; }
    .news-ticker { min-height: 36px; margin-top: 8px; border-radius: 7px; }
    .ticker-label { padding: 0 10px; font-size: .62rem; }
    .ticker-track { gap: 52px; padding-left: 52px; font-size: .75rem; animation-duration: 15s; }
    .leader-card { min-height: 174px; }
    .leader-identity { width: 70%; min-height: 174px; grid-template-columns: 88px minmax(0,1fr); align-items: center; }
    .leader-identity > img { height: 148px; padding: 0 8px; }
    .leader-copy { height: 148px; padding: 0 7px 0 0; display: flex; flex-direction: column; }
    .leader-scene { background-position: 66% center; background-size: auto 100%; }
    .leader-ribbon { padding: 6px 10px; font-size: .68rem; }
    .leader-copy h2 { margin: 8px 0 4px; font-size: 1.15rem; }
    .leader-score { font-size: 1.05rem; }
    .leader-score > span { font-size: 1.4rem; }
    .leader-copy .progress-wrap { display: block; width: 126%; margin-top: auto; }
    .leader-copy .progress-label { display: block; margin-top: 5px; font-size: .65rem; }
    .shared-lead-label { padding: 7px 12px; font-size: .78rem; }
    .dual-leader-team { padding: 10px 7px; display: flex; flex-direction: column; gap: 5px; text-align: center; }
    .dual-leader-team > img { width: 62px; height: 88px; }
    .dual-team-copy h2 { font-size: .92rem; }
    .dual-team-copy > strong { font-size: .86rem; }
    .dual-team-copy .progress-wrap { margin-top: 8px; }
    .dual-team-copy .progress-label { font-size: .62rem; }
    .ranking-row { grid-template-columns: 32px 48px minmax(72px,1fr) 61px 18px; gap: 7px; border-left-width: 5px; }
    .rank-number { width: 29px; height: 29px; font-size: .9rem; }
    .row-crest { width: 46px; height: 59px; }
    .row-name,.row-score { font-size: .9rem; }
    .row-score span { font-size: .55rem; }
    .row-star { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
    .ticker-track {
        width: auto;
        padding: 0 14px;
        animation: none;
        white-space: normal;
    }
    .ticker-track span[aria-hidden="true"] { display: none; }
}
