:root {
    --primary: #990000;
    --secondary: #111111;
    --accent: #ff3333;
    --glass: rgba(15, 0, 0, 0.8);
    --glass-border: rgba(255, 0, 0, 0.25);
    --btn-scale: 1.0;
    --run-left: -150px;
    --run-right: 90vw;
}

body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle at center, transparent 30%, rgba(10, 0, 0, 0.9) 100%); /* Trả lại độ tối cũ (Vignette 90%) */
    pointer-events: none;
    z-index: 1; /* Chuyển xuống dưới lớp UI */
}

body {
    margin: 0;
    width: 100%;
    height: 100%;
    position: fixed;
    overflow: hidden;
    background: #050505;
    font-family: 'Outfit', sans-serif;
    user-select: none;
    touch-action: none;
    color: #fff;
}

.damage-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: radial-gradient(circle, transparent 20%, rgba(139, 0, 0, 0.4) 100%);
    pointer-events: none; z-index: 1000;
    opacity: 0; transition: opacity 0.1s;
}
.taking-damage .damage-overlay { opacity: 1; }

.history-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    padding: 12px 18px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    text-align: left;
    backdrop-filter: blur(10px);
    transition: transform 0.2s;
}
.history-item:hover { transform: scale(1.02); }


.scope-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    display: none; pointer-events: none; z-index: 200;
    background: radial-gradient(circle 35vh at center, transparent 35vh, rgba(0,0,0,0.6) 35.1vh);
}

.scope-lens {
    position: absolute; top: 50%; left: 50%; width: 70vh; height: 70vh;
    transform: translate(-50%, -50%); border: 4px solid #111; border-radius: 50%;
    background: rgba(0, 50, 100, 0.05); /* Subtle lens tint */
    box-shadow: inset 0 0 50px rgba(0,0,0,0.5);
}
.scope-cross-h, .scope-cross-v {
    position: absolute; top: 50%; left: 50%; background: #ff0000; opacity: 0.8;
}
.scope-cross-h { width: 50vh; height: 1.5px; transform: translate(-50%, -50%); }
.scope-cross-v { width: 1.5px; height: 50vh; transform: translate(-50%, -50%); }



canvas {
    display: block;
    width: 100vw;
    height: 100vh;
}

/* UI Overlay */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: none;
}

/* HUD Glassmorphism */
.hud-panel {
    position: absolute;
    pointer-events: none;
    background: var(--glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}


#crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    border: 2px solid #00ffcc;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0, 255, 204, 0.5);
    transition: transform 0.1s ease, border-color 0.1s ease;
    z-index: 100;
}
#crosshair::before, #crosshair::after {
    content: "";
    position: absolute;
    background: #00ffcc;
}
/* Thêm các vạch nhỏ cho ngầu */
#crosshair::before { top: 50%; left: -5px; width: 4px; height: 2px; transform: translateY(-50%); }
#crosshair::after { top: 50%; right: -5px; width: 4px; height: 2px; transform: translateY(-50%); }

#health-bar-container {
    bottom: 30px;
    left: 30px;
    width: 200px;
    height: 15px;
    padding: 4px;
    overflow: hidden;
    pointer-events: none;
    z-index: 2000;
    scale: var(--btn-scale, 1.0);
}

#health-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #ff3366, #ff66b2);
    border-radius: 6px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 15px rgba(255, 51, 102, 0.4);
}

#armor-bar-container {
    bottom: 75px;
    left: 30px;
    width: 150px;
    height: 10px;
    padding: 3px;
    pointer-events: none;
    z-index: 2000;
    scale: var(--btn-scale, 1.0);
}

#armor-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #3366ff, #00d4ff);
    border-radius: 4px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(51, 102, 255, 0.4);
}

#ammo-display {
    top: 50%;
    right: 20px;
    transform: translateY(-50%);
    font-size: 24px;
    font-weight: 900;
    text-align: right;
    letter-spacing: -2px;
    padding: 5px 10px;
    pointer-events: auto;
    z-index: 2000;
    scale: var(--btn-scale, 1.0);
}

#weapon-name {
    font-size: 14px;
    color: #aaa;
    font-weight: 400;
    letter-spacing: 2px;
}

#stats-display {
    position: absolute;
    top: 60px;
    right: 10px;
    text-align: right;
    font-size: 11px;
    font-weight: 700;
    pointer-events: auto;
    z-index: 2000;
    scale: var(--btn-scale, 1.0);
    background: rgba(0,0,0,0.5);
    padding: 5px 10px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
}

