#main-container {
    display: flex;
    align-items: flex-start;
    width: 100vw;
    height: 100vh;
    background-color: #000;
}

#game-area {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    flex: 1;
}

#gameCanvas {
    display: none !important;
    background: radial-gradient(circle, #1a1a1a 0%, #000 100%);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.8);
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 400 / 800;
    object-fit: contain;
}

#control-panel {
    display: flex;
    width: 120px;
    height: 100%;
    background: #111;
    border-left: 1px solid #333;
    flex-direction: column;
    align-items: center;
    padding: 10px 5px;
    gap: 10px;
    overflow-y: auto;
    pointer-events: auto;
    z-index: 100;
}

.mobile-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-weight: 900;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
    touch-action: none;
    border: 4px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.1s, background 0.1s;
}

.mobile-btn:active {
    transform: scale(0.9);
}

#bomb-btn {
    background: linear-gradient(135deg, #f97316, #ea580c);
    box-shadow: 0 0 15px rgba(249, 115, 22, 0.4);
}

#power-btn {
    background: linear-gradient(135deg, #eab308, #ca8a04);
    box-shadow: 0 0 15px rgba(234, 179, 8, 0.4);
}

#power-btn.active {
    background: #fff;
    color: #ca8a04;
    box-shadow: 0 0 20px #fff;
    border-color: #ca8a04;
}

@media (max-width: 600px) {
    #control-panel {
        width: 90px;
    }

    .mobile-btn {
        width: 70px;
        height: 70px;
        font-size: 12px;
    }

    /* Reward Screen Mobile Adjustments */
    #result-screen {
        padding: 1rem !important;
        width: 95% !important;
        max-width: none !important;
    }

    #result-screen h2 {
        font-size: 1.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    #result-screen .flex.gap-8 {
        gap: 0.5rem !important;
        margin-top: 0.5rem !important;
        margin-bottom: 0.5rem !important;
    }

    #result-screen p {
        font-size: 0.6rem !important;
        margin-bottom: 0.5rem !important;
    }

    .reward-card {
        padding: 0.75rem !important;
        width: 130px !important;
    }

    .reward-icon {
        font-size: 1.5rem !important;
        margin-bottom: 0.4rem !important;
    }

    .reward-title {
        font-size: 0.75rem !important;
    }

    .reward-desc {
        font-size: 0.65rem !important;
    }
}

body {
    margin: 0;
    overflow: hidden;
    background-color: #111;
    font-family: 'Arial', sans-serif;
    touch-action: none;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    z-index: 50;
    /* Below control-panel but above canvas */
}

.btn {
    pointer-events: auto;
    background: linear-gradient(135deg, #e11d48, #be123c);
    padding: 0.6rem 2rem;
    border-radius: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 4px 0 #881337, 0 8px 15px rgba(225, 29, 72, 0.3);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 #881337, 0 12px 20px rgba(225, 29, 72, 0.4);
    filter: brightness(1.1);
}

.btn:active {
    transform: translateY(4px);
    box-shadow: 0 0 0 #881337;
}

.elite-alert {
    position: absolute;
    top: 20%;
    color: #ef4444;
    font-size: 2rem;
    font-weight: 900;
    text-shadow: 0 0 10px #000;
    animation: blink 0.5s infinite;
}

@keyframes blink {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.2;
    }

    100% {
        opacity: 1;
    }
}

#freeze-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(147, 197, 253, 0.1);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
    border: 0px solid rgba(191, 219, 254, 0.5);
}

.frozen-active #freeze-overlay {
    opacity: 1;
    border-width: 10px;
}

#bomb-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    pointer-events: none;
    opacity: 0;
}

/* Map Screen Styles */
#map-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    pointer-events: auto;
    padding: 20px;
}

#map-scroll-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

#map-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 60px;
    min-width: 300px;
    transform-origin: center;
    transition: transform 0.3s ease;
    isolation: isolate;
}


#map-lines-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

