* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Press Start 2P', cursive;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #222;
    background-size: 20px 20px;
    overflow: hidden;
    color: white;
    text-shadow: 2px 2px 0 #000;
}

.game-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.game-area {
    height: 60vh;
    min-height: 400px;
    background-image: url('sprites/bg.png');
    background-size: cover;
    background-position: center;
    border: 8px solid #FFD700;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.game-area::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 20%;
    z-index: 1;
}

/* Background explosions */
.bg-explosion {
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,215,0,0.8) 0%, rgba(255,87,34,0.6) 50%, rgba(0,0,0,0) 70%);
    z-index: 0;
    transform: scale(0);
    animation: bgExplode 1.5s ease-out forwards;
    opacity: 0.7;
    filter: blur(2px);
}

@keyframes bgExplode {
    0% {
        transform: scale(0);
        opacity: 0.7;
    }
    50% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

.character {
    position: absolute;
    width: 200px;
    height: 350px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center bottom;
    z-index: 2;
    transform-origin: center bottom;
    will-change: bottom;
}

.nerd {
    background-image: url('sprites/nerd.png');
    bottom: 20%;
    right: 20%;
}

.punk {
    background-image: url('sprites/punk.png');
    bottom: 20%;
    left: 20%;
}

.character.flip {
    transform: scaleX(-1);
}

/* Simplified jump - no animation, physics-driven only */
.character.jump {
    /* No animation - we'll use pure physics for the jump */
}

/* Remove the flipped jump animation - just use the flip class directly */
.character.jump.flip {
    /* No separate animation for flipped jumps */
}

.character.attack {
    animation: attack 0.3s ease-in-out;
}

.character.hit {
    animation: hitShake 0.3s ease-in-out;
    filter: brightness(1.2) contrast(1.2);
}

/* Blood Splatter Effect */
.blood-splatter {
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: #bf0000;
    border-radius: 50%;
    opacity: 0.9;
    mix-blend-mode: multiply;
    box-shadow: inset 0 0 10px #500, 0 0 5px #ff0000;
    animation: splatter 0.5s ease-out forwards;
    z-index: 5;
}

/* Blood splatter variations for more realistic effect */
.blood-splatter:nth-child(3n+1) {
    background-color: #a50000;
    clip-path: polygon(50% 0%, 100% 50%, 80% 100%, 20% 100%, 0% 50%);
}

.blood-splatter:nth-child(3n+2) {
    background-color: #c30000;
    clip-path: polygon(30% 0%, 70% 0%, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0% 70%, 0% 30%);
}

.blood-splatter:nth-child(3n+3) {
    background-color: #8a0303;
    clip-path: polygon(50% 0%, 83% 12%, 100% 43%, 94% 78%, 68% 100%, 32% 100%, 6% 78%, 0% 43%, 17% 12%);
}

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

@keyframes hitShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-5px); }
    40% { transform: translateX(5px); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

@keyframes frontFlip {
    0% { 
        bottom: 20%; 
        transform: rotateX(0deg) translateY(0);
    }
    15% { 
        bottom: 35%; 
        transform: rotateX(90deg) translateY(-10px);
    }
    50% { 
        bottom: 60%; 
        transform: rotateX(180deg) translateY(-10px);
    }
    85% { 
        bottom: 35%; 
        transform: rotateX(270deg) translateY(-10px);
    }
    100% { 
        bottom: 20%; 
        transform: rotateX(360deg) translateY(0);
    }
}

@keyframes attack {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(-15deg); }
    50% { transform: rotate(10deg); }
    100% { transform: rotate(0deg); }
}

.ui {
    padding: 15px;
    background-color: #333;
    border: 5px solid #FFD700;
    border-radius: 8px;
    color: white;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.health-bars {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 10px;
}

.health-bar {
    width: 45%;
}

/* First health bar (NERD) - move to the left */
.health-bars .health-bar:first-child {
    order: 1; /* Move to the left */
}

/* Second health bar (PUNK) - move to the right */
.health-bars .health-bar:last-child {
    order: 2; /* Move to the right */
    flex-direction: row-reverse;
}

/* Reverse the direction of PUNK's health bar to fill from right to left */
.health-bars .health-bar:last-child .bar {
    direction: rtl;
}

.label {
    font-weight: bold;
    margin-bottom: 10px;
    text-align: center;
    color: #FFD700;
    letter-spacing: 2px;
    font-size: 14px;
}

.bar {
    height: 25px;
    background-color: #555;
    border-radius: 10px;
    overflow: hidden;
    border: 3px solid #FFD700;
}

.health {
    height: 100%;
    width: 100%;
    background-color: #4CAF50;
    transition: width 0.3s ease;
}

#p1-health {
    background: linear-gradient(to right, #00FFFF, #2196F3);
}

#p2-health {
    background: linear-gradient(to right, #FF5722, #FF9800);
}

.controls-info {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    text-align: center;
    margin-bottom: 10px;
}

.instructions {
    text-align: center;
    font-size: 14px;
    color: #FFEB3B;
    animation: pulse 2s infinite;
    margin-top: 10px;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Simplified text display for character reactions - no bubble */
.explosion {
    position: absolute;
    font-size: 30px;
    font-family: 'Comic Sans MS', cursive, sans-serif;
    font-weight: bold;
    text-align: center;
    z-index: 100; /* Ensure it's on top of everything */
    color: white;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000;
    animation: centerTextAnimation 1s ease-out forwards;
    pointer-events: none; /* Ensure it doesn't interfere with clicks */
    width: auto;
    max-width: 80%; /* Allow space for longer phrases */
    white-space: normal; /* Allow text wrapping for long phrases */
}

/* All explosion text will be white regardless of character */
.explosion.nerd, .explosion.punk {
    color: white;
}

/* New animation for centered text display - quick flash */
@keyframes centerTextAnimation {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.8);
    }
    20% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.1);
    }
    30% {
        transform: translate(-50%, -50%) scale(1);
    }
    70% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .game-container {
        width: 95%;
    }
    
    .game-area {
        height: 50vh;
    }
    
    .character {
        width: 150px;
        height: 262px;
    }
    
    .nerd {
        right: 10%;
    }
    
    .punk {
        left: 10%;
    }
    
    .health-bars {
        flex-direction: column;
    }
    
    .health-bar {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .controls-info {
        flex-direction: column;
    }
}

