:root {
    --bg-color: #f7f9fc;
    --primary-orange: #ff7b00;
    --primary-blue: #0088fe;
    --primary-green: #00c49f;
    --primary-red: #ff4d4f;
    --text-dark: #2d3436;
    --text-light: #f1f2f6;
    --overlay-bg: rgba(255, 255, 255, 0.85);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    font-family: 'Poppins', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 100%;
    max-height: 800px;
    background-color: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

canvas {
    display: block;
    background-color: #f0f3f5;
    width: 100%;
    height: auto;
    aspect-ratio: 60/65;
    /* Soft corner radius only applies properly if borders are transparent or matched, applying wrapper mask instead via game-container overflow hidden */
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#top-ui {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    text-shadow: 0 2px 4px rgba(255,255,255,0.7);
}

.score-box {
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-box span {
    font-size: 24px;
    font-weight: 800;
    color: var(--primary-orange);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

.rainbow-text {
    font-size: 40px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #ff7b00, #ff007f);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.2;
    letter-spacing: -1px;
}

.blink {
    animation: pulse 2s infinite ease-in-out;
    color: var(--primary-blue);
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 30px;
}

@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.98); }
}

.zone-selection {
    margin-top: 20px;
    text-align: center;
    width: 80%;
    max-width: 300px;
}

.zone-selection p {
    color: var(--text-dark);
    font-weight: 600;
    margin-bottom: 15px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.zone-btn {
    display: block;
    width: 100%;
    padding: 15px;
    margin: 10px auto;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    color: var(--text-dark);
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
}

.zone-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.05);
}

.zone-btn.active {
    border-color: var(--primary-orange);
    color: white;
    background: var(--primary-orange);
    box-shadow: 0 6px 15px rgba(255, 123, 0, 0.3);
}

#bottom-ui {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(0,0,0,0.05);
}

#lives-container {
    display: flex;
    gap: 6px;
}

.life-icon {
    width: 24px;
    height: 24px;
    background-color: var(--primary-orange);
    border-radius: 50%;
    position: relative;
    box-shadow: 0 2px 4px rgba(255,123,0,0.3);
}

.life-icon::before, .life-icon::after {
    content: '';
    position: absolute;
    top: -2px;
    width: 8px;
    height: 8px;
    background-color: var(--primary-orange);
    border-radius: 2px;
}

.life-icon::before { left: 2px; transform: rotate(-15deg); }
.life-icon::after { right: 2px; transform: rotate(15deg); }

#timer-container {
    width: 180px;
    height: 12px;
    background-color: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

#timer-bar {
    width: 100%;
    height: 100%;
    background-color: var(--primary-green);
    border-radius: 6px;
    transition: background-color 0.3s, width 0.1s linear;
}

/* --- Mobile Controls --- */
#mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background-color: #f8fafc;
    border-top: 1px solid #e2e8f0;
    z-index: 20;
    flex: 1;
}

.dpad-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
}

.dpad-btn {
    width: 65px;
    height: 65px;
    background-color: #ffffff;
    border: none;
    border-radius: 16px;
    color: var(--primary-orange);
    font-size: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05), inset 0 -4px 0 rgba(0,0,0,0.05);
    transition: all 0.1s;
}

.dpad-btn:active, .dpad-btn.pressed {
    transform: translateY(4px);
    box-shadow: 0 0 0 rgba(0,0,0,0.05), inset 0 2px 4px rgba(0,0,0,0.05);
    background-color: #fff9f5;
}

.action-btn {
    color: var(--primary-blue);
    font-size: 18px;
    font-weight: 800;
}

/* Responsiveness */
@media (max-width: 600px), (max-height: 850px) {
    body {
        align-items: flex-start;
        background-color: #f8fafc;
    }
    
    #game-container {
        border-radius: 0;
        box-shadow: none;
        height: 100vh;
        max-height: 100vh;
    }
    
    #mobile-controls {
        display: flex;
    }
    
    #ui-layer {
        height: auto;
        bottom: 0px; 
    }
    
    .rainbow-text { font-size: 32px; }
    #top-ui { padding: 10px 15px; font-size: 12px; }
    .score-box span { font-size: 18px; }
    .zone-btn { padding: 12px; font-size: 14px; }
}
