/* === Overlay & Popup Styling === */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    opacity: 1;
    transition: opacity 0.4s ease-out;
    z-index: 200;
}
.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#settings-menu { z-index: 300; }
#popup-instructions { z-index: 250; }
#pause-menu { z-index: 200; }

.popup-content {
    background-color: #2a2a3a;
    padding: clamp(20px, 5vmin, 30px) clamp(25px, 6vmin, 40px);
    border-radius: 10px;
    text-align: center;
    max-width: 90%;
    width: 500px;
    color: #eee;
    border: 1px solid #55f;
    box-shadow: 0 0 25px rgba(80, 80, 255, 0.5);
}

.popup-content h2 {
    color: #7f7;
    font-size: clamp(1.5rem, 4vmin, 2.2rem);
    margin: 0 0 25px 0;
}
.popup-content p {
    font-size: clamp(0.9rem, 2.5vmin, 1.1rem);
    line-height: 1.5;
    margin-bottom: 15px;
}
.popup-content button {
    padding: 12px 25px;
    font-size: clamp(1rem, 3vmin, 1.2rem);
    background-color: #0f8;
    color: #111;
    border: none;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease;
    min-width: 120px;
}
.popup-content button:hover:not(:disabled) {
    background-color: #5f5;
}
.popup-content button:disabled {
    background-color: #555;
    cursor: not-allowed;
}

/* === Settings Menu Styling === */
#settings-menu .settings-content {
    width: 550px;
    text-align: center;
}

.setting-group {
    margin-bottom: 15px;
}
.setting-group label {
    display: block;
    color: #ccc;
    font-weight: bold;
    margin-bottom: 6px;
    font-size: clamp(0.85rem, 2.2vmin, 1rem);
}
.setting-group select,
#setting-block-count,
#setting-speed {
    width: 100%;
    padding: 8px 10px;
    border-radius: 4px;
    background-color: #334858;
    color: #eee;
    border: 1px solid #557;
    font-size: clamp(0.9rem, 2.5vmin, 1.1rem);
    box-sizing: border-box;
    margin-bottom: 10px;
    appearance: none;
}
#settings-save-button {
    display: block;
    width: 100%;
    margin-top: 30px;
    background-color: #0f8;
    color: #111;
}

#game-container {
    width: 88dvw;
    height: 100dvh;
    max-width: 700px;
    max-height: 1150px;
    margin: 5px auto;
    background-size: cover;
    background-position: center;
    border: 3px solid #66f;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(100, 100, 255, 0.7);
    cursor: pointer;
    display: flex;
    touch-action: manipulation;
}

#score {
    position: absolute;
    top: 3%;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(1rem, 2.5vmin, 1.5rem);
    color: #edffe2e3;
    background-color: rgba(0,0,0,0.3);
    padding: 0.3em 0.6em;
    border-radius: 5px;
    text-shadow: 1px 1px 2px black;
    z-index: 10;
    user-select: none;
}

