
/* ===============================================
   Stage Selection Screen Styles
   =============================================== */
.stage-selection-screen {
    display: flex;
    flex-direction: column;
    padding: 0;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

.stage-selection-screen .screen-title-bar {
    padding: 10px 20px 0px 20px;
    background: transparent;
    border-bottom: none;
}

.stage-selection-screen .screen-scroll-content {
    padding: 0px 20px 20px 20px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.stage-selection-screen .stages-grid {
    margin: auto 0;
    min-height: 0;
}

/* Remove auto margin in portrait to allow proper vertical scrolling */
@media (max-width: 768px) and (orientation: portrait) {
    .stage-selection-screen .stages-grid {
        margin: 0;
    }
}

.stage-selection-screen.hidden {
    display: none;
}

/* Generic reusable gradient background layer */
.gradient-bg-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--overlay-bg);
    z-index: 0;
    pointer-events: none;
}

/* Base gradient layer (Light theme) */
.gradient-bg-layer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at top left, rgba(60, 80, 180, 0.7) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(220, 60, 60, 0.7) 0%, transparent 50%);
    background-size: 150% 150%;
    animation: gradientMove1 12s ease-in-out infinite;
    z-index: 0;
    pointer-events: none;
}

[data-theme="dark"] .gradient-bg-layer::before {
    background: 
        radial-gradient(ellipse at top left, rgba(120, 150, 255, 0.5) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(255, 120, 120, 0.5) 0%, transparent 50%);
    background-size: 150% 150%;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .gradient-bg-layer::before {
        background: 
            radial-gradient(ellipse at top left, rgba(120, 150, 255, 0.5) 0%, transparent 50%),
            radial-gradient(ellipse at bottom right, rgba(255, 120, 120, 0.5) 0%, transparent 50%);
        background-size: 150% 150%;
    }
}

/* Second gradient layer with different timing (Light theme) */
.gradient-bg-layer::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at bottom left, rgba(200, 80, 120, 0.65) 0%, transparent 40%),
        radial-gradient(circle at top right, rgba(50, 150, 220, 0.65) 0%, transparent 40%);
    background-size: 180% 180%;
    animation: gradientMove2 18s ease-in-out 2s infinite;
    z-index: 0;
    pointer-events: none;
}

[data-theme="dark"] .gradient-bg-layer::after {
    background: 
        radial-gradient(circle at bottom left, rgba(255, 150, 200, 0.45) 0%, transparent 40%),
        radial-gradient(circle at top right, rgba(100, 200, 255, 0.45) 0%, transparent 40%);
    background-size: 180% 180%;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .gradient-bg-layer::after {
        background: 
            radial-gradient(circle at bottom left, rgba(255, 150, 200, 0.45) 0%, transparent 40%),
            radial-gradient(circle at top right, rgba(100, 200, 255, 0.45) 0%, transparent 40%);
        background-size: 180% 180%;
    }
}

.stage-selection-screen .back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.15);
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.stage-selection-screen .back-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.stage-selection-screen .back-btn svg {
    width: 24px;
    height: 24px;
}

[data-theme="light"] .stage-selection-screen .back-btn {
    background: rgba(51, 51, 51, 0.1);
    border-color: rgba(51, 51, 51, 0.3);
}

[data-theme="light"] .stage-selection-screen .back-btn:hover {
    background: rgba(51, 51, 51, 0.15);
}

.stage-selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.stage-selection-screen .header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0;
    flex-shrink: 0;
    position: relative;
    background: none; /* No background - show gradient from screen */
}

.stage-selection-screen .screen-title-bar .screen-title {
    font-size: 2.5em;
    margin: 0;
    flex: 1;
    text-align: center;
}

.stage-stats-footer {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
    position: relative;
}

.stat-item {
    background: var(--container-bg);
    border-radius: 10px;
    padding: 8px 15px;
    text-align: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    min-width: 110px;
}

.stat-label {
    font-size: 0.75em;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.3em;
    font-weight: bold;
    color: var(--text-color);
}

.stages-grid {
    display: flex;
    gap: 20px;
    padding: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x center;
    scrollbar-width: none;
    -ms-overflow-style: none;
    flex: 1;
    align-items: center;
    position: relative;
}

.stages-grid::-webkit-scrollbar {
    display: none;
}

.stage-tile {
    background: var(--container-bg);
    border-radius: 15px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    height: 180px;
    width: 240px;
    min-width: 240px;
    max-width: 240px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    scroll-snap-align: center;
    box-sizing: border-box;
}

.stage-tile:hover:not(.locked) {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.2);
}

.stage-tile.locked {
    background: rgba(100, 100, 110, 0.9);
    border-color: rgba(120, 120, 130, 0.8);
    color: rgba(180, 180, 190, 1);
    cursor: not-allowed;
}

