body {
    margin: 0;
    background-color: #111;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    display: flex;
    flex-direction: row;
}

/* Touch control panels on left/right */
.touch-side {
    display: none;
    flex-shrink: 0;
    width: 115px;
    background: #111;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 8px 0;
    box-sizing: border-box;
}

.touch-p1 { border-right: 1px solid #333; }
.touch-p2 { border-left: 1px solid #333; }

/* D-Pad */
.dpad {
    position: relative;
    width: 90px;
    height: 90px;
    flex-shrink: 0;
}

.dpad-btn {
    position: absolute;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.8);
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
    transition: background 0.05s;
}

.dpad-btn:active, .dpad-btn.active {
    background: rgba(255, 255, 255, 0.45);
}

.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%); }

/* Action Buttons */
.action-btns {
    display: flex;
    flex-wrap: wrap;
    width: 105px;
    gap: 6px;
    justify-content: center;
}

.action-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    font-family: 'Press Start 2P', monospace;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.05s, transform 0.05s;
    line-height: 1;
}

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

.btn-atk      { background: rgba(220, 50, 50, 0.55); color: #fff; }
.btn-atk:active, .btn-atk.active { background: rgba(220, 50, 50, 0.85); }

.btn-jmp      { background: rgba(50, 180, 50, 0.55); color: #fff; }
.btn-jmp:active, .btn-jmp.active { background: rgba(50, 180, 50, 0.85); }

.btn-blk      { background: rgba(50, 120, 220, 0.55); color: #fff; }
.btn-blk:active, .btn-blk.active { background: rgba(50, 120, 220, 0.85); }

.btn-special      { background: rgba(200, 160, 0, 0.55); color: #fff; }
.btn-special:active, .btn-special.active { background: rgba(200, 160, 0, 0.85); }

.btn-melee      { background: rgba(180, 50, 180, 0.55); color: #fff; width: 34px; height: 34px; font-size: 9px; }
.btn-melee:active, .btn-melee.active { background: rgba(180, 50, 180, 0.85); }

/* Show touch panels on touch devices */
@media (hover: none) and (pointer: coarse) {
    .touch-side {
        display: flex;
    }
}

/* Game wrapper */
#game-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    background: #000;
}

.container {
    position: absolute;
    width: 1024px;
    height: 576px;
    background-color: #333;
    overflow: hidden;
    touch-action: none;
    transform-origin: top left;
}

canvas {
    background-color: #000;
    display: block;
    width: 100%;
    height: 100%;
}

.shake {
    animation: shake-animation 0.2s ease-in-out;
}

@keyframes shake-animation {
    0% { transform: translate(0, 0); }
    25% { transform: translate(5px, 5px); }
    50% { transform: translate(-5px, -5px); }
    75% { transform: translate(5px, -5px); }
    100% { transform: translate(0, 0); }
}

.health-bars {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.player-health { text-align: center; }

#player1Name {
    color: #00BFFF;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    margin-bottom: 5px;
    display: block;
}

#player2Name {
    color: #32CD32;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    margin-bottom: 5px;
    display: block;
}

.health-bar-container {
    width: 200px;
    height: 20px;
    background: #333;
    border: 2px solid #fff;
    margin-bottom: 5px;
    position: relative;
}

.special-bar-container {
    width: 200px;
    height: 20px;
    background: white;
    border: 2px solid #fff;
    margin-bottom: 5px;
    position: relative;
    box-shadow: 0 0 10px rgba(68, 170, 255, 0.3);
}

.health-bar {
    width: 100%;
    height: 100%;
    background: #ff4444;
    transition: width 0.1s;
}

.special-bar {
    width: 0%;
    height: 100%;
    background: #44aaff;
    transition: width 0.1s;
}

.overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 300;
    color: white;
    font-family: 'Press Start 2P', cursive;
    text-align: center;
    gap: 15px;
    box-sizing: border-box;
    padding: 20px;
}

.game-title {
    color: #FFD700;
    font-size: clamp(20px, 4vw, 40px);
    margin: 0;
    text-shadow: 0 0 10px #FFD700, 0 0 20px #FFD700, 0 0 40px #ff00de, 0 0 80px #ff00de;
    animation: title-pulse 2s infinite;
}

@keyframes title-pulse {
    0%, 100% { text-shadow: 0 0 10px #FFD700, 0 0 40px #ff00de; }
    50% { text-shadow: 0 0 20px #FFD700, 0 0 80px #ff00de; }
}

#startButton, #restartButton {
    background: transparent;
    border: 4px solid #00ffea;
    color: #00ffea;
    padding: 12px 40px;
    font-size: clamp(14px, 2vw, 20px);
    font-family: 'Press Start 2P', cursive;
    cursor: pointer;
    box-shadow: 0 0 10px #00ffea, inset 0 0 10px #00ffea;
    text-shadow: 0 0 5px #00ffea;
    transition: all 0.2s ease;
    z-index: 310;
    text-transform: uppercase;
    position: relative;
    overflow: hidden;
    margin-bottom: 10px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#startButton:hover, #restartButton:hover {
    background: #00ffea;
    color: black;
    box-shadow: 0 0 20px #00ffea, 0 0 40px #00ffea;
    transform: scale(1.1);
}

#winner-text {
    font-size: clamp(30px, 6vw, 70px);
    margin-bottom: 20px;
    text-transform: uppercase;
    animation: neon-flicker 1.5s infinite alternate;
}

@keyframes neon-flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        text-shadow: 0 0 4px #fff, 0 0 11px #fff, 0 0 19px #fff,
            0 0 40px #0fa, 0 0 80px #0fa, 0 0 90px #0fa, 0 0 100px #0fa, 0 0 150px #0fa;
    }
    20%, 24%, 55% { text-shadow: none; }
}

.controls-container {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 90%;
    margin-top: 10px;
    flex-wrap: wrap;
}

.control-group {
    background: rgba(255, 255, 255, 0.1);
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 200px;
    text-align: left;
}

.control-group h3 {
    color: #FFD700;
    font-size: 11px;
    margin-top: 0;
    margin-bottom: 8px;
    text-align: center;
    text-decoration: underline;
}

.control-item {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    font-size: 9px;
    color: #ddd;
    font-family: sans-serif;
}

kbd {
    display: inline-block;
    padding: 2px 4px;
    font-family: 'Press Start 2P', monospace;
    font-size: 7px;
    font-weight: bold;
    color: #333;
    vertical-align: middle;
    background-color: #f7f7f7;
    border: solid 1px #ccc;
    border-bottom-color: #bbb;
    border-radius: 3px;
    box-shadow: inset 0 -2px 0 #bbb;
    margin-right: 3px;
    min-width: 10px;
    text-align: center;
}

.control-item span {
    margin-left: auto;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
}

/* Small phones */
@media (max-width: 480px) and (orientation: landscape) {
    .touch-side { width: 95px; }
    .dpad { width: 78px; height: 78px; }
    .dpad-btn { width: 32px; height: 32px; font-size: 13px; }
    .action-btn { width: 34px; height: 34px; font-size: 9px; }
    .btn-melee { width: 28px; height: 28px; font-size: 8px; }
    .action-btns { width: 90px; gap: 5px; }
    .health-bar-container, .special-bar-container { width: 100px; height: 12px; }
    #player1Name, #player2Name { font-size: 9px; }
}
