#theme-modal { padding: 12px 12px 74px !important; }
#theme-modal .theme-window {
    width: min(440px, calc(100vw - 24px));
    max-height: calc(100dvh - 96px) !important;
    overflow-y: auto;
    overscroll-behavior: contain;
    text-align: left;
}
#theme-modal, #theme-modal * { touch-action: pan-y !important; }
#theme-modal h2 { margin: 0 0 8px; }
#theme-modal p { color: #aab5c8; line-height: 1.5; }
#theme-options { display: grid; gap: 8px; margin: 16px 0; }
.theme-option {
    display: flex; align-items: center; gap: 12px; width: 100%; min-height: 60px;
    padding: 10px; border: 1px solid #ffffff20; border-radius: 10px;
    background: #ffffff06; color: #f1f5f9; text-align: left; cursor: pointer;
}
.theme-option[aria-pressed="true"] { border-color: var(--accent-color); background: #ffffff10; }
.theme-option:disabled { opacity: .5; cursor: default; }
.theme-option strong { display: block; font-size: 13px; }
.theme-option small { display: block; font-size: 11px; color: #aab5c8; margin-top: 4px; }
.theme-swatch { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; border: 1px solid #ffffff30; }
.theme-status { margin-left: auto; font-size: 10px; }
#theme-close { width: 100%; min-height: 44px; }
#theme-modal button:focus-visible { outline: 2px solid var(--accent-color) !important; outline-offset: 2px; }

/* Compact layouts: change real dimensions so card placement and HUD collision
   detection continue to use the same geometry the player sees. */
@media (max-width: 768px), (max-height: 600px) and (max-width: 1024px) {
    :root {
        --card-width: 88px;
        --card-height: 123px;
        --rewards-header-height: calc(52px + env(safe-area-inset-top, 0px));
    }

    #rewards-dock {
        gap: 6px;
        padding-top: calc(4px + env(safe-area-inset-top, 0px));
        padding-bottom: 4px;
    }
    #playtime-gift-button { width: 132px; }
    #daily-goals-button { padding: 6px 10px; }

    #top-hud { padding: 10px 64px 8px 10px !important; gap: 3px !important; }
    #hud-money { padding: 5px 8px; }
    #hud-money #cash-display { font-size: 24px; margin: 0; }
    #hud-money #combo-meter { margin-top: 4px; }
    #hud-money #relic-tray { margin-top: 4px; gap: 4px; }
    #hud-missions { margin-top: 0 !important; }
    #mission-card { padding: 5px 8px !important; }
    #mission-card > div:first-child { margin-bottom: 2px !important; }
    #mission-card .progress-track { height: 4px; margin-top: 4px; }

    body #game-board ~ #right-panel #game-controls {
        top: 8px !important;
        left: -80px !important;
        width: 48px !important;
        gap: 5px !important;
    }
    #game-controls .icon-btn { width: 48px !important; height: 48px !important; }
    #game-controls .sprite-icon { --size: 34px !important; }

    #right-panel .panel-header { padding: 10px 12px; }
    #right-panel .panel-content { padding: 10px; gap: 10px; }
    #market-tabs { padding-bottom: 8px; margin-bottom: 6px; gap: 4px; }
    #sponsors-list { padding: 5px; gap: 5px; }
    .sponsor-card { padding: 4px 6px; }

    .modal-content:not(.rewards-window) { padding: 16px !important; }
    .modal-content:not(.rewards-window) > h2 { font-size: 1.2rem !important; white-space: normal !important; }
    .modal-content:not(.rewards-window) > p { font-size: .8rem !important; margin-bottom: 14px !important; }
    .rewards-header { padding: 14px; }
    #rewards-modal .rewards-header h2 { font-size: 20px; }
    #rewards-scroll { padding: 12px; }
    .reward-section-heading { margin-bottom: 12px; }
    .gift-stop { padding: 9px 8px; gap: 8px; }
    .quest-card { padding: 10px 8px; }
    .daily-finish { padding: 12px 10px; margin-bottom: 12px; }
    .milestone-card { padding: 10px; }
    .rewards-footer { padding: 9px 12px; }
}

@media (max-width: 430px) {
    :root { --card-width: 80px; --card-height: 112px; }
    #hud-money { display: grid; grid-template-columns: auto auto; column-gap: 8px; }
    #hud-money > div:first-child, #cash-display { grid-column: 1 / -1; }
    #hud-money #combo-meter { font-size: 10px; align-self: center; }
    #hud-money #relic-tray { justify-content: flex-end; }
}

@media (max-height: 480px) and (max-width: 1024px) {
    :root { --card-width: 72px; --card-height: 101px; }
    /* Keep the existing short-screen rail scale and modal scrolling. */
    .modal-content:not(.rewards-window) { padding: 12px !important; }
    .rewards-header { padding: 10px 14px; }
    #rewards-scroll { padding: 10px 12px; }
}
