* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    outline: none;
    box-sizing: border-box;
}

body {
    margin: 0;
    overflow: hidden;
    background: #050505;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: none;
}

canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

#ui {
    position: absolute;
    top: 5vh;
    left: 0;
    width: 100%;
    color: #fff;
    text-align: center;
    pointer-events: none;
    z-index: 20;
    text-shadow: 0 0 10px #0ff;
}

#level-counter {
    font-size: clamp(1.5rem, 5vw, 3rem);
    font-weight: 900;
    letter-spacing: 5px;
    color: #e0ffff;
}

#hint {
    font-size: clamp(0.6rem, 3vw, 1rem);
    margin-top: 5px;
    background: rgba(0, 20, 20, 0.8);
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    text-transform: uppercase;
    border: 1px solid #0ff;
    box-shadow: 0 0 5px #0ff;
    transition: all 0.3s ease;
}

.top-btn {
    position: absolute;
    top: 20px;
    width: 45px;
    height: 45px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #0ff;
    color: #0ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    z-index: 40;
    pointer-events: auto;
    box-shadow: 0 0 10px #0ff;
    transition: transform 0.2s, background 0.2s;
}

.top-btn:active {
    transform: scale(0.9);
    background: rgba(0, 255, 255, 0.2);
}

#btn-info {
    right: 20px;
}

#btn-custom {
    right: 75px;
    font-size: 18px;
}

#guide-overlay,
#finish-screen,
#custom-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    color: #fff;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 100;
    text-align: center;
}

#finish-screen {
    background: linear-gradient(135deg, #fff 0%, #ddd 100%);
    color: #000;
}

#finish-screen h1 {
    font-size: clamp(1.5rem, 6vw, 3rem);
    margin-bottom: 10px;
}

#custom-overlay {
    justify-content: flex-start;
    padding-top: 50px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.custom-box {
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid #0ff;
    padding: 20px;
    border-radius: 10px;
    width: 100%;
    max-width: 500px;
    margin-bottom: 20px;
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
    flex-shrink: 0;
    text-align: left;
}

.custom-box h3 {
    margin-top: 0;
    text-align: center;
    color: #0ff;
    border-bottom: 1px solid #333;
    padding-bottom: 10px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: #ccc;
    margin-bottom: 5px;
}

.input-group input[type="text"],
.input-group select {
    width: 100%;
    padding: 10px;
    background: #000;
    border: 1px solid #555;
    color: #fff;
    border-radius: 5px;
    font-family: monospace;
    font-size: 0.9rem;
}

.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.setting-row label {
    color: #fff;
    font-size: 0.9rem;
}

input[type="checkbox"] {
    width: 22px;
    height: 22px;
    accent-color: #0ff;
    cursor: pointer;
}

input[type="range"] {
    width: 100%;
    accent-color: #0ff;
    height: 5px;
    margin-top: 5px;
    cursor: pointer;
}

.id-display {
    font-family: monospace;
    font-size: 1.1rem;
    color: #ff0;
    text-align: center;
    background: #222;
    padding: 8px 12px;
    border-radius: 5px;
    user-select: text;
    -webkit-user-select: text;
    word-break: break-all;
}

.action-btn {
    margin-top: 15px;
    padding: 12px 30px;
    border: none;
    border-radius: 30px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    width: 100%;
    text-transform: uppercase;
    transition: transform 0.2s, opacity 0.2s;
}

.action-btn:active {
    transform: scale(0.97);
}

.start-btn {
    background: #0ff;
    color: #000;
    box-shadow: 0 0 15px #0ff;
}

.restart-btn {
    background: #333;
    color: #fff;
    border: 1px solid #666;
}

.save-btn {
    background: #0f0;
    color: #000;
    margin-top: 0;
}

.load-btn {
    background: #ff0;
    color: #000;
}

.close-btn {
    background: #f00;
    color: #fff;
    margin-bottom: 30px;
}

/* JOYSTICK - POSISI DIPERBAIKI (LEBIH KE ATAS) */
#joystick-container {
    position: absolute;
    bottom: 20vh;  /* Diubah dari 8vh menjadi 20vh (lebih ke atas) */
    left: 8vw;
    width: 110px;
    height: 110px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    border: 2px solid rgba(0, 255, 255, 0.5);
    z-index: 30;
    backdrop-filter: blur(3px);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

#joystick-knob {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 45px;
    height: 45px;
    background: radial-gradient(circle, #0ff, #0088aa);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 15px #0ff;
    transition: transform 0.05s ease;
}

#message {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    text-align: center;
    font-size: clamp(1.5rem, 6vw, 3rem);
    opacity: 0;
    transition: opacity 0.3s;
    z-index: 25;
    font-weight: bold;
    text-shadow: 0 0 20px #000;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 20px;
    letter-spacing: 2px;
}

#loading {
    position: fixed;
    inset: 0;
    background: #000;
    color: #0ff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 200;
    font-family: monospace;
    letter-spacing: 2px;
}

.loader {
    width: 60px;
    height: 60px;
    border: 3px solid transparent;
    border-top: 3px solid #0ff;
    border-right: 3px solid #0ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#pursuer-video {
    display: none;
}

/* Responsive untuk layar kecil */
@media (max-width: 600px) {
    .top-btn {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
    
    #btn-custom {
        right: 65px;
    }
    
    #joystick-container {
        width: 90px;
        height: 90px;
        bottom: 18vh;  /* Sesuaikan untuk layar kecil */
        left: 6vw;
    }
    
    #joystick-knob {
        width: 38px;
        height: 38px;
    }
    
    .custom-box {
        padding: 15px;
    }
    
    .action-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

/* Untuk tablet */
@media (min-width: 601px) and (max-width: 1024px) {
    #joystick-container {
        bottom: 22vh;
    }
}

/* Untuk landscape mode di HP */
@media (orientation: landscape) and (max-height: 500px) {
    #joystick-container {
        bottom: 15vh;
        width: 80px;
        height: 80px;
    }
    
    #joystick-knob {
        width: 35px;
        height: 35px;
    }
}