* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background-color: #000000;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    color: #ffffff;
    overflow: hidden;
}

#game-container {
    text-align: center;
    position: relative;
    width: 660px;
    padding: 8px 0 0 0;
    animation: fadeIn 0.5s ease-out;
}

#click-to-start {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    cursor: pointer;
    transition: opacity 0.3s ease-out;
}

#click-to-start.hidden {
    opacity: 0;
    pointer-events: none;
}

#start-text {
    text-align: center;
}

#start-text p {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    color: #ffffff;
    text-shadow: 2px 2px 0px #000000;
    animation: pulse 1.5s ease-in-out infinite;
    letter-spacing: 1px;
}

#gameCanvas {
    border: 2px solid #ffffff;
    background-color: #1a1a1a;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    display: block;
    margin: 0 auto;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
    transition: transform 0.1s ease-out;
}

/* Screen shake effect - triggered via class */
#gameCanvas.shake {
    animation: shake 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

/* Intense shake for pillar impacts */
#gameCanvas.pillar-shake {
    animation: pillarImpact 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

/* Hit flash effect */
#gameCanvas.hit-flash {
    animation: hitFlash 0.15s ease-out;
}

#debug-info {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px;
    border: 1px solid #ffffff;
    font-size: 12px;
    text-align: left;
    backdrop-filter: blur(4px);
    z-index: 10;
}

#debug-info p {
    margin: 5px 0;
}

/* UNDERTALE-style text */
.dialogue-text {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    letter-spacing: 1px;
    animation: textReveal 0.05s steps(1) forwards;
}

/* Loading screen with smooth pulsing */
.loading {
    color: #ffffff;
    font-size: 24px;
    animation: pulse 1.5s ease-in-out infinite;
}

/* ==================== */
/* ANIMATIONS */
/* ==================== */

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.05);
    }
}

@keyframes shake {
    0%, 100% { transform: translate(0, 0); }
    10%, 30%, 50%, 70%, 90% { transform: translate(-4px, 3px) rotate(-0.3deg); }
    20%, 40%, 60%, 80% { transform: translate(4px, -3px) rotate(0.3deg); }
}

@keyframes pillarImpact {
    0%, 100% { 
        transform: translate(0, 0) rotate(0deg);
        filter: brightness(1) contrast(1);
    }
    5%, 15%, 25%, 35%, 45% { 
        transform: translate(-6px, 4px) rotate(-0.8deg);
        filter: brightness(1.2) contrast(1.15);
    }
    10%, 20%, 30%, 40%, 50% { 
        transform: translate(6px, -4px) rotate(0.8deg);
        filter: brightness(1.2) contrast(1.15);
    }
    55%, 65%, 75%, 85% { 
        transform: translate(-4px, 3px) rotate(-0.5deg);
        filter: brightness(1.1) contrast(1.1);
    }
    60%, 70%, 80%, 90% { 
        transform: translate(4px, -3px) rotate(0.5deg);
        filter: brightness(1.1) contrast(1.1);
    }
}

@keyframes hitFlash {
    0% { 
        filter: brightness(1) saturate(1); 
        box-shadow: 0 0 0 rgba(255, 255, 255, 0);
    }
    25% { 
        filter: brightness(2.5) saturate(0) contrast(1.5); 
        box-shadow: 0 0 40px rgba(255, 255, 255, 0.8);
    }
    50% { 
        filter: brightness(1.8) saturate(1.3); 
        box-shadow: 0 0 30px rgba(255, 100, 100, 0.6);
    }
    100% { 
        filter: brightness(1) saturate(1); 
        box-shadow: 0 0 0 rgba(255, 255, 255, 0);
    }
}

