/* Which Is Bigger? — Score Popup — Version 0.2.18 Alpha */

#game-board {
    position: relative;
}

#score-popup {
    --score-popup-y-translate:-50%;
    position: absolute;
    left: 50%;
    top: calc(var(--card-size) / 2);
    transform: translate(-50%, var(--score-popup-y-translate));
    width: clamp(210px, 20vw, 280px);
    padding: 14px 16px 12px;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 16px;
    background: rgba(15, 23, 42, .96);
    box-shadow: 0 16px 36px rgba(0, 0, 0, .42);
    z-index: 5;
}

#score-popup[hidden] {
    display: none;
}

.score-popup-title {
    margin: 0 0 9px;
    text-align: center;
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--color-success);
}

.score-popup-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 4px 0;
    font-size: clamp(.76rem, 1.3vw, .92rem);
    line-height: 1.15;
}

.score-popup-row span:first-child {
    color: var(--map-ink);
}

.score-popup-row strong {
    color: var(--map-ink);
    font-weight: 900;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.score-popup-total {
    margin-top: 7px;
    padding-top: 9px;
    border-top: 1px solid rgba(7, 60, 109, .32);
    font-size: clamp(.9rem, 1.6vw, 1.08rem);
}

.score-popup-total strong {
    color: var(--map-red);
    font-size: 1.18em;
}

#score-popup-next {
    display: block;
    width: 100%;
    margin-top: 12px;
    padding: 9px 14px;
    border-radius: 10px;
    font-size: .9rem;
}

.score-popup-show {
    animation: scorePopupIn .18s ease-out;
}

@keyframes scorePopupIn {
    from {
        opacity: 0;
        transform: translate(-50%, var(--score-popup-y-translate)) scale(.94);
    }
    to {
        opacity: 1;
        transform: translate(-50%, var(--score-popup-y-translate)) scale(1);
    }
}

@media (max-width: 700px) {
    #score-popup {
        top: calc(var(--card-size) / 2 - 12px);
        width: clamp(176px, 45vw, 220px);
        padding: 10px 11px 9px;
        border-radius: 12px;
    }

    .score-popup-title {
        margin-bottom: 6px;
        font-size: .62rem;
    }

    .score-popup-row {
        gap: 7px;
        padding: 3px 0;
        font-size: clamp(.62rem, 2.5vw, .76rem);
    }

    .score-popup-total {
        margin-top: 5px;
        padding-top: 6px;
    }

    #score-popup-next {
        margin-top: 8px;
        padding: 7px 10px;
        font-size: .76rem;
    }
}

/* Keep the decorative BWSQ artwork behind every interactive mobile element,
   including the score popup, while still leaving it above the map background. */
@media (max-width: 900px) {
    html:not(.desktop-canvas-mode) #app {
        isolation: isolate!important;
    }
    html:not(.desktop-canvas-mode) #app #mobile-tagline {
        z-index: 0!important;
    }
    html:not(.desktop-canvas-mode) #app > :not(#mobile-tagline) {
        position: relative;
        z-index: 1;
    }
    html:not(.desktop-canvas-mode) #game-board #score-popup {
        z-index: 50!important;
    }
}

/* Very short phones do not have enough vertical room for the normal stacked
   popup. Reflow the same content into a compact two-column panel without
   shrinking the text. Taller mobile layouts keep the normal popup unchanged. */
@media (max-width: 430px) and (max-height: 700px) {
    html:not(.desktop-canvas-mode) #game-board #score-popup:not([hidden]) {
        display: grid!important;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr)!important;
        grid-template-rows: repeat(3, auto)!important;
        column-gap: 18px!important;
        row-gap: 0!important;
        width: calc(100vw - 28px)!important;
        max-width: 360px!important;
        padding: 8px 12px!important;
        border-radius: 12px!important;
    }

    html:not(.desktop-canvas-mode) #game-board #score-popup::before {
        content: "";
        position: absolute;
        top: 8px;
        bottom: 8px;
        left: 50%;
        width: 1px;
        background: rgba(20,70,100,.22)!important;
        transform: translateX(-.5px);
        pointer-events: none;
    }

    html:not(.desktop-canvas-mode) #score-popup .score-popup-row {
        min-width: 0!important;
        gap: 6px!important;
        padding: 3px 0!important;
        font-size: clamp(.62rem, 2.5vw, .76rem)!important;
    }

    html:not(.desktop-canvas-mode) #score-popup .score-popup-row:nth-child(1) {
        grid-column: 1!important;
        grid-row: 1!important;
        padding-right: 4px!important;
    }
    html:not(.desktop-canvas-mode) #score-popup .score-popup-row:nth-child(2) {
        grid-column: 1!important;
        grid-row: 2!important;
        padding-right: 4px!important;
    }
    html:not(.desktop-canvas-mode) #score-popup .score-popup-row:nth-child(3) {
        grid-column: 1!important;
        grid-row: 3!important;
        padding-right: 4px!important;
    }
    html:not(.desktop-canvas-mode) #score-popup .score-popup-row:nth-child(4) {
        grid-column: 2!important;
        grid-row: 1!important;
        margin: 0!important;
        padding: 3px 0 3px 4px!important;
        border-top: 0!important;
        font-size: clamp(.62rem, 2.5vw,.76rem)!important;
    }
    html:not(.desktop-canvas-mode) #score-popup .score-popup-row:nth-child(5) {
        grid-column: 2!important;
        grid-row: 2!important;
        padding-left: 4px!important;
    }

    html:not(.desktop-canvas-mode) #score-popup #score-popup-next {
        grid-column: 2!important;
        grid-row: 3!important;
        align-self: center!important;
        width: calc(100% - 4px)!important;
        margin: 2px 0 0 4px!important;
        padding: 7px 10px!important;
        font-size: .76rem!important;
    }
}