#ball {
    position: absolute;
    width: 3vmin;
    height: 3vmin;
    min-width: 15px;
    min-height: 15px;
    border-radius: 50%;
    box-shadow: 0 0 8px #fff;
    z-index: 5;
}
.ball-standard { background-color: #fff; }
.ball-comet { background-color: #f99; box-shadow: 0 0 10px #f66, 0 0 15px #fcc; }
.ball-plasma { background: radial-gradient(circle, #ff0 0%, #f80 50%, #f00 100%); box-shadow: 0 0 12px #f80; }

#paddle-ai.paddle {
    position: absolute;
    width: 20vmin;
    height: 2.5vmin;
    min-width: 80px;
    min-height: 12px;
    background-color: #0f8;
    box-shadow: 0 0 10px #0f8;
    border-radius: 3px;
    top: 1.5vmin;
    left: 50%;
    z-index: 5;
}

#player-area {
    position: absolute;
    bottom: 1.5vmin;
    left: 0;
    width: 100%;
    height: 6vmin;
    min-height: 40px;
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    z-index: 5;
}

.block {
    height: 2.5vmin;
    padding: 0.25rem;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 12px;
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.5);
    background-color: #98b3e18f;
    box-shadow: inset 0 0 5px rgba(100, 100, 255, 0.5);
    border-radius: 2px;
    transition: background-color 0.1s ease, box-shadow 0.1s ease;
    cursor: default;
    backdrop-filter: blur(1px); /* Blurs content behind the block */
    animation: spectral-float 1s infinite alternate;
    background-color: rgba(152, 179, 225, 0.5); /* More transparent */
    box-shadow: 
        inset 0 0 5px rgba(100, 100, 255, 0.5),
        0 0 15px rgba(120, 180, 255, 0.6); /* Outer glow */
    border: 1px solid rgba(247, 215, 54, 0.3); /* Ethereal border */
    backdrop-filter: blur(1px); /* Blurs content behind the block */
    animation: spectral-pulse 1.5s infinite alternate;
}

@keyframes spectral-pulse {
    0% {
        opacity: 0.7;
        box-shadow: 
            inset 0 0 5px rgba(100, 100, 255, 0.5),
            0 0 15px rgba(120, 180, 255, 0.6);
    }
    100% {
        opacity: 0.9;
        box-shadow: 
            inset 0 0 8px rgba(100, 100, 255, 0.7),
            0 0 25px rgba(120, 180, 255, 0.8);
    }
}

.block.crumbling {
    animation: crumble 0.4s ease-out forwards;
    pointer-events: none;
    z-index: 1;
}
@keyframes crumble {
    0%   { transform: scale(1); opacity: 1; background-color: #f80; }
    15%  { transform: scale(1.05) translateY(-2px); opacity: 0.95; background-color: #fa6; }
    30%  { transform: scale(1); background-color: #fa5; box-shadow: 0 0 10px rgba(255, 120, 0, 0.6); }
    60%  { transform: scale(0.9) rotate(3deg) translateY(5px); opacity: 0.7; background-color: #f94; }
    85%  { transform: scale(0.6) rotate(-5deg) translateY(10px); opacity: 0.3; background-color: #f62; }
    100% { transform: scale(0.2) rotate(8deg) translateY(30px); opacity: 0; background-color: #f30; filter: blur(3px); }
}

.block.solid {
    background-color: rgba(249, 188, 34, 0.95);
    box-shadow: 0 0 10px rgb(245, 136, 12);
}

.block .word-display {
    position: absolute;
    bottom: calc(-1.8vmin - 4px);
    width: 100%;
    text-align: center;
    font-size: clamp(1rem, 3vmin, 3rem);
    font-weight: bold;
    font-family: Arial, Helvetica, sans-serif;
    color: #c4ebfbec;
    text-shadow: 1px 1px 4px #7f7fa05e;
    opacity: 1 !important;
    text-shadow: none;
    white-space: nowrap;
    overflow: visible;
    z-index: 2;
    user-select: none;
}

#recognition-status {
    position: absolute;
    bottom: 0.5vmin;
    left: 50%;
    transform: translateX(-50%);
    font-size: clamp(0.7rem, 1.5vmin, 0.9rem);
    color: #aaa;
    background-color: rgba(0,0,0,0.4);
    padding: 2px 5px;
    border-radius: 3px;
    z-index: 6;
    white-space: nowrap;
}

@media (max-height: 450px) {
    .word-display {
        font-size: 0.7rem;
        bottom: -15px;
    }
    #player-area { min-height: 30px; height: 5vmin; }
    .block { min-height: 10px; height: 2vmin; }
    .paddle { min-height: 10px; height: 2vmin; }
    #ball { min-width: 12px; min-height: 12px; width: 2.5vmin; height: 2.5vmin; }
}
