* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: #05050d;
    color: #ffffff;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100vw;
    max-width: 480px;
    height: 100vh;
    background: #0a0a1a;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 242, 254, 0.15);
    overflow: hidden;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#ui-layer * {
    pointer-events: auto;
}

.hidden {
    display: none !important;
}

/* Glassmorphism Panel */
.glass-panel {
    background: rgba(15, 18, 37, 0.88);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.6);
    border-radius: 20px;
    padding: 24px 28px;
    text-align: center;
    max-width: 550px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
}

.glass-panel.wide {
    max-width: 960px;
}

/* HUD Top Bar */
#hud-bar {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: rgba(10, 15, 30, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 5px 12px;
    border-radius: 14px;
    border: 1.5px solid rgba(0, 242, 254, 0.35);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7);
    z-index: 100;
    max-width: 95vw;
    width: auto;
}

.hud-stats-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    white-space: nowrap;
}

.hud-controls-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    white-space: nowrap;
}

.hud-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.80rem;
    font-weight: 800;
    color: #ffffff;
    white-space: nowrap;
}

.hud-item .hud-icon {
    font-size: 0.90rem;
    line-height: 1;
}

.hud-value {
    color: #ffd700;
    font-size: 0.80rem;
}

/* Compact Inline HP Bar */
.hp-bar-outer {
    position: relative;
    width: 90px;
    height: 16px;
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(0, 242, 254, 0.6);
    border-radius: 8px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.hp-bar-inner {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    background: linear-gradient(90deg, #22c55e, #10b981);
    transition: width 0.2s ease, background 0.3s ease;
    z-index: 1;
}

.hp-bar-text {
    position: relative;
    z-index: 2;
    font-size: 10px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
    letter-spacing: 0.2px;
    line-height: 1;
    white-space: nowrap;
}

/* Button Controls */
.btn-hud {
    font-family: 'Outfit', sans-serif;
    font-size: 11px;
    font-weight: 900;
    padding: 3px 10px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    transition: transform 0.1s ease, filter 0.1s ease;
}

.btn-hud:active {
    transform: scale(0.95);
}

.btn-buy {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    color: #000000;
}

.btn-shop {
    background: linear-gradient(135deg, #00f2fe, #4facfe);
    color: #000000;
}

.btn-pause {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 480px) {
    #hud-bar {
        padding: 4px 8px;
        gap: 3px;
        max-width: 98vw;
    }

    .hud-stats-row {
        gap: 8px;
    }

    .hud-item {
        font-size: 0.74rem;
    }

    .hp-bar-outer {
        width: 76px;
        height: 14px;
    }

    .hp-bar-text {
        font-size: 9px;
    }

    .btn-hud {
        font-size: 10px;
        padding: 2px 7px;
    }
}

/* Hero Dock & Ultimate Meter (Đặt ngay phía dưới HUD Bar) */
#hero-dock {
    position: absolute;
    top: 48px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(10, 12, 28, 0.90);
    backdrop-filter: blur(10px);
    padding: 5px 14px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    z-index: 10;
}

.dock-header {
    display: flex;
    justify-content: space-between;
    width: 100%;
    align-items: center;
    gap: 10px;
}

.dock-title {
    font-size: 0.70rem;
    font-weight: 600;
    color: #a0a5c0;
    text-transform: uppercase;
}

.ult-hint {
    font-size: 0.65rem;
    color: #ffd700;
}

.hero-slot-container {
    display: flex;
    gap: 8px;
}

.hero-slot {
    width: 66px;
    height: 72px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px dashed rgba(255, 255, 255, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 3px 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.hero-slot.filled {
    border-style: solid;
    background: rgba(255, 255, 255, 0.1);
}

.hero-slot:hover {
    transform: translateY(-2px);
    border-color: #00f2fe;
}

.hero-slot img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.slot-info {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
    margin-top: 1px;
}

.badge-lvl {
    position: absolute;
    top: -4px;
    right: -2px;
    background: #ff9800;
    color: #000;
    font-size: 0.55rem;
    font-weight: 900;
    padding: 0px 4px;
    border-radius: 6px;
}

.ult-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    overflow: hidden;
}

.xp-bar-container {
    width: 100%;
    height: 4px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 1px;
}

.xp-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #00f2fe 0%, #4facfe 100%);
    transition: width 0.3s ease;
}

.ult-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff0055 0%, #ffd700 100%);
    transition: width 0.3s ease;
}

.btn-ult {
    width: 100%;
    border: none;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: #888;
    font-size: 0.6rem;
    font-weight: 800;
    padding: 2px 0;
    cursor: pointer;
}

.btn-ult.ready {
    background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
    color: #fff;
    box-shadow: 0 0 10px rgba(255, 8, 68, 0.8);
}

/* Element Filter */
.element-filter {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-bottom: 14px;
}

.filter-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ccc;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    font-weight: 600;
}

.filter-btn.active {
    background: #00f2fe;
    color: #000;
    border-color: #00f2fe;
    font-weight: 800;
}

/* Screen Layouts */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(5, 5, 13, 0.75);
    backdrop-filter: blur(6px);
    z-index: 20;
}

.game-title {
    font-size: 2.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    letter-spacing: 2px;
}

.subtitle {
    color: #a0a5c0;
    margin-bottom: 20px;
    font-size: 1rem;
}

.instruction {
    color: #a0a5c0;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

/* Hero Selection Grid */
.hero-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
    max-height: 380px;
    overflow-y: auto;
    padding: 6px;
}

