/* css/game.css */

#screen-game {
    background: radial-gradient(circle, #25120e 0%, #0c0504 100%);
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
}

/* Panel HUD — Terpaku di bagian atas sasis */
#hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    background: rgba(18, 9, 7, 0.92);
    border: 1px solid #4a2d18;
    border-radius: 6px;
    padding: 10px 16px;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

#hud > div {
    font-family: 'Georgia', serif;
    font-size: 0.9rem;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Kanvas Utama Game — Berada di area tengah, fleksibel dan tidak 0x0 */
#game-canvas {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    height: 320px;
    max-width: calc(100% - 40px);
    max-height: 38%;
    aspect-ratio: 1 / 1;
    border: 1px solid var(--color-gold-dim, #b59410); /* Bingkai tipis emas kuno */
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.7);
    background: #120907;
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated; /* Rendering pixel tajam pada layar high-DPI */
    image-rendering: crisp-edges;
    z-index: 2;
}

/* Bottom controls layout wrapper */
.bottom-controls {
    position: absolute;
    bottom: 15px;
    left: 15px;
    right: 15px;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 12px;
    z-index: 10;
    pointer-events: none;
}

.controls-right {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: auto;
}

/* Kotak Log Pertarungan — Pojok kiri bawah untuk menghindari overlap dengan kontroler */
#combat-log {
    position: relative !important;
    bottom: 0 !important;
    left: 0 !important;
    width: auto !important;
    flex: 1;
    height: 140px !important;
    max-width: 210px;
    overflow-y: auto;
    background: rgba(10, 5, 5, 0.93);
    border: 1px solid #4a2d18;
    border-radius: 6px;
    padding: 10px;
    font-size: 0.75rem;
    font-family: 'Courier New', Courier, monospace;
    color: #f0e6df;
    z-index: 10;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.9);
    scrollbar-width: thin;
    scrollbar-color: #8e6d2b #120907;
    pointer-events: auto;
}

#combat-log::-webkit-scrollbar {
    width: 6px;
}
#combat-log::-webkit-scrollbar-track {
    background: #120907;
}
#combat-log::-webkit-scrollbar-thumb {
    background-color: #8e6d2b;
    border-radius: 3px;
}

.log-line {
    margin-bottom: 4px;
    line-height: 1.3;
    border-bottom: 1px dotted rgba(74, 45, 24, 0.2);
    padding-bottom: 2px;
}

.log-system { color: #8c7361; }
.log-combat { color: #ffd700; font-weight: bold; }
.log-enemy { color: #f87171; }
.log-victory { color: #4ade80; font-weight: bold; }

/* Control D-Pad — Pojok kanan bawah */
#dpad {
    position: relative !important;
    bottom: 0 !important;
    right: 0 !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}

.dpad-btn {
    width: 44px;
    height: 44px;
    margin: 1px;
    background: radial-gradient(circle, #3d1c12 0%, #220e09 100%);
    border: 2px solid #8e6d2b;
    border-radius: 50%;
    color: #ffd700;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.6);
    transition: all 0.1s ease;
    user-select: none;
}

.dpad-btn:active {
    background: #8e6d2b;
    color: #120907;
    transform: scale(0.92);
}

.dpad-row {
    display: flex;
}

#dpad-center {
    background: #120907;
    border-color: #4a2d18;
    color: #8c7361;
    cursor: default;
}
#dpad-center:active {
    transform: none;
    background: #120907;
    color: #8c7361;
}

/* Tombol Aksi Pertarungan — Ditumpuk vertikal di atas D-Pad kanan bawah */
#action-btns {
    position: relative !important;
    bottom: 0 !important;
    right: 0 !important;
    display: flex;
    flex-direction: row !important;
    gap: 8px;
    z-index: 10;
}

.action-btn {
    width: 44px;
    height: 44px;
    background: radial-gradient(circle, #4a0a0d 0%, #290406 100%);
    border: 2px solid #8e6d2b;
    border-radius: 50%;
    color: #ffd700;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.7);
    transition: all 0.2s ease;
    user-select: none;
}

.action-btn:hover {
    background: radial-gradient(circle, #611115 0%, #3a0609 100%);
    border-color: #ffd700;
    transform: translateY(-2px);
    box-shadow: 0 6px 14px rgba(255, 215, 0, 0.2);
}

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

/* Modifikasi Efek Aksi Selama Pertarungan Aktif */
#action-btns.combat-mode .action-btn {
    border-color: #b91c1c;
}

.glowing-combat-btn {
    border-color: #ffd700 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.6) !important;
    animation: attackPulse 1.2s infinite alternate;
}

@keyframes attackPulse {
    from {
        box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
        transform: scale(1);
    }
    to {
        box-shadow: 0 0 22px rgba(255, 215, 0, 0.9);
        transform: scale(1.06);
    }
}

/* Overlay HP Bar Musuh — Melayang persis di atas kanvas grafis */
#enemy-hp-bar-container {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 280px;
    background: rgba(18, 9, 7, 0.94);
    border: 2px solid #8e6d2b;
    border-radius: 6px;
    padding: 10px 14px;
    z-index: 100;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.85);
    display: none;
    text-align: center;
    backdrop-filter: blur(4px);
    border-top-color: #ffd700;
}