@keyframes textReveal {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Boss damage slash animation */
@keyframes slashImpact {
    0% { 
        filter: brightness(1) contrast(1) hue-rotate(0deg);
        transform: scale(1) rotate(0deg);
    }
    5% {
        filter: brightness(3) contrast(2) hue-rotate(30deg);
        transform: scale(1.08) rotate(2deg);
    }
    15% {
        filter: brightness(2.5) contrast(1.8) hue-rotate(-30deg);
        transform: scale(1.06) rotate(-2deg);
    }
    30% {
        filter: brightness(1.5) contrast(1.3) hue-rotate(15deg);
        transform: scale(1.03) rotate(1deg);
    }
    50% {
        filter: brightness(1.2) contrast(1.1) hue-rotate(-10deg);
        transform: scale(1.01) rotate(-0.5deg);
    }
    100% { 
        filter: brightness(1) contrast(1) hue-rotate(0deg);
        transform: scale(1) rotate(0deg);
    }
}

#gameCanvas.boss-slash {
    animation: slashImpact 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Soul/heart pulse animation */
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Menu selection glow */
@keyframes menuGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 255, 255, 0.5); }
    50% { box-shadow: 0 0 15px rgba(255, 255, 255, 0.8); }
}

/* Calm meter fill animation */
@keyframes fillMeter {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

/* Damage number popup */
@keyframes damagePopup {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-20px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-40px) scale(0.8);
    }
}

/* Victory/defeat text entrance */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mercy sparkle effect */
@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }
}

/* Attack telegraph pulse */
@keyframes warningPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.95);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

/* Intense danger zone rumble */
@keyframes dangerRumble {
    0%, 100% {
        opacity: 0.2;
        transform: translateY(0) scaleY(1);
    }
    25% {
        opacity: 0.4;
        transform: translateY(-2px) scaleY(1.02);
    }
    50% {
        opacity: 0.6;
        transform: translateY(0) scaleY(0.98);
    }
    75% {
        opacity: 0.4;
        transform: translateY(2px) scaleY(1.02);
    }
}

/* Pillar rise effect */
@keyframes pillarRise {
    0% {
        transform: translateY(100%) scaleY(0);
        filter: brightness(2);
    }
    30% {
        transform: translateY(0) scaleY(1.1);
        filter: brightness(1.5);
    }
    100% {
        transform: translateY(0) scaleY(1);
        filter: brightness(1);
    }
}

/* Debris whoosh effect */
@keyframes debrisWhoosh {
    0% {
        transform: translateY(-100px) scale(0.5) rotate(0deg);
        opacity: 0;
    }
    20% {
        opacity: 1;
    }
    100% {
        transform: translateY(0) scale(1) rotate(360deg);
        opacity: 1;
    }
}

/* Impact flash for arena */
@keyframes arenaFlash {
    0%, 100% {
        box-shadow: inset 0 0 0 rgba(255, 255, 255, 0);
    }
    50% {
        box-shadow: inset 0 0 30px rgba(255, 50, 50, 0.3);
    }
}

/* Danger vignette */
@keyframes dangerVignette {
    0%, 100% {
        box-shadow: inset 0 0 50px rgba(255, 0, 0, 0);
    }
    50% {
        box-shadow: inset 0 0 80px rgba(255, 0, 0, 0.4);
    }
}

/* Intense combat state with chromatic aberration */
@keyframes combatIntensity {
    0% {
        filter: brightness(1) contrast(1.05) saturate(1.1);
        transform: scale(1);
    }
    25% {
        filter: brightness(1.08) contrast(1.15) saturate(1.2);
        transform: scale(1.002);
    }
    50% {
        filter: brightness(1) contrast(1.05) saturate(1.1);
        transform: scale(1);
    }
    75% {
        filter: brightness(1.08) contrast(1.15) saturate(1.2);
        transform: scale(1.002);
    }
    100% {
        filter: brightness(1) contrast(1.05) saturate(1.1);
        transform: scale(1);
    }
}

