/* ============================================
   BOMBSKUY: GEMA RESOLUSI JIHAD — CUSTOM CSS
   ============================================ */

/* ============================================
   CSS VARIABLES (THEME)
   ============================================ */
:root {
    --merah-putih: #CC0001;
    --emas-perjuangan: #D4A017;
    --hijau-hutan: #2D5016;
    --coklat-tanah: #6B3A2A;
    --krem-tua: #F5E6C8;
    --hitam-malam: #1A1008;
    --abu-batu: #4A4035;
    --putih-bersih: #FDF8EE;
}

/* ============================================
   BASE RESETS & GLOBAL
   ============================================ */
* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    overflow: hidden;
    touch-action: manipulation;
}

/* ============================================
   SCREEN TRANSITIONS
   ============================================ */
.screen {
    transition: opacity 0.4s ease-in-out;
}

.screen.hidden {
    display: none !important;
}

.screen-enter {
    animation: screenFadeIn 0.5s ease-out forwards;
}

@keyframes screenFadeIn {
    from {
        opacity: 0;
        transform: perspective(800px) rotateY(-5deg);
    }
    to {
        opacity: 1;
        transform: perspective(800px) rotateY(0deg);
    }
}

/* ============================================
   MENU BUTTONS
   ============================================ */
.menu-btn {
    background: linear-gradient(180deg, #8B6914 0%, #6B3A2A 50%, #4A2518 100%);
    color: var(--krem-tua);
    font-family: 'Special Elite', cursive;
    font-size: 1rem;
    padding: 0.7rem 1.5rem;
    border: 2px solid rgba(212, 160, 23, 0.5);
    border-radius: 0.6rem;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.25s ease;
    text-align: center;
    letter-spacing: 0.05em;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.menu-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(212, 160, 23, 0.15), transparent);
    transition: left 0.5s ease;
}

.menu-btn:hover {
    transform: translateY(-2px) scale(1.02);
    border-color: var(--emas-perjuangan);
    box-shadow: 0 6px 20px rgba(212, 160, 23, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.menu-btn:hover::before {
    left: 100%;
}

.menu-btn:active {
    transform: translateY(1px) scale(0.98);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* ============================================
   PARCHMENT / PAPER EFFECT
   ============================================ */
.parchment-box {
    background: linear-gradient(145deg,
        rgba(245, 230, 200, 0.12) 0%,
        rgba(107, 58, 42, 0.15) 50%,
        rgba(26, 16, 8, 0.2) 100%);
    border: 1px solid rgba(212, 160, 23, 0.25);
    box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.3),
                0 4px 20px rgba(0, 0, 0, 0.4);
    position: relative;
}

.parchment-box::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
    border-radius: inherit;
    pointer-events: none;
}

/* ============================================
   CHAPTER CARDS
   ============================================ */
.chapter-card {
    background: linear-gradient(135deg, rgba(107, 58, 42, 0.4), rgba(26, 16, 8, 0.6));
    border: 1px solid rgba(212, 160, 23, 0.3);
    border-radius: 0.75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.chapter-card:hover:not(.locked) {
    transform: translateY(-3px);
    border-color: var(--emas-perjuangan);
    box-shadow: 0 8px 25px rgba(212, 160, 23, 0.2);
}

.chapter-card.locked {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.chapter-card .chapter-icon {
    font-size: 2rem;
    float: left;
    margin-right: 0.75rem;
}

.chapter-card .chapter-lock {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    font-size: 1.2rem;
}

.room-badge {
    display: inline-block;
    font-size: 0.65rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    background: rgba(74, 64, 53, 0.5);
    color: var(--krem-tua);
    border: 1px solid rgba(212, 160, 23, 0.2);
}

.room-badge.completed {
    background: rgba(45, 80, 22, 0.5);
    border-color: rgba(45, 80, 22, 0.6);
    color: #a8d88a;
}

.room-badge.current {
    background: rgba(212, 160, 23, 0.25);
    border-color: var(--emas-perjuangan);
    color: var(--emas-perjuangan);
}

/* ============================================
   TYPEWRITER CURSOR
   ============================================ */
.typewriter-cursor::after {
    content: '▌';
    animation: blink 0.8s step-end infinite;
    color: var(--emas-perjuangan);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ============================================
   D-PAD CONTROLS
   ============================================ */
.dpad-btn {
    position: absolute;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.1s ease, opacity 0.15s ease;
    opacity: 0.85;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.dpad-btn:active,
.dpad-btn.pressed {
    transform: scale(0.85);
    opacity: 1;
}

.dpad-up {
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-down {
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.dpad-left {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
}

.dpad-right {
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.dpad-up:active, .dpad-up.pressed { transform: translateX(-50%) scale(0.85); }
.dpad-down:active, .dpad-down.pressed { transform: translateX(-50%) scale(0.85); }
.dpad-left:active, .dpad-left.pressed { transform: translateY(-50%) scale(0.85); }
.dpad-right:active, .dpad-right.pressed { transform: translateY(-50%) scale(0.85); }

/* ============================================
   TOGGLE SWITCH
   ============================================ */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

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

.toggle-slider {
    position: absolute;
    inset: 0;
    background-color: var(--abu-batu);
    border-radius: 24px;
    cursor: pointer;
    transition: 0.3s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: var(--krem-tua);
    border-radius: 50%;
    transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--emas-perjuangan);
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(24px);
}

/* ============================================
   GAME TITLE GLOW
   ============================================ */
#game-title {
    text-shadow:
        0 0 10px rgba(204, 0, 1, 0.6),
        0 0 20px rgba(204, 0, 1, 0.4),
        0 0 40px rgba(212, 160, 23, 0.3);
    animation: titleGlow 2.5s ease-in-out infinite alternate;
}

@keyframes titleGlow {
    0% {
        text-shadow:
            0 0 10px rgba(204, 0, 1, 0.6),
            0 0 20px rgba(204, 0, 1, 0.4),
            0 0 40px rgba(212, 160, 23, 0.3);
        filter: brightness(1);
    }
    100% {
        text-shadow:
            0 0 20px rgba(212, 160, 23, 0.7),
            0 0 40px rgba(212, 160, 23, 0.5),
            0 0 60px rgba(204, 0, 1, 0.4);
        filter: brightness(1.1);
    }
}

/* ============================================
   CREDITS SCROLL
   ============================================ */
.credits-scroll {
    animation: creditsScroll 1s ease-out forwards;
}

@keyframes creditsScroll {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   RANGE INPUT CUSTOM
   ============================================ */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--abu-batu);
    outline: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--emas-perjuangan);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transition: transform 0.15s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--emas-perjuangan);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ============================================
   PHASER CANVAS STYLING
   ============================================ */
#game-container canvas {
    display: block;
    image-rendering: pixelated;
    border: 2px solid rgba(212, 160, 23, 0.35);
    border-radius: 6px;
    box-shadow: 
        0 0 15px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(0, 0, 0, 0.3),
        inset 0 0 20px rgba(0, 0, 0, 0.2),
        0 0 8px rgba(212, 160, 23, 0.1);
}

/* ============================================
   GRADIENTS & UTILITIES
   ============================================ */
.bg-gradient-radial {
    background: radial-gradient(ellipse at center, var(--tw-gradient-from), var(--tw-gradient-via), var(--tw-gradient-to));
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: var(--hitam-malam);
}
::-webkit-scrollbar-thumb {
    background: var(--abu-batu);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--emas-perjuangan);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
    .menu-btn {
        font-size: 0.875rem;
        padding: 0.6rem 1rem;
    }

    #game-title {
        font-size: 2.5rem !important;
    }
}

@media (max-height: 500px) {
    .menu-btn {
        font-size: 0.75rem !important;
        padding: 0.35rem 1rem !important;
    }

    #game-title {
        font-size: 2.5rem !important;
    }
    
    #screen-mainmenu .relative.z-10 {
        gap: 0.5rem !important;
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    #screen-mainmenu .flex.flex-col.gap-2 {
        gap: 0.35rem !important;
    }
    
    #screen-mainmenu h2 {
        font-size: 0.9rem !important;
        margin-top: 0 !important;
    }
    
    #best-score-widget {
        margin-top: 0.25rem !important;
        padding: 0.25rem 0.5rem !important;
    }
}

