* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; }
body, html { width: 100%; height: 100%; overflow: hidden; background-color: #000; font-family: 'Rajdhani', sans-serif; }

#gameCanvas { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }

.hidden { display: none !important; }
#ui-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; pointer-events: none; }

/* Top HUD */
#top-hud {
    position: absolute; top: 0; left: 0; width: 100%;
    display: flex; justify-content: space-between; align-items: flex-start;
    padding: 15px 20px; background: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent);
    pointer-events: auto;
}

.fighter-status { width: 40%; max-width: 350px; display: flex; align-items: center; gap: 15px; }
.p1 { flex-direction: row; }
.p2 { flex-direction: row-reverse; }

.portrait {
    width: 60px; height: 60px; border-radius: 5px; border: 2px solid #555;
    background-size: cover; background-position: center;
    box-shadow: 0 0 10px rgba(0,0,0,0.8);
}
.player-portrait { background-color: #2244ff; border-color: #aaaaff; }
.enemy-portrait { background-color: #ff2222; border-color: #ffaaaa; }

.status-info { display: flex; flex-direction: column; flex-grow: 1; }
.right-align { text-align: right; align-items: flex-end; }

.name-plate {
    font-family: 'Bebas Neue', cursive; font-size: 28px; color: #fff;
    text-shadow: 2px 2px 0 #000, 0 0 5px rgba(255,255,255,0.5); letter-spacing: 1px;
}

.bars { width: 100%; display: flex; flex-direction: column; gap: 4px; }

.bar-container { 
    width: 100%; background: rgba(30,30,30,0.8); border: 2px solid #777; 
    overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,0.8);
    transform: skewX(-15deg); /* Advanced slanted look */
}
.hp { height: 24px; border-color: #fff; }
.st { height: 10px; width: 80%; border-color: #555; }
.right-align .st { margin-left: 20%; }

.bar-fill { height: 100%; width: 100%; transition: width 0.1s linear; }
#p1-hp { background: linear-gradient(90deg, #FF0000, #FF5555, #FFFF00); transform-origin: left; box-shadow: inset 0 0 10px rgba(255,255,255,0.5); }
#p2-hp { background: linear-gradient(90deg, #FFFF00, #FF5555, #FF0000); transform-origin: right; box-shadow: inset 0 0 10px rgba(255,255,255,0.5); }
#p1-st, #p2-st { background: linear-gradient(90deg, #FFA500, #FFD700); }

.round-timer {
    text-align: center; color: #FFD700; font-family: 'Bebas Neue', cursive;
    background: rgba(0,0,0,0.7); padding: 5px 20px; border-radius: 0 0 10px 10px;
    border: 2px solid #555; border-top: none; box-shadow: 0 5px 15px rgba(0,0,0,0.8);
    position: relative; z-index: 2;
}
#round-num { font-size: 18px; letter-spacing: 2px; }
#time-val { font-size: 32px; text-shadow: 0 0 10px #FFA500; }

/* Combo Meter */
#combo-container {
    position: absolute; top: 80px; left: 50%; transform: translateX(-50%);
    text-align: center; color: #FF8C00; font-family: 'Bebas Neue', cursive;
    text-shadow: 0 2px 10px rgba(255,140,0,0.8);
    animation: comboPulse 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes comboPulse { 0% { transform: translateX(-50%) scale(1.5); } 100% { transform: translateX(-50%) scale(1); } }
#combo-text { font-size: 32px; letter-spacing: 2px; }
#combo-count { font-size: 48px; color: #FFD700; }
#combo-bar { width: 150px; height: 10px; background: rgba(0,0,0,0.8); border: 2px solid #FF8C00; border-radius: 5px; margin: 0 auto; overflow: hidden; }
#combo-fill { width: 100%; height: 100%; background: linear-gradient(90deg, #FF8C00, #FFD700); transform-origin: left; transition: width 0.1s linear; }

/* Floating Damage Numbers */
.dmg-text {
    position: absolute; font-family: 'Bebas Neue', cursive; font-size: 40px; font-weight: bold;
    color: #FF3333; text-shadow: 2px 2px 0px #000, 0 0 10px #FF0000;
    pointer-events: none; z-index: 50;
    animation: dmgFloat 1s forwards cubic-bezier(0.1, 0.8, 0.3, 1);
}
.dmg-text.crit { font-size: 60px; color: #FFD700; text-shadow: 2px 2px 0px #000, 0 0 15px #FF8C00; }
@keyframes dmgFloat { 0% { transform: translate(-50%, 0) scale(0.5); opacity: 1; } 50% { transform: translate(-50%, -50px) scale(1.2); opacity: 1; } 100% { transform: translate(-50%, -80px) scale(1); opacity: 0; } }

/* Blood Screen Vignette */
#blood-screen {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none; z-index: 5;
    box-shadow: inset 0 0 150px rgba(204,0,0,0);
    transition: box-shadow 0.2s ease-in-out;
}
.low-health { box-shadow: inset 0 0 200px rgba(255,0,0,0.6) !important; animation: heartbeat 1s infinite alternate; }
@keyframes heartbeat { 0% { box-shadow: inset 0 0 200px rgba(255,0,0,0.5); } 100% { box-shadow: inset 0 0 250px rgba(255,0,0,0.8); } }

/* Center Alerts */
#center-alert {
    position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);
    text-align: center; color: #fff; font-family: 'Bebas Neue', cursive;
    text-shadow: 0 5px 15px #000;
}
#alert-text { font-size: 60px; color: #CC0000; letter-spacing: 2px; animation: pulse 1s infinite alternate; }
#count-num { font-size: 100px; color: #FFD700; margin-top: -20px; }
@keyframes pulse { 0% { transform: scale(1); } 100% { transform: scale(1.1); } }

#btn-restart {
    margin-top: 20px; background: #CC0000; color: #fff; border: 2px solid #ff4444;
    padding: 10px 30px; font-family: 'Bebas Neue', cursive; font-size: 24px;
    letter-spacing: 2px; cursor: pointer; box-shadow: 0 0 15px rgba(204,0,0,0.6);
    border-radius: 5px; transition: transform 0.1s, background 0.2s; pointer-events: auto;
}
#btn-restart:hover { background: #ff2222; transform: scale(1.05); }