/* Motion blur on fast attacks */
@keyframes motionBlur {
    0% {
        filter: blur(0px);
        transform: translateY(0);
    }
    50% {
        filter: blur(2px);
        transform: translateY(5px);
    }
    100% {
        filter: blur(0px);
        transform: translateY(0);
    }
}

/* Screen distortion for powerful hits */
@keyframes screenDistort {
    0%, 100% {
        transform: scale(1) skew(0deg);
        filter: hue-rotate(0deg);
    }
    10% {
        transform: scale(1.02, 0.98) skew(1deg);
        filter: hue-rotate(5deg);
    }
    20% {
        transform: scale(0.98, 1.02) skew(-1deg);
        filter: hue-rotate(-5deg);
    }
    30% {
        transform: scale(1.01, 0.99) skew(0.5deg);
        filter: hue-rotate(2deg);
    }
    40% {
        transform: scale(0.99, 1.01) skew(-0.5deg);
        filter: hue-rotate(-2deg);
    }
}

/* Rainstorm effect for dust motes attack */
@keyframes rainstorm {
    0%, 100% {
        filter: brightness(0.9) contrast(1.1) blur(0px);
        box-shadow: inset 0 0 50px rgba(100, 150, 255, 0.1);
    }
    50% {
        filter: brightness(0.85) contrast(1.15) blur(0.3px);
        box-shadow: inset 0 0 80px rgba(100, 150, 255, 0.2);
    }
}

.rainstorm-active {
    animation: rainstorm 2s ease-in-out infinite;
}

/* Impact flash with color shift */
@keyframes impactFlash {
    0% {
        filter: brightness(1) saturate(1);
        box-shadow: inset 0 0 0 rgba(255, 255, 255, 0);
    }
    20% {
        filter: brightness(3) saturate(0);
        box-shadow: inset 0 0 100px rgba(255, 255, 255, 0.8);
    }
    40% {
        filter: brightness(1.5) saturate(1.5);
        box-shadow: inset 0 0 50px rgba(255, 100, 100, 0.4);
    }
    100% {
        filter: brightness(1) saturate(1);
        box-shadow: inset 0 0 0 rgba(255, 255, 255, 0);
    }
}

/* Chromatic aberration effect */
@keyframes chromaticShift {
    0%, 100% {
        text-shadow: 0 0 0 rgba(255, 0, 0, 0);
    }
    25% {
        text-shadow: -2px 0 0 rgba(255, 0, 0, 0.5),
                     2px 0 0 rgba(0, 255, 255, 0.5);
    }
    50% {
        text-shadow: -3px 0 0 rgba(255, 0, 0, 0.7),
                     3px 0 0 rgba(0, 255, 255, 0.7);
    }
    75% {
        text-shadow: -2px 0 0 rgba(255, 0, 0, 0.5),
                     2px 0 0 rgba(0, 255, 255, 0.5);
    }
}

/* Attack telegraph with intense pulse */
@keyframes intenseTelegraph {
    0% {
        opacity: 0.2;
        transform: scale(0.9);
        filter: brightness(1) drop-shadow(0 0 5px rgba(255, 50, 50, 0.3));
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
        filter: brightness(1.5) drop-shadow(0 0 20px rgba(255, 50, 50, 0.8));
    }
    100% {
        opacity: 0.2;
        transform: scale(0.9);
        filter: brightness(1) drop-shadow(0 0 5px rgba(255, 50, 50, 0.3));
    }
}

/* Attack incoming pulse */
@keyframes attackPulse {
    0% {
        border-color: #ffffff;
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
    }
    50% {
        border-color: #ff5555;
        box-shadow: 0 0 20px rgba(255, 50, 50, 0.6);
    }
    100% {
        border-color: #ffffff;
        box-shadow: 0 0 5px rgba(255, 255, 255, 0.2);
    }
}

/* Dialogue box slide in */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Button hover effect (for future touch/mouse support) */
@keyframes buttonPress {
    0% { transform: scale(1); }
    50% { transform: scale(0.95); }
    100% { transform: scale(1); }
}