#stats-display div span {
    color: var(--accent);
}

#zone-timer {
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 14px;
    padding: 6px 15px;
    letter-spacing: 1px;
}

#zone-warning {
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    color: #ff3333;
    display: none;
    animation: blinkHud 0.8s infinite;
    font-weight: 900;
    text-shadow: 0 0 10px rgba(255, 0, 0, 0.5);
}

#interaction-msg {
    top: 65%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 24px;
    color: var(--accent);
    display: none;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 30px;
    border: 1px solid var(--accent);
}

#kill-feed {
    bottom: 80px;
    left: 20px;
    font-size: 10px;
    color: rgba(255,255,255,0.7);
    display: flex;
    flex-direction: column;
    gap: 4px;
    pointer-events: none;
}

#pickup-msg {
    position: fixed;
    top: 18%;
    left: 50%;
    transform: translate(-50%, -10px) scale(0.9);
    font-size: 16px;
    color: #fff;
    font-weight: 900;
    opacity: 0;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    background: rgba(10, 10, 10, 0.9);
    padding: 8px 20px;
    border-radius: 8px;
    border: 1px solid #00ffaa;
    z-index: 9999;
    pointer-events: none;
    backdrop-filter: blur(8px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

#pickup-msg.show {
    opacity: 1 !important;
    transform: translate(-50%, 0) scale(1);
}

/* New Fun UI Elements */
#streak-msg {
    top: 25%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 14px;
    color: #ff00ff;
    font-weight: 900;
    text-shadow: 1px 1px 0 #000;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    text-align: center;
}

#global-announcement {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translate(-50%, 0) scale(0);
    width: auto;
    min-width: 150px;
    padding: 6px 16px;
    background: rgba(139, 0, 0, 0.85);
    border: 1px solid #ff0000;
    color: #fff;
    text-align: center;
    font-weight: 900;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 1px;
    z-index: 9999;
    pointer-events: none;
    backdrop-filter: blur(10px);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.4);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    opacity: 0;
}

#global-announcement.show {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
}





#minimap-container {
    top: 20px;
    left: 20px;
    width: 120px;
    height: 120px;
    border: 2px solid rgba(255, 255, 255, 0.5); /* Viền sáng hơn */
    background: rgba(255, 255, 255, 0.1);      /* Nền trong suốt sáng */
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    z-index: 1000; /* Đảm bảo nằm trên lớp bóng tối */
}

#minimap {
    width: 100%;
    height: 100%;
    opacity: 0.8;
}

/* Hurt/Hit Feedback */
#damage-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 0 0 rgba(255, 0, 0, 0);
    transition: box-shadow 0.1s;
    pointer-events: none;
    z-index: 999;
}

#powerup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 998;
    opacity: 0;
    transition: opacity 0.3s, box-shadow 0.3s;
    box-shadow: inset 0 0 0 0 rgba(0, 255, 255, 0);
}

#powerup-overlay.active {
    opacity: 1;
    animation: puPulse 2s infinite ease-in-out;
}

@keyframes puPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.5); }
}

#hit-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
}

/* Menus */
.menu-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at center, #1a1a2e 0%, #0a0a0a 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;   /* tránh center che nội dung khi tràn */
    align-items: center;
    pointer-events: auto;
    z-index: 1000;
    transition: opacity 0.5s;
    overflow-y: auto;              /* cho phép scroll khi nội dung dài hơn màn hình */
    overflow-x: hidden;
    padding: 40px 16px 30px;       /* padding trên/dưới để nội dung không bị cắt */
    box-sizing: border-box;
}

.menu-title {
    font-size: clamp(28px, 7vw, 80px);
    font-weight: 900;
    background: linear-gradient(to bottom, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: -2px;
    font-style: normal;
    animation: titleFloat 3s ease-in-out infinite;
    text-align: center;
    width: 100%;
    flex-shrink: 0;   /* không bị ép nhỏ bởi flexbox */
}

@keyframes titleFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }  /* giảm bounce để không bị cắt */
}

/* --- BOSS EVENT STYLES --- */
#boss-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 5000;
    opacity: 0;
    transition: opacity 2s;
    pointer-events: none;
}

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

#boss-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5001;
    text-align: center;
    pointer-events: none;
}

#boss-visual {
    font-size: 200px;
    filter: drop-shadow(0 0 50px red);
    opacity: 0;
    transform: scale(0.5);
}

