/* HKTC 2026 Ranking
 *
 * The look follows the CMS RankingWebServer skin used by ranking.ioi2026.uz:
 * same layout (fixed top bar, 220px left rail with the clock and the score
 * overview, scrollable board on the right), same table chrome and the same
 * hsl(120, 30%, x%) score ramp.
 */

body {
    font: .85em/1.3em sans-serif;
    color: black;
    background-color: #F6F6F6;
    background-image: linear-gradient(#FFFFFF, #EDEDED);
    background-attachment: fixed;
    margin: 0;
}

td { padding: 0; }
a { outline: none; }
abbr { text-decoration: none; }


/******************************************************************************\
|                                  Page layout                                 |
\******************************************************************************/

#LogoPanel {
    position: absolute;
    top: 56px;
    left: 0;
    width: 220px;
    text-align: center;
    z-index: 9;
}

#LogoPanel .logo_mark {
    display: inline-block;
    padding: 10px 14px 8px;
    border-radius: 10px;
    background: linear-gradient(160deg, #0B3C6E, #0F6FB5);
    color: #FFFFFF;
    box-shadow: 0 2px 6px rgba(11, 60, 110, 0.35);
}

#LogoPanel .logo_title {
    font-size: 26px;
    font-weight: bold;
    letter-spacing: 1px;
    line-height: 1.1em;
}

#LogoPanel .logo_sub {
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    opacity: 0.85;
    margin-top: 3px;
}

#LogoPanel .logo_round {
    margin-top: 6px;
    font-size: 12px;
    color: #444;
    letter-spacing: 1px;
}

#UpperPanel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3em;
    border-width: 0 0 2px 2px;
    border-style: solid;
    border-color: #FAFAFA;
    border-radius: 0 0 0 10px;
    background-color: #EAEAEC;
    box-shadow: 0 0 2px 0 gray;
    z-index: 100;
}

#ContestTitle {
    position: absolute;
    left: 250px;
    top: 0;
    height: 3em;
    line-height: 3em;
    font-size: 1.15em;
    font-weight: bold;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
}

#ContestTitle .sep {
    color: #AAA;
    font-weight: normal;
    margin: 0 6px;
}

#ContestTitle .badge {
    display: inline-block;
    vertical-align: middle;
    margin-left: 10px;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    line-height: 18px;
    letter-spacing: 0.5px;
    color: #FFF;
    background-color: #999;
}

#ContestTitle .badge.frozen { background-color: #3465A4; }
#ContestTitle .badge.hidden_badge { display: none; }

/* Round 1 / Round 2 / Total switch, in the top bar. */
#RoundTabs {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    height: 3em;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

/* One view means no choice to make — the strip stays out of the way. */
#RoundTabs.hidden_tabs { display: none; }

#RoundTabs .tab {
    position: relative;
    border: 1px solid #D0D0D2;
    border-radius: 14px;
    background-color: #F4F4F6;
    color: #555;
    font: inherit;
    font-weight: bold;
    padding: 4px 14px;
    cursor: pointer;
    box-shadow: 0 0 2px 0 #D2D2D4 inset;
}

#RoundTabs .tab:hover { background-color: #FFFFFF; color: #111; }

#RoundTabs .tab.active {
    background: linear-gradient(160deg, #0B3C6E, #0F6FB5);
    border-color: #0B3C6E;
    color: #FFFFFF;
    box-shadow: 0 1px 3px rgba(11, 60, 110, 0.35);
}

#RoundTabs .tab .dot {
    display: none;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-left: 7px;
    vertical-align: 1px;
    background-color: #4E9A06;
}

#RoundTabs .tab.live .dot {
    display: inline-block;
    animation: tab_pulse 1.6s ease-in-out infinite;
}

#RoundTabs .tab.done .dot {
    display: inline-block;
    background-color: #A40000;
}

@keyframes tab_pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.25; }
}

#ConnectionStatus_box {
    position: absolute;
    right: 0;
    top: 0;
    height: 3em;
    line-height: 3em;
    padding-right: 1em;
    white-space: nowrap;
}

