/* Supporting UI: spend the screen on windows, keep the existing materials. */
/* Completion gives the restored window the space left by its real controls.
   No fixed height allowance: wrapped titles and sharing actions take precedence. */
:root body.solved-phase-2 #screen-game .restoration-frame {
    height: 100svh; min-height: 100svh;
    padding: max(24px, env(safe-area-inset-top)) 20px max(18px, env(safe-area-inset-bottom));
    gap: 4px; justify-content: center;
}
:root body.solved-phase-2 #screen-game .game-topbar {
    padding: 0 52px; max-width: 620px;
}
:root body.solved-phase-2 #screen-game #win-message { font-size: 1.25rem; line-height: 1.3; }
:root body.solved-phase-2 #screen-game #frame-instructions { margin-top: 4px; font-size: .8rem; line-height: 1.4; }
:root body.solved-phase-2 #screen-game #game-container.has-depth-reward {
    flex: 1 1 0; width: min(620px, 100%); height: auto; min-height: 140px;
    max-height: min(540px, calc(100vw - 40px)); max-width: 100%; left: 0; margin: 0;
    overflow: visible; border: 0; outline: none;
}
:root body.solved-phase-2 #screen-game .restoration-frame > #puzzle-title {
    margin: 0; font-size: 1.35rem; line-height: 1.3;
    max-width: 100%; flex-shrink: 0;
}
:root body.solved-phase-2 #screen-game .win-note { margin: 0; line-height: 1.5; flex-shrink: 0; }
:root body.solved-phase-2 #screen-game .win-actions { margin-top: 6px; gap: 8px; flex-shrink: 0; }
:root body.solved-phase-2 #screen-game .win-actions button { min-height: 44px; }

:root body #screen-game #tutorial-skip[hidden] { display: none; }
:root body #screen-commissions { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
:root body #screen-commissions .gallery-heading { margin-bottom: 12px; }
:root body #screen-commissions .gallery-toolbar { padding: 10px 12px; gap: 12px 20px; }
:root body #screen-commissions .daily-play-note:empty { display: none; }
:root body #screen-commissions .level-grid { padding-block: 14px; gap: 18px; }
:root body #screen-commissions .level-card-info { min-height: 0; padding: 10px 12px; gap: 4px; }
:root body #screen-commissions .level-card-title { min-height: 0; }
:root body #screen-commissions .level-card-meta { padding-top: 4px; }
:root body #screen-commissions .gallery-footer { gap: 2px; padding-top: 4px; }
/* Wide, short embeds use the existing navigation row for the title. */
@media (min-width: 601px) and (max-height: 760px) {
    :root body #screen-commissions .gallery-heading {
        position: absolute; top: max(14px, env(safe-area-inset-top));
        left: max(198px, calc(env(safe-area-inset-left) + 180px));
        right: max(78px, calc(env(safe-area-inset-right) + 62px));
        min-height: 44px; margin: 0; display: grid; place-items: center;
    }
    :root body #screen-commissions .gallery-heading h2 { font-size: 1.75rem; line-height: 1.2; margin: 0; }
    :root body #screen-commissions .level-thumb { height: clamp(100px, 23vh, 150px); aspect-ratio: auto; }
    :root body #screen-commissions .level-thumb-art { width: 88px; height: 88px; }
    :root body #screen-commissions .level-thumb-art.is-mystery { width: 78px; height: 78px; margin-block: 12px; border-width: 5px; }
}
@media (max-width: 600px) {
    :root body #screen-commissions .gallery-heading h2 { font-size: 1.75rem; margin: 0; }
    :root body #screen-commissions .level-grid { gap: 16px 12px; }
    :root body #screen-commissions .level-thumb { aspect-ratio: 1.35; }
    :root body #screen-commissions .level-thumb-art.is-mystery { width: 54%; margin-block: 16px 10px; }
}

/* Dense boards use smaller fixed clue slots, rather than wasting zoom space. */
:root body #screen-game #game-container.dense-board :is(.clue-row, .clue-col) {
    --clue-base-size: 16px;
    font-size: calc(12px * var(--board-clue-scale, 1)); gap: 1px;
}
:root body #screen-game #game-container.dense-board .clue-col {
    padding-block: 6px;
    font-size: clamp(10px, calc(var(--cell-size) * .68), calc(12px * var(--board-clue-scale, 1)));
}
:root body #screen-game #game-container.dense-board .clue-row {
    padding-inline: 6px;
    font-size: clamp(8px, calc(var(--cell-size) * .8), calc(12px * var(--board-clue-scale, 1)));
}
/* Five-square blocks aid counting without changing the artwork or targets. */
:root body:not(.solved-phase-1) #screen-game #game-container.dense-board {
    left: calc(-1 * var(--board-side-offset, 0px));
}
:root body:not(.solved-phase-1) #screen-game #game-container .cell.group-column { border-right: 2px solid #79613d !important; }
:root body:not(.solved-phase-1) #screen-game #game-container .cell.group-row { border-bottom: 2px solid #79613d !important; }
:root body #screen-game #game-container :is(.clue-row, .clue-col).clue-current {
    outline: 2px solid #8d632b; outline-offset: -2px;
}
@media (min-width: 720px) and (max-height: 430px) {
    :root body #screen-game:has(#game-container.dense-board:not(.is-enlarged)) #hint-guide {
        position: absolute; left: 48px; top: 100px; width: 150px;
        padding: 0 8px 0 0; text-align: left;
    }
    :root body #screen-game:has(#game-container.dense-board:not(.is-enlarged)) #hint-dismiss { top: -36px; right: 0; }
}
@media (min-width: 720px) and (max-width: 840px) and (max-height: 430px) {
    :root body #screen-game:has(#game-container.dense-board:not(.is-enlarged)) #hint-guide {
        left: 32px; width: 112px;
    }
}
/* In wide short views, use the existing side rail to return height to solving.
   The zoom control stays in Options as requested. */
@media (min-width: 720px) and (max-height: 760px) {
    :root body #screen-game:has(#game-container.dense-board) .board-tools {
        position: absolute; top: 96px; bottom: max(20px, env(safe-area-inset-bottom));
        right: max(24px, calc((100vw - 680px) / 2));
        margin: 0; gap: 10px; flex-direction: column;
    }
    :root body #screen-game:has(#game-container.dense-board) .mark-tools { flex-direction: column; }
}