.boss-appear {
    animation: bossFadeScale 5s forwards;
}

@keyframes bossFadeScale {
    0% { opacity: 0; transform: scale(0.5); }
    100% { opacity: 1; transform: scale(1.5); }
}

/* --- UI CLEANUP v18.3.2 --- */


#boss-msg {
    color: #ff3300;
    font-size: 48px;
    font-weight: 900;
    text-shadow: 0 0 20px #000;
    opacity: 0;
    margin-top: 20px;
}

.boss-text-show {
    opacity: 1 !important;
    transition: opacity 0.5s;
    animation: textGlitch 0.2s infinite;
}

@keyframes textGlitch {
    0% { transform: translate(0) skew(0deg); color: #ff3300; }
    20% { transform: translate(-2px, 2px) skew(5deg); color: #ff00ff; }
    40% { transform: translate(2px, -2px) skew(-5deg); color: #00ffff; }
    60% { transform: translate(-2px, -2px) skew(2deg); color: #ffff00; }
    100% { transform: translate(0) skew(0deg); color: #ff3300; }
}

#boss-hp-container {
    box-shadow: 0 0 30px rgba(255, 0, 0, 0.8);
    border: 4px solid #330000 !important;
    background: rgba(0, 0, 0, 0.9) !important;
}

#boss-hp-fill {
    background: linear-gradient(90deg, #660000, #ff0000, #660000) !important;
    background-size: 200% 100% !important;
    animation: hpFlow 2s linear infinite;
}

@keyframes hpFlow {
    0% { background-position: 200% 0; }
    100% { background-position: 0% 0; }
}


/* Screen Shake Animation */
.shake-screen {
    animation: screenShake 0.2s infinite;
}

@keyframes screenShake {
    0% { transform: translate(2px, 1px) rotate(0deg); }
    20% { transform: translate(-3px, -2px) rotate(-1deg); }
    40% { transform: translate(-1px, 0px) rotate(1deg); }
    60% { transform: translate(3px, 2px) rotate(0deg); }
    80% { transform: translate(1px, -1px) rotate(1deg); }
    100% { transform: translate(-2px, 1px) rotate(-1deg); }
}

/* ------------------------- */

.menu-btn {
    padding: 14px 32px;
    margin: 6px 0;
    font-size: clamp(13px, 3.2vw, 20px);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    border-radius: 50px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 700;
    letter-spacing: 1px;
    backdrop-filter: blur(5px);
    text-transform: uppercase;
    font-family: 'Outfit', sans-serif;
    box-sizing: border-box;
    white-space: normal;    /* cho phép text xuống dòng */
    word-break: break-word;
    line-height: 1.3;
}

.menu-btn:hover {
    background: #fff;
    color: #000;
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 10px 30px rgba(255, 255, 255, 0.2);
}

.menu-btn:active { transform: translateY(0); }

.menu-btn.primary {
    background: var(--primary);
    border: none;
    box-shadow: 0 5px 20px rgba(255, 77, 77, 0.4);
}

.menu-btn.primary:hover {
    background: #ff6666;
    box-shadow: 0 10px 40px rgba(255, 77, 77, 0.6);
    color: #fff;
}

.menu-guide {
    color: #888;
    margin-top: 40px;
    text-align: center;
    font-size: 14px;
    line-height: 2;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.menu-update {
    color: var(--accent);
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    opacity: 0.8;
    letter-spacing: 2px;
}

/* ============================================
   MENU LAYOUT SYSTEM (Responsive)
   ============================================ */

/* Container bên trong mọi menu screen */
.menu-inner {
    width: 100%;
    max-width: 480px;
    margin: auto;            /* auto tự căn giữa dọc khi space thừa */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 0 16px;
    box-sizing: border-box;
}

/* Wrap input nhập tên */
.menu-input-wrap {
    width: 100%;
    max-width: 340px;
    margin-bottom: 12px;
}

/* Input nhập tên */
.menu-name-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #ffcc00;
    color: #fff;
    padding: 12px 20px;
    border-radius: 12px;
    font-family: 'Outfit', sans-serif;
    text-align: center;
    font-size: 18px;
    outline: none;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.2);
    box-sizing: border-box;
    transition: box-shadow 0.3s;
}
.menu-name-input:focus {
    box-shadow: 0 0 25px rgba(255, 204, 0, 0.5);
}

/* Slider box (bot count) */
.menu-slider-box {
    width: 100%;
    max-width: 340px;
    background: rgba(0, 0, 0, 0.4);
    padding: 12px 16px;
    border-radius: 15px;
    border: 1px solid rgba(255, 204, 0, 0.3);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    margin-bottom: 14px;
    box-sizing: border-box;
}

.menu-slider-label {
    color: #ffcc00;
    font-weight: bold;
    font-size: 13px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.menu-slider-val {
    font-size: 20px;
    color: #fff;
    font-weight: 900;
}

.menu-range {
    width: 100%;
    cursor: pointer;
    accent-color: #ffcc00;
    background: transparent;
}

/* Nút rộng (full-width trong menu) */
.w-menu-btn {
    width: 100%;
    max-width: 340px;
    text-align: center;
}

/* Hàng 2 nút (Guide + Feedback) nằm ngang */
.menu-btn-row {
    display: flex;
    flex-direction: row;
    gap: 12px;
    width: 100%;
    max-width: 340px;
    margin-top: 10px;
}

.menu-btn-row .menu-btn {
    flex: 1;
    margin: 0;
    padding: 14px 10px;
    font-size: 15px;
}

.menu-btn-guide {
    background: rgba(255, 204, 0, 0.3) !important;
    border-color: rgba(255, 204, 0, 0.5) !important;
}
.menu-btn-guide:hover {
    background: rgba(255, 204, 0, 0.8) !important;
    color: #000 !important;
}

.menu-btn-feedback {
    background: rgba(0, 150, 255, 0.3) !important;
    border-color: rgba(0, 150, 255, 0.5) !important;
}
.menu-btn-feedback:hover {
    background: rgba(0, 150, 255, 0.8) !important;
    color: #fff !important;
}

/* Cột nút (pause / game over) */
.menu-btn-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 100%;
}

/* Stats game over */
.end-stats-text {
    color: white;
    font-size: clamp(16px, 4vw, 28px);
    margin-bottom: 20px;
    font-weight: 700;
}


/* [MỚI] VICTORY BACKGROUND OVERLAY */
#victory-bg {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle, rgba(0,0,0,0) 0%, rgba(0,0,0,0.9) 100%);
    z-index: 9999;
    display: none;
    pointer-events: none;
    animation: victoryBgFade 1s ease-out forwards;
}

@keyframes victoryBgFade {
    from { opacity: 0; background: rgba(0,0,0,0); }
    to { opacity: 1; background: radial-gradient(circle, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.9) 100%); }
}

/* [CẢI TIẾN] HAKARI DANCE EPIC VERSION */
#hakari-dance-img {
    position: fixed;
    left: 50%;
    top: 45%;
    transform: translate(-50%, -50%) scale(0);
    width: min(550px, 95vw);
    pointer-events: none;
    display: none;
    z-index: 10000;
    filter: drop-shadow(0 0 40px rgba(0, 255, 255, 1));
    animation: hakariEpicEntry 0.6s cubic-bezier(0.17, 0.89, 0.32, 1.49) forwards, 
               hakariEpicPulse 0.4s ease-in-out infinite alternate,
               hakariEpicShake 0.05s infinite,
               hakariEpicFlip 0.8s steps(2) infinite;
}