#ConnectionStatus_label {
    display: inline-block;
    color: #777;
    font-size: 0.85em;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-right: 8px;
}

#ConnectionStatus_text {
    display: inline-block;
    font-weight: bold;
}

#ConnectionStatus_text::before {
    content: "";
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    background-color: #999;
}

#ConnectionStatus_text.live::before   { background-color: #4E9A06; }
#ConnectionStatus_text.wait::before   { background-color: #C4A000; }
#ConnectionStatus_text.paused::before { background-color: #F57900; }
#ConnectionStatus_text.ended::before  { background-color: #A40000; }

#SidePanel {
    position: absolute;
    left: 0;
    top: 262px;
    bottom: 30px;
    width: 220px;
    border-width: 2px 2px 2px 0;
    border-style: solid;
    border-color: #FAFAFA;
    border-radius: 0 10px 10px 0;
    background-color: #EAEAEC;
    box-shadow: 0 0 2px 0 gray;
    padding: 0;
    z-index: 8;
}

#Overview {
    position: relative;
    height: calc(100% - 34px);
    width: 100%;
}

#Overview svg { display: block; }

#SidePanel .credits {
    position: absolute;
    bottom: 4px;
    left: 0;
    right: 0;
    color: #999;
    text-align: center;
    font-size: 11px;
}

#SidePanel .credits a { color: #00A3DA; text-decoration: none; }

#InnerFrame {
    position: absolute;
    top: 3em;
    left: 220px;
    right: 0;
    bottom: 0;
    margin: 2px 0 0 2px;
    padding: 0 3em;
    overflow-y: scroll;
}


/******************************************************************************\
|                                   Time view                                  |
\******************************************************************************/

#TimeView {
    position: absolute;
    top: 208px;
    left: 0;
    width: 220px;
    z-index: 10;
    text-align: center;
}

#TimeView_selector {
    display: inline-block;
    height: 28px;
    padding: 0;
    z-index: 10;
    margin: 4px;
    overflow: hidden;
    user-select: none;
}

#TimeView.pre_cont #TimeView_selector:hover,
#TimeView.cont #TimeView_selector:hover,
#TimeView_selector.open {
    margin: 2px;
    background-color: #EAEAEC;
    border: 2px solid #FAFAFA;
    border-radius: 4px;
    box-shadow: 0 0 2px 0 gray;
}

#TimeView_selector.open { height: auto; }

#TimeView_time {
    display: inline-block;
    vertical-align: top;
    text-align: center;
    line-height: 28px;
    font-size: 24px;
    margin: 0 2px 0 16px;
    font-variant-numeric: tabular-nums;
}

#TimeView_expand {
    display: inline-block;
    position: relative;
    width: 8px;
    height: 28px;
    vertical-align: top;
    cursor: pointer;
    margin: 0 4px 0 2px;
}

#TimeView_selector .caret {
    position: absolute;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 6px solid #AAAAAA;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
    border-bottom: 0;
}

#TimeView_selector:hover .caret { border-top-color: #000000; }

#TimeView_selector.open .caret {
    top: 10px;
    border-top: 0;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
    border-bottom: 6px solid #000000;
}

#TimeView.post_cont #TimeView_time { margin-right: 16px; }
#TimeView.post_cont #TimeView_expand { display: none; }

#TimeView_name {
    font-size: 11px;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #888;
}

#TimeView_selector_elapsed,
#TimeView_selector_remaining,
#TimeView_selector_current {
    padding: 2px 4px;
    font-size: 0.875em;
    line-height: 1.4em;
    color: #444444;
    cursor: pointer;
}

#TimeView.pre_cont #TimeView_selector_elapsed,
#TimeView.post_cont #TimeView_selector_elapsed,
#TimeView.post_cont #TimeView_selector_remaining { display: none; }

#TimeView.elapsed #TimeView_selector_elapsed,
#TimeView.remaining #TimeView_selector_remaining,
#TimeView.current #TimeView_selector_current {
    background-color: #F2F2F3;
    color: #000000;
}