#enemy-hp-name {
    font-family: 'Georgia', serif;
    font-size: 0.95rem;
    font-weight: bold;
    color: #f0e6df;
    margin-bottom: 6px;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.9);
}

.text-elite {
    color: #f97316 !important;
    text-shadow: 0 0 8px rgba(249, 115, 22, 0.6) !important;
}

.hp-bar-outer {
    background: #1a0805;
    border: 1px solid #4a2d18;
    border-radius: 4px;
    overflow: hidden;
    height: 16px;
    margin-bottom: 4px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.8);
}

.hp-bar-inner {
    background: linear-gradient(90deg, #991b1b 0%, #dc2626 50%, #ef4444 100%);
    height: 100%;
    width: 100%;
    transition: width 0.25s cubic-bezier(0.1, 0.8, 0.3, 1);
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

#enemy-hp-text {
    font-family: monospace;
    font-size: 0.75rem;
    color: #b59410;
    font-weight: bold;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.8);
}

.flash-hit {
    animation: flashRed 0.2s 2 ease-in-out;
}

@keyframes flashRed {
    0% { border-color: #8e6d2b; background: rgba(18, 9, 7, 0.92); }
    50% { border-color: #ef4444; background: rgba(74, 10, 13, 0.95); }
    100% { border-color: #8e6d2b; background: rgba(18, 9, 7, 0.92); }
}

/* Optimasi Khusus untuk Layar Smartphone Asli (Kurang dari 480px) */
@media (max-width: 480px) {
    #hud {
        top: 10px;
        left: 10px;
        right: 10px;
        padding: 6px 12px;
    }
    
    #game-canvas {
        top: 75px;
        width: 280px;
        height: 280px;
    }
    
    #enemy-hp-bar-container {
        top: 85px;
        width: 250px;
    }

    /* Bottom controls are automatically positioned by the flex container */
}

/* ─── Visual Novel-style Cutscene Overlay ────────────────────────────────────── */

#cutscene-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.6s ease-out;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

#cutscene-overlay.active {
    opacity: 1;
}

.cutscene-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(12, 5, 4, 0.4) 30%, rgba(0, 0, 0, 0.85) 100%);
    pointer-events: none;
    z-index: -1;
}

.story-portrait {
    position: absolute;
    bottom: 220px; /* Di atas dialog box */
    left: 20px;
    width: 150px;
    height: 180px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: bottom center;
    z-index: 1;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.7));
    transform: translateY(50px);
    opacity: 0;
    transition: all 0.7s cubic-bezier(0.25, 1, 0.5, 1);
}

#cutscene-overlay.active .story-portrait {
    transform: translateY(0);
    opacity: 1;
}

.story-portrait.right {
    left: auto;
    right: 20px;
}