#click-anywhere {
    position: fixed;
    inset: 0;
    display: none;
    z-index: 999999;
    pointer-events: auto !important;
    touch-action: manipulation;
}

.continue-text {
    position: fixed;
    bottom: 15%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 22px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px #000;
    z-index: 50;
    pointer-events: none;
    animation: blinkHud 1s infinite;
}

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

.hidden { display: none; }

/* --run-left / --run-right đã gộp vào :root ở trên */

@keyframes hakariEpicEntry {
    0% { transform: translate(-50%, -50%) scale(0) rotate(-15deg); opacity: 0; filter: brightness(5) blur(10px); }
    70% { transform: translate(-50%, -50%) scale(1.2) rotate(5deg); opacity: 1; filter: brightness(2) blur(0px); }
    100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; filter: brightness(1); }
}

@keyframes hakariEpicPulse {
    from { filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.6)) contrast(1); }
    to { filter: drop-shadow(0 0 60px rgba(255, 0, 255, 1)) contrast(1.8); transform: translate(-50%, -50%) scale(1.1); }
}

@keyframes hakariEpicShake {
    0% { margin-left: 0; margin-top: 0; }
    25% { margin-left: 12px; margin-top: -12px; }
    50% { margin-left: -12px; margin-top: 12px; }
    75% { margin-left: 12px; margin-top: 12px; }
    100% { margin-left: -12px; margin-top: -12px; }
}