[data-theme="dark"] .stage-tile.locked {
    background: rgba(60, 60, 70, 0.9);
    border-color: rgba(80, 80, 90, 0.8);
    color: rgba(140, 140, 150, 1);
}

[data-theme="light"] .stage-tile.locked {
    background: rgba(200, 200, 210, 0.9);
    border-color: rgba(180, 180, 190, 0.8);
    color: rgba(100, 100, 110, 1);
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .stage-tile.locked {
        background: rgba(60, 60, 70, 0.9);
        border-color: rgba(80, 80, 90, 0.8);
        color: rgba(140, 140, 150, 1);
    }
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .stage-tile.locked {
        background: rgba(200, 200, 210, 0.9);
        border-color: rgba(180, 180, 190, 0.8);
        color: rgba(100, 100, 110, 1);
    }
}

.stage-tile.completed {
    border: 2px solid #4caf50;
}

.lock-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.stage-number {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stage-name {
    font-size: 1.5em;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    width: 100%;
    max-height: 3.6em;
    line-height: 1.3em;
    overflow: hidden;
    overflow-y: auto;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    word-wrap: break-word;
    word-break: break-word;
    scrollbar-width: thin;
    scrollbar-color: var(--text-secondary) transparent;
}

.stage-name::-webkit-scrollbar {
    width: 4px;
}

.stage-name::-webkit-scrollbar-track {
    background: transparent;
}

.stage-name::-webkit-scrollbar-thumb {
    background: var(--text-secondary);
    border-radius: 2px;
}

.stage-score {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-top: 10px;
}

.stage-reaction {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-top: 5px;
}

.stage-hit-ratio {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-top: 5px;
}

.checkmark {
    position: absolute;
    top: 10px;
    right: 10px;
    color: #4caf50;
    font-size: 1.5em;
    font-weight: bold;
}

/* ===============================================
   Stage Preview Modal Styles
   =============================================== */
.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s ease;
    z-index: 1000; /* Above all screen content, modal stacking handled by DOM order */
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.stage-preview-modal {
    background: var(--container-bg);
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.stage-preview-header h3 {
    font-size: 1.8em;
    color: var(--text-color);
    margin-bottom: 20px;
    text-align: center;
}

.stage-preview-content {
    color: var(--text-color);
}

.stage-description {
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 25px;
    color: var(--text-secondary);
    text-align: center;
}

.stage-mechanics,
.stage-objectives {
    margin-bottom: 25px;
}

.stage-mechanics h4,
.stage-objectives h4 {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: var(--text-color);
}

.circle-types-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.circle-type-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: var(--game-area-bg);
    border-radius: 10px;
}

.circle-icon {
    font-size: 2em;
}

.circle-type-details {
    flex: 1;
}

.circle-type-label {
    font-weight: 600;
    font-size: 1.1em;
    margin-bottom: 5px;
    color: var(--text-color);
}

.circle-type-desc {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.stage-objectives ul {
    list-style: none;
    padding-left: 0;
}

.stage-objectives li {
    padding: 10px;
    background: var(--game-area-bg);
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 1em;
    color: var(--text-secondary);
}

.stage-objectives li strong {
    color: var(--text-color);
}

.stage-preview-actions {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    justify-content: center;
}

.btn {
    padding: 12px 30px;
    font-size: 1.1em;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled,
.btn-primary[disabled] {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.btn-primary:disabled:hover,
.btn-primary[disabled]:hover {
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-color);
}

.btn-secondary:hover {
    background: var(--outline-color);
}

/* Responsive adjustments for stages */
@media (max-width: 768px) and (orientation: portrait) {
    .stages-grid {
        flex-direction: column;
        overflow-y: auto;
        overflow-x: hidden;
        gap: 15px;
        padding: 10px 20px;
        scroll-snap-type: y proximity;
        align-items: stretch;
    }
    
    .stage-tile {
        height: 160px;
        width: 100%;
        min-width: unset;
        max-width: unset;
        padding: 15px;
        scroll-snap-align: start;
    }
}

@media (max-width: 768px) and (orientation: landscape) {
    .stages-grid {
        gap: 15px;
        padding: 10px 5px;
    }
    
    .stage-tile {
        height: 160px;
        width: 200px;
        min-width: 200px;
        max-width: 200px;
        padding: 15px;
    }
}
    
    .stage-name {
        font-size: 1em;
        max-height: 2.6em;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    .stat-item {
        min-width: 90px;
        padding: 6px 12px;
    }
    
    .stat-value {
        font-size: 1.1em;
    }
    
    .stage-preview-modal {
        padding: 20px;
        width: 95%;
    }
    
    .stage-preview-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
}

