* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Poppins', sans-serif;
    color: #fff;
}

#container {
    width: 100%;
    height: 100%;
    position: relative;
}

#game {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #1a1a2e;
}

/* --- Control Panel --- */
.control-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 20;
}

.icon-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.icon-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-2px);
}

.icon-button.active {
    background: #ff4757;
}

/* --- UI Panels --- */
.ui-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 40px;
    border-radius: 12px;
    background: rgba(25, 25, 45, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    z-index: 10;
    max-width: 90%;
    width: 450px;
}

.ui-panel h1, .ui-panel h2 {
    margin: 0 0 20px 0;
    font-size: clamp(2em, 5vw, 3em);
    letter-spacing: 2px;
    text-transform: uppercase;
}

.ui-panel p {
    margin: 0 0 15px 0;
    font-size: clamp(1em, 3vw, 1.2em);
}

.tutorial {
    margin-bottom: 30px;
    text-align: left;
}

.tutorial p {
    margin-bottom: 10px;
    position: relative;
    padding-left: 20px;
}

.tutorial p:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #ff4757;
}

.tutorial-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

.tutorial-item {
    display: flex;
    align-items: center;
    gap: 15px;
    text-align: left;
}

.tutorial-item i {
    font-size: 1.5em;
    color: #ff4757;
    width: 30px;
}

.tutorial-item p {
    margin: 0;
}

.btn {
    padding: 15px 40px;
    border: none;
    border-radius: 50px;
    background: #ff4757;
    color: white;
    font-size: clamp(1em, 3vw, 1.2em);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
    letter-spacing: 1px;
    margin: 10px 5px;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.3);
}

.btn:hover {
    background: #ff6b81;
    transform: translateY(-3px);
    box-shadow: 0 7px 14px rgba(255, 71, 87, 0.4);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 3px 6px rgba(255, 71, 87, 0.3);
}

/* --- In-Game UI --- */
#score {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: clamp(1.5em, 4vw, 2em);
    font-weight: bold;
    z-index: 10;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease, color 0.3s ease;
}

#score.update {
    animation: scoreUpdate 0.5s ease;
}

@keyframes scoreUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); color: #ffcc00; }
    100% { transform: scale(1); }
}

#level-indicator {
    position: absolute;
    top: 60px;
    left: 20px;
    font-size: clamp(1em, 3vw, 1.2em);
    z-index: 10;
    opacity: 0.9;
    text-shadow: 0 2px 3px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.2);
    padding: 5px 10px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    transition: all 0.3s ease;
}

#game-info {
    position: absolute;
    bottom: 20px;
    width: 100%;
    text-align: center;
    font-size: clamp(0.8em, 2.5vw, 1em);
    opacity: 0.8;
    z-index: 10;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    backdrop-filter: blur(5px);
}

#perfect-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(2em, 6vw, 4em);
    font-weight: bold;
    color: #ffcc00;
    text-shadow: 0 0 15px #ffcc00;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10;
    pointer-events: none;
}

/* --- Animations --- */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out forwards;
}

#instructions,
#game-over-modal,
#pause-modal,
#tutorial-modal,
#score,
#level-indicator,
#game-info {
    display: none;
}

#container.ready #instructions { display: block; }
#container.ready #game-controls { display: none; }

#container.playing #score { display: block; }
#container.playing #level-indicator { display: block; }
#container.playing #game-info { display: block; }
#container.playing #game-controls { display: flex; }

#container.ended #game-over-modal { display: block; }
#container.ended #score { display: block; }
#container.ended #game-controls { display: flex; }

#container.paused #pause-modal { display: block; }
#container.paused #score { display: block; }
#container.paused #level-indicator { display: block; }
#container.paused #game-info { display: block; }
#container.paused #game-controls { display: flex; }

#container.resetting #score { display: block; }
#container.resetting #game-controls { display: flex; }

#perfect-indicator.show {
    opacity: 1;
}

@media screen and (max-width: 768px) {
    .ui-panel {
        padding: 30px;
        width: 90%;
    }
    
    .btn {
        padding: 12px 30px;
    }
    
    .control-panel {
        top: 15px;
        right: 15px;
    }
    
    .icon-button {
        width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    #score {
        top: 15px;
        left: 15px;
    }
    
    #level-indicator {
        top: 50px;
        left: 15px;
    }
    
    #game-info {
        bottom: 15px;
    }
}

@media screen and (max-width: 480px) {
    .ui-panel {
        padding: 20px;
    }
    
    .btn {
        padding: 10px 25px;
        margin: 5px 3px;
    }
    
    .tutorial-item {
        gap: 10px;
    }
    
    .tutorial-item i {
        font-size: 1.2em;
        width: 20px;
    }
}