/* Mobile controls */
.mobile-controls {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 0;
    width: 100%;
    padding: 10px;
    z-index: 100;
}

.controller {
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.dpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 5px;
    width: 150px;
    height: 150px;
    position: relative; /* Added for absolute positioning of overlays */
}

.dpad-btn {
    background-color: #444;
    border: 2px solid #FFD700;
    border-radius: 8px;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    user-select: none;
    touch-action: manipulation;
    position: relative; /* For z-index control */
    z-index: 1;
}

.dpad-btn:active {
    background-color: #FF5722;
}

.dpad-btn.up {
    grid-column: 2;
    grid-row: 1;
    border-radius: 50% 50% 10px 10px;
    z-index: 3; /* Higher z-index to ensure it's on top */
}

.dpad-btn.left {
    grid-column: 1;
    grid-row: 2;
    border-radius: 50% 10px 10px 50%;
    z-index: 2;
}

.dpad-btn.right {
    grid-column: 3;
    grid-row: 2;
    border-radius: 10px 50% 50% 10px;
    z-index: 2;
}

.dpad-btn.down {
    grid-column: 2;
    grid-row: 3;
    border-radius: 10px 10px 50% 50%;
}

.dpad-center {
    grid-column: 2;
    grid-row: 2;
    background-color: #333;
    border: 2px solid #FFD700;
    border-radius: 50%;
}

/* Corner overlays to allow diagonal presses */
.dpad::before, .dpad::after {
    content: '';
    position: absolute;
    width: 40px;
    height: 40px;
    background-color: transparent;
    z-index: 2;
    pointer-events: none; /* Let touches pass through */
}

/* Top-left corner overlay */
.dpad::before {
    top: 0;
    left: 0;
    border-radius: 50% 0 0 0;
}

/* Top-right corner overlay */
.dpad::after {
    top: 0;
    right: 0;
    border-radius: 0 50% 0 0;
}

/* Extend touch areas for better diagonal control */
.dpad-btn.up::after, 
.dpad-btn.left::after, 
.dpad-btn.right::after {
    content: '';
    position: absolute;
    background-color: transparent;
    z-index: -1;
}

.dpad-btn.up::after {
    width: 100%;
    height: 30px;
    bottom: -15px;
    left: 0;
}

.dpad-btn.left::after {
    width: 30px;
    height: 100%;
    right: -15px;
    top: 0;
}

.dpad-btn.right::after {
    width: 30px;
    height: 100%;
    left: -15px;
    top: 0;
}

/* Show mobile controls only on smaller screens */
@media (max-width: 1024px) {
    .mobile-controls {
        display: block;
    }
    
    .controller {
        justify-content: space-around;
    }
    
    .instructions {
        margin-bottom: 80px; /* Make room for controls */
    }
}

/* Adjust for very small screens */
@media (max-width: 480px) {
    .dpad {
        width: 130px;
        height: 130px;
    }
    
    .dpad-btn {
        font-size: 20px;
    }
}

/* Game mode selection */
.mode-selection {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.mode-selection h2 {
    color: white;
    font-family: 'Press Start 2P', cursive;
    margin-bottom: 40px;
    text-align: center;
    text-shadow: 0 0 10px #ff00ff;
}

.mode-buttons {
    display: flex;
    gap: 20px;
}

.mode-btn {
    background: linear-gradient(to bottom, #444, #222);
    color: white;
    font-family: 'Press Start 2P', cursive;
    border: 3px solid #fff;
    padding: 15px 30px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.mode-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

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

/* Game over screen */
.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    z-index: 100;
    font-family: 'Press Start 2P', cursive;
    border: 3px solid white;
}

.game-over h2 {
    color: #ff0;
    margin-bottom: 30px;
    text-shadow: 0 0 10px #f00;
}

.game-over button {
    background: linear-gradient(to bottom, #444, #222);
    color: white;
    font-family: 'Press Start 2P', cursive;
    border: 3px solid #fff;
    padding: 10px 20px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.game-over button:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px white;
}

/* Character selection */
.character-selection {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.character-selection h2 {
    color: white;
    font-family: 'Press Start 2P', cursive;
    margin-bottom: 40px;
    text-align: center;
    text-shadow: 0 0 10px #ff00ff;
}

.character-buttons {
    display: flex;
    gap: 40px;
}

.character-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s;
    padding: 15px;
    border: 4px solid transparent;
    border-radius: 10px;
}

.character-btn:hover {
    transform: scale(1.1);
    border-color: white;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}

.character-btn .char-preview {
    width: 100px;
    height: 150px;
    margin-bottom: 15px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.character-btn .ronnie {
    background-image: url('sprites/nerd.png');
}

.character-btn .luigi {
    background-image: url('sprites/punk.png');
}

.character-btn .char-name {
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 14px;
    text-align: center;
    text-shadow: 0 0 5px #000;
}

.character-btn.ronnie-btn:hover {
    border-color: #00FFFF;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
}

.character-btn.luigi-btn:hover {
    border-color: #FF00FF;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.6);
}

/* Falling animation */
.character.falling {
    animation: falling 2s forwards;
    z-index: 5;
}

@keyframes falling {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(180deg);
    }
} 