/* Desktop hiding rule removed to allow JS settings control */

/* ============================================
   SETTINGS MODAL NEW STYLES
   ============================================ */
.control-style-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    background: rgba(74, 64, 53, 0.4);
    border: 1px solid rgba(212, 160, 23, 0.3);
    border-radius: 0.5rem;
    color: var(--krem-tua);
    transition: all 0.2s ease;
    cursor: pointer;
}

.control-style-btn:hover {
    background: rgba(107, 58, 42, 0.6);
}

.control-style-btn.active {
    background: rgba(212, 160, 23, 0.2);
    border-color: var(--emas-perjuangan);
    box-shadow: 0 0 10px rgba(212, 160, 23, 0.2);
}

.control-style-icon {
    font-size: 1.5rem;
}

.control-style-label {
    font-size: 0.75rem;
    font-family: 'Oswald', sans-serif;
    letter-spacing: 0.05em;
}

.joystick-style-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem;
    background: transparent;
    border: 2px solid transparent;
    border-radius: 0.5rem;
    color: var(--krem-tua);
    transition: all 0.2s ease;
    cursor: pointer;
}

.joystick-style-btn:hover {
    background: rgba(74, 64, 53, 0.3);
}

.joystick-style-btn.active {
    border-color: var(--emas-perjuangan);
    background: rgba(212, 160, 23, 0.1);
}

.joystick-style-label {
    font-size: 0.7rem;
    font-family: 'Oswald', sans-serif;
}

/* ============================================
   JOYSTICK VIRTUAL CONTROL
   ============================================ */
.joystick-handle-centered {
    transition: top 0.1s, left 0.1s;
}

/* ============================================
   ADVANCED IN-GAME SETTINGS
   ============================================ */
#dpad-container, #joystick-container {
    transform-origin: bottom left;
    transition: transform 0.2s ease, bottom 0.2s ease, left 0.2s ease;
}

#btn-bomb-mobile {
    transform-origin: bottom right;
    transition: transform 0.2s ease, bottom 0.2s ease, right 0.2s ease;
}
