/* ============================================
   SLITHER ARENA – Main Stylesheet
   ============================================ */

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

body {
    font-family: 'Outfit', sans-serif;
    background: #0a0a1a;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
}

/* ============ NAME ENTRY SCREEN ============ */
#start-screen {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    background: radial-gradient(ellipse at 50% 30%, #1a1a3e 0%, #0a0a1a 70%);
}

#start-screen::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(2px 2px at 20% 30%, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 40% 70%, rgba(255,255,255,0.2), transparent),
        radial-gradient(2px 2px at 60% 20%, rgba(255,255,255,0.3), transparent),
        radial-gradient(2px 2px at 80% 60%, rgba(255,255,255,0.15), transparent),
        radial-gradient(3px 3px at 10% 80%, rgba(120,200,255,0.4), transparent),
        radial-gradient(3px 3px at 90% 10%, rgba(255,120,200,0.4), transparent);
    animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
    0% { opacity: 0.5; }
    100% { opacity: 1; }
}

.game-logo {
    font-size: clamp(3rem, 8vw, 6rem);
    font-weight: 900;
    background: linear-gradient(135deg, #00ff88 0%, #00ccff 40%, #ff44cc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: none;
    filter: drop-shadow(0 0 30px rgba(0,255,136,0.3));
    letter-spacing: -2px;
    position: relative;
    z-index: 1;
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.03); }
}

.game-subtitle {
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    color: rgba(255,255,255,0.5);
    margin-top: 8px;
    margin-bottom: 40px;
    position: relative;
    z-index: 1;
    letter-spacing: 4px;
    text-transform: uppercase;
}

.input-container {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

#player-name {
    width: 320px;
    padding: 16px 24px;
    font-size: 1.2rem;
    font-family: 'Outfit', sans-serif;
    border: 2px solid rgba(0,255,136,0.3);
    border-radius: 16px;
    background: rgba(255,255,255,0.05);
    color: #fff;
    text-align: center;
    outline: none;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    direction: ltr;
}

#player-name:focus {
    border-color: #00ff88;
    box-shadow: 0 0 30px rgba(0,255,136,0.2), inset 0 0 30px rgba(0,255,136,0.05);
}

#player-name::placeholder {
    color: rgba(255,255,255,0.3);
}

.input-error {
    border-color: #ff4466 !important;
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-8px); }
    75% { transform: translateX(8px); }
}

#play-btn {
    width: 320px;
    padding: 16px 32px;
    font-size: 1.3rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #00ff88, #00ccff);
    color: #0a0a1a;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#play-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 40px rgba(0,255,136,0.4);
}

#play-btn:active {
    transform: translateY(0);
}

#open-skins-btn {
    position: relative;
    z-index: 10;
    margin-top: 15px;
    width: 220px;
    font-size: 1.15rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    border-radius: 14px;
    padding: 12px;
    border: 2px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
    color: #fff;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    backdrop-filter: blur(10px);
    letter-spacing: 1px;
}

#open-skins-btn:hover {
    background: rgba(0,255,136,0.1);
    border-color: #00ff88;
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 10px 25px rgba(0,255,136,0.3), inset 0 0 15px rgba(0,255,136,0.1);
    color: #00ff88;
}

#open-skins-btn:active {
    transform: translateY(0) scale(0.98);
}

/* ============ SKINS CAROUSEL MODAL ============ */
.skins-carousel-card {
    position: relative;
    z-index: 1;
    background: rgba(20, 20, 50, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 30px;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    animation: pauseCardIn 0.3s ease-out;
    width: 90vw;
    max-width: 450px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.skins-title {
    font-size: 2.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #00ff88, #00ccff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 25px;
    text-shadow: 0 4px 15px rgba(0,255,136,0.3);
}

.skin-slider-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 25px;
    width: 100%;
}

.skin-nav-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.skin-nav-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: scale(1.15);
    box-shadow: 0 0 20px rgba(255,255,255,0.3);
}

.skin-nav-btn:active {
    transform: scale(0.95);
}

.skin-canvas-container {
    width: 220px;
    height: 220px;
    position: relative;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,255,255,0.08) 0%, transparent 70%);
    box-shadow: inset 0 0 50px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border: 2px solid rgba(255,255,255,0.05);
    touch-action: pan-y; /* allow swipe horizontal */
}