#TimeView_selector_elapsed:hover,
#TimeView_selector_remaining:hover,
#TimeView_selector_current:hover {
    background-color: #FAFAFA !important;
    color: #000000;
}


/******************************************************************************\
|                                    Search                                    |
\******************************************************************************/

#Search_input {
    position: absolute;
    box-sizing: content-box;
    top: 0;
    left: 24px;
    width: 200px;
    height: 1.5em;
    margin: 0.5em;
    border: 0;
    padding: 0.25em 0.5em;
    z-index: 401;
    border-radius: 0.5em;
    font-size: 1em;
    background-color: #FFFFFF;
    box-shadow: 0 0 2px 0 gray inset;
}

#Search_input:focus { outline: 2px solid #0F6FB5; }


/******************************************************************************\
|                                   Scoreboard                                 |
\******************************************************************************/

#Scoreboard {
    width: 100%;
    table-layout: fixed;
    margin: 20px 0;
    border-collapse: separate;
    border-spacing: 2px 1px;
}

#Scoreboard_cols col.rank { width: 48px; }
#Scoreboard_cols col.team { width: 72px; }
#Scoreboard_cols col.score { width: 64px; }
#Scoreboard_cols col.total { width: 84px; }

#Scoreboard_head tr { height: 2.5em; }
/* Tall enough for the 26px portrait that sits beside the name. */
#Scoreboard_body tr { height: 30px; }

#Scoreboard_head tr th {
    background-color: #ECECEF;
    border: 1px #D0D0D2 solid;
    border-radius: 4px;
    box-shadow: 0 0 2px 0 #D2D2D4 inset;
    height: 24px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#Scoreboard_head tr th,
#Scoreboard_body tr td { text-align: center; }

/* Each header holds a full and a short label; only one is ever shown. */
#Scoreboard_head .narrow { display: none; }

#Scoreboard_head tr th.score { cursor: pointer; }
#Scoreboard_head tr th.sort_key { background-color: #DFE6ED; border-color: #9BB2C6; }

/* The combined view puts a round band above that round's task columns, the
 * way the CMS ranking bands a contest above its tasks. */
#Scoreboard_head tr.groups th.group {
    background-color: #E3E8EE;
    border-color: #C2CCD6;
    font-size: 0.92em;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: #0B3C6E;
}

#Scoreboard_head tr.groups th.blank {
    background: none;
    border: 0;
    box-shadow: none;
}

#Scoreboard_body tr td.f_name,
#Scoreboard_body tr td.l_name {
    text-align: left;
    padding: 0 0.5em;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

#Scoreboard_body tr td.team {
    vertical-align: middle;
    cursor: default;
}

/* Contestant portraits — square headshots, the way the IOI contestant pages
 * do it. `.row` sits next to the name on the board, `.big` heads the detail
 * panel. */
.avatar {
    flex: none;
    overflow: hidden;
    background-color: #D8DEE5;
    border: 1px solid #C8D3DE;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar.row { width: 26px; height: 26px; }
.avatar.big { width: 112px; height: 112px; }

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Headshots are framed for the face, which sits above centre. */
    object-position: 50% 25%;
    display: block;
}

.avatar span {
    font-weight: bold;
    color: #6B7885;
}

.avatar.row span { font-size: 10px; letter-spacing: 0.5px; }
.avatar.big span { font-size: 34px; letter-spacing: 1px; }

/* Portrait + name, side by side inside the name cell. */
.who {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.who .nm {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Wide screens keep First Name and Last Name in their own columns, so the
 * surname copy that rides along in this cell stays hidden. */
.who .ln { display: none; }

/* The waving flags are the 144x108 PNGs used by the IOI 2026 ranking. */
#Scoreboard_body tr td.team img {
    display: block;
    max-width: 40px;
    max-height: 24px;
    margin: 0 auto;
}

#Scoreboard_body tr:hover td.f_name,
#Scoreboard_body tr:hover td.l_name,
#Scoreboard_body tr:hover td.team {
    background-color: rgba(200, 200, 200, 0.35);
    border-radius: 5px;
}

#Scoreboard_body tr.selected td.f_name,
#Scoreboard_body tr.selected td.l_name { font-weight: bold; }

