@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;800&display=swap');

body {
    margin: 0;
    overflow: hidden;
    background-color: #050505;
    font-family: 'Montserrat', sans-serif;
    touch-action: none;
    transition: background-color 0.5s;
}

/* --- Main UI Container --- */
#game-ui {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 0;
    box-sizing: border-box;
}

/* --- Top HUD --- */
.hud-top {
    width: 100%;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    pointer-events: auto;
    /* Enable clicks for settings button */
}

.level-info {
    text-align: left;
}

.level-label {
    color: #aaa;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.level-val {
    font-size: 2.2rem;
    font-weight: 800;
    color: #00ffff;
    line-height: 1;
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.4);
}

.best-score {
    font-size: 0.7rem;
    color: #ffd700;
    font-weight: bold;
    margin-top: 2px;
    opacity: 0.8;
}

/* TIMER Styles */
.timer-container {
    text-align: center;
}

.timer-val {
    font-size: 2.5rem;
    font-weight: 800;
    color: #00ff00;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 15px rgba(0, 255, 0, 0.3);
}

.timer-label {
    font-size: 0.6rem;
    color: #aaa;
    letter-spacing: 2px;
}

.timer-danger {
    color: #ff0000;
    animation: pulse 0.5s infinite;
}

.stats-mini {
    text-align: right;
    font-size: 0.7rem;
    color: #888;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 5px;
}

.btn-settings {
    background: none;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-settings:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #fff;
}

/* --- Center Status --- */
.center-msg {
    position: absolute;
    top: 30%;
    left: 0;
    width: 100%;
    text-align: center;
    pointer-events: none;
    z-index: 10;
}

#status {
    font-size: 2.5rem;
    font-weight: 800;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
    text-transform: uppercase;
    letter-spacing: 2px;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* --- Power Meter (Right Side) --- */
.meter-container {
    position: absolute;
    right: 20px;
    top: 55%;
    transform: translateY(-50%);
    width: 30px;
    height: 250px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column-reverse;
    padding: 3px;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.5);
}

.meter-fill {
    width: 100%;
    height: 0%;
    background: linear-gradient(to top, #00ff00, #ffff00, #ff0000);
    border-radius: 15px;
    transition: height 0.3s ease-out;
    opacity: 0.8;
}

.meter-marker {
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background: white;
    z-index: 5;
}

.mark-ideal {
    bottom: 25%;
    border-bottom: 2px dashed rgba(255, 255, 255, 0.9);
    box-shadow: 0 0 5px white;
}

/* --- Bottom Controls --- */
.game-controls {
    position: absolute;
    bottom: 80px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
    pointer-events: auto;
}

.btn-reset-cup {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 10px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.btn-reset-cup:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.05);
}

.btn-reset-cup:active {
    transform: scale(0.95);
}

.btn-reset-game {
    background: rgba(255, 0, 0, 0.2);
    color: #ffaaaa;
    border: 1px solid rgba(255, 0, 0, 0.3);
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    backdrop-filter: blur(4px);
}

.btn-reset-game:hover {
    background: rgba(255, 0, 0, 0.4);
    border-color: #ff4444;
    color: white;
}


/* --- Bottom Instructions --- */
.instructions {
    text-align: center;
    padding-bottom: 30px;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* --- Level Overlay --- */
#level-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 150;
    pointer-events: auto; /* Allow clicks if we want later */
}

.level-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#level-text {
    font-size: 5rem;
    color: #00ffff;
    text-transform: uppercase;
    text-shadow: 0 0 30px rgba(0, 255, 255, 0.8);
    margin: 0;
    animation: scaleUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scaleUp {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}


/* --- Overlay for Game Over --- */
#overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 100;
}

#overlay h2 {
    font-size: 3rem;
    color: #ff4444;
    margin: 0 0 20px 0;
    text-transform: uppercase;
    text-shadow: 0 0 20px #ff0000;
}

#overlay p {
    color: white;
    font-size: 1.2rem;
    margin-bottom: 30px;
}