.skin-canvas-container.glow {
    border-color: #00ff88;
    box-shadow: inset 0 0 30px rgba(0,255,136,0.2), 0 0 40px rgba(0,255,136,0.4);
}

#skin-preview-canvas {
    transition: filter 0.4s ease, opacity 0.3s ease;
}

.skin-canvas-container.locked #skin-preview-canvas {
    filter: grayscale(100%) brightness(0.35);
}

.skin-info-panel {
    min-height: 70px;
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.skin-name-lg {
    font-size: 2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 4px 15px rgba(0,0,0,0.8);
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

.skin-req-lg {
    font-size: 1.1rem;
    color: #ffd700;
    font-weight: 700;
    margin-top: 8px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#skin-select-btn {
    font-size: 1.2rem;
    padding: 14px 30px;
}

#skin-select-btn:disabled {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.3);
    border: 2px solid rgba(255,255,255,0.05);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* ============ GAME CANVAS ============ */
#game-canvas {
    display: none;
    position: fixed;
    inset: 0;
}

/* ============ HUD ============ */
#hud {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    padding: 15px 20px;
    pointer-events: none;
}

.hud-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    pointer-events: none;
}

.score-display {
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 10px 20px;
    border: 1px solid rgba(255,255,255,0.08);
    color: #fff;
    pointer-events: auto;
}

.score-display .label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.score-display .value {
    font-size: 1.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, #00ff88, #00ccff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Length Display */
.length-display {
    text-align: center;
    background: rgba(0,0,0,0.6);
    padding: 8px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    pointer-events: auto;
}

.length-display .label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2px;
}

.length-display .value {
    font-size: 1.6rem;
    font-weight: 800;
    color: #00ff88;
    text-shadow: 0 0 10px rgba(0,255,136,0.3);
}

.fps-badge {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(8px);
    padding: 6px 12px;
    border-radius: 20px;
    color: rgba(255,255,255,0.6);
    font-size: 0.7rem;
    font-weight: 700;
    font-family: monospace;
    border: 1px solid rgba(255,255,255,0.05);
    pointer-events: none;
    white-space: nowrap;
}

/* Leaderboard */
.leaderboard {
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    border-radius: 14px;
    padding: 12px 16px;
    border: 1px solid rgba(255,255,255,0.08);
    min-width: 200px;
    pointer-events: auto;
    position: absolute;
    top: 90px;
    right: 20px;
}

.leaderboard h3 {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 8px;
    text-align: center;
}

.lb-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.7);
    direction: ltr;
}

.lb-entry.highlight {
    color: #00ff88;
    font-weight: 700;
}

.lb-entry .rank {
    width: 20px;
    text-align: center;
    margin-right: 8px;
    opacity: 0.5;
}

.lb-entry .name {
    flex-grow: 1;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    text-align: left;
}

.lb-entry .score {
    min-width: 40px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.leader-text {
    color: #FFD700 !important;
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.6);
    font-weight: 900;
    animation: pulse-gold 2s infinite;
}

@keyframes pulse-gold {
    0% { text-shadow: 0 0 5px rgba(255, 215, 0, 0.4); }
    50% { text-shadow: 0 0 15px rgba(255, 215, 0, 0.8); }
    100% { text-shadow: 0 0 5px rgba(255, 215, 0, 0.4); }
}

/* Minimap */
#minimap {
    position: fixed;
    bottom: 15px;
    right: 15px;
    width: 150px;
    height: 150px;
    border-radius: 14px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    z-index: 50;
    display: none;
    pointer-events: none;
}

/* ============ GAME OVER SCREEN ============ */
#game-over {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(15px);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#game-over.active {
    display: flex;
}

.go-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    background: linear-gradient(135deg, #ff4466, #ff8844);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.go-score {
    font-size: 1.5rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 30px;
}

.go-score span {
    color: #00ff88;
    font-weight: 700;
    font-size: 2rem;
}