#Scoreboard_body tr.filtered_out { display: none; }

#Scoreboard_body tr td.score {
    opacity: 0.75;
    border-radius: 5px;
    font-variant-numeric: tabular-nums;
}

#Scoreboard_body tr td.score.sort_key {
    border: 1px solid #777777;
    box-shadow: 0 0 1px white inset;
}

#Scoreboard_body tr:hover td.score,
#Scoreboard_body tr.selected td.score,
#Scoreboard_body tr td.score.sort_key { opacity: 1; }

#Scoreboard_body tr td.score.total { font-weight: bold; }

.score_0        { color: #666; }
.score_0_10     { background-color: hsl(120, 30%, 87%); }
.score_10_20    { background-color: hsl(120, 30%, 84%); }
.score_20_30    { background-color: hsl(120, 30%, 81%); }
.score_30_40    { background-color: hsl(120, 30%, 78%); }
.score_40_50    { background-color: hsl(120, 30%, 75%); }
.score_50_60    { background-color: hsl(120, 30%, 72%); }
.score_60_70    { background-color: hsl(120, 30%, 69%); }
.score_70_80    { background-color: hsl(120, 30%, 66%); }
.score_80_90    { background-color: hsl(120, 30%, 63%); }
.score_90_100   { background-color: hsl(120, 30%, 60%); }
.score_100      { background-color: hsl(120, 30%, 55%); }

/* Rank flashes green when a contestant moves up, red when they move down. */
#Scoreboard_body tr td.rank { border-radius: 5px; font-variant-numeric: tabular-nums; }

#Scoreboard_body tr.score_up td.rank {
    animation: score_up 5s ease-in;
}

#Scoreboard_body tr.score_down td.rank {
    animation: score_down 5s ease-in;
}

@keyframes score_up {
    from { background-color: rgba(138, 226, 52, 0); }
    10%  { background-color: rgba(138, 226, 52, 0.6); }
    to   { background-color: rgba(138, 226, 52, 0); }
}

@keyframes score_down {
    from { background-color: rgba(239, 41, 41, 0); }
    10%  { background-color: rgba(239, 41, 41, 0.6); }
    to   { background-color: rgba(239, 41, 41, 0); }
}

/* Cell flashes when the score itself changes. */
#Scoreboard_body tr td.score.flash { animation: cell_flash 4s ease-out; }

@keyframes cell_flash {
    from { box-shadow: 0 0 0 2px rgba(78, 154, 6, 0.9) inset; }
    to   { box-shadow: 0 0 0 2px rgba(78, 154, 6, 0) inset; }
}

/* Rows slide to their new position (FLIP). */
#Scoreboard_body tr.moving { transition: transform 0.6s cubic-bezier(.2, .7, .2, 1); }


/******************************************************************************\
|                                  User detail                                 |
\******************************************************************************/

#UserDetail_bg {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 500;
}

#UserDetail_bg.open { display: block; }

#UserDetail {
    position: relative;
    width: 720px;
    max-width: calc(100% - 40px);
    max-height: calc(100% - 80px);
    overflow-y: auto;
    margin: 40px auto;
    padding: 20px 24px;
    background-color: #FFFFFF;
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

#UserDetail_close {
    position: absolute;
    top: 10px;
    right: 14px;
    font-size: 22px;
    line-height: 1em;
    color: #999;
    cursor: pointer;
    border: 0;
    background: none;
}
#UserDetail_close:hover { color: #333; }

#UserDetail_head {
    display: flex;
    align-items: center;
    gap: 16px;
}

#UserDetail_photo .avatar { flex: none; }

#UserDetail_name { font-size: 1.7em; font-weight: bold; }
#UserDetail_team { color: #666; margin-top: 4px; }
#UserDetail_school { color: #0B3C6E; margin-top: 2px; font-size: 0.95em; }
#UserDetail_team .flag {
    height: 26px;
    vertical-align: -8px;
    margin-right: 6px;
}

#UserDetail_summary {
    margin: 14px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