@keyframes hakariEpicFlip {
    0%, 49% { transform: translate(-50%, -45%) scaleX(1.3) scaleY(1.3); }
    50%, 100% { transform: translate(-50%, -45%) scaleX(-1.3) scaleY(1.3); }
}

@keyframes fireGlow {
    from { text-shadow: 0 0 10px red, 0 0 20px orange; }
    to { text-shadow: 0 0 20px yellow, 0 0 40px red; }
}

/* --- MOBILE CONTROLS (FREE FIRE STYLE) --- */
#mobile-controls {
    display: block;
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1000;
}

@media (max-width: 800px), (pointer: coarse) {
    #mobile-controls {
        display: block;
    }
}

#joystick-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 33.33vw;
    height: 100vh;
    pointer-events: auto;
    touch-action: none;
}

#joystick-base {
    position: absolute;
    width: 65px;
    height: 65px;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
}

#joystick-knob {
    position: absolute;
    width: 25px;
    height: 25px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.1s;
}

#touch-aim-zone {
    position: absolute;
    top: 0;
    right: 0;
    width: 66.66vw;
    height: 100vh;
    pointer-events: auto;
    touch-action: none;
}

#mobile-weapons {
    position: absolute;
    top: calc(10px + env(safe-area-inset-top));
    right: calc(10px + env(safe-area-inset-right));
    display: flex;
    flex-direction: row;
    gap: 8px;
    pointer-events: auto;
    z-index: 2000;
    scale: var(--btn-scale, 1.0);
}

.weapon-btn {
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    width: 50px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 800;
    backdrop-filter: blur(8px);
    transition: all 0.2s;
}

.weapon-btn.active {
    color: #ffcc00;
    border-color: #ffcc00;
    background: rgba(0, 0, 0, 0.8);
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.5);
}

.action-buttons {
    position: absolute;
    bottom: env(safe-area-inset-bottom);
    right: env(safe-area-inset-right);
    width: 280px;
    height: 280px;
    pointer-events: none;
}

.action-buttons button {
    position: absolute;
    pointer-events: auto;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.7);
    font-weight: 900;
    color: white;
    box-shadow: 0 5px 15px rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, background 0.1s;
    scale: var(--btn-scale, 1.0);
}

#btn-shoot {
    width: 60px;
    height: 60px;
    bottom: 25px;
    right: 65px;
    background: rgba(255, 50, 50, 0.5);
    font-size: 11px;
    border-width: 3px;
    box-shadow: 0 0 15px rgba(255, 50, 50, 0.4);
}

#btn-jump {
    width: 48px;
    height: 48px;
    bottom: 90px;
    right: 12px;
    background: rgba(255, 204, 0, 0.5);
    font-size: 10px;
    border-width: 2px;
}

#btn-aim {
    width: 48px;
    height: 48px;
    bottom: 110px;
    right: 80px;
    background: rgba(0, 150, 255, 0.5);
    font-size: 10px;
    border-width: 2px;
}

#btn-reload {
    width: 48px;
    height: 48px;
    bottom: 22px;
    right: 145px;
    background: rgba(200, 200, 200, 0.5);
    font-size: 10px;
    border-width: 2px;
}

#btn-shoot:active, #btn-shoot.pressed { background: rgba(255, 50, 50, 0.9); transform: scale(0.92); }
#btn-jump:active { background: rgba(255, 204, 0, 0.9); transform: scale(0.92); }
#btn-aim:active, #btn-aim.pressed { background: rgba(0, 150, 255, 0.9); transform: scale(0.92); }
#btn-reload:active, #btn-reload.pressed { background: rgba(255, 255, 255, 0.9); color: black; transform: scale(0.92); }


/* --- PORTRAIT WARNING (YÊU CẦU XOAY NGANG) --- */
#portrait-warning {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 99999999;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    font-family: 'Outfit', sans-serif;
}


@keyframes rotatePhone {
    0% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
    100% { transform: rotate(-90deg); }
}

#btn-sprint {
    position: absolute;
    bottom: 150px;
    left: 40px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.8);
    font-weight: bold;
    color: white;
    font-size: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    pointer-events: auto;
    backdrop-filter: blur(5px);
    z-index: 10;
    scale: var(--btn-scale, 1.0);
}