#map-nodes-layer {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#map-svg,
#map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    z-index: 1;
    pointer-events: none;
}

.map-line {
    stroke: #444;
    stroke-width: 3;
    stroke-dasharray: 8 4;
    fill: none;
    transition: stroke 0.3s, stroke-width 0.3s;
}

.map-line.available {
    stroke: #e11d48;
    stroke-width: 4;
    stroke-dasharray: none;
}

.map-line.cleared {
    stroke: #10b981;
    stroke-width: 3;
    stroke-dasharray: none;
}

.map-node {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #333;
    border: 4px solid #555;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    color: #888;
    cursor: not-allowed;
    position: relative;
    transition: all 0.2s;
    margin: 5px;
    z-index: 2;
}

.node-id {
    font-size: 1.2rem;
}

.node-modifier {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    white-space: nowrap;
    z-index: 5;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    line-height: 1;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.map-node.available {
    background: #e11d48;
    border-color: #ff4d6d;
    color: white;
    cursor: pointer;
    box-shadow: 0 0 15px #e11d48;
    animation: pulse-node 1.5s infinite;
}

.map-node.cleared {
    background: #10b981;
    border-color: #34d399;
    color: white;
    /* opacity: 0.7; Removed to hide lines behind */
}

.map-node.locked {
    /* opacity: 0.3; Removed to hide lines behind */
    background: #222;
    /* Darker background for locked */
    border-color: #444;
    /* Darker border */
    color: #555;
    /* Dimmer text */
}

@keyframes pulse-node {
    0% {
        transform: scale(1);
        box-shadow: 0 0 15px #e11d48;
    }

    50% {
        transform: scale(1.1);
        box-shadow: 0 0 25px #e11d48;
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 15px #e11d48;
    }
}

.map-row {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 15px 0;
    position: relative;
    z-index: 2;
}

/* Reward Screen Styles */
#reward-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    pointer-events: auto;
}

.reward-card {
    background: linear-gradient(135deg, rgba(31, 41, 55, 0.95), rgba(17, 24, 39, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1rem;
    padding: 1.5rem;
    width: 160px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.reward-card:hover {
    transform: translateY(-8px);
    border-color: #eab308;
    box-shadow: 0 10px 25px -5px rgba(234, 179, 8, 0.4);
    background: linear-gradient(135deg, rgba(55, 65, 81, 0.95), rgba(31, 41, 55, 0.95));
}

.reward-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, rgba(234, 179, 8, 0.1) 0%, transparent 70%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.reward-card:hover::after {
    opacity: 1;
}

.reward-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    filter: drop-shadow(0 0 10px rgba(234, 179, 8, 0.3));
}

.reward-title {
    font-weight: 900;
    color: #fef08a;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.reward-desc {
    font-size: 0.75rem;
    color: #9ca3af;
    line-height: 1.2;
}

#result-screen,
#start-screen,
#dialog-screen,
#game-over-screen {
    z-index: 200;
    pointer-events: auto;
}

/* Fix for Tailwind hidden class conflict with ID selectors */
#result-screen.hidden,
#reward-screen.hidden,
#map-screen.hidden,
#game-over-screen.hidden,
#start-screen.hidden,
#game-screen.hidden,
#dialog-screen.hidden {
    display: none !important;
}

.portrait-frame {
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.2);
    background: radial-gradient(circle at center, #1f2937 0%, #111827 100%);
}

#game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#rescue-notification {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.animate-rescue-in {
    animation: rescue-in 0.6s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes rescue-in {
    0% {
        transform: scale(0.8) translateY(20px);
        opacity: 0;
        filter: brightness(2);
    }

    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
        filter: brightness(1);
    }
}

.animate-scale-x {
    animation: scale-x 1s ease-out both;
    animation-delay: 0.3s;
}

@keyframes scale-x {
    0% {
        transform: scaleX(0);
        opacity: 0;
    }

    100% {
        transform: scaleX(1);
        opacity: 1;
    }
}

#rescue-notification.hidden {
    display: none !important;
}