/* v0.2.21 reveal/answer emphasis. Outlines do not affect layout geometry. */
#game-board .city-card .population {
    outline: 1px solid var(--color-warning)!important;
    outline-offset: 0!important;
    text-shadow: 0 0 16px rgba(251, 191, 36, .45)!important;
}

#game-board .city-card.correct-card .place-label {
    outline: 3px solid var(--color-success)!important;
    outline-offset: 0!important;
}

#game-board .city-card.incorrect-card .place-label {
    outline: 3px solid var(--color-danger)!important;
    outline-offset: 0!important;
}

/* On an incorrect choice, suppress every green correct-place treatment so only
   the selected wrong card receives red feedback. */
#game-board:has(.city-card.incorrect-card) .city-card.correct-card {
    border-color: transparent!important;
    box-shadow: none!important;
}
#game-board:has(.city-card.incorrect-card) .city-card.correct-card .city-image-frame {
    border-color: #fff!important;
    box-shadow: 0 4px 10px rgba(44,40,30,.4)!important;
}
#game-board:has(.city-card.incorrect-card) .city-card.correct-card .place-label {
    outline: 0!important;
}

/* Keep desktop population boxes above the green/red image-ring glow. Mobile
   reveal positioning has its own higher-specificity/inline stacking rules. */
@media (min-width: 901px) {
    #game-board .city-card .population {
        position: relative!important;
        z-index: 6!important;
    }
}
html.desktop-canvas-mode #game-board .city-card .population {
    position: relative!important;
    z-index: 6!important;
}

/* Mobile mockup sizing: tighten only the visible controls while preserving the
   desktop canvas and the surrounding mobile layout. */
@media (max-width: 900px) {
    html:not(.desktop-canvas-mode) #difficulty-control {
        width: 64%!important;
        margin-left: auto!important;
        margin-right: auto!important;
    }
    html:not(.desktop-canvas-mode) #difficulty-button,
    html:not(.desktop-canvas-mode) #difficulty-menu {
        width: 100%!important;
        max-width: 100%!important;
    }
    html:not(.desktop-canvas-mode) #start-game-button,
    html:not(.desktop-canvas-mode) #round-timer {
        width: 72.25%!important;
        margin-left: auto!important;
        margin-right: auto!important;
    }

    /* The mobile scoreboard separators keep their existing size/color/weight,
       but remove inherited corner rounding so each divider is perfectly straight. */
    html:not(.desktop-canvas-mode) #top-stats .stat-card {
        border-radius: 0!important;
    }
}

/* Desktop scoreboard typography and dividers. The separator is drawn as a
   translated pseudo-element rather than the card border so it sits halfway
   between the current value and the following stat label. */
@media (min-width: 901px) {
    html:not(.desktop-canvas-mode) #top-stats {
        padding-top: 5px!important;
        padding-bottom: 5px!important;
    }
    html:not(.desktop-canvas-mode) #top-stats .stat-card {
        position: relative!important;
        padding-top: 0!important;
        padding-bottom: 0!important;
        text-align: center!important;
        border-bottom: 0!important;
        border-radius: 0!important;
    }
    html:not(.desktop-canvas-mode) #top-stats .stat-card:not(:last-child)::after {
        content: ""!important;
        position: absolute!important;
        left: 0!important;
        right: 0!important;
        bottom: -5px!important;
        height: 1px!important;
        background: rgba(20,70,100,.22)!important;
        border-radius: 0!important;
        pointer-events: none!important;
    }
    html:not(.desktop-canvas-mode) #top-stats .stat-label {
        font-size: 14.28px!important;
        font-weight: 400!important;
        text-align: center!important;
        margin-bottom: 5.2px!important;
    }
    html:not(.desktop-canvas-mode) #top-stats .stat-value {
        font-size: 28.98px!important;
        text-align: center!important;
    }
}
html.desktop-canvas-mode #top-stats {
    padding-top: 5px!important;
    padding-bottom: 5px!important;
}
html.desktop-canvas-mode #top-stats .stat-card {
    position: relative!important;
    padding-top: 0!important;
    padding-bottom: 0!important;
    text-align: center!important;
    border-bottom: 0!important;
    border-radius: 0!important;
}
html.desktop-canvas-mode #top-stats .stat-card:not(:last-child)::after {
    content: ""!important;
    position: absolute!important;
    left: 0!important;
    right: 0!important;
    bottom: -5px!important;
    height: 1px!important;
    background: rgba(20,70,100,.22)!important;
    border-radius: 0!important;
    pointer-events: none!important;
}
html.desktop-canvas-mode #top-stats .stat-label {
    font-size: 14.28px!important;
    font-weight: 400!important;
    text-align: center!important;
    margin-bottom: 5.2px!important;
}
html.desktop-canvas-mode #top-stats .stat-value {
    font-size: 28.98px!important;
    text-align: center!important;
}