#btn-ulti {
    position: absolute;
    top: 55px;
    right: 145px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.85);
    border: 2px solid #00f2ff;
    color: #00f2ff;
    font-weight: 900;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    z-index: 2000;
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.5), inset 0 0 15px rgba(0, 242, 255, 0.3);
    animation: unti-modern-pulse 2s infinite ease-in-out;
    scale: var(--btn-scale, 1.0);
    text-shadow: 0 0 10px #00f2ff;
    overflow: hidden;
}

/* Hiệu ứng Scanline cho nút Unti */
#btn-ulti::after {
    content: '';
    position: absolute;
    top: -100%;
    left: 0;
    width: 100%;
    height: 200%;
    background: linear-gradient(0deg, transparent 0%, rgba(0, 242, 255, 0.2) 50%, transparent 100%);
    animation: scanline 3s infinite linear;
    pointer-events: none;
}

@keyframes scanline {
    0% { top: -100%; }
    100% { top: 100%; }
}

#btn-ulti.hidden { display: none; }

@keyframes unti-modern-pulse {
    0% { transform: scale(1); box-shadow: 0 0 15px rgba(0, 242, 255, 0.4); }
    50% { transform: scale(1.1); box-shadow: 0 0 35px rgba(0, 242, 255, 0.9), 0 0 60px rgba(255, 106, 0, 0.5); border-color: #ff6a00; color: #ff6a00; text-shadow: 0 0 20px #ff6a00; }
    100% { transform: scale(1); box-shadow: 0 0 15px rgba(0, 242, 255, 0.4); }
}
#btn-sprint:active, #btn-sprint.pressed {
    background: rgba(255, 255, 255, 0.9);
    color: black;
    transform: scale(calc(var(--btn-scale, 1.0) * 0.9));
}

/* THÙNG GÓP Ý & LỆ HỘP ĐỒ */
#feedback-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}
#feedback-modal.hidden {
    display: none;
}
.feedback-content {
    background: #222;
    padding: 20px;
    border-radius: 12px;
    border: 2px solid #555;
    text-align: center;
    width: 300px;
    box-shadow: 0 0 20px rgba(0,0,0,0.8);
}
#feedback-text {
    width: 100%;
    height: 100px;
    background: #111;
    color: white;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 10px;
    margin-top: 10px;
    font-family: 'Outfit', sans-serif;
    resize: none;
    box-sizing: border-box;
}

#loot-legend {
    position: absolute;
    top: 110px;
    right: 20px;
    bottom: auto;
    left: auto;
    font-size: 10px;
    text-align: left;
    background: rgba(0,0,0,0.6);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 5px;
    border-radius: 8px;
    pointer-events: auto;
    z-index: 2000;
    scale: var(--btn-scale, 1.0);
}

#settings-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
}
#settings-modal.hidden { display: none; }

.editing-btn {
    border: 2px dashed rgba(255, 255, 255, 0.5) !important;
}
.selected-edit-btn {
    box-shadow: 0 0 15px rgba(255, 0, 0, 0.8) !important;
    border: 2px solid #ff0000 !important;
    background: rgba(255, 0, 0, 0.3) !important;
}

@media (max-width: 800px), (pointer: coarse) {
    #btn-settings { display: block !important; }

    #stats-display {
        top: 10px !important;
        right: 10px !important;
        bottom: auto !important;
        transform: none !important;
    }

    #mobile-weapons {
        top: 60px !important;
        right: 10px !important;
    }

    #loot-legend {
        top: 110px !important;
        right: 10px !important;
        bottom: auto !important;
        left: auto !important;
        transform: scale(0.6) !important;
        transform-origin: top right;
    }

    #ammo-display {
        top: auto !important;
        bottom: 20px !important;
        right: auto !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        font-size: 18px !important;
    }

    /* Menu — scale font/spacing, giữ layout */
    .menu-guide {
        display: none;
    }
}

@media (max-width: 740px) {
    .action-buttons { right: 20px !important; bottom: 10px !important; }
    #btn-sprint { left: 60px !important; bottom: 140px !important; }
    #joystick-zone { left: 40px !important; bottom: 40px !important; }
    #health-bar-container { left: 40px !important; bottom: 20px !important; width: 180px !important; }
}

/* SÁCH HƯỚNG DẪN STYLES */
#guide-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 6000;
    backdrop-filter: blur(10px);
}

#guide-modal.hidden { display: none; }

