/* ============================================
   STACK BLOCK GAME — Final CSS
   ============================================ */

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

body {
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #0a0a1a;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 500px;
    background: #000;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
    overflow: hidden;
}

/* ---------- Canvas with Dynamic Theme ---------- */
canvas {
    display: block;
    width: 100%;
    height: 100%;
    /* CSS Variables for Dynamic Backgrounds */
    --bg-top: #1a1a2e;
    --bg-mid: #16213e;
    --bg-bot: #0f3460;
    background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 40%, var(--bg-bot) 100%);
    transition: background 1.5s ease;
    touch-action: none;
}

/* ---------- HUD Layer ---------- */
.ui-layer {
    position: absolute;
    top: 8%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    z-index: 10;
}

#score {
    font-size: clamp(60px, 15vw, 100px);
    font-weight: 900;
    color: rgba(255, 255, 255, 0.12);
    line-height: 1;
    letter-spacing: -2px;
    transition: color 0.15s;
}

#highScore {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 3px;
    font-weight: 600;
}

#comboDisplay {
    margin-top: 12px;
    font-size: 20px;
    font-weight: 800;
    color: #ffd700;
    letter-spacing: 2px;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.2s, transform 0.2s;
}

#comboDisplay.visible {
    opacity: 1;
    transform: scale(1);
}

/* Full Screen Button */
#fullscreenBtn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.7);
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    pointer-events: auto;
}
#fullscreenBtn:hover {
    background: rgba(255, 255, 255, 0.25);
    color: #fff;
    transform: scale(1.1);
}

/* ---------- Menu Overlay ---------- */
#menu {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 20, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 20;
}

#menu.active {
    opacity: 1;
    pointer-events: auto;
}

#menu h1 {
    font-size: clamp(2.5rem, 10vw, 4.5rem);
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 6px;
    font-weight: 900;
    background: linear-gradient(135deg, #f857a6 0%, #ff5858 50%, #ffd700 100%);
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

#menuSubtitle {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 1px;
    margin-bottom: 8px;
}

#menuScore {
    font-size: 18px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 24px;
    min-height: 24px;
}

/* ---------- Difficulty Slider (Gradient Style) ---------- */
.difficulty-container {
    width: 85%;
    max-width: 320px;
    margin-bottom: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.difficulty-container label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.5);
    letter-spacing: 3px;
    margin-bottom: 15px;
    font-weight: 800;
    text-transform: uppercase;
}

/* Track */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
    margin-bottom: 15px;
    height: 12px;
}
input[type=range]:focus { outline: none; }

/* Chrome/Safari Track */
input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, #4cd964 0%, #ffcc00 50%, #ff3b30 100%);
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    border: none;
}
/* Firefox Track */
input[type=range]::-moz-range-track {
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, #4cd964 0%, #ffcc00 50%, #ff3b30 100%);
    border-radius: 10px;
    border: none;
}

/* Thumb (Glowing White Circle) */
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 28px;
    width: 28px;
    border-radius: 50%;
    background: #ffffff;
    margin-top: -10px; 
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8), 0 0 5px rgba(0,0,0,0.2);
    transition: transform 0.1s ease, box-shadow 0.2s;
}
input[type=range]::-moz-range-thumb {
    height: 28px;
    width: 28px;
    border-radius: 50%;
    background: #ffffff;
    border: none;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
    transition: transform 0.1s ease;
}
input[type=range]:active::-webkit-slider-thumb {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(255, 255, 255, 1);
}

/* Labels */
.diff-labels {
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 2px;
}
.diff-labels span {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.2);
    font-weight: 800;
    letter-spacing: 1px;
    transition: all 0.3s;
    cursor: pointer;
    text-transform: uppercase;
}

/* Active Color States */
#label-easy.active { color: #4cd964; text-shadow: 0 0 12px rgba(76, 217, 100, 0.6); transform: scale(1.1); }
#label-medium.active { color: #ffcc00; text-shadow: 0 0 12px rgba(255, 204, 0, 0.6); transform: scale(1.1); }
#label-hard.active { color: #ff3b30; text-shadow: 0 0 12px rgba(255, 59, 48, 0.6); transform: scale(1.1); }

/* ---------- Button ---------- */
button#actionBtn {
    background: linear-gradient(135deg, #ffffff 0%, #e8e8e8 100%);
    color: #1a1a2e;
    border: none;
    padding: 18px 56px;
    font-size: 1.2rem;
    font-weight: 900;
    border-radius: 50px;
    cursor: pointer;
    letter-spacing: 3px;
    text-transform: uppercase;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
button#actionBtn:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5); }
button#actionBtn:active { transform: scale(0.95) translateY(0); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4); }

/* ---------- Footer ---------- */
.footer-links {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 12px;
    letter-spacing: 0.5px;
}
.footer-links a { color: rgba(255, 255, 255, 0.4); text-decoration: none; transition: color 0.2s; pointer-events: auto; }
.footer-links a:hover { color: rgba(255, 255, 255, 0.75); text-decoration: underline; }
.footer-links span { color: rgba(255, 255, 255, 0.25); margin: 0 6px; }