.overlay-buttons {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-restart {
    background: #fff;
    color: #000;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 30px;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
    transition: transform 0.1s;
}

.btn-restart:active {
    transform: scale(0.95);
}

.btn-replay {
    background: #8a2be2; /* Purple */
    color: #fff;
    border: none;
    padding: 15px 40px;
    font-size: 1.2rem;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    border-radius: 30px;
    box-shadow: 0 0 20px rgba(138, 43, 226, 0.4);
    transition: transform 0.1s;
}

.btn-replay:active {
    transform: scale(0.95);
}

/* Win Replay Button (on Level Splash) */
.btn-win-replay {
    background: rgba(138, 43, 226, 0.2);
    border: 2px solid #8a2be2;
    color: #fff;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 20px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
    opacity: 0;
    animation: fadeIn 0.5s forwards 1s;
    pointer-events: auto;
}
.btn-win-replay:hover {
    background: rgba(138, 43, 226, 0.6);
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#btn-stop-replay {
    display: none;
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: #ff4444;
    color: white;
    border: 2px solid white;
    padding: 12px 30px;
    border-radius: 30px;
    font-size: 1rem;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    z-index: 200;
    pointer-events: auto;
    box-shadow: 0 0 15px rgba(0,0,0,0.5);
}

/* --- Settings Modal --- */
#settings-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
    z-index: 200;
    color: white;
}

.settings-content {
    width: 90%;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.05);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-content h2 {
    margin-top: 0;
    text-transform: uppercase;
    text-align: center;
    color: #00ffff;
}

.setting-group {
    margin-bottom: 20px;
}

.setting-label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    color: #aaa;
    font-weight: bold;
}

.setting-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.option-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.option-btn.active {
    background: #00ffff;
    color: #000;
    border-color: #00ffff;
    font-weight: bold;
}

.btn-close-settings {
    width: 100%;
    margin-top: 20px;
    background: #fff;
    color: #000;
    border: none;
    padding: 12px;
    border-radius: 10px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
}

/* --- Start Screen --- */
#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #050505 0%, #1a0a2e 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 300;
    pointer-events: auto;
}

.start-content {
    text-align: center;
    color: white;
}

.start-content h1 {
    font-size: 4rem;
    margin: 0;
    color: #00ffff;
    text-transform: uppercase;
    text-shadow: 0 0 30px rgba(0, 255, 255, 0.6);
    letter-spacing: 5px;
}

.subtitle {
    font-size: 1.2rem;
    color: #aaa;
    margin-bottom: 40px;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.start-menu-settings {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 300px;
    margin-left: auto;
    margin-right: auto;
}

.menu-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.menu-group label {
    color: #ccc;
    font-size: 0.9rem;
    font-weight: bold;
}

.toggle-switch {
    background: rgba(0, 0, 0, 0.3);
    padding: 5px 15px;
    border-radius: 20px;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: all 0.2s;
}

.toggle-switch:hover {
    background: rgba(255, 255, 255, 0.1);
}

#start-theme-select {
    background: rgba(0, 0, 0, 0.3);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 5px 10px;
    border-radius: 5px;
    font-family: inherit;
    cursor: pointer;
}

.btn-start-game {
    background: #00ff00;
    color: #000;
    border: none;
    padding: 20px 60px;
    font-size: 1.5rem;
    font-weight: 900;
    border-radius: 50px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.4);
    transition: transform 0.1s, box-shadow 0.2s;
    margin-bottom: 15px;
}

.btn-start-game:hover {
    transform: scale(1.05);
    box-shadow: 0 0 50px rgba(0, 255, 0, 0.6);
}

.btn-start-game:active {
    transform: scale(0.95);
}

.btn-secondary {
    background: transparent;
    color: #aaa;
    border: 1px solid #555;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-secondary:hover {
    color: white;
    border-color: white;
}

/* --- Animations --- */
@keyframes pop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.pop-anim {
    animation: pop 0.3s forwards;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}