/* ========================================
   STAGE MODE UI - Week 3
   ======================================== */

/* Menu Stars Display */
.menu-stars {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 215, 0, 0.2);
    background: rgba(0, 0, 0, 0.25);
    color: #fff;
    letter-spacing: 1px;
}

.menu-stars .star-icon {
    font-size: 14px;
}

.menu-stars .stars-value {
    font-size: 14px;
    font-weight: 700;
    color: #ffd700;
}

.menu-stars .stars-max {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
}

/* Stage Mode Button */
.btn-stage-mode {
    border-color: #ffd700;
    color: #1a0e00;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.95), rgba(255, 195, 0, 0.8));
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.35);
    margin-bottom: 18px;
}

.btn-stage-mode:hover {
    background: #ffd700;
    color: #000;
    box-shadow: 0 0 30px #ffd700, 0 0 60px #ffd700;
}

/* Overlay Base (shared by level-select, stage-info, results) */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 220;
    padding: calc(20px + var(--safe-area-inset-top)) calc(20px + var(--safe-area-inset-right)) calc(20px + var(--safe-area-inset-bottom)) calc(20px + var(--safe-area-inset-left));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.overlay.is-open {
    display: flex;
}

.overlay-panel {
    width: min(500px, 92vw);
    max-height: calc(90vh - var(--safe-area-inset-top) - var(--safe-area-inset-bottom));
    background: rgba(8, 2, 20, 0.95);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 20px;
    padding: 20px;
    box-shadow:
        0 0 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(0, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    gap: 0;
}

.overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.overlay-title {
    color: #fff;
    letter-spacing: 4px;
    font-size: 18px;
    text-transform: uppercase;
    text-shadow: 0 0 20px rgba(255, 0, 255, 0.4);
    font-weight: 600;
}

.back-btn {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-btn:hover {
    border-color: rgba(0, 255, 255, 0.6);
    color: #00ffff;
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.3);
}

.header-stars {
    color: #ffd700;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Level Select - Stage Path */
.level-select-panel {
    max-height: calc(85vh - var(--safe-area-inset-top) - var(--safe-area-inset-bottom));
}

.stage-path {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    row-gap: 24px;
    column-gap: 14px;
    justify-content: center;
    align-items: center;
    padding: 16px 12px 24px 12px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.stage-node {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.stage-node.unlocked {
    background: linear-gradient(135deg, rgba(0, 255, 100, 0.2) 0%, rgba(0, 200, 80, 0.3) 100%);
    border: 2px solid rgba(0, 255, 100, 0.6);
    box-shadow: 0 0 15px rgba(0, 255, 100, 0.3);
}

.stage-node.unlocked:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(0, 255, 100, 0.5);
}

.stage-node.locked {
    background: rgba(80, 80, 80, 0.3);
    border: 2px solid rgba(100, 100, 100, 0.5);
    cursor: not-allowed;
}

.stage-node.completed {
    background: linear-gradient(135deg, rgba(0, 255, 255, 0.2) 0%, rgba(0, 200, 200, 0.3) 100%);
    border-color: rgba(0, 255, 255, 0.6);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

.node-number {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 10px rgba(0, 255, 100, 0.5);
}

.node-stars {
    font-size: 10px;
    margin-top: 2px;
}

.node-lock {
    font-size: 20px;
    opacity: 0.6;
}

.stage-connector {
    /* Connector line between stage nodes */
    width: 32px;
    height: 4px;
    background: linear-gradient(90deg, rgba(0, 255, 255, 0.5) 0%, rgba(255, 0, 255, 0.5) 100%);
    border-radius: 2px;
    flex-shrink: 0;
    /* Ensure connectors don't wrap and stay centered vertically with nodes */
}

.locked-tooltip {
    display: none;
}

.stage-info-bar {
    padding: 12px 16px;
    margin-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 255, 100, 0.08) 100%);
    border-radius: 8px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
    flex-shrink: 0;
}

/* Stage Info Card */
.stage-info-card {
    text-align: center;
    max-width: 360px;
}

.stage-info-header {
    margin-bottom: 20px;
}

.stage-number {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(255, 0, 255, 0.3) 0%, rgba(200, 0, 200, 0.4) 100%);
    border: 2px solid rgba(255, 0, 255, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 24px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 0 15px #ff00ff;
}

.stage-name {
    font-size: 22px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 3px;
    text-shadow: 0 0 15px rgba(255, 0, 255, 0.5);
}

.stage-description {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.85);
    margin: 10px 0 0 0;
    line-height: 1.4;
    padding: 0 10px;
    font-style: italic;
    font-weight: 300;
    letter-spacing: 0.5px;
}

.stage-info-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 20px;
}

.stat-row {
    text-align: center;
}

.stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 18px;
    color: #00ffff;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.stage-star-goals {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}

.star-goal {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.star-goal:last-child {
    border-bottom: none;
}

.star-tier {
    font-size: 16px;
    min-width: 50px;
    text-align: left;
}

.star-requirement {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    text-align: left;
}

.stage-info-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.stage-info-buttons .btn {
    min-width: 120px;
    padding: 14px 30px;
}

/* Stage Mode HUD - Secondary HUD row REMOVED */
/* Hits counter is now in the main HUD alongside Distance and Orbs */

/* Results Screen */
.results-panel {
    text-align: center;
    max-width: 400px;
}

.results-header {
    margin-bottom: 25px;
}

.results-message {
    font-size: 28px;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 4px;
    margin-bottom: 15px;
    text-shadow: 0 0 20px rgba(255, 0, 255, 0.6);
}

.results-stars {
    font-size: 40px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.result-star {
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.8);
}

.result-star.empty {
    opacity: 0.3;
    text-shadow: none;
}

.results-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 20px;
}

.results-stat {
    text-align: center;
}

.results-stat .stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 4px;
}

.results-stat .stat-value {
    font-size: 20px;
    color: #00ffff;
    font-weight: 600;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
}

.results-tip {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    border-radius: 8px;
    padding: 10px 15px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #ffd700;
    display: none;
}

.results-tip.is-visible {
    display: block;
}

.results-progress {
    margin-bottom: 25px;
}

.progress-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 8px;
}

.results-progress-bar {
    width: 100%;
    max-width: 250px;
    margin: 0 auto 8px;
}

.progress-text {
    font-size: 16px;
    color: #ffd700;
    font-weight: 600;
}

.results-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.results-buttons .btn {
    min-width: 100px;
    padding: 12px 20px;
    font-size: 14px;
}

/* Mobile Responsive for Stage Mode UI */
@media (max-width: 768px) {
    .overlay {
        padding: var(--safe-area-inset-top) var(--safe-area-inset-right) var(--safe-area-inset-bottom) var(--safe-area-inset-left);
    }

    .overlay-panel {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        padding: 16px 16px 12px 16px;
    }

    .stage-info-bar {
        margin-top: 12px;
        padding: 10px 14px;
        min-height: 40px;
        font-size: 12px;
    }

    /* Tablet: Reduce stage node size but maintain visual balance */
    .stage-node {
        width: 52px;
        height: 52px;
    }

    .node-number {
        font-size: 16px;
    }

    .node-stars {
        font-size: 8px;
    }

    /* Proportionally scale connector lines for tablet */
    .stage-connector {
        width: 28px;
        height: 4px;
    }

    .stage-path {
        gap: 12px;
        row-gap: 20px;
        column-gap: 12px;
        padding: 14px 10px 20px 10px;
    }

    .results-message {
        font-size: 22px;
        letter-spacing: 2px;
    }

    .results-stars {
        font-size: 32px;
    }

    .results-buttons {
        flex-direction: column;
        align-items: center;
    }

    .results-buttons .btn {
        width: 100%;
        max-width: 250px;
    }
}

@media (max-width: 380px) {
    /* Small phones: Compact layout with improved spacing */
    .stage-node {
        width: 48px;
        height: 48px;
    }

    .node-number {
        font-size: 14px;
    }

    /* Small phone connector: Maintain visibility while conserving space */
    .stage-connector {
        width: 24px;
        height: 3px;
    }

    .stage-path {
        gap: 10px;
        row-gap: 18px;
        column-gap: 10px;
        padding: 12px 8px 18px 8px;
    }

    .stage-info-buttons {
        flex-direction: column;
    }

    .stage-info-buttons .btn {
        width: 100%;
    }
}

/* ========================================
   Tutorial Overlay System
   Priority 1: Enhanced Onboarding
   ======================================== */

/* Tutorial animations */
@keyframes tutorial-fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes tutorial-fade-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Tutorial step container */
.tutorial-step {
    z-index: 1000;
}

.tutorial-message {
    background: rgba(0, 0, 0, 0.65);  /* More transparent - was 0.85 */
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 12px;
    padding: 12px 20px;  /* Smaller padding for less screen space */
    box-shadow:
        0 0 30px rgba(0, 255, 255, 0.4),
        0 0 60px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    max-width: 500px;  /* Wider but thinner */
}

.tutorial-text {
    color: #fff;
    font-size: 16px;  /* Slightly smaller */
    line-height: 1.4;  /* Tighter line height */
    text-align: center;
    text-shadow:
        0 0 10px rgba(0, 255, 255, 0.6),
        0 1px 2px rgba(0, 0, 0, 0.8);  /* Better text contrast */
    letter-spacing: 0.5px;
    font-weight: 600;  /* Bolder for better readability */
}

/* Mobile adjustments for tutorial */
@media (max-width: 768px) {
    .tutorial-message {
        padding: 10px 16px;  /* Even more compact on mobile */
        max-width: 90vw;
        border-radius: 10px;
        background: rgba(0, 0, 0, 0.6);  /* Slightly more transparent on mobile */
    }

    .tutorial-text {
        font-size: 14px;  /* Smaller on mobile */
        line-height: 1.3;
    }
}

@media (max-width: 380px) {
    .tutorial-message {
        padding: 8px 14px;  /* Very compact on small phones */
        max-width: 92vw;
    }

    .tutorial-text {
        font-size: 13px;  /* Even smaller on small phones */
        line-height: 1.3;
    }
}