.guide-content {
    background: var(--glass);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    width: 90%;
    max-width: 650px;
    max-height: 85vh;
    padding: 30px;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}

.guide-section {
    margin-bottom: 25px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    padding-bottom: 15px;
}

.guide-section h3 {
    color: var(--accent);
    font-size: 18px;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.guide-section p {
    font-size: 14px;
    line-height: 1.6;
    color: #ddd;
    margin: 5px 0;
}

@media (max-width: 800px) {
    .guide-content {
        padding: 20px;
        width: 95%;
    }
    .guide-section h3 { font-size: 16px; }
    .guide-section p { font-size: 12px; }
}

/* ============================================
   RESPONSIVE — Màn hình nhỏ (< 480px / điện thoại dọc)
   ============================================ */
@media (max-width: 480px) {

    /* Menu inner co vừa màn hình */
    .menu-inner {
        padding: 0 12px;
    }

    /* Tiêu đề menu nhỏ hơn nữa */
    .menu-title {
        font-size: clamp(28px, 10vw, 48px) !important;
        margin-bottom: 16px !important;
        letter-spacing: -1px !important;
    }

    /* Input tên full-width */
    .menu-name-input {
        font-size: 15px;
        padding: 10px 14px;
    }

    /* Slider box full-width */
    .menu-slider-box {
        max-width: 100%;
        padding: 12px 14px;
    }

    /* Nút chính full-width */
    .w-menu-btn {
        max-width: 100%;
    }

    /* Hàng 2 nút — xếp dọc trên màn hình rất nhỏ */
    .menu-btn-row {
        flex-direction: column;
        max-width: 100%;
        gap: 8px;
    }

    .menu-btn-row .menu-btn {
        font-size: 14px;
        padding: 12px 10px;
    }

    /* Reward wheel — co nhỏ, xếp dọc */
    #wheel-layout {
        flex-direction: column;
        gap: 15px;
    }

    #wheel-container {
        width: clamp(160px, 70vw, 240px);
        height: clamp(160px, 70vw, 240px);
        margin: 10px 0;
    }

    #reward-legend {
        padding: 15px;
        gap: 10px;
    }

    .legend-item {
        font-size: 13px;
        gap: 10px;
    }

    .reward-title {
        font-size: clamp(18px, 6vw, 32px) !important;
    }

    /* Guide content co hơn */
    .guide-content {
        padding: 15px;
        max-height: 90vh;
    }

    .guide-section h3 { font-size: 14px; }
    .guide-section p  { font-size: 11px; }
}
/* ============================================
   LANDSCAPE MOBILE — M\u00e0n h\u00ecnh ngang \u0111i\u1ec7n tho\u1ea1i
   (chi\u1ec1u cao nh\u1ecf, chi\u1ec1u r\u1ed9ng l\u1edbn)
   ============================================ */