.hero-card {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hero-card:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.hero-card.selected {
    border-color: #00f2fe;
    background: rgba(0, 242, 254, 0.15);
    box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
}

.hero-card .card-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hero-card .hero-name {
    font-weight: 700;
    font-size: 1rem;
}

.hero-card .hero-element {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 700;
}

.tag-Vật\ lý { background: rgba(76, 175, 80, 0.3); color: #81c784; }
.tag-Phép { background: rgba(156, 39, 176, 0.3); color: #ce93d8; }
.tag-Hỗ\ trợ { background: rgba(0, 188, 212, 0.3); color: #80deea; }

.hero-card .hero-cost {
    margin-left: auto;
    color: #ffd700;
    font-weight: 700;
}

.hero-card .hero-desc {
    font-size: 0.78rem;
    color: #b0b5d0;
    line-height: 1.3;
}

.hero-card .hero-stats-mini {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #8088b0;
}

/* Weapon Shop Grid */
.weapon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
    max-height: 420px;
    overflow-y: auto;
    padding: 6px;
    margin-top: 14px;
}

.weapon-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 14px;
    text-align: left;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wep-title { font-weight: 800; font-size: 1rem; color: #00f2fe; }
.wep-type { font-size: 0.8rem; color: #aaa; }
.wep-desc { font-size: 0.8rem; color: #ddd; }
.wep-price { font-size: 0.9rem; color: #ffd700; font-weight: 700; margin-top: 4px; }
.btn-buy-wep { margin-top: 6px; font-size: 0.85rem; padding: 6px 12px; }

.weapon-equip-box {
    margin-top: 14px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: left;
}

/* Buttons */
.icon-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    padding: 6px 12px;
    font-size: 1.1rem;
    border-radius: 12px;
    cursor: pointer;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 10px 20px;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.primary-btn {
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    color: #000;
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.hero-btn {
    background: linear-gradient(135deg, #ff0844 0%, #ffb199 100%);
    color: #fff;
    font-size: 1.15rem;
    padding: 14px 32px;
    border-radius: 50px;
}

.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pulse {
    animation: pulse-anim 2s infinite;
}

@keyframes pulse-anim {
    0% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0.6); }
    70% { box-shadow: 0 0 0 12px rgba(0, 242, 254, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 242, 254, 0); }
}

/* Modals */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30;
}

.close-modal {
    position: absolute;
    top: 14px;
    right: 18px;
    font-size: 1.5rem;
    color: #aaa;
    cursor: pointer;
}

.text-danger { color: #ff4757; }
.text-success { color: #2ed573; }

/* Buff Modal Styles */
.buff-modal {
    max-width: 450px;
}

.buff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.buff-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    padding: 16px 14px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 16px;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    position: relative;
    cursor: pointer;
}

.buff-card:hover {
    transform: scale(1.02);
    background: rgba(255, 255, 255, 0.12);
}

.buff-card:active {
    transform: scale(0.98);
}

.buff-card.common { 
    border: 2px solid #2ecc71; 
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.3);
}
.buff-card.rare { 
    border: 2px solid #e056fd; 
    box-shadow: 0 0 14px rgba(224, 86, 253, 0.4);
}
.buff-card.epic { 
    border: 2.5px solid #f0932b; 
    box-shadow: 0 0 18px rgba(240, 147, 43, 0.5);
}
.buff-card.legendary { 
    border: 3px solid #ff4757; 
    box-shadow: 0 0 25px rgba(255, 71, 87, 0.7);
    animation: legendary-glow 1.5s infinite alternate;
}

@keyframes legendary-glow {
    0% { box-shadow: 0 0 15px rgba(255, 71, 87, 0.5), inset 0 0 10px rgba(255, 71, 87, 0.2); }
    100% { box-shadow: 0 0 30px rgba(255, 71, 87, 0.9), inset 0 0 20px rgba(255, 71, 87, 0.4); }
}

.buff-rarity-badge {
    font-size: 0.65rem;
    font-weight: 900;
    padding: 3px 10px;
    border-radius: 10px;
    letter-spacing: 1px;
    margin-bottom: 4px;
}
.buff-rarity-badge.common { background: #2ecc71; color: #000; }
.buff-rarity-badge.rare { background: linear-gradient(135deg, #e056fd 0%, #be2edd 100%); color: #fff; }
.buff-rarity-badge.epic { background: linear-gradient(135deg, #f0932b 0%, #ffbe76 100%); color: #000; }
.buff-rarity-badge.legendary { background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%); color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.5); }

.buff-card:hover {
    transform: translateY(-5px);
}
.buff-card.common:hover {
    border-color: #2ecc71;
    box-shadow: 0 0 25px rgba(46, 204, 113, 0.7), inset 0 0 10px rgba(46, 204, 113, 0.2);
}
.buff-card.rare:hover {
    border-color: #e056fd;
    box-shadow: 0 0 28px rgba(224, 86, 253, 0.8), inset 0 0 12px rgba(224, 86, 253, 0.3);
}
.buff-card.epic:hover {
    border-color: #f0932b;
    box-shadow: 0 0 32px rgba(240, 147, 43, 0.85), inset 0 0 14px rgba(240, 147, 43, 0.35);
}
.buff-card.legendary:hover {
    border-color: #ff4757;
    box-shadow: 0 0 40px rgba(255, 71, 87, 1.0), inset 0 0 18px rgba(255, 71, 87, 0.5);
}

.buff-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
}

.buff-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.buff-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: #00f2fe;
    margin-bottom: 6px;
}

.buff-desc {
    font-size: 0.88rem;
    color: #ccc;
    margin-bottom: 16px;
    line-height: 1.3;
}

.select-buff-btn {
    width: 100%;
}
