/* css/mobile/stage_select.css */
#game-safe-area.mobile-viewport,
.mobile-viewport {
    width: 100%;
    height: 100dvh !important;
    position: relative;
    background: var(--bg-primary, #e0f7fa);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.anchor-ad {
    height: 50px;
    background: #ffffff;
    border-bottom: 1px solid #eee;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; color: #999;
    flex-shrink: 0;
    z-index: 2000;
}

/* --- Header --- */
.stage-header {
    height: 50px !important;
    background: #fff !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 0 16px !important;
    border: none !important;
    border-bottom: 1px solid rgba(0, 131, 143, 0.1) !important;
    margin-bottom: 0 !important;
    border-radius: 0 !important;
    backdrop-filter: none !important;
    text-align: left !important;
    flex-shrink: 0 !important;
    z-index: 1500 !important;
}
.stage-header .header-left { width: 30px; }
.stage-header .header-back { font-size: 1.1rem; color: #00838f; font-weight: 900; cursor: pointer; user-select: none; -webkit-user-select: none; }
.stage-header .header-title { font-family: 'Orbitron', sans-serif; font-size: 0.95rem; font-weight: 900; letter-spacing: 1px; color: #00838f; flex: 1; text-align: center; }
.stage-header .header-right { width: 30px; }

/* --- Difficulty Banner --- */
.stage-banner {
    background: #00838f;
    color: #fff;
    padding: 14px 20px;
    display: flex; align-items: center; justify-content: space-between;
    flex-shrink: 0;
}
.banner-info { display: flex; flex-direction: column; }
.banner-diff { font-family: 'Orbitron', sans-serif; font-size: 0.8rem; font-weight: 900; color: #00e5ff; }
.banner-title { font-size: 1.1rem; font-weight: 900; margin-top: 2px; }
.banner-progress { text-align: right; }
.progress-val { font-family: 'Orbitron', sans-serif; font-size: 1.2rem; font-weight: 900; display: block; }
.progress-label { font-size: 0.6rem; opacity: 0.8; }

/* Dynamic Banner Colors */
.stage-banner.diff-easy { background: #388e3c; }
.stage-banner.diff-easy .banner-diff { color: #b9f6ca; }

.stage-banner.diff-normal { background: #f57c00; }
.stage-banner.diff-normal .banner-diff { color: #ffe0b2; }

.stage-banner.diff-hard { background: #d32f2f; }
.stage-banner.diff-hard .banner-diff { color: #ffcdd2; }

/* --- Stage Grid Area --- */
.stage-grid-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
}

.stage-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.stage-item {
    aspect-ratio: 1;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    cursor: pointer;
    transition: all 0.2s;
}

/* --- Cleared State --- */
.stage-item.cleared {
    background: #00bcd4;
    border-color: #00bcd4;
    box-shadow: 0 4px 10px rgba(0, 188, 212, 0.2);
}
.stage-item.cleared .stage-num { color: #fff; }

.stage-num {
    font-family: 'Orbitron', sans-serif;
    font-size: 1.3rem;
    font-weight: 900;
    color: #455a64;
}

/* --- Legend Footer --- */
.stage-footer {
    padding: 16px;
    background: #fff;
    border-top: 1px solid #eee;
    display: flex; align-items: center; justify-content: center;
    gap: 20px;
    flex-shrink: 0;
}
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: #78909c; font-weight: 700; }
.legend-box { width: 14px; height: 14px; border-radius: 4px; }
.box-cleared { background: #00bcd4; }
.box-unplayed { background: #fff; border: 2px solid #e0e0e0; }

/* --- Mobile SPA Screen Layout --- */
#game-safe-area .screen,
.mobile-viewport .screen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    background: transparent;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out;
    z-index: 1;
}

#game-safe-area .screen.active,
.mobile-viewport .screen.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    z-index: 10;
}

#loading-screen,
#error-screen {
    align-items: center !important;
    justify-content: center !important;
    background: var(--bg-primary, #e0f7fa) !important;
}

#stage-screen {
    padding-top: 50px !important;
}