/* Fight Intro Animation */
#fight-intro {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0);
    font-family: 'Bebas Neue', cursive; font-size: 150px; color: #FFD700;
    text-shadow: 0 0 20px #FF0000, 5px 5px 0 #000; z-index: 100;
    pointer-events: none;
}
.show-fight { animation: popFight 1.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards; }
@keyframes popFight { 0% { transform: translate(-50%, -50%) scale(0); opacity: 0; } 20% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; } 80% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(2); opacity: 0; } }

/* Mobile Controls - Optimized for No Overlap */
#mobile-controls {
    position: absolute; bottom: 20px; left: 0; width: 100%;
    display: flex; justify-content: space-between; padding: 0 20px;
    pointer-events: auto;
}

.control-zone { display: flex; flex-direction: column; gap: 15px; align-items: center; }

.btn-group.d-pad { display: flex; gap: 5px; background: rgba(0,0,0,0.6); padding: 8px; border-radius: 50%; border: 2px solid #555; }
.ctrl-btn {
    width: 60px; height: 60px; border-radius: 50%; border: none;
    background: radial-gradient(circle, #555, #222); color: #fff; font-size: 24px;
    cursor: pointer; display: flex; justify-content: center; align-items: center;
    box-shadow: 0 5px 15px rgba(0,0,0,0.8), inset 0 2px 5px rgba(255,255,255,0.2);
}
.ctrl-btn:active { background: #333; transform: scale(0.9); }

.action-btn {
    width: 90px; height: 90px; border-radius: 50%; border: 3px solid #333;
    color: #fff; font-family: 'Bebas Neue', cursive; font-size: 22px; letter-spacing: 1px;
    box-shadow: 0 10px 20px rgba(0,0,0,0.8), inset 0 0 20px rgba(0,0,0,0.5);
    cursor: pointer; text-shadow: 2px 2px 4px #000;
    transition: transform 0.05s, filter 0.1s; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2;
}
.action-btn:active { transform: scale(0.9); filter: brightness(1.5) drop-shadow(0 0 15px #fff); }
.action-btn.red { background: radial-gradient(circle, #ff5555 0%, #880000 100%); border-color: #ffaaaa; }
.action-btn.blue { background: radial-gradient(circle, #5555ff 0%, #000088 100%); border-color: #aaaaff; }
.action-btn.gold { background: radial-gradient(circle, #ffcc00 0%, #aa7700 100%); border-color: #ffffaa; width: 75px; height: 75px; font-size: 18px; }

.power-btns { display: flex; gap: 15px; }

/* Start Menu */
#start-menu {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: radial-gradient(circle, rgba(50,20,20,0.95) 0%, rgba(0,0,0,0.95) 100%);
    display: flex; justify-content: center; align-items: center; z-index: 100;
}
.menu-box {
    background: rgba(20,20,20,0.9); border: 2px solid #CC0000; padding: 40px;
    border-radius: 10px; text-align: center; color: white; width: 90%; max-width: 500px;
    box-shadow: 0 0 30px rgba(204,0,0,0.3), inset 0 0 20px rgba(0,0,0,0.8);
}
.menu-box h1 { font-family: 'Bebas Neue', cursive; font-size: 50px; color: #fff; text-shadow: 0 5px 10px #000; letter-spacing: 2px; }
.menu-box h1 span { color: #CC0000; }
.menu-box p { color: #aaa; margin: 10px 0 20px; }

.fighter-select { margin-bottom: 30px; }
.fighter-select h3 { color: #FFD700; margin-bottom: 15px; font-family: 'Bebas Neue', cursive; font-size: 24px; }
.select-grid { display: flex; flex-direction: column; gap: 10px; }
.style-btn {
    background: #222; border: 1px solid #555; color: #fff; padding: 12px;
    font-family: 'Rajdhani', sans-serif; font-size: 16px; font-weight: bold; cursor: pointer;
    transition: all 0.2s;
}
.style-btn:hover { background: #333; }
.style-btn.active { background: #CC0000; border-color: #ff4444; box-shadow: 0 0 15px rgba(204,0,0,0.5); }

.start-btn {
    width: 100%; background: #FFD700; color: #000; border: none;
    padding: 15px; font-family: 'Bebas Neue', cursive; font-size: 28px; letter-spacing: 2px;
    cursor: pointer; transition: transform 0.1s, background 0.2s; box-shadow: 0 5px 15px rgba(255,215,0,0.3);
}
.start-btn:hover { background: #ffea00; transform: translateY(-2px); }
.controls-info { margin-top: 25px; font-size: 14px; color: #777; line-height: 1.5; }

/* Responsive Adjustments to prevent overlaps */
@media (max-width: 700px) {
    #top-hud { padding: 10px; }
    .name-plate { font-size: 18px; }
    .hp { height: 12px; }
    .st { height: 6px; }
    .round-timer { padding: 2px 10px; }
    #time-val { font-size: 24px; }
    
    .ctrl-btn { width: 40px; height: 40px; font-size: 12px; }
    .action-btn { width: 65px; height: 65px; font-size: 16px; }
    .action-btn.gold { width: 55px; height: 55px; font-size: 12px; }
    
    #center-alert { top: 30%; } /* Move up slightly to avoid fingers */
}