.story-dialog-box {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(30px);
    width: calc(100% - 40px);
    max-width: 380px;
    background: rgba(22, 11, 7, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 2px solid rgba(142, 109, 43, 0.6);
    border-radius: 12px;
    padding: 16px 20px;
    z-index: 2;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85), inset 0 0 15px rgba(142, 109, 43, 0.2);
    box-sizing: border-box;
    cursor: pointer;
    opacity: 0;
    transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#cutscene-overlay.active .story-dialog-box {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.story-name {
    font-family: 'Georgia', serif;
    font-size: 0.9rem;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
}

.story-text {
    font-family: 'Georgia', serif;
    font-size: 0.85rem;
    line-height: 1.5;
    color: #e8d4b8;
    min-height: 48px;
    word-wrap: break-word;
    white-space: pre-wrap;
    text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.8);
}

.story-continue-indicator {
    position: absolute;
    bottom: 12px;
    right: 16px;
    opacity: 0;
    transition: opacity 0.4s ease-out;
}

.story-continue-indicator .continue-arrow {
    color: #ffd700;
    font-size: 0.9rem;
    display: inline-block;
    animation: bounceArrow 0.8s infinite alternate;
}

@keyframes bounceArrow {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(4px);
    }
}

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

@keyframes dialogSlideUp {
    from {
        transform: translateX(-50%) translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@media (max-width: 480px) {
    #action-btns {
        bottom: 155px;
        right: 10px;
        gap: 6px;
    }
}

/* Quest / Objective HUD Styling */
#quest-hud {
    position: absolute;
    top: 425px;
    left: 20px;
    right: 20px;
    background: rgba(18, 9, 7, 0.92);
    border: 1px solid #4a2d18;
    border-radius: 6px;
    padding: 8px 12px;
    z-index: 10;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    border-top: 2px solid #8e6d2b;
}

.quest-header {
    font-family: 'Georgia', serif;
    font-size: 0.8rem;
    font-weight: bold;
    color: #ffd700;
    margin-bottom: 5px;
    border-bottom: 1px solid rgba(142, 109, 43, 0.4);
    padding-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.quest-item {
    font-size: 0.72rem;
    color: #f0e6df;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Courier New', Courier, monospace;
}

.quest-item.completed {
    color: #4ade80;
    text-decoration: line-through;
    opacity: 0.6;
}

.quest-item::before {
    font-weight: bold;
}

.quest-item.completed::before {
    content: "✓";
    color: #4ade80;
}

.quest-item.active::before {
    content: "○";
    color: #ffd700;
}

.artifact-item {
    font-size: 0.72rem;
    color: #f0e6df;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Courier New', Courier, monospace;
}

.artifact-item.completed {
    color: #4ade80;
    font-weight: bold;
}

.artifact-item.active {
    color: #8c7361;
}

/* ─── Window Combat (1-on-1 QTE) Styles ────────────────────────────────────── */

#combat-window {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 500;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.combat-overlay-vignette {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(12, 5, 4, 0.65) 20%, rgba(0, 0, 0, 0.95) 100%);
    pointer-events: none;
    z-index: 1;
}

