/* Phase A — tablet-first play layout */

.game-container--playing {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    padding: 0 !important;
    margin: 0;
    overflow: hidden;
    box-sizing: border-box;
}

.game-container--idle {
    padding: 12px 16px;
    max-height: 100vh;
    overflow-y: auto;
}

.game-idle-screen {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: min(100%, 100vh);
}

.game-idle-screen .start-screen {
    min-height: unset;
    max-height: none;
    overflow: visible;
    padding: 24px 16px;
    width: 100%;
    max-width: 420px;
}

.game-container--idle .start-screen h2 {
    margin-bottom: 16px;
    font-size: 1.75rem;
}

.game-container--idle .scoreboard {
    overflow: visible;
    max-height: none;
    padding: 16px;
    margin: 16px 0;
}

.game-container--idle .scoreboard h3 {
    margin: 0 0 12px;
    font-size: 1.15rem;
}

.game-container--idle .scoreboard-content {
    gap: 8px;
}

.game-container--idle .scoreboard-item {
    padding: 10px 14px;
    flex-direction: row;
    align-items: center;
}

.game-container--idle .start-screen-actions {
    margin-top: 8px;
    gap: 10px;
}

@media screen and (max-width: 900px) and (orientation: landscape) {
    .game-container--idle {
        padding: 8px 12px;
    }

    .game-idle-screen .start-screen {
        padding: 12px 10px;
    }

    .game-container--idle .start-screen h2 {
        margin-bottom: 8px;
        font-size: 1.35rem;
    }

    .game-container--idle .whats-next {
        margin-bottom: 8px;
        padding: 8px 10px;
        font-size: 0.9rem;
    }

    .game-container--idle .scoreboard {
        padding: 10px 12px;
        margin: 8px 0;
    }

    .game-container--idle .scoreboard h3 {
        margin-bottom: 8px;
        font-size: 1rem;
    }

    .game-container--idle .scoreboard-item {
        padding: 6px 10px;
    }

    .game-container--idle .scoreboard-label,
    .game-container--idle .scoreboard-value {
        font-size: 0.9rem;
    }

    .game-container--idle .start-screen-actions .btn {
        padding: 8px 16px;
    }
}

.whats-next {
    font-size: 1.05rem;
    color: #1b6ec2;
    font-weight: 600;
    margin: 0 0 16px;
    padding: 10px 14px;
    background: #e8f4fd;
    border-radius: 8px;
    line-height: 1.4;
}

/* Top HUD bar */
.game-top-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 12px;
    padding: 6px 10px;
    background: linear-gradient(180deg, #f8f9fa 0%, #eef1f4 100%);
    border-bottom: 1px solid #dee2e6;
    flex-shrink: 0;
    z-index: 10;
}

.game-top-bar-primary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    flex: 1;
    min-width: 0;
}

.game-top-bar-secondary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    flex: 1 1 100%;
    order: 3;
}

@media (min-width: 640px) {
    .game-top-bar-secondary {
        flex: 1;
        order: unset;
    }
}

.game-top-bar-actions {
    flex-shrink: 0;
    margin-left: auto;
}

.game-top-stars {
    font-size: 1rem;
    letter-spacing: 1px;
}

.game-top-stat {
    font-size: 0.9rem;
    color: #444;
    white-space: nowrap;
}

.game-top-stat strong {
    color: #1b6ec2;
    font-size: 1.05em;
}

.game-top-stat--timer {
    font-weight: 700;
    color: #c0392b;
}

.game-top-stat--timer strong {
    color: #c0392b;
}

.game-top-meta {
    font-size: 0.8rem;
    color: #666;
}

.game-top-goal {
    font-size: 0.8rem;
    color: #1b6ec2;
    font-weight: 600;
}

/* Play area: stave + keyboard stack; ladder on wide screens */
.game-play-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.game-play-main {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
}

.game-stave-panel {
    flex: 1 1 45%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    overflow: hidden;
}

.game-stave-panel .stave-feedback-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    height: 100%;
}

.game-stave-panel #music-output {
    flex: 1;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
}

.game-stave-panel #music-output svg {
    max-width: 100%;
    max-height: 100%;
    height: auto;
}

.game-stave-panel .feedback-indicator-container {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}

.game-stave-panel .feedback-indicator {
    width: 56px;
    height: 56px;
}

.game-stave-panel .feedback-symbol {
    font-size: 36px;
}

.game-keyboard-panel {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 4px 8px 8px;
    overflow-x: auto;
    overflow-y: hidden;
}

.game-keyboard-panel .keyboard {
    margin: 0 auto;
    transform-origin: bottom center;
}

/* Streak ladder — hidden on narrow / landscape phones */
.game-ladder-panel {
    display: none;
    flex-shrink: 0;
    width: 100px;
    padding: 4px;
    overflow: hidden;
    border-left: 1px solid #eee;
}

.game-ladder-panel .streak-ladder-container {
    padding: 0;
    gap: 4px;
    height: 100%;
}

.game-ladder-panel .ladder-wrapper {
    width: 88px;
    height: 100%;
    max-height: 100%;
    padding: 4px;
}

.game-ladder-panel .streak-text {
    display: none;
}

/* Phone landscape — primary target */
@media screen and (max-width: 900px) and (orientation: landscape) {
    .game-container--playing {
        padding: 0;
    }

    .game-top-bar {
        padding: 4px 8px;
        gap: 4px 8px;
    }

    .game-top-stat {
        font-size: 0.85rem;
    }

    .game-top-bar-actions .btn {
        padding: 4px 10px;
        font-size: 0.8rem;
    }

    .game-stave-panel {
        flex: 1 1 42%;
        padding: 2px 6px;
    }

    .game-stave-panel .feedback-indicator-container,
    .game-stave-panel .feedback-indicator {
        width: 44px;
        height: 44px;
    }

    .game-stave-panel .feedback-symbol {
        font-size: 28px;
    }

    .game-keyboard-panel {
        padding: 2px 4px 4px;
    }

    .game-keyboard-panel .keyboard {
        height: 9em;
        margin: 0;
    }

    .game-keyboard-panel .keyboard-two-octaves {
        transform: scale(0.88);
    }

    .game-ladder-panel {
        display: none;
    }
}

/* Portrait phones — scale keyboard down */
@media screen and (max-width: 600px) and (orientation: portrait) {
    .game-keyboard-panel .keyboard {
        transform: scale(0.92);
    }

    .game-keyboard-panel .keyboard-two-octaves {
        transform: scale(0.78);
    }
}

/* Desktop / large tablet — show compact ladder */
@media (min-width: 901px) {
    .game-ladder-panel {
        display: flex;
        flex-direction: column;
        width: 120px;
    }

    .game-top-bar-secondary {
        flex: 0 1 auto;
        order: unset;
    }
}

/* Main layout: reduce padding during play */
.page main .content:has(.game-container--playing) {
    padding-left: 0 !important;
    padding-right: 0 !important;
    padding-top: 0 !important;
}

.game-container--playing .audio-banner {
    top: auto;
    bottom: 8px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}