#restart-btn {
    padding: 16px 48px;
    font-size: 1.2rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    border: 2px solid rgba(0,255,136,0.4);
    border-radius: 16px;
    background: rgba(0,255,136,0.1);
    color: #00ff88;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#restart-btn:hover {
    background: rgba(0,255,136,0.2);
    transform: translateY(-3px);
    box-shadow: 0 10px 40px rgba(0,255,136,0.2);
}

.go-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 300px;
}

#go-quit-btn {
    padding: 14px;
    font-size: 1.05rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    border: 2px solid rgba(255, 68, 102, 0.4);
    border-radius: 14px;
    background: rgba(255, 68, 102, 0.08);
    color: #ff4466;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

#go-quit-btn:hover {
    background: rgba(255, 68, 102, 0.18);
    transform: translateY(-2px);
}

/* ============ PAUSE MENU ============ */
#pause-menu {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 300;
    align-items: center;
    justify-content: center;
}

#pause-menu.active {
    display: flex;
}

.pause-overlay-bg {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    animation: pauseFadeIn 0.25s ease-out;
}

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

.pause-card {
    position: relative;
    z-index: 1;
    background: rgba(20, 20, 50, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    padding: 40px 50px;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.08);
    animation: pauseCardIn 0.3s ease-out;
    min-width: 340px;
}

@keyframes pauseCardIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.pause-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.pause-title {
    font-size: 2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #00ff88, #00ccff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.pause-score-info {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 30px;
}

.pause-score-info span {
    color: #00ff88;
    font-weight: 700;
    font-size: 1.3rem;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

#resume-btn {
    width: 100%;
    padding: 14px 32px;
    font-size: 1.15rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #00ff88, #00ccff);
    color: #0a0a1a;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

#resume-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 255, 136, 0.4);
}

#resume-btn:active {
    transform: translateY(0);
}

#quit-btn {
    width: 100%;
    padding: 14px 32px;
    font-size: 1.05rem;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    border: 2px solid rgba(255, 68, 102, 0.4);
    border-radius: 14px;
    background: rgba(255, 68, 102, 0.08);
    color: #ff4466;
    cursor: pointer;
    transition: all 0.3s ease;
    letter-spacing: 1px;
}

#quit-btn:hover {
    background: rgba(255, 68, 102, 0.18);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(255, 68, 102, 0.2);
}

#quit-btn:active {
    transform: translateY(0);
}

.pause-hint {
    margin-top: 20px;
    font-size: 0.78rem;
    color: rgba(255, 255, 255, 0.25);
    letter-spacing: 1px;
}

/* ============ FLOATING SNAKE BACKGROUND ANIMATION ============ */
.bg-snake {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    opacity: 0.15;
    z-index: 0;
    animation: floatSnake linear infinite;
}

@keyframes floatSnake {
    0% { transform: translateY(100vh) rotate(0deg); }
    100% { transform: translateY(-100px) rotate(720deg); }
}

/* Mobile Controls */
.mobile-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,0.3);
    font-size: 0.8rem;
    z-index: 51;
    display: none;
    pointer-events: none;
}

/* ============ MOBILE JOYSTICK ============ */
#joystick-container {
    display: none; /* Hidden by default, shown via JS on touch */
    position: fixed;
    width: 120px;
    height: 120px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    z-index: 200;
    backdrop-filter: blur(5px);
    touch-action: none;
    box-shadow: 0 0 20px rgba(0,0,0,0.3);
    pointer-events: none; /* Let canvas handle the touches */
}

#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), rgba(200, 200, 200, 0.5));
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    pointer-events: none;
}

#mobile-pause-btn {
    display: none;
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-size: 1.5rem;
    z-index: 100;
    pointer-events: auto;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#mobile-pause-btn:active {
    transform: scale(0.9);
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 768px) {
    .mobile-hint { display: block; }
    #mobile-pause-btn { display: flex; }
    
    .hud-top-bar {
        padding: 0 10px;
    }
    
    .score-display, .length-display {
        padding: 6px 15px;
    }
    
    .score-display .value, .length-display .value {
        font-size: 1.4rem;
    }
    
    .leaderboard {
        top: 85px;
        right: 15px;
        min-width: 160px;
        padding: 8px 12px;
    }

    #power-up-container {
        bottom: 100px; /* Stay above joystick area if needed */
    }

    #combo-notifier {
        bottom: 155px !important;
        font-size: 1.6rem !important;
    }
}