.combat-card {
    position: relative;
    width: calc(100% - 40px);
    max-width: 380px;
    background: rgba(18, 9, 7, 0.94);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid rgba(142, 109, 43, 0.85);
    border-radius: 12px;
    padding: 20px;
    z-index: 2;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.95), inset 0 0 25px rgba(142, 109, 43, 0.15);
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 16px;
    animation: combatWindowPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes combatWindowPop {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.combat-header {
    text-align: center;
    border-bottom: 2px solid rgba(142, 109, 43, 0.4);
    padding-bottom: 8px;
}

.combat-title {
    font-family: 'Georgia', serif;
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffd700;
    letter-spacing: 0.15em;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.combatants {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 8px 0;
}

.combatant {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.player-side {
    border-left: 3px solid #0077b6;
}

.enemy-side {
    border-right: 3px solid #b91c1c;
}

.avatar-frame {
    width: 68px;
    height: 68px;
    border: 2px solid #8e6d2b;
    border-radius: 50%;
    background: radial-gradient(circle, #2a1a08 0%, #120907 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.8), 0 4px 8px rgba(0, 0, 0, 0.4);
}

.avatar-frame canvas {
    width: 64px;
    height: 64px;
    image-rendering: pixelated;
}

.combatant-info {
    text-align: center;
}

.combatant-name {
    font-family: 'Georgia', serif;
    font-size: 0.85rem;
    font-weight: bold;
    color: #f0e6df;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
}

.combatant-level {
    font-size: 0.7rem;
    color: #ffd700;
    opacity: 0.8;
    margin-top: 2px;
    font-weight: 600;
}

.combat-vs {
    font-family: 'Georgia', serif;
    font-size: 1.1rem;
    font-style: italic;
    font-weight: bold;
    color: #8e6d2b;
    text-shadow: 0 0 8px rgba(142, 109, 43, 0.5);
    animation: vsPulse 1.5s infinite alternate;
}

@keyframes vsPulse {
    from { transform: scale(0.9); opacity: 0.7; }
    to { transform: scale(1.1); opacity: 1; }
}

.hp-bar-wrapper {
    width: 100%;
    margin-top: 4px;
    text-align: center;
}

.hp-bar-wrapper .hp-bar-outer {
    height: 12px;
    margin-bottom: 2px;
    border-radius: 6px;
    background: #1a0805;
    border: 1px solid #4a2d18;
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.8);
}

.hp-bar-wrapper .hp-bar-inner {
    height: 100%;
    transition: width 0.2s cubic-bezier(0.1, 0.8, 0.3, 1);
}

.player-side .hp-bar-inner {
    background: linear-gradient(90deg, #0284c7 0%, #0ea5e9 100%);
    box-shadow: 0 0 4px rgba(14, 165, 233, 0.5);
}

.enemy-side .hp-bar-inner {
    background: linear-gradient(90deg, #991b1b 0%, #ef4444 100%);
    box-shadow: 0 0 4px rgba(239, 68, 68, 0.5);
}

.hp-bar-wrapper .hp-text {
    font-family: monospace;
    font-size: 0.7rem;
    color: #a1a1aa;
    font-weight: bold;
}

/* QTE Container & Hit Bar */
.qte-container {
    background: rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(142, 109, 43, 0.35);
    border-radius: 8px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    box-shadow: inset 0 2px 10px rgba(0,0,0,0.8);
}

.qte-instruction {
    font-size: 0.72rem;
    color: #e8d4b8;
    text-align: center;
    line-height: 1.4;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.9);
}

.qte-instruction .highlight {
    color: #ffd700;
    font-weight: bold;
    background: rgba(142, 109, 43, 0.2);
    padding: 2px 5px;
    border-radius: 3px;
    border: 1px solid rgba(142, 109, 43, 0.3);
}

.qte-hit-bar-outer {
    position: relative;
    width: 100%;
    height: 28px;
    background: linear-gradient(180deg, #22120e, #120907);
    border: 2px solid #4a2d18;
    border-radius: 14px;
    box-shadow: inset 0 4px 6px rgba(0,0,0,0.8), 0 2px 4px rgba(0,0,0,0.5);
    overflow: hidden;
    margin: 4px 0;
}

.qte-success-zone {
    position: absolute;
    top: 0;
    height: 100%;
    background: linear-gradient(180deg, #22c55e 0%, #15803d 100%);
    box-shadow: 0 0 12px rgba(34, 197, 94, 0.7);
    transition: all 0.3s ease;
}

.qte-marker {
    position: absolute;
    top: -2px;
    width: 6px;
    height: calc(100% + 4px);
    background: #ffffff;
    box-shadow: 0 0 8px #ffd700, 0 0 16px #f97316;
    border-radius: 3px;
    z-index: 10;
}

.qte-controls {
    display: flex;
    width: 100%;
    gap: 8px;
    margin-top: 4px;
}

.qte-btn {
    flex: 2;
    padding: 10px 14px;
    background: radial-gradient(circle, #4a0a0d 0%, #290406 100%);
    border: 2px solid #8e6d2b;
    border-radius: 6px;
    color: #ffd700;
    font-size: 0.85rem;
    font-weight: bold;
    font-family: 'Georgia', serif;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    transition: all 0.15s ease;
    user-select: none;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.9);
}

.qte-btn:hover {
    background: radial-gradient(circle, #611115 0%, #3a0609 100%);
    border-color: #ffd700;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.qte-btn:active {
    transform: scale(0.96);
}

.qte-btn.flee-btn {
    flex: 1;
    background: radial-gradient(circle, #2a1a08 0%, #120907 100%);
    border-color: #4a2d18;
    color: #8c7361;
}

.qte-btn.flee-btn:hover {
    background: radial-gradient(circle, #3d2511 0%, #1e1104 100%);
    border-color: #8e6d2b;
    color: #e8d4b8;
}

/* Combat Feedback Overlay (Damage Popup) */
.combat-feedback {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.feedback-text {
    font-family: 'Georgia', serif;
    font-size: 1.8rem;
    font-weight: 900;
    text-shadow: 2px 2px 0px #000, -2px -2px 0px #000, 2px -2px 0px #000, -2px 2px 0px #000, 0px 4px 10px rgba(0,0,0,0.8);
    letter-spacing: 0.05em;
    animation: feedbackSlideUp 0.9s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

.feedback-hit {
    color: #4ade80; /* Hijau sukses */
}

.feedback-crit {
    color: #ffd700; /* Gold */
    font-size: 2.2rem;
    animation: feedbackCritBounce 0.9s ease-out forwards;
}

.feedback-miss {
    color: #ef4444; /* Merah gagal */
}

.feedback-damage {
    font-size: 2rem;
}

@keyframes feedbackSlideUp {
    0% {
        transform: translateY(20px) scale(0.6);
        opacity: 0;
    }
    15% {
        transform: translateY(0) scale(1.1);
        opacity: 1;
    }
    30% {
        transform: translateY(-5px) scale(1);
        opacity: 1;
    }
    80% {
        transform: translateY(-15px) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-30px) scale(0.9);
        opacity: 0;
    }
}

@keyframes feedbackCritBounce {
    0% {
        transform: translateY(20px) scale(0.5);
        opacity: 0;
    }
    20% {
        transform: translateY(-10px) scale(1.3);
        opacity: 1;
    }
    40% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    80% {
        transform: translateY(-15px) scale(1);
        opacity: 0.8;
    }
    100% {
        transform: translateY(-30px) scale(0.8);
        opacity: 0;
    }
}

/* Screen Shake Effect */
.shake-screen {
    animation: screenShake 0.4s ease-in-out;
}

@keyframes screenShake {
    0%, 100% { transform: translate(0, 0) translate(-50%, -50%); }
    10% { transform: translate(-4px, 2px) translate(-50%, -50%); }
    20% { transform: translate(3px, -3px) translate(-50%, -50%); }
    30% { transform: translate(-2px, -2px) translate(-50%, -50%); }
    40% { transform: translate(3px, 2px) translate(-50%, -50%); }
    50% { transform: translate(-3px, -1px) translate(-50%, -50%); }
    60% { transform: translate(2px, 3px) translate(-50%, -50%); }
    70% { transform: translate(-2px, -2px) translate(-50%, -50%); }
    80% { transform: translate(3px, 1px) translate(-50%, -50%); }
    90% { transform: translate(-1px, 2px) translate(-50%, -50%); }
}

@media (max-width: 480px) {
    #combat-window {
        width: 100%;
        height: 100%;
    }
    
    .combat-card {
        width: calc(100% - 20px);
        padding: 14px;
        gap: 12px;
    }
    
    .avatar-frame {
        width: 52px;
        height: 52px;
    }
    
    .avatar-frame canvas {
        width: 48px;
        height: 48px;
    }
    
    .qte-container {
        padding: 10px;
        gap: 8px;
    }
    
    .qte-hit-bar-outer {
        height: 24px;
    }
    
    .qte-btn {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}

/* ─── Layar Game Over (Petualangan Berakhir) Beautification ────────────────── */
#screen-gameover {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: 100% !important;
    max-height: 100% !important;
    transform: none !important;
    background: radial-gradient(circle, #1a0505 0%, #000000 100%) !important;
    display: none; /* Dikontrol jQuery fadeIn */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999 !important;
    box-sizing: border-box;
    padding: 30px;
    backdrop-filter: blur(8px);
}

#screen-gameover.active {
    display: flex !important;
}

#screen-gameover h2 {
    font-family: 'Georgia', serif;
    font-size: 2.3rem;
    color: #ffd700;
    margin-top: 0;
    margin-bottom: 20px;
    text-shadow: 0 0 15px rgba(255, 0, 0, 0.85), 0 0 30px #000;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center;
    animation: fadeInDown 1s ease-out;
}

#screen-gameover #gameover-summary {
    color: #dddddd;
    font-style: italic;
    font-size: 1.1rem;
    margin-bottom: 35px;
    text-align: center;
    max-width: 90%;
    line-height: 1.6;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
    animation: fadeInDown 1.2s ease-out;
}

#screen-gameover .gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    justify-content: center;
    align-items: center;
    width: 100%;
    animation: fadeInDown 1.4s ease-out;
}

#screen-gameover .menu-btn {
    padding: 12px 20px !important;
    font-size: 0.95rem !important;
    font-weight: bold;
    color: #ffffff !important;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 6px !important;
    cursor: pointer;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.6) !important;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
    text-transform: uppercase;
    letter-spacing: 1.8px;
    outline: none;
    transform: none;
    width: 80% !important;
    max-width: none !important;
}

#screen-gameover .menu-btn:hover {
    background: rgba(139, 0, 0, 0.75) !important;
    border-color: rgba(255, 50, 50, 0.6) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 8px 20px rgba(255, 0, 0, 0.4) !important;
    color: #ffffff !important;
}

#screen-gameover .menu-btn:active {
    transform: scale(0.97) !important;
}

/* ─── Tombol Kembali Layar Kredit (Credits Screen) ────────────────────────── */
#btn-close-credits {
    padding: 10px 20px !important;
    font-size: 0.95rem !important;
    font-weight: bold;
    color: #ffffff !important;
    background: rgba(212, 175, 55, 0.2) !important;
    border: 1px solid #d4af37 !important;
    border-radius: 4px !important;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4) !important;
    transition: all 0.3s ease !important;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    outline: none;
    transform: none;
    width: auto !important;
    max-width: none !important;
}