@media (orientation: landscape) and (max-height: 500px) {

    /* Menu screen: padding nh\u1ecf, kh\u00f4ng scroll d\u1ecdc */
    .menu-screen {
        padding: 10px 16px 10px;
        justify-content: center;
        overflow-y: auto;
    }

    /* menu-inner chuy\u1ec3n sang 2 c\u1ed9t ngang */
    .menu-inner {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        max-width: 860px;
        gap: 0 28px;
        padding: 0 8px;
    }

    /* Title v\u1eabn \u1edf tr\u00ean c\u00f9ng, full-width */
    .menu-title {
        width: 100% !important;
        font-size: clamp(14px, 5vh, 32px) !important;
        margin-bottom: 8px !important;
        letter-spacing: -1px !important;
        animation: none !important;   /* t\u1eaft bounce, tr\u00e1nh b\u1ecb c\u1eaft */
        transform: none !important;
        flex-shrink: 0;
        order: 0;
    }

    /* C\u1ed9t TR\u00c1I: Input t\u00ean + Slider bot */
    .menu-input-wrap {
        flex: 1 1 220px;
        max-width: 300px;
        margin-bottom: 8px;
        order: 1;
    }

    .menu-slider-box {
        flex: 1 1 220px;
        max-width: 300px;
        margin-bottom: 0;
        padding: 8px 12px;
        order: 2;
    }

    /* C\u1ed9t PH\u1ea2I: c\u00e1c n\u00fat */
    .w-menu-btn {
        flex: 1 1 180px;
        max-width: 260px;
        order: 3;
        margin: 4px 0;
    }

    .menu-btn-row {
        flex: 1 1 180px;
        max-width: 260px;
        order: 4;
        margin-top: 6px;
        flex-direction: row;    /* gi\u1eef ngang */
    }

    #btn-join-discord {
        flex: 1 1 180px;
        max-width: 260px;
        order: 5;
    }

    /* \u1ea8n guide text v\u00e0 version \u0111\u1ec3 ti\u1ebft ki\u1ec7m ch\u1ed7 */
    .menu-guide,
    .menu-update {
        display: none !important;
    }

    /* Input t\u00ean compact h\u01a1n */
    .menu-name-input {
        font-size: 13px;
        padding: 8px 14px;
    }

    /* Slider label nh\u1ecf h\u01a1n */
    .menu-slider-label {
        font-size: 11px;
        margin-bottom: 5px;
    }

    .menu-slider-val {
        font-size: 15px;
    }

    /* N\u00fat menu compact */
    .menu-btn {
        padding: 9px 20px !important;
        font-size: clamp(11px, 2.5vh, 15px) !important;
        margin: 3px 0 !important;
    }

    .menu-btn-row .menu-btn {
        padding: 9px 10px !important;
        font-size: 12px !important;
    }



    /* Guide modal trong landscape */
    .guide-content {
        max-height: 90vh;
        padding: 14px;
        overflow-y: auto;
    }

    .guide-section h3 { font-size: 13px; }
    .guide-section p  { font-size: 11px; line-height: 1.4; }

    /* [CẢI TIẾN] Tối ưu hóa thanh máu Boss cho màn hình ngang */
    #boss-hp-container {
        top: 8px !important;
        width: 35% !important;
        height: 12px !important;
        border-width: 1px !important;
    }
    #boss-hp-container div[style*="font-size"] {
        font-size: 8px !important;
        top: 0px !important;
        letter-spacing: 2px !important;
    }

    #settings-modal .card {
        margin-top: 5px !important;
    }
}

/* [CẢI TIẾN] Hiệu ứng số dame phong cách Free Fire */
.damage-number {
    position: fixed;
    pointer-events: none;
    font-family: 'Outfit', sans-serif;
    font-weight: 900;
    font-size: 24px;
    text-shadow: 2px 2px 0px #000, -1px -1px 0px #000, 1px -1px 0px #000, -1px 1px 0px #000;
    z-index: 100;
    animation: damageFloat 0.8s ease-out forwards;
    white-space: nowrap;
}
.damage-normal { color: #ffff00; } /* Vàng cho dame thường */
.damage-headshot { color: #ff0000; font-size: 32px; } /* Đỏ to cho Headshot */

@keyframes damageFloat {
    0% { transform: translate(-50%, 0) scale(0.5); opacity: 0; }
    20% { transform: translate(-50%, -20px) scale(1.2); opacity: 1; }
    50% { transform: translate(-50%, -50px) scale(1.0); opacity: 1; }
    100% { transform: translate(-50%, -100px) scale(0.8); opacity: 0; }
}

#sprint-overlay { position: fixed; inset: 0; pointer-events: none; z-index: 5; background: radial-gradient(circle, transparent 60%, rgba(255,255,255,0.1) 100%); overflow: hidden; } #sprint-overlay::before { content: ''; position: absolute; inset: -50%; background-image: radial-gradient(ellipse at center, transparent 30%, white 31%, transparent 32%), radial-gradient(ellipse at center, transparent 40%, white 41%, transparent 42%); background-size: 15% 2%, 25% 1%; background-repeat: repeat; opacity: 0.3; animation: speedLines 0.3s linear infinite; } @keyframes speedLines { 0% { transform: scale(1) rotate(0deg); opacity: 0; } 50% { opacity: 0.4; } 100% { transform: scale(1.5) rotate(0.1deg); opacity: 0; } } #sprint-overlay.hidden { display: none; }

/* NÚT CHỌN ĐỘ KHÓ */
.diff-btn {
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 900;
    font-family: 'Outfit', sans-serif;
    border-radius: 8px;
    border: 2px solid var(--dc, #ffcc00);
    background: rgba(0,0,0,0.4);
    color: var(--dc, #ffcc00);
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    white-space: nowrap;
}
.diff-btn:hover { background: rgba(255,255,255,0.1); transform: scale(1.05); }
.diff-btn.active {
    background: var(--dc, #ffcc00);
    color: #000 !important;
    box-shadow: 0 0 16px var(--dc);
    transform: scale(1.1);
}