/* ============ COMBO INDICATOR ============ */
#combo-notifier {
    display: none;
    position: fixed;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 140;
    pointer-events: none;
    color: #FFD700;
    font-weight: 900;
    font-size: 1.8rem;
    text-transform: uppercase;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5), 0 0 5px rgba(0,0,0,0.8);
    letter-spacing: 2px;
    animation: comboPulse 0.5s ease-in-out infinite alternate;
}

@keyframes comboPulse {
    from { transform: translateX(-50%) scale(1); }
    to { transform: translateX(-50%) scale(1.1); }
}

/* ============ POWER-UP TIMER ============ */
#power-up-container {
    display: none;
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 150;
    pointer-events: none;
    text-align: center;
    width: 220px;
}

#power-up-label {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.power-up-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.1);
}

#power-up-progress {
    width: 100%;
    height: 100%;
    background: #00ff88;
    transition: width 0.1s linear;
}

/* ============ RANK NOTIFICATION ============ */
#rank-notifier {
    display: none;
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    pointer-events: none;
    font-size: clamp(1.4rem, 4vw, 2rem);
    font-weight: 900;
    text-align: center;
    white-space: nowrap;
    animation: rankAppear 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes rankAppear {
    from { opacity: 0; transform: translate(-50%, 20px) scale(0.8); }
    to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}
/* ============ SETTINGS UI ============ */
.hud-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.settings-trigger, #mobile-pause-btn {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.settings-trigger:hover, #mobile-pause-btn:hover {
    background: rgba(255,255,255,0.2);
    transform: translateY(-2px);
    border-color: #00ff88;
}

.settings-trigger:active, #mobile-pause-btn:active {
    transform: translateY(0) scale(0.95);
}

/* Modal UI */
.modal-ui {
    display: none; /* Controlled by JS */
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-ui.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(8px);
}

.modal-card {
    position: relative;
    width: 100%;
    max-width: 420px;
    background: linear-gradient(135deg, rgba(30,30,60,0.95) 0%, rgba(15,15,35,0.98) 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 28px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5), 0 0 40px rgba(0,255,136,0.1);
    padding: 32px;
    animation: modalSlide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

@keyframes modalSlide {
    from { transform: scale(0.9) translateY(40px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h3 {
    font-size: 1.8rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -0.5px;
}

.modal-close {
    background: rgba(255,255,255,0.05);
    border: none;
    color: rgba(255,255,255,0.4);
    font-size: 2rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.modal-close:hover {
    background: rgba(255,68,102,0.15);
    color: #ff4466;
}

/* Setting Items */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.setting-item.vertical {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.setting-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.setting-icon { font-size: 1.2rem; }
.setting-label { 
    font-size: 1rem; 
    color: rgba(255,255,255,0.8);
    font-weight: 600;
}

.setting-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.1), transparent);
    margin: 24px 0;
}

/* Quality Selector */
.quality-selector {
    display: flex;
    width: 100%;
    background: rgba(0,0,0,0.2);
    padding: 4px;
    border-radius: 12px;
    gap: 4px;
}

.quality-btn {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: rgba(255,255,255,0.4);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quality-btn:hover { color: #fff; }

.quality-btn.active {
    background: rgba(0,255,136,0.15);
    color: #00ff88;
    box-shadow: 0 4px 12px rgba(0,255,136,0.1);
}

/* Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.switch input { opacity: 0; width: 0; height: 0; }

.slider-round {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background-color: rgba(255,255,255,0.1);
    transition: .3s;
    border-radius: 34px;
    border: 1px solid rgba(255,255,255,0.05);
}

.slider-round:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 3px;
    background-color: #fff;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

input:checked + .slider-round { background-color: #00ee77; }
input:checked + .slider-round:before { transform: translateX(22px); }

/* Range Slider */
.modern-range {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 10px;
    outline: none;
    cursor: pointer;
}

.modern-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: #00ff88;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0,255,136,0.5);
}

.range-labels {
    width: 100%;
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.3);
    margin-top: 4px;
}

/* Actions */
.modal-footer {
    margin-top: 32px;
}

.primary-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #00ff88 0%, #00ccff 100%);
    color: #0a0a1a;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 8px 25px rgba(0,255,136,0.2);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0,255,136,0.3);
}

.primary-btn:active {
    transform: translateY(0) scale(0.98);
}

/* Mobile only setting visibility */
.mobile-only-setting {
    display: none;
}

/* ============ SETTINGS BUTTON REFINEMENTS ============ */
.main-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 10px;
}

#start-settings-btn {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    font-size: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#start-settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: #00ff88;
    transform: translateY(-2px);
}