#btn-close-credits:hover {
    background: rgba(212, 175, 55, 0.5) !important;
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.6) !important;
    transform: translateY(-1px) !important;
}

#btn-close-credits:active {
    transform: translateY(1px) !important;
}

/* ─── Layar Jeda (Pause Screen) Polishing ─────────────────────────────────── */
.pause-screen {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.85) !important;
    z-index: 9999 !important;
    display: none; /* Dikontrol jQuery/JS */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    padding: 30px;
    backdrop-filter: blur(8px);
}

.pause-screen h2 {
    font-family: 'Georgia', serif;
    font-size: 2.8rem;
    color: #d4af37;
    margin-top: 0;
    margin-bottom: 30px;
    text-shadow: 0 0 10px rgba(212, 175, 55, 0.6);
    letter-spacing: 3px;
    text-transform: uppercase;
    text-align: center;
}

.pause-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
    justify-content: center;
    align-items: center;
    width: 100%;
}

.pause-buttons .menu-btn {
    padding: 12px 30px !important;
    font-size: 1rem !important;
    font-weight: bold;
    color: #ffd700 !important;
    background: rgba(30, 20, 10, 0.6) !important;
    border: 1px solid #d4af37 !important;
    border-radius: 4px !important;
    cursor: pointer;
    min-width: 180px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5) !important;
    transition: all 0.3s ease !important;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    outline: none;
    transform: none;
    width: auto !important;
    max-width: none !important;
}

.pause-buttons .menu-btn:hover {
    background: rgba(212, 175, 55, 0.3) !important;
    border-color: #ffd700 !important;
    box-shadow: 0 0 15px rgba(212, 175, 55, 0.4) !important;
    color: #ffffff !important;
    transform: scale(1.05) !important;
}

.pause-buttons .menu-btn:active {
    transform: scale(0.97) !important;
}