/* HP bar drain animation */
@keyframes hpDrain {
    0% { filter: brightness(1); }
    25% { filter: brightness(1.5); }
    50% { filter: brightness(1); }
    75% { filter: brightness(1.5); }
    100% { filter: brightness(1); }
}

/* Boss awakening glow */
@keyframes awakeningGlow {
    0% {
        filter: brightness(1);
        opacity: 1;
    }
    50% {
        filter: brightness(1.5) saturate(1.5);
        opacity: 0.9;
    }
    100% {
        filter: brightness(1);
        opacity: 1;
    }
}

/* Pixel-perfect scanline effect (optional, very subtle) */
@keyframes scanline {
    0% { transform: translateY(-100%); }
    100% { transform: translateY(100%); }
}

/* Intro text fade */
@keyframes introFade {
    0% {
        opacity: 0;
        letter-spacing: 10px;
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        letter-spacing: 2px;
    }
}

/* ==================== */
/* UTILITY CLASSES */
/* ==================== */

.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.fade-out {
    animation: fadeIn 0.3s ease-out reverse forwards;
}

.slide-up {
    animation: slideUp 0.3s ease-out forwards;
}

.glow {
    animation: menuGlow 1s ease-in-out infinite;
}

.pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

.combat-intense {
    animation: combatIntensity 2s ease-in-out infinite;
}

.danger-state {
    animation: dangerVignette 1s ease-in-out infinite, combatIntensity 2s ease-in-out infinite;
}

/* Low-health pulsing vignette with red border blink */
@keyframes lowHealthVignette {
    0%, 100% {
        box-shadow: inset 0 0 60px rgba(255, 0, 0, 0.3), inset 0 0 100px rgba(0, 0, 0, 0.4);
        filter: saturate(0.9) brightness(0.96) contrast(1.05);
    }
    50% {
        box-shadow: inset 0 0 150px rgba(255, 0, 0, 0.7), inset 0 0 120px rgba(0, 0, 0, 0.5);
        filter: saturate(0.8) brightness(0.88) contrast(1.1);
    }
}

@keyframes redBorderBlink {
    0%, 100% {
        border-color: rgba(255, 0, 0, 0.6);
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.4), inset 0 0 20px rgba(255, 0, 0, 0.2);
    }
    50% {
        border-color: rgba(255, 0, 0, 0.95);
        box-shadow: 0 0 40px rgba(255, 0, 0, 0.8), inset 0 0 40px rgba(255, 0, 0, 0.4);
    }
}

.low-health {
    animation: lowHealthVignette 1.2s ease-in-out infinite, redBorderBlink 0.8s ease-in-out infinite;
    border: 3px solid rgba(255, 0, 0, 0.6);
}

.attack-incoming {
    animation: attackPulse 0.8s ease-in-out infinite;
}

.screen-distort {
    animation: screenDistort 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.impact-flash {
    animation: impactFlash 0.3s ease-out;
}

.motion-blur {
    animation: motionBlur 0.2s ease-out;
}

.chromatic-text {
    animation: chromaticShift 0.5s ease-in-out infinite;
}

/* Selection indicator (for menu) */
.selected {
    position: relative;
}

.selected::before {
    content: '❤';
    position: absolute;
    left: -20px;
    animation: heartbeat 0.5s ease-in-out infinite;
}

/* Smooth transitions for all interactive elements */
* {
    transition: transform 0.1s ease, opacity 0.2s ease;
}

/* Performance optimization: will-change hints */
#gameCanvas,
.dialogue-text,
.loading {
    will-change: transform, opacity;
}

/* Prevent text selection for game elements */
#game-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    user-select: none;
}

/* Crisp pixel rendering across browsers */
canvas {
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Accessibility: reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    #gameCanvas {
        border-width: 3px;
    }
    
    #debug-info {
        background: rgba(0, 0, 0, 0.95);
    }
}