#pause-settings-btn {
    margin: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 14px 28px;
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid rgba(0, 204, 255, 0.2); /* Subtle cyan border */
    border-radius: 14px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    box-sizing: border-box;
}

#pause-settings-btn:hover {
    background: rgba(0, 204, 255, 0.1);
    border-color: #00ccff;
    box-shadow: 0 0 20px rgba(0, 204, 255, 0.2);
}

.btn-icon {
    width: 24px; /* Slightly larger as requested */
    height: 24px;
    stroke: #00ccff;
    filter: drop-shadow(0 0 5px rgba(0, 204, 255, 0.5));
    transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    flex-shrink: 0;
}

#pause-settings-btn:hover .btn-icon {
    transform: rotate(180deg) scale(1.1);
}

.settings-trigger-btn:active {
    transform: scale(0.95);
}

/* Redefine old trigger if still used somewhere, otherwise it's safe to keep */
/* ============ COINS & SHOP SYSTEM ============ */

/* HUD Coin Display */
.coin-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(20, 20, 20, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 6px 20px;
    border-radius: 16px;
    border: 1.5px solid rgba(255, 215, 0, 0.3);
    min-width: 100px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 0 15px rgba(255, 215, 0, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.coin-display::before {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 50%; height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.1),
        transparent
    );
    transition: 0.5s;
}

.coin-display:hover::before {
    left: 200%;
}

.coin-display .label {
    color: rgba(255, 215, 0, 0.7);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.coin-display .value {
    color: #ffcc00;
    font-size: 1.4rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 0 15px rgba(255, 204, 0, 0.4);
}

.coin-icon {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.6));
    animation: coinRotate 3s infinite linear;
}

@keyframes coinRotate {
    0% { transform: rotateY(0deg); }
    100% { transform: rotateY(360deg); }
}

/* Modal Shop Header */
.skins-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-bottom: 20px;
    padding: 0 10px;
}

.modal-coins-display {
    background: rgba(255, 255, 255, 0.06);
    padding: 8px 18px;
    border-radius: 20px;
    border: 1px solid rgba(255, 215, 0, 0.3);
    font-weight: 900;
    font-size: 1.2rem;
    color: #ffcc00;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

/* Dual Requirements Display */
.skin-req-split {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-top: 10px;
    background: rgba(0,0,0,0.2);
    padding: 10px 20px;
    border-radius: 15px;
}

.req-item {
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 5px;
}

.req-divider {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.3);
    font-weight: 900;
    text-transform: uppercase;
}

.req-item.🪙 { color: #ffcc00; }

/* Buy Button Variants */
.buy-btn.affordable {
    background: linear-gradient(135deg, #ffcc00, #ff8800) !important;
    color: #000 !important;
    box-shadow: 0 5px 15px rgba(255, 204, 0, 0.4);
    transform: scale(1.05);
}

.buy-btn.affordable:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(255, 204, 0, 0.6);
}

.buy-btn.locked {
    background: rgba(255,255,255,0.05) !important;
    color: rgba(255,255,255,0.3) !important;
    border: 1px solid rgba(255,255,255,0.1);
    cursor: not-allowed;
}

/* Purchase Feedback Animation */
.purchase-flash {
    animation: purchaseSuccess 0.5s ease-out;
}

@keyframes purchaseSuccess {
    0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); transform: scale(1); }
    50% { box-shadow: 0 0 50px 20px rgba(255, 215, 0, 0.5); transform: scale(1.02); background: rgba(255,215,0,0.1); }
    100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); transform: scale(1); }
}

@media (max-width: 768px) {
    .coin-display {
        min-width: 60px;
        padding: 2px 8px;
    }
    .coin-display .label { font-size: 0.7rem; }
    .coin-display .value { font-size: 0.9rem; }
}