#UserDetail_summary .card {
    flex: 1 1 90px;
    padding: 8px 10px;
    border: 1px solid #E1E5E9;
    border-radius: 6px;
    background: #FAFAFA;
    text-align: center;
}

#UserDetail_summary .card .k {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

#UserDetail_summary .card .v { font-size: 1.5em; font-weight: bold; }

#UserDetail_chart { margin: 10px 0 16px; }

#UserDetail h3 {
    font-size: 1em;
    margin: 16px 0 6px;
    color: #0B3C6E;
    border-bottom: 1px solid #E1E5E9;
    padding-bottom: 4px;
}

#UserDetail h3 .rk {
    float: right;
    font-weight: normal;
    font-size: 0.9em;
    color: #8A97A5;
}

#UserDetail table { width: 100%; border-collapse: collapse; }
#UserDetail table th {
    text-align: left;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
    padding: 4px 6px;
}
#UserDetail table td { padding: 4px 6px; border-top: 1px solid #EEE; }
#UserDetail table td.num,
#UserDetail table th.num { text-align: right; font-variant-numeric: tabular-nums; }
#UserDetail .empty { color: #999; padding: 8px 6px; }


/******************************************************************************\
|                                  Narrow screens                              |
\******************************************************************************/

@media (max-width: 900px) {
    #UpperPanel, #LogoPanel, #TimeView, #SidePanel {
        position: static;
        width: auto;
        height: auto;
        border-radius: 0;
    }
    #UpperPanel { padding-bottom: 8px; }
    #ConnectionStatus_box {
        position: static;
        height: auto;
        line-height: 2em;
        text-align: center;
        padding: 0;
    }
    #LogoPanel { padding-top: 10px; }
    #TimeView { margin: 8px 0; }
    #SidePanel { display: none; }
    #InnerFrame {
        position: static;
        padding: 0 6px 20px;
        /* Belt and braces: if a board still ends up wider than the phone, it
         * scrolls sideways on its own instead of spilling off the page. */
        overflow-x: auto;
        overflow-y: visible;
    }
    #ContestTitle { display: none; }
    #Search_input { position: static; display: block; width: auto; margin: 8px 10px; }
    /* The board is the whole point on a phone, so let it size itself to the
     * content instead of squeezing eight fixed columns into 390px — which is
     * what turned every header and every name into an ellipsis. */
    #Scoreboard {
        table-layout: auto;
        font-size: 0.95em;
        margin: 10px 0;
        border-spacing: 1px;
    }

    #Scoreboard_cols col { width: auto; }

    /* One name column: the surname copy inside the name cell takes over and
     * the whole name wraps onto a second line rather than being cut off. */
    #Scoreboard_cols col.l_name,
    #Scoreboard_head tr th.l_name,
    #Scoreboard_body tr td.l_name { display: none; }

    #Scoreboard_head .wide { display: none; }
    #Scoreboard_head .narrow { display: inline; }

    #Scoreboard_head tr th {
        white-space: normal;
        text-overflow: clip;
        padding: 2px 3px;
        line-height: 1.15em;
    }

    #Scoreboard_body tr { height: auto; }

    #Scoreboard_body tr td.f_name {
        white-space: normal;
        text-overflow: clip;
        padding: 3px 4px;
        line-height: 1.2em;
    }

    .who { gap: 6px; }
    .who .nm { overflow: visible; text-overflow: clip; }
    .who .ln { display: inline; }

    /* Keep the numbers readable; the name column gets whatever is left. */
    #Scoreboard_body tr td.score,
    #Scoreboard_head tr th.score { min-width: 34px; }
    #Scoreboard_body tr td.rank { min-width: 20px; }
    #Scoreboard_body tr td.team img { max-width: 30px; max-height: 20px; }

    #RoundTabs {
        position: static;
        transform: none;
        height: auto;
        justify-content: center;
        padding: 6px 0 0;
    }
    #UserDetail_head { flex-direction: column; text-align: center; }
}

/* Between the two: the centred tab strip would run into the contest title. */
@media (min-width: 901px) and (max-width: 1200px) {
    #RoundTabs { left: auto; right: 190px; transform: none; }
}
