/* ============================================
     RESET & BASE
     ============================================ */
  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    background: #0a0a0f;
    color: #e0e0e0;
    font-family: 'Poppins', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  /* ============================================
     GAME CONTAINER
     ============================================ */
  #game {
    width: 100%;
    max-width: 900px;
    height: 100vh;
    max-height: 620px;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
    border: 2px solid #1a1a2e;
  }

  /* ============================================
     ARENA
     ============================================ */
  #arena {
    flex: 1;
    position: relative;
    background: linear-gradient(180deg, #0a0a18 0%, #121230 50%, #1a1a40 100%);
    overflow: hidden;
    min-height: 300px;
  }

  /* ============================================
     BACKGROUNDS
     ============================================ */
  #bg-layer {
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
  }

  .bg-arena {
    background:
      radial-gradient(circle at 20% 30%, rgba(74, 158, 237, 0.08) 0%, transparent 40%),
      radial-gradient(circle at 80% 20%, rgba(239, 68, 68, 0.08) 0%, transparent 40%),
      linear-gradient(180deg, #0c0c18 0%, #161628 60%, #1e1e3a 100%);
  }

  .bg-arena::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -50%;
    width: 200%;
    height: 140px;
    background:
      linear-gradient(to top, rgba(10,10,25,0.95), transparent),
      repeating-linear-gradient(90deg, rgba(74,74,138,0.25) 0px, rgba(74,74,138,0.25) 1px, transparent 1px, transparent 50px);
    transform: perspective(400px) rotateX(60deg);
    transform-origin: bottom;
    opacity: 0.5;
  }

  .bg-forest {
    background:
      radial-gradient(circle at 10% 90%, rgba(34, 197, 94, 0.1) 0%, transparent 50%),
      radial-gradient(circle at 90% 80%, rgba(34, 197, 94, 0.08) 0%, transparent 40%),
      linear-gradient(180deg, #051105 0%, #0a1a0f 60%, #0f2a15 100%);
  }

  .bg-space {
    background:
      radial-gradient(circle at 30% 20%, rgba(139, 92, 246, 0.12) 0%, transparent 40%),
      radial-gradient(circle at 70% 40%, rgba(59, 130, 246, 0.1) 0%, transparent 40%),
      linear-gradient(180deg, #050510 0%, #0a0a1a 60%, #10102a 100%);
  }

  .bg-platformer {
    background: linear-gradient(180deg, #0a0a15 0%, #121225 40%, #1a1a35 70%, #252040 100%);
  }

  .bg-platformer::before,
  .bg-platformer::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: #fff;
  }

  .bg-platformer::before {
    width: 2px;
    height: 2px;
    top: 10%;
    left: 15%;
    box-shadow:
      120px 40px 0 #fff, 300px 20px 0 #fff, 450px 60px 0 #fff,
      600px 30px 0 #fff, 750px 50px 0 #fff, 80px 100px 0 #fff,
      220px 120px 0 #fff, 380px 90px 0 #fff, 520px 110px 0 #fff,
      680px 80px 0 #fff, 50px 160px 0 #fff, 200px 180px 0 #fff,
      350px 150px 0 #fff, 500px 170px 0 #fff, 650px 140px 0 #fff,
      820px 25px 0 #fff, 900px 70px 0 #fff, 40px 220px 0 #fff,
      180px 240px 0 #fff, 320px 210px 0 #fff, 480px 230px 0 #fff,
      620px 200px 0 #fff, 780px 190px 0 #fff, 950px 130px 0 #fff,
      30px 280px 0 #fff, 150px 300px 0 #fff, 290px 270px 0 #fff,
      440px 290px 0 #fff, 580px 260px 0 #fff, 720px 280px 0 #fff,
      860px 250px 0 #fff, 980px 180px 0 #fff;
    opacity: 0.6;
  }

  .bg-platformer::after {
    width: 3px;
    height: 3px;
    top: 8%;
    left: 8%;
    box-shadow:
      200px 60px 0 #fff, 420px 30px 0 #fff, 640px 80px 0 #fff,
      850px 40px 0 #fff, 110px 140px 0 #fff, 330px 170px 0 #fff,
      550px 130px 0 #fff, 770px 160px 0 #fff, 920px 100px 0 #fff,
      60px 260px 0 #fff, 280px 230px 0 #fff, 500px 270px 0 #fff;
    opacity: 0.4;
  }

  /* If you drop in a custom image, just add it to assets/bg/ and set the URL in config */
  .bg-custom {
    background-color: #0a0a12;
    background-size: cover;
    background-position: center bottom;
    background-repeat: no-repeat;
  }

  /* Subtle platform glow under tiles */
  #arena::after {
    content: '';
    position: absolute;
    bottom: 26px;
    left: 5%;
    width: 90%;
    height: 4px;
    background: linear-gradient(90deg, transparent, #2a2a5a, #4a4a8a, #2a2a5a, transparent);
    border-radius: 2px;
    box-shadow: 0 0 15px #2a2a5a44;
    opacity: 0.5;
  }

  /* ============================================
     HEALTH BARS
     ============================================ */
  #hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    z-index: 10;
  }

  .health-section { width: 38%; }

  .health-name {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 4px;
  }

  .player-name { color: #4a9eed; }
  .boss-name { color: #ef4444; text-align: right; }

  .health-bar-bg {
    width: 100%;
    height: 16px;
    background: #0d0d15;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #2a2a4a;
  }

  .health-bar-fill {
    height: 100%;
    border-radius: 8px;
    transition: width 0.5s ease;
  }

  .player-health .health-bar-fill {
    background: linear-gradient(90deg, #1d4ed8, #4a9eed);
    box-shadow: inset 0 1px 0 #6ab5f7, 0 0 8px #4a9eed44;
  }

  .boss-health .health-bar-fill {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    box-shadow: inset 0 1px 0 #f87171, 0 0 8px #ef444444;
    float: right;
  }

  @keyframes hp-critical-pulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.4) saturate(1.3); }
  }

  .hp-critical .health-bar-fill {
    animation: hp-critical-pulse 0.8s ease-in-out infinite;
  }

  .player-health.hp-critical .health-bar-fill {
    background: linear-gradient(90deg, #dc2626, #ef4444);
    box-shadow: inset 0 1px 0 #f87171, 0 0 12px #ef4444aa;
  }

  .boss-health.hp-critical .health-bar-fill {
    background: linear-gradient(90deg, #dc2626, #ef4444);
    box-shadow: inset 0 1px 0 #f87171, 0 0 12px #ef4444aa;
  }

  .health-text {
    font-size: 11px;
    color: #666;
    margin-top: 3px;
  }
  .boss-health .health-text { text-align: right; }

  /* ============================================
     AP DISPLAY
     ============================================ */
  #ap-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    text-align: center;
  }

  .ap-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #f59e0b;
    opacity: 0.7;
  }

  .ap-orbs {
    display: flex;
    gap: 3px;
    margin-top: 3px;
  }

  .ap-orb {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: background 0.2s;
  }

  .ap-orb.filled {
    background: #22c55e;
  }

  .ap-orb.boss.filled {
    background: #ef4444;
  }

  /* ============================================
     CHARACTERS
     ============================================ */
  .character {
    position: absolute;
    bottom: 68px;
    width: 160px;
    height: 200px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 5;
  }

  .character img {
    width: 140px;
    height: auto;
    image-rendering: auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 12px #00000088);
    transition: filter 0.2s;
  }

  #player-char { left: 8%; }
  #boss-char {
    right: 8%;
    transform: scaleX(-1);
  }

  #boss-char.intro-hidden {
    transform: scaleX(-1) translateX(300px);
    opacity: 0;
  }

  @keyframes boss-walk-in {
    0% { transform: scaleX(-1) translateX(300px); opacity: 0; }
    10% { opacity: 1; }
    100% { transform: scaleX(-1) translateX(0); opacity: 1; }
  }

  .anim-boss-intro { animation: boss-walk-in 1.2s ease-out forwards; }

  /* Idle bounce */
  @keyframes idle-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
  }

  @keyframes idle-bounce-flipped {
    0%, 100% { transform: scaleX(-1) translateY(0); }
    50% { transform: scaleX(-1) translateY(-5px); }
  }

  #player-char.idle { animation: idle-bounce 2s ease-in-out infinite; }
  #boss-char.idle { animation: idle-bounce-flipped 2.3s ease-in-out infinite; }

  /* Attack lunge */
  @keyframes player-lunge {
    0% { transform: translateX(0); }
    35% { transform: translateX(100px) scale(1.05); }
    65% { transform: translateX(100px) scale(1.05); }
    100% { transform: translateX(0) scale(1); }
  }

  @keyframes boss-lunge {
    0% { transform: scaleX(-1) translateX(0); }
    35% { transform: scaleX(-1) translateX(100px) scale(1.05); }
    65% { transform: scaleX(-1) translateX(100px) scale(1.05); }
    100% { transform: scaleX(-1) translateX(0) scale(1); }
  }

  /* Damage shake */
  @keyframes damage-shake {
    0%, 100% { transform: translateX(0); filter: brightness(1); }
    15% { transform: translateX(-8px); filter: brightness(2) sepia(1) hue-rotate(-30deg); }
    30% { transform: translateX(8px); filter: brightness(1); }
    45% { transform: translateX(-6px); filter: brightness(2) sepia(1) hue-rotate(-30deg); }
    60% { transform: translateX(6px); filter: brightness(1); }
    75% { transform: translateX(-3px); filter: brightness(1.5) sepia(1) hue-rotate(-30deg); }
  }

  @keyframes boss-damage-shake {
    0%, 100% { transform: scaleX(-1) translateX(0); filter: brightness(1); }
    15% { transform: scaleX(-1) translateX(-8px); filter: brightness(2) sepia(1) hue-rotate(-30deg); }
    30% { transform: scaleX(-1) translateX(8px); filter: brightness(1); }
    45% { transform: scaleX(-1) translateX(-6px); filter: brightness(2) sepia(1) hue-rotate(-30deg); }
    60% { transform: scaleX(-1) translateX(6px); filter: brightness(1); }
    75% { transform: scaleX(-1) translateX(-3px); filter: brightness(1.5) sepia(1) hue-rotate(-30deg); }
  }

  /* Special glow */
  @keyframes special-glow {
    0% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
    50% { filter: brightness(1.8) drop-shadow(0 0 25px #f59e0b) drop-shadow(0 0 50px #f59e0baa); }
    100% { filter: brightness(1) drop-shadow(0 0 0 transparent); }
  }

  /* Slash effect */
  #slash-effect {
    position: absolute;
    width: 120px;
    height: 120px;
    pointer-events: none;
    opacity: 0;
    z-index: 18;
    background: linear-gradient(135deg, transparent 45%, #ffffff 48%, #ffffff 52%, transparent 55%);
    transform: translate(-50%, -50%) rotate(-45deg) scale(0.5);
  }

  @keyframes slash-swing {
    0% { opacity: 0; transform: translate(-50%, -50%) rotate(-60deg) scale(0.3); }
    20% { opacity: 1; transform: translate(-50%, -50%) rotate(-45deg) scale(1); }
    60% { opacity: 1; transform: translate(-50%, -50%) rotate(-30deg) scale(1.1); }
    100% { opacity: 0; transform: translate(-50%, -50%) rotate(0deg) scale(0.5); }
  }

  .anim-slash { animation: slash-swing 0.45s ease-out forwards; }

  /* Defend glow */
  #defend-glow {
    position: absolute;
    width: 180px;
    height: 220px;
    bottom: 30px;
    left: 8%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(74,158,237,0.25) 0%, transparent 70%);
    opacity: 0;
    pointer-events: none;
    z-index: 4;
    transition: opacity 0.3s ease;
  }

  #defend-glow.show { opacity: 1; animation: shield-pulse 1s ease-in-out infinite; }

  @keyframes shield-pulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.08); opacity: 1; }
  }

  .defending img {
    filter: drop-shadow(0 0 10px #4a9eed) drop-shadow(0 0 20px #4a9eed66) !important;
  }

  /* Stronger screen shake for special */
  @keyframes screen-shake-hard {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-8px, 5px); }
    20% { transform: translate(8px, -5px); }
    30% { transform: translate(-6px, 4px); }
    40% { transform: translate(6px, -4px); }
    50% { transform: translate(-4px, 5px); }
    60% { transform: translate(4px, -3px); }
    70% { transform: translate(-2px, 2px); }
  }

  .anim-screen-shake-hard { animation: screen-shake-hard 0.55s ease; }

  /* Knockback */
  @keyframes player-knockback {
    0% { transform: translateX(0); }
    30% { transform: translateX(-60px); filter: brightness(1.5) sepia(1) hue-rotate(-30deg); }
    60% { transform: translateX(-40px); }
    100% { transform: translateX(0); }
  }

  @keyframes boss-knockback {
    0% { transform: scaleX(-1) translateX(0); }
    30% { transform: scaleX(-1) translateX(-60px); filter: brightness(1.5) sepia(1) hue-rotate(-30deg); }
    60% { transform: scaleX(-1) translateX(-40px); }
    100% { transform: scaleX(-1) translateX(0); }
  }

  .anim-player-knockback { animation: player-knockback 0.55s ease-out !important; }
  .anim-boss-knockback { animation: boss-knockback 0.55s ease-out !important; }

  /* Block sparks */
  #block-sparks {
    position: absolute;
    width: 140px;
    height: 140px;
    bottom: 60px;
    left: 8%;
    pointer-events: none;
    opacity: 0;
    z-index: 18;
    background:
      radial-gradient(circle at 30% 30%, #fff 2px, transparent 3px),
      radial-gradient(circle at 70% 40%, #4a9eed 3px, transparent 4px),
      radial-gradient(circle at 40% 70%, #fff 2px, transparent 3px),
      radial-gradient(circle at 60% 60%, #4a9eed 2px, transparent 3px);
  }

  @keyframes sparks-burst {
    0% { opacity: 1; transform: scale(0.5) rotate(0deg); }
    50% { opacity: 1; transform: scale(1.3) rotate(45deg); }
    100% { opacity: 0; transform: scale(1.6) rotate(90deg); }
  }

  .anim-sparks { animation: sparks-burst 0.5s ease-out forwards; }

  /* AP popup */
  .ap-popup {
    position: absolute;
    font-size: 20px;
    font-weight: 900;
    color: #f59e0b;
    pointer-events: none;
    z-index: 25;
    animation: ap-float 1s ease-out forwards;
    text-shadow: 0 0 10px #f59e0b88;
  }

  @keyframes ap-float {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    50% { opacity: 1; transform: translateY(-25px) scale(1.15); }
    100% { opacity: 0; transform: translateY(-45px) scale(0.9); }
  }

  /* Boss attack warning */
  #attack-warning {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 42px;
    font-weight: 900;
    color: #ef4444;
    text-transform: uppercase;
    letter-spacing: 4px;
    opacity: 0;
    pointer-events: none;
    z-index: 30;
    text-shadow: 0 0 20px #ef4444aa;
  }

  @keyframes warning-flash {
    0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    50% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
    75% { opacity: 1; transform: translate(-50%, -50%) scale(1.02); }
  }

  .anim-warning { animation: warning-flash 0.9s ease-in-out forwards; }


  /* Power-ups */
  .powerup {
    position: absolute;
    width: 36px;
    height: 36px;
    bottom: 90px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 900;
    color: #fff;
    pointer-events: auto;
    cursor: pointer;
    z-index: 15;
    animation: powerup-bob 1.2s ease-in-out infinite;
    box-shadow: 0 0 15px currentColor;
  }
  @keyframes powerup-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
  }
  .powerup.hp { background: #ef4444; left: 42%; }
  .powerup.time { background: #22c55e; left: 50%; }
  .powerup.ap { background: #f59e0b; left: 58%; }

  /* Animated HP drain */
  .health-bar-fill-delay {
    height: 100%;
    border-radius: 8px;
    position: absolute;
    top: 0;
    transition: width 0.8s ease 0.3s;
    opacity: 0.35;
  }
  .player-health .health-bar-fill-delay {
    background: #4a9eed;
    left: 0;
  }
  .boss-health .health-bar-fill-delay {
    background: #ef4444;
    right: 0;
  }
  .health-bar-bg { position: relative; }

  /* Particles */
  .particle {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    z-index: 16;
  }
  .dust {
    background: rgba(200,200,200,0.4);
    animation: dust-fade 0.6s ease-out forwards;
  }
  @keyframes dust-fade {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(2.5); opacity: 0; }
  }
  .spark {
    background: #f59e0b;
    box-shadow: 0 0 6px #f59e0b;
    animation: spark-fly 0.5s ease-out forwards;
  }
  @keyframes spark-fly {
    0% { transform: translate(0,0) scale(1); opacity: 1; }
    100% { transform: translate(var(--tx), var(--ty)) scale(0.3); opacity: 0; }
  }
  .explosion {
    background: radial-gradient(circle, #fff 0%, #f59e0b 40%, #ef4444 70%, transparent 100%);
    animation: explode 0.6s ease-out forwards;
  }
  @keyframes explode {
    0% { transform: translate(-50%,-50%) scale(0.2); opacity: 1; }
    100% { transform: translate(-50%,-50%) scale(2.5); opacity: 0; }
  }

  /* Streak glow */
  .streak-charged img {
    filter: drop-shadow(0 0 12px #f59e0b) drop-shadow(0 0 24px #ef4444) !important;
  }

  /* Skins */
  .skin-gold img { filter: brightness(1.15) sepia(1) saturate(3) hue-rotate(-15deg) drop-shadow(0 4px 12px #00000088) !important; }
  .skin-neon img { filter: brightness(1.1) saturate(2.5) hue-rotate(180deg) drop-shadow(0 4px 12px #00000088) !important; }
  .skin-shadow img { filter: grayscale(1) brightness(0.7) drop-shadow(0 0 10px #8b5cf6) !important; }

  /* Tile layer */
  #tile-layer {
    position: absolute;
    inset: 0;
    z-index: 1;
    pointer-events: none;
  }
  #tile-layer .tile {
    position: absolute;
    image-rendering: pixelated;
    object-fit: cover;
    pointer-events: none;
  }
  #tile-layer .torch {
    animation: torch-flicker 1.2s ease-in-out infinite alternate;
  }
  @keyframes torch-flicker {
    0% { filter: brightness(1) drop-shadow(0 0 4px #f59e0b66); transform: scale(1); }
    100% { filter: brightness(1.25) drop-shadow(0 0 10px #f59e0baa); transform: scale(1.06); }
  }
/* Timer bar */
  #timer-bar-container {
    width: 100%;
    height: 5px;
    background: #e2e8f0;
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.3s;
  }
  #timer-bar-container.show { opacity: 1; }
  #timer-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #22c55e, #f59e0b, #ef4444);
    width: 100%;
    transform-origin: left;
    transition: transform 0.1s linear;
  }

  /* Enrage mode */
  #boss-char.enraged img {
    filter: drop-shadow(0 0 8px #ef4444) drop-shadow(0 0 16px #ef4444aa) brightness(1.15) !important;
    animation: enraged-pulse 0.6s ease-in-out infinite !important;
  }
  @keyframes enraged-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.04); }
  }

  /* Overdrive warning */
  #overdrive-warning {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: 900;
    color: #f59e0b;
    text-transform: uppercase;
    letter-spacing: 6px;
    opacity: 0;
    pointer-events: none;
    z-index: 35;
    text-shadow: 0 0 30px #f59e0bbb, 0 0 60px #ef4444aa;
  }
  @keyframes overdrive-flash {
    0%, 100% { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
    40% { opacity: 0.2; transform: translate(-50%, -50%) scale(1); }
    60% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
    80% { opacity: 0.3; transform: translate(-50%, -50%) scale(0.98); }
  }
  .anim-overdrive { animation: overdrive-flash 1.2s ease-in-out forwards; }

  /* Combo fire */
  #combo-fire {
    position: absolute;
    width: 160px;
    height: 200px;
    bottom: 68px;
    left: 8%;
    pointer-events: none;
    opacity: 0;
    z-index: 6;
    transition: opacity 0.4s ease;
  }
  #combo-fire.show { opacity: 1; }
  .fire-particle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, #f59e0b 0%, #ef4444 60%, transparent 100%);
    border-radius: 50%;
    animation: fire-rise 1s ease-out forwards;
  }
  @keyframes fire-rise {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    100% { transform: translateY(-80px) scale(0.3); opacity: 0; }
  }

  /* AP orb combo burn */
  .ap-orb.filled.combo-burn {
    background: #f59e0b;
    border-color: #ef4444;
    box-shadow: 0 0 10px #ef4444, inset 0 0 4px #f59e0b;
    animation: orb-burn 0.6s ease-in-out infinite;
  }
  @keyframes orb-burn {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); box-shadow: 0 0 14px #ef4444; }
  }

  /* Crit popup & lightning */
  .damage-popup.crit {
    color: #facc15;
    font-size: 38px;
    text-shadow: 0 0 15px #facc15aa, 0 0 30px #fff;
    animation: crit-bounce 1s ease-out forwards;
  }
  @keyframes crit-bounce {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    30% { transform: translateY(-45px) scale(1.4); }
    100% { opacity: 0; transform: translateY(-75px) scale(0.9); }
  }
  #crit-flash {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.25);
    opacity: 0;
    pointer-events: none;
    z-index: 20;
  }
  @keyframes lightning-flash {
    0%, 100% { opacity: 0; }
    10% { opacity: 1; }
    20% { opacity: 0; }
    30% { opacity: 0.7; }
    40% { opacity: 0; }
  }
  .anim-lightning { animation: lightning-flash 0.4s ease-out forwards; }

  /* Dodge */
  @keyframes player-dodge {
    0% { transform: translateX(0); filter: blur(0); opacity: 1; }
    25% { transform: translateX(-40px) scaleX(0.8); filter: blur(2px); opacity: 0.8; }
    50% { transform: translateX(20px) scaleX(0.9); filter: blur(1px); opacity: 0.9; }
    100% { transform: translateX(0) scaleX(1); filter: blur(0); opacity: 1; }
  }
  .anim-player-dodge { animation: player-dodge 0.5s ease-out !important; }

  .damage-popup.dodge {
    color: #4a9eed;
    font-size: 24px;
    text-shadow: 0 0 10px #4a9eed88;
  }

  /* Death */
  @keyframes player-death {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    40% { transform: translateY(-20px) rotate(-10deg); opacity: 1; }
    100% { transform: translateY(30px) rotate(90deg); opacity: 0.3; }
  }

  @keyframes boss-death {
    0% { transform: scaleX(-1) translateY(0) rotate(0deg); opacity: 1; }
    40% { transform: scaleX(-1) translateY(-20px) rotate(10deg); opacity: 1; }
    100% { transform: scaleX(-1) translateY(30px) rotate(-90deg); opacity: 0.3; }
  }

  /* Screen shake */
  @keyframes screen-shake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-5px, 3px); }
    20% { transform: translate(5px, -3px); }
    30% { transform: translate(-4px, 2px); }
    40% { transform: translate(4px, -2px); }
    50% { transform: translate(-3px, 3px); }
    60% { transform: translate(3px, -1px); }
  }

  .anim-player-lunge { animation: player-lunge 0.65s ease-out !important; }
  .anim-boss-lunge { animation: boss-lunge 0.65s ease-out !important; }
  .anim-player-damage { animation: damage-shake 0.5s ease !important; }
  .anim-boss-damage { animation: boss-damage-shake 0.5s ease !important; }
  .anim-special-glow { animation: special-glow 0.9s ease-in-out !important; }
  .anim-player-death { animation: player-death 0.8s ease-in forwards !important; }
  .anim-boss-death { animation: boss-death 0.8s ease-in forwards !important; }
  .anim-screen-shake { animation: screen-shake 0.4s ease; }
  .anim-screen-shake-hard { animation: screen-shake-hard 0.55s ease; }

  /* ============================================
     IMPACT FLASH
     ============================================ */
  #impact-flash {
    position: absolute;
    width: 90px;
    height: 90px;
    border-radius: 50%;
    background: radial-gradient(circle, #ffffffee, #f59e0b88, transparent);
    pointer-events: none;
    opacity: 0;
    z-index: 20;
    transform: translate(-50%, -50%);
  }

  @keyframes impact-burst {
    0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
  }

  #impact-flash.show { animation: impact-burst 0.4s ease-out forwards; }

  /* ============================================
     DAMAGE POPUP
     ============================================ */
  .damage-popup {
    position: absolute;
    font-size: 26px;
    font-weight: 900;
    pointer-events: none;
    z-index: 25;
    animation: damage-float 1s ease-out forwards;
    text-shadow: 2px 2px 4px #000000aa;
  }

  .damage-popup.player-dmg { color: #ef4444; }
  .damage-popup.boss-dmg { color: #22c55e; }
  .damage-popup.special-dmg { color: #f59e0b; font-size: 34px; }
  .damage-popup.blocked { color: #4a9eed; font-size: 20px; }

  @keyframes damage-float {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    50% { opacity: 1; transform: translateY(-35px) scale(1.2); }
    100% { opacity: 0; transform: translateY(-65px) scale(0.8); }
  }

  /* ============================================
     COMBO
     ============================================ */
  #combo-display {
    position: absolute;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    font-weight: 800;
    color: #f59e0b;
    text-transform: uppercase;
    letter-spacing: 2px;
    opacity: 0;
    z-index: 10;
    text-shadow: 0 0 12px #f59e0b66;
    transition: opacity 0.3s;
  }

  #combo-display.show { opacity: 1; }

  /* ============================================
     BOTTOM PANEL
     ============================================ */
  #bottom-panel {
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    padding: 6px 14px 10px;
    min-height: 230px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  #question-box {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 8px 12px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.03);
  }

  #question-text {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.4;
  }

  #options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .option-btn {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 10px 12px;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: left;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  }

  .option-btn:hover:not(:disabled) {
    border-color: #94a3b8;
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.06);
  }

  .option-btn.correct { border-color: #22c55e; background: #f0fdf4; color: #15803d; }
  .option-btn.wrong { border-color: #ef4444; background: #fef2f2; color: #b91c1c; }
  .option-btn:disabled { cursor: default; }

  #action-bar { display: none; flex-direction: column; gap: 8px; }

  .action-row { display: flex; gap: 8px; }
  .action-row .action-btn, .action-row .action-dropdown { flex: 1; }

  /* Clean flat action buttons */
  .action-btn {
    position: relative;
    padding: 10px 6px;
    border: 1px solid;
    border-radius: 12px;
    background: #ffffff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    line-height: 1.1;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  }
  .action-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0,0,0,0.08);
  }
  .action-btn:disabled {
    opacity: 0.35;
    cursor: default;
    transform: none;
    box-shadow: none;
    filter: grayscale(0.8);
  }
  .action-btn .cost-label {
    font-size: 9px;
    font-weight: 600;
    opacity: 0.75;
    margin-top: 2px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  /* Role accent colours — all blue family */
  #btn-attack, #btn-free { color: #2563eb; border-color: #bfdbfe; background: #eff6ff; }
  #btn-attack:hover:not(:disabled), #btn-free:hover:not(:disabled) { background: #dbeafe; border-color: #93c5fd; }
  #btn-defend { color: #059669; border-color: #a7f3d0; background: #ecfdf5; }
  #btn-defend:hover:not(:disabled) { background: #d1fae5; border-color: #6ee7b7; }
  #btn-special { color: #d97706; border-color: #fde68a; background: #fffbeb; }
  #btn-special:hover:not(:disabled) { background: #fef3c7; border-color: #fcd34d; }
  #btn-ultimate { color: #7c3aed; border-color: #ddd6fe; background: #f5f3ff; }
  #btn-ultimate:hover:not(:disabled) { background: #ede9fe; border-color: #c4b5fd; }
  #btn-focus { color: #0891b2; border-color: #a5f3fc; background: #ecfeff; }
  #btn-focus:hover:not(:disabled) { background: #cffafe; border-color: #67e8f9; }
  #btn-attack { width: 100%; height: 100%; }

  /* Dropdown */
  .action-dropdown { position: relative; }
  .dropdown-menu {
    display: none;
    position: absolute;
    bottom: 108%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    overflow: hidden;
    z-index: 50;
    flex-direction: column;
    padding: 6px;
    gap: 4px;
    box-shadow: 0 -6px 16px rgba(15, 23, 42, 0.08);
  }
  .action-dropdown.open .dropdown-menu { display: flex; }
  .dropdown-btn {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    color: #334155;
    padding: 9px 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.12s ease;
  }
  .dropdown-btn:hover { background: #f1f5f9; border-color: #cbd5e1; }
  .dropdown-btn:disabled { opacity: 0.25; cursor: default; }
  .dropdown-btn .cost-label { font-size: 10px; font-weight: 600; opacity: 0.75; color: #64748b; margin-top: 0; text-transform: uppercase; }
  .dropdown-header {
    font-size: 9px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 6px 8px 2px;
    text-align: center;
    opacity: 0.9;
    pointer-events: none;
  }
  .dropdown-gambit { color: #ef4444; font-weight: 700; }
  .dropdown-gambit:hover { background: #fef2f2; border-color: #fecaca; }
  #boss-intent { display: none; }

  .cost-label { font-size: 10px; display: block; opacity: 0.6; margin-top: 2px; }

  #modifier-badge { text-align: center; font-size: 12px; color: #7c3aed; font-weight: 700; margin-bottom: 6px; min-height: 18px; letter-spacing: 0.6px; text-transform: uppercase; }
  #status-msg { display: none; }

  /* ============================================
     OVERLAYS
     ============================================ */
  .overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(6px);
    background: #0a0a0fdd;
    gap: 14px;
  }

  .overlay h1 {
    font-size: 38px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 4px;
  }

  .overlay p {
    font-size: 15px;
    color: #999;
    max-width: 380px;
    text-align: center;
    line-height: 1.5;
    white-space: pre-line;
  }

  .overlay-btn {
    margin-top: 10px;
    padding: 14px 44px;
    font-size: 16px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    border: 2px solid;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
  }

  #start-screen { display: none; }
  #start-screen h1 { color: #4a9eed; }
  #start-screen .overlay-btn { border-color: #4a9eed; color: #4a9eed; }
  #start-screen .overlay-btn:hover { background: #4a9eed; color: #0a0a0f; }

  #victory-screen { display: none; }
  #victory-screen h1 { color: #22c55e; }
  #victory-screen .overlay-btn { border-color: #22c55e; color: #22c55e; }
  #victory-screen .overlay-btn:hover { background: #22c55e; color: #0a0a0f; }

  #defeat-screen { display: none; }
  #defeat-screen h1 { color: #ef4444; }
  #defeat-screen .overlay-btn { border-color: #ef4444; color: #ef4444; }
  #defeat-screen .overlay-btn:hover { background: #ef4444; color: #0a0a0f; }

  /* ============================================
     CHARACTER SELECT
     ============================================ */
  #select-screen {
    display: none !important;
    flex-direction: column;
    padding: 24px;
    gap: 16px;
  }

  #select-screen h1 {
    font-size: 26px;
    color: #e0e0e0;
    margin-bottom: 4px;
  }

  .select-section {
    width: 100%;
    max-width: 520px;
  }

  .select-label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #888;
    margin-bottom: 8px;
    display: block;
  }

  .select-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }

  .select-card {
    background: #151520;
    border: 2px solid #2a2a4a;
    border-radius: 10px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .select-card:hover {
    border-color: #4a9eed;
    background: #1a1a2e;
  }

  .select-card.selected {
    border-color: #22c55e;
    background: #0d2210;
    box-shadow: 0 0 12px #22c55e33;
  }

  .select-card img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    image-rendering: auto;
  }

  .select-card.boss-card img { transform: scaleX(-1); }

  .select-card span {
    font-size: 11px;
    font-weight: 600;
    color: #ccc;
    text-align: center;
  }

  .select-card.selected span { color: #22c55e; }

  @media (max-width: 600px) {
    .select-grid { grid-template-columns: repeat(3, 1fr); }
    .select-card img { width: 44px; height: 44px; }
    #select-screen h1 { font-size: 20px; }
  }

  /* ============================================
     RESPONSIVE
     ============================================ */
  @media (max-width: 600px) {
    #game { max-height: none; height: 100vh; border-radius: 0; border: none; }
    .character { width: 120px; height: 150px; }
    .character img { width: 100px; }
    #question-text { font-size: 14px; }
    .option-btn { font-size: 13px; padding: 8px 10px; }
    .action-btn { font-size: 11px; padding: 10px 6px; }
    .overlay h1 { font-size: 26px; }
    #hud { padding: 8px 10px; }
    .health-name { font-size: 11px; }
    #player-char { left: 3%; }
    #boss-char { right: 3%; }
  }
