/* ========================================
       CSS Variables — easy to theme later
       ======================================== */
:root {
  --bg:           #ffffff;
  --bg2:          #ffffff;
  --bg3:          #f5f5f5;
  --bg-card:      #ffffff;
  --bg-card-hover:#f7f7f7;
  --text:         #1a1a2e;
  --text-dim:     #6b7280;
  --accent:       #FF2D55;
  --accent-glow:  #FF2D5533;
  --hp-high: #00E639;
  --hp-mid: #FFD600;
  --hp-low: #FF3333;
  --fire: #FF6B00;
  --water: #0099FF;
  --earth: #8B5E3C;
  --normal: #7B8794;
  --error-bg: #dc2626;
  --error-text: #fff;
  --shake-distance: 5px;
}

/* ========================================
       Base Styles
       ======================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&display=swap');

body {
  font-family: 'Fredoka', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #ffffff;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Battle theme backgrounds — full viewport pixel grid */
body.battle-theme-fire {
  background-color: #FFF5EB;
  background-image: radial-gradient(circle, #FF6B0022 1px, transparent 1px);
  background-size: 16px 16px;
}
body.battle-theme-water {
  background-color: #EBF5FF;
  background-image: radial-gradient(circle, #0099FF22 1px, transparent 1px);
  background-size: 16px 16px;
}
body.battle-theme-earth {
  background-color: #FFF8F0;
  background-image: radial-gradient(circle, #8B5E3C22 1px, transparent 1px);
  background-size: 16px 16px;
}
body.battle-theme-normal {
  background-color: #F5F7FA;
  background-image: radial-gradient(circle, #7B879422 1px, transparent 1px);
  background-size: 16px 16px;
}

/* ========================================
       Particle Canvas
       ======================================== */
#particle-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ========================================
       Error Banner
       ======================================== */
#error-banner {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--error-bg);
  color: var(--error-text);
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
}

/* ========================================
       Screen Layout
       ======================================== */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  position: relative;
  z-index: 2;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.screen.active {
  opacity: 1;
  transform: translateY(0);
}

/* ========================================
       Mute Button
       ======================================== */
#btn-mute {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 999;
  background: #f3f4f6;
  border: 2px solid #d1d5db;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  color: #1a1a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

#btn-mute:hover {
  background: #e5e7eb;
  transform: scale(1.1);
}

/* ========================================
       Lobby Screen
       ======================================== */
.lobby-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 3.2rem;
  font-weight: 700;
  letter-spacing: -1px;
  margin-bottom: 8px;
  color: var(--accent);
}

.lobby-subtitle {
  color: var(--text-dim);
  margin-bottom: 40px;
  font-size: 1.1rem;
}

.lobby-section {
  background: #ffffff;
  border-radius: 8px;
  padding: 28px;
  margin-bottom: 16px;
  width: 100%;
  max-width: 380px;
  border: 3px solid #222;
  box-shadow: 4px 4px 0 #222;
}

.lobby-section h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.lobby-input {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: 2px solid #d1d5db;
  background: #ffffff;
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.2s;
}

.lobby-input:focus {
  border-color: var(--accent);
}

.lobby-input::placeholder {
  color: var(--text-dim);
}

.btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: 8px;
  border: 3px solid #222;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 4px 4px 0 #222;
  transition:
    transform 0.1s,
    box-shadow 0.1s;
}

.btn:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #222;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #222;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-secondary {
  background: #ffffff;
  color: var(--text);
}

.btn-local {
  background: transparent;
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 500;
  margin-top: 8px;
  border: 1px solid #d1d5db;
  opacity: 0.7;
}

.btn-local:hover {
  opacity: 1;
}

.join-row {
  display: flex;
  gap: 10px;
}

.join-row .lobby-input {
  flex: 1;
  margin-bottom: 0;
  text-align: center;
  font-size: 1.3rem;
  letter-spacing: 6px;
  font-weight: 700;
}

.join-row .btn {
  width: auto;
  white-space: nowrap;
}

/* ========================================
       Waiting Screen
       ======================================== */
.waiting-title {
  font-size: 1.3rem;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.room-code-big {
  font-family: 'Fredoka', sans-serif;
  font-size: 4rem;
  font-weight: 900;
  letter-spacing: 12px;
  color: var(--accent);
  margin-bottom: 12px;
}

.waiting-hint {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.waiting-message {
  text-align: center;
  padding: 40px;
  color: var(--text-dim);
  font-size: 1.2rem;
}

/* ========================================
       Monster Selection
       ======================================== */
.selecting-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.monster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 700px;
}

.monster-card {
  background: #ffffff;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition:
    transform 0.1s,
    box-shadow 0.1s,
    border-color 0.2s;
  border: 3px solid #222;
  position: relative;
  overflow: hidden;
  box-shadow: 4px 4px 0 #222;
}

.monster-card:hover {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #222;
}

.monster-card:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #222;
}

.monster-card.type-fire:hover {
  border-color: var(--fire);
}
.monster-card.type-water:hover {
  border-color: var(--water);
}
.monster-card.type-earth:hover {
  border-color: var(--earth);
}
.monster-card.type-normal:hover {
  border-color: var(--normal);
}

/* Monster card image (replaces emoji) */
.monster-card-image {
  width: 120px;
  height: 120px;
  object-fit: contain;
  margin: 0 auto 12px;
  display: block;
  transition: transform 0.2s;
}

.monster-card:hover .monster-card-image {
  transform: scale(1.08);
}

.monster-card-emoji {
  font-size: 3.5rem;
  margin-bottom: 12px;
}

.monster-card-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.monster-card-type {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}

.type-fire .monster-card-type {
  color: var(--fire);
}
.type-water .monster-card-type {
  color: var(--water);
}
.type-earth .monster-card-type {
  color: var(--earth);
}
.type-normal .monster-card-type {
  color: var(--normal);
}

.monster-card-stats {
  display: flex;
  justify-content: center;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ========================================
       Battle Screen
       ======================================== */
#screen-battle {
  justify-content: space-between;
  padding: 16px;
  max-width: 500px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  background-image: radial-gradient(circle, #e0e0e0 1px, transparent 1px);
  background-size: 16px 16px;
}

/* Battle arena background */
#screen-battle.has-arena-bg {
  background-image: var(--arena-bg);
  background-size: cover;
  background-position: center;
}

#screen-battle.has-arena-bg::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  z-index: 0;
  border-radius: inherit;
}

#screen-battle.has-arena-bg > * {
  position: relative;
  z-index: 1;
}

.turn-indicator {
  text-align: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 8px;
  transition: color 0.3s, background 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.my-turn {
  color: #004D12;
  background: #00E639;
  border: 2px solid #004D12;
  box-shadow: 2px 2px 0 #004D12;
  animation: turnBounceIn 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.their-turn {
  color: var(--text-dim);
  background: #f3f4f6;
  border: 2px solid #d1d5db;
  box-shadow: 2px 2px 0 #d1d5db;
}

@keyframes turnBounceIn {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

.monster-panel {
  width: 100%;
  position: relative;
  background: #ffffff;
  border-radius: 8px;
  padding: 12px;
  border: 3px solid #222;
  box-shadow: 4px 4px 0 #222;
}

/* Type-colored border on panels */
#my-monster.type-panel-fire,
#their-monster.type-panel-fire { border-color: var(--fire); }
#my-monster.type-panel-water,
#their-monster.type-panel-water { border-color: var(--water); }
#my-monster.type-panel-earth,
#their-monster.type-panel-earth { border-color: var(--earth); }
#my-monster.type-panel-normal,
#their-monster.type-panel-normal { border-color: var(--normal); }

/* Active turn border pulse */
.monster-panel.active-turn {
  animation: panelBorderPulse 1.2s ease-in-out infinite;
}

.monster-panel.active-turn.type-panel-fire { animation-name: panelPulseFire; }
.monster-panel.active-turn.type-panel-water { animation-name: panelPulseWater; }
.monster-panel.active-turn.type-panel-earth { animation-name: panelPulseEarth; }
.monster-panel.active-turn.type-panel-normal { animation-name: panelPulseNormal; }

@keyframes panelBorderPulse {
  0%, 100% { border-color: #00E639; }
  50% { border-color: #fff; }
}
@keyframes panelPulseFire {
  0%, 100% { border-color: var(--fire); }
  50% { border-color: #fff; }
}
@keyframes panelPulseWater {
  0%, 100% { border-color: var(--water); }
  50% { border-color: #fff; }
}
@keyframes panelPulseEarth {
  0%, 100% { border-color: var(--earth); }
  50% { border-color: #fff; }
}
@keyframes panelPulseNormal {
  0%, 100% { border-color: var(--normal); }
  50% { border-color: #fff; }
}

.monster-info {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.avatar {
  width: 100px;
  height: 100px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  flex-shrink: 0;
  transition:
    opacity 0.15s,
    transform 0.3s;
  animation: idleBounce 1.8s ease-in-out infinite;
  overflow: hidden;
  border: 3px solid #222;
  box-shadow: 3px 3px 0 #222;
}

/* Avatar image support */
.avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes idleBob {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.02); }
}

@keyframes idleBounce {
  0%, 100% { transform: translateY(0) scale(1); }
  40% { transform: translateY(-8px) scale(1.04); }
  60% { transform: translateY(-8px) scale(1.04); }
  80% { transform: translateY(2px) scale(0.98); }
}

/* Type-specific idle animations */
.avatar.type-bg-fire {
  animation: idleFire 2s ease-in-out infinite;
}
.avatar.type-bg-water {
  animation: idleWater 3s ease-in-out infinite;
}
.avatar.type-bg-earth {
  animation: idleEarth 2.5s ease-in-out infinite;
}

@keyframes idleFire {
  0%, 100% { transform: translateY(0) scale(1); filter: brightness(1); }
  25% { transform: translateY(-3px) scale(1.03); filter: brightness(1.1); }
  75% { transform: translateY(-1px) scale(0.99); filter: brightness(0.95); }
}

@keyframes idleWater {
  0%, 100% { transform: translateX(0) translateY(0); }
  25% { transform: translateX(3px) translateY(-2px); }
  75% { transform: translateX(-3px) translateY(-1px); }
}

@keyframes idleEarth {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-2px) scale(1.01); }
}

.type-bg-fire {
  background: var(--fire);
}
.type-bg-water {
  background: var(--water);
}
.type-bg-earth {
  background: var(--earth);
}
.type-bg-normal {
  background: var(--normal);
}

.avatar.flash {
  animation: avatarFlash 0.4s ease-out;
}

.avatar.ko {
  animation: avatarKO 0.8s ease-in forwards;
}

/* Wind-up anticipation */
.avatar.windup-down {
  animation: windupDown 0.06s ease-out forwards;
}
.avatar.windup-up {
  animation: windupUp 0.06s ease-out forwards;
}

@keyframes windupDown {
  0% { transform: translateY(0); }
  100% { transform: translateY(-6px) scale(0.95); }
}

@keyframes windupUp {
  0% { transform: translateY(0); }
  100% { transform: translateY(6px) scale(0.95); }
}

/* Attack lunge animations — 2x distance */
.avatar.lunge-down {
  animation: lungeDown 0.35s ease-out;
}
.avatar.lunge-up {
  animation: lungeUp 0.35s ease-out;
}

@keyframes lungeDown {
  0% { transform: translateY(0); }
  35% { transform: translateY(40px) scale(1.12); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes lungeUp {
  0% { transform: translateY(0); }
  35% { transform: translateY(-40px) scale(1.12); }
  100% { transform: translateY(0) scale(1); }
}

/* Motion blur during lunge */
.avatar.motion-blur {
  filter: blur(2px);
}

/* Hit recoil */
.avatar.recoil {
  animation: recoil 0.35s ease-out;
}

@keyframes recoil {
  0% { transform: translateX(0); }
  25% { transform: translateX(12px) rotate(3deg); }
  50% { transform: translateX(-6px) rotate(-1deg); }
  100% { transform: translateX(0) rotate(0); }
}

/* Super effective recoil — knockback + bounce off edge */
.avatar.recoil-super {
  animation: recoilSuper 0.45s ease-out;
}

@keyframes recoilSuper {
  0% { transform: translateX(0); }
  20% { transform: translateX(25px) rotate(5deg) scale(0.95); }
  40% { transform: translateX(-8px) rotate(-2deg); }
  60% { transform: translateX(10px) rotate(1deg); }
  100% { transform: translateX(0) rotate(0) scale(1); }
}

.monster-name {
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
}

/* Type badge next to monster name */
.type-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
}

.type-badge-fire { background: rgba(255, 107, 0, 0.3); color: var(--fire); border: 1.5px solid var(--fire); }
.type-badge-water { background: rgba(0, 153, 255, 0.3); color: var(--water); border: 1.5px solid var(--water); }
.type-badge-earth { background: rgba(139, 94, 60, 0.3); color: var(--earth); border: 1.5px solid var(--earth); }
.type-badge-normal { background: rgba(123, 135, 148, 0.3); color: var(--normal); border: 1.5px solid var(--normal); }

.hp-bar-container {
  flex: 1;
}

.hp-bar {
  width: 100%;
  height: 22px;
  background: #E8E8E8;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
  transition: box-shadow 0.5s;
  position: relative;
  border: 3px solid #222;
  box-shadow: 2px 2px 0 #222;
}

.hp-fill {
  height: 100%;
  border-radius: 1px;
  background: var(--hp-high);
  transition: width 0.5s ease-out;
  position: relative;
}

/* Ghost HP bar (Street Fighter style) */
.hp-ghost {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  border-radius: 1px;
  background: rgba(239, 68, 68, 0.5);
  transition: width 1.5s ease-out;
  z-index: -1;
}

.hp-critical .hp-fill {
  animation: hpPulse 0.35s ease-in-out infinite;
}

.hp-critical .hp-bar {
  border-color: var(--hp-low);
  box-shadow: 2px 2px 0 var(--hp-low);
}

@keyframes hpPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.hp-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: right;
}

/* Low HP red vignette */
#screen-battle.low-hp-vignette {
  animation: vignetteGlow 1.5s ease-in-out infinite;
}

@keyframes vignetteGlow {
  0%, 100% { box-shadow: inset 0 0 60px rgba(239, 68, 68, 0.08); }
  50% { box-shadow: inset 0 0 100px rgba(239, 68, 68, 0.18); }
}

/* Battle Log */
.battle-log {
  width: 100%;
  max-height: 120px;
  overflow-y: auto;
  background: #ffffff;
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
  font-size: 0.9rem;
  border: 3px solid #222;
  box-shadow: 3px 3px 0 #222;
}

.log-entry {
  padding: 3px 0;
  color: var(--text-dim);
  border-bottom: 1px solid #f3f4f6;
  animation: slideInRight 0.3s ease-out;
}

.log-entry:last-child {
  color: var(--text);
  font-weight: 700;
  border-bottom: none;
}

.log-entry.log-fire { color: var(--fire); }
.log-entry.log-water { color: var(--water); }
.log-entry.log-earth { color: var(--earth); }
.log-entry.log-normal { color: var(--normal); }

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Move Buttons */
.move-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
}

.move-btn {
  padding: 14px 8px;
  border-radius: 8px;
  border: 3px solid #222;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.2);
  box-shadow: 4px 4px 0 #222;
  transition:
    transform 0.1s,
    box-shadow 0.1s;
  text-align: center;
}

.move-btn .move-name {
  font-size: 0.95rem;
  display: block;
}

.move-btn .move-detail {
  font-size: 0.7rem;
  opacity: 0.9;
  font-weight: 400;
  display: block;
  margin-top: 2px;
}

.move-btn:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 #222;
}

.move-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #222;
}

.move-btn:disabled {
  filter: grayscale(0.8);
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Solid backgrounds for move type buttons */
.type-btn-fire {
  background: var(--fire);
}
.type-btn-water {
  background: var(--water);
}
.type-btn-earth {
  background: var(--earth);
}
.type-btn-normal {
  background: var(--normal);
}

/* ========================================
       Hit Flash Overlay
       ======================================== */
#hit-flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.05s;
  mix-blend-mode: screen;
}

#hit-flash-overlay.active {
  opacity: 1;
}

/* Shockwave ripple on big hits */
#hit-flash-overlay.shockwave::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 3px solid var(--flash-color, #fff);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: shockwaveExpand 0.5s ease-out forwards;
}

#hit-flash-overlay.shockwave-double::before,
#hit-flash-overlay.shockwave-double::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 3px solid var(--flash-color, #fff);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: shockwaveExpand 0.5s ease-out forwards;
}

#hit-flash-overlay.shockwave-double::after {
  animation-delay: 0.1s;
  border-width: 2px;
}

#hit-flash-overlay.shockwave-triple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 4px solid var(--flash-color, #fff);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: shockwaveExpand 0.6s ease-out forwards;
}

@keyframes shockwaveExpand {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(40); opacity: 0; }
}

/* Letterbox slam for crits/KOs */
.letterbox-bar {
  position: fixed;
  left: 0;
  right: 0;
  height: 40px;
  background: #222;
  z-index: 55;
  pointer-events: none;
}

.letterbox-bar-top {
  top: 0;
  animation: letterboxSlam 0.6s ease-out forwards;
}

.letterbox-bar-bottom {
  bottom: 0;
  animation: letterboxSlam 0.6s ease-out forwards;
}

@keyframes letterboxSlam {
  0% { transform: scaleY(0); }
  15% { transform: scaleY(1); }
  65% { transform: scaleY(1); }
  100% { transform: scaleY(0); }
}

/* Turn transition sweep */
.turn-sweep {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  z-index: 60;
  pointer-events: none;
}

.turn-sweep-my {
  background: var(--hp-high);
  animation: sweepRight 0.4s ease-out forwards;
  box-shadow: 0 0 8px var(--hp-high);
}

.turn-sweep-their {
  background: #aaa;
  animation: sweepLeft 0.4s ease-out forwards;
  box-shadow: 0 0 8px #aaa;
}

@keyframes sweepRight {
  0% { transform: translateX(-100%); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateX(100%); opacity: 0; }
}

@keyframes sweepLeft {
  0% { transform: translateX(100%); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateX(-100%); opacity: 0; }
}

/* ========================================
       Cinematic Text
       ======================================== */
#cinematic-text {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  z-index: 60;
  pointer-events: none;
  font-family: 'Fredoka', sans-serif;
  font-size: 3.5rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text);
  text-shadow: 3px 3px 0 #222;
  opacity: 0;
}

/* Cinematic text streak behind */
#cinematic-text::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -100vw;
  right: -100vw;
  height: 6px;
  background: currentColor;
  opacity: 0.3;
  transform: translateY(-50%);
  z-index: -1;
}

/* Overkill shake */
#cinematic-text.overkill-shake {
  animation: slamInShake 1s ease-out forwards;
}

@keyframes slamInShake {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(3); }
  15% { opacity: 1; transform: translate(-50%, -50%) scale(0.9); }
  25% { transform: translate(-48%, -52%) scale(1.05); }
  30% { transform: translate(-52%, -48%) scale(1.02); }
  35% { transform: translate(-49%, -51%) scale(1); }
  40% { transform: translate(-51%, -49%) scale(1); }
  45% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.1); }
}

#cinematic-text.slam {
  animation: slamIn 1s ease-out forwards;
}

@keyframes slamIn {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(3);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.9);
  }
  25% {
    transform: translate(-50%, -50%) scale(1.05);
  }
  35% {
    transform: translate(-50%, -50%) scale(1);
  }
  75% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.1);
  }
}

/* ========================================
       VS Screen
       ======================================== */
#screen-vs {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 80;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  background-image: radial-gradient(circle, #e0e0e0 1px, transparent 1px);
  background-size: 16px 16px;
}

#screen-vs.active {
  display: flex;
}

.vs-monster {
  font-size: 5rem;
  transition: transform 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

/* VS screen monster images */
.vs-monster img {
  width: 150px;
  height: 150px;
  object-fit: contain;
}

#vs-left {
  transform: translateX(-100vw);
}

#vs-right {
  transform: translateX(100vw);
}

#screen-vs.animate #vs-left {
  transform: translateX(0);
}

#screen-vs.animate #vs-right {
  transform: translateX(0);
}

.vs-text {
  font-family: 'Fredoka', sans-serif;
  font-size: 4rem;
  font-weight: 900;
  color: var(--accent);
  margin: 0 30px;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.4s ease 0.4s, transform 0.4s cubic-bezier(0.18, 0.89, 0.32, 1.28) 0.4s;
  text-shadow: 3px 3px 0 #222;
}

#screen-vs.animate .vs-text {
  opacity: 1;
  transform: scale(1);
}

/* ========================================
       Turn Banner
       ======================================== */
#turn-banner {
  position: absolute;
  top: 50%;
  left: -100%;
  transform: translateY(-50%) skewX(-5deg);
  width: 100%;
  padding: 12px 0;
  text-align: center;
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 3px;
  background: #dcfce7;
  color: #166534;
  pointer-events: none;
  z-index: 10;
  transition: left 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#turn-banner.show {
  left: 0;
}

#turn-banner.hide {
  left: 100%;
}

/* ========================================
       Floating Numbers
       ======================================== */
.float-number {
  position: absolute;
  font-family: 'Fredoka', sans-serif;
  font-weight: 900;
  pointer-events: none;
  animation: floatUp 1.2s ease-out forwards;
  z-index: 100;
  left: 50%;
  top: 20%;
  text-shadow: 2px 2px 0 #222;
}

.float-damage {
  color: #fff;
  font-size: 2.2rem;
}

.float-crit {
  color: #FFD600;
  font-size: 2.8rem;
  text-shadow: 2px 2px 0 #222, 0 0 10px rgba(255,214,0,0.6);
}

.float-heal {
  color: var(--hp-high);
  font-size: 2rem;
}

.float-miss {
  color: var(--text);
  font-size: 1.6rem;
  font-weight: 700;
}

.float-effective {
  color: var(--fire);
  font-size: 1rem;
  top: 45%;
}

.float-burn {
  color: #FF6B00;
  font-size: 1.8rem;
  text-shadow: 2px 2px 0 #222, 0 0 8px rgba(255,107,0,0.5);
}

/* ========================================
       Status Effects
       ======================================== */
.status-effects {
  display: flex;
  gap: 6px;
  margin-top: 4px;
  min-height: 22px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  font-family: 'Fredoka', sans-serif;
  border: 2px solid #222;
  box-shadow: 2px 2px 0 #222;
}

.status-burn {
  background: linear-gradient(135deg, #FF6B00, #FF2D00);
  color: #fff;
  animation: burnPulse 1.5s ease-in-out infinite;
}

@keyframes burnPulse {
  0%, 100% { box-shadow: 2px 2px 0 #222, 0 0 4px rgba(255,107,0,0.3); }
  50% { box-shadow: 2px 2px 0 #222, 0 0 12px rgba(255,107,0,0.7); }
}

.avatar.burn-flash {
  animation: avatarBurnFlash 0.6s ease-out;
}

@keyframes avatarBurnFlash {
  0% { filter: brightness(1); }
  20% { filter: brightness(1.5) sepia(1) saturate(3) hue-rotate(-10deg); }
  100% { filter: brightness(1); }
}

.move-status-tag {
  display: block;
  font-size: 0.55rem;
  font-weight: 700;
  margin-top: 3px;
  padding: 1px 6px;
  border-radius: 4px;
  background: linear-gradient(135deg, #FF6B00, #FF2D00);
  color: #fff;
  letter-spacing: 0.5px;
}

/* ========================================
       Victory Screen
       ======================================== */
.victory-title {
  font-family: 'Fredoka', sans-serif;
  font-size: 3rem;
  font-weight: 900;
  margin-bottom: 20px;
}

.victory-title.win {
  color: #FFD600;
  text-shadow: 3px 3px 0 #222;
  animation: victoryBounceIn 0.6s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes victoryBounceIn {
  0% { transform: translateY(-100vh); }
  60% { transform: translateY(10px); }
  80% { transform: translateY(-5px); }
  100% { transform: translateY(0); }
}

@keyframes victoryGlow {
  0%, 100% { filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.3)); }
  50% { filter: drop-shadow(0 0 25px rgba(251, 191, 36, 0.6)); }
}

.victory-title.lose {
  color: var(--text-dim);
}

.victory-emoji {
  font-size: 5rem;
  animation: winnerBounce 1s ease-out;
  margin-bottom: 16px;
}

/* Victory screen monster images */
.victory-emoji img {
  width: 120px;
  height: 120px;
  object-fit: contain;
}

@keyframes winnerBounce {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  70% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

.recap-matchup {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 1.3rem;
  margin-bottom: 24px;
}

/* Recap monster images */
.recap-monster img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  vertical-align: middle;
  margin-right: 4px;
}

.recap-vs {
  color: var(--text-dim);
  font-weight: 700;
  font-size: 0.9rem;
}

.victory-code-msg {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  max-width: 400px;
  margin-bottom: 30px;
}

/* Victory stats */
.victory-stats {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.victory-stat {
  text-align: center;
}

.victory-stat-value {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

/* ========================================
       Animations
       ======================================== */
@keyframes floatUp {
  0% {
    opacity: 1;
    transform: translate(-50%, 0) scale(0.5);
  }
  20% {
    transform: translate(-50%, -10px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -80px) scale(1);
  }
}

@keyframes shake {
  0%, 100% {
    transform: translateX(0) rotate(0);
  }
  10% {
    transform: translateX(calc(-1 * var(--shake-distance))) rotate(calc(-1 * var(--shake-rotation, 0deg)));
  }
  20% {
    transform: translateX(var(--shake-distance)) rotate(var(--shake-rotation, 0deg));
  }
  30% {
    transform: translateX(calc(-1 * var(--shake-distance) * 0.8)) rotate(calc(-0.8 * var(--shake-rotation, 0deg)));
  }
  40% {
    transform: translateX(calc(var(--shake-distance) * 0.8)) rotate(calc(0.6 * var(--shake-rotation, 0deg)));
  }
  50% {
    transform: translateX(calc(-1 * var(--shake-distance) * 0.5)) rotate(calc(-0.4 * var(--shake-rotation, 0deg)));
  }
  60% {
    transform: translateX(calc(var(--shake-distance) * 0.5)) rotate(calc(0.3 * var(--shake-rotation, 0deg)));
  }
  70% {
    transform: translateX(calc(-1 * var(--shake-distance) * 0.3));
  }
  80% {
    transform: translateX(calc(var(--shake-distance) * 0.3));
  }
  90% {
    transform: translateX(calc(-1 * var(--shake-distance) * 0.1));
  }
}

@keyframes avatarFlash {
  0% {
    opacity: 1;
  }
  25% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
  75% {
    opacity: 0.3;
  }
  100% {
    opacity: 1;
  }
}

@keyframes avatarKO {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: saturate(1);
  }
  30% {
    filter: saturate(0);
  }
  50% {
    transform: scale(0.8) rotate(10deg);
    opacity: 0.5;
  }
  100% {
    transform: scale(0) rotate(30deg);
    opacity: 0;
  }
}

/* ========================================
       Hit Freeze Frame
       ======================================== */
.hit-freeze,
.hit-freeze * {
  animation-play-state: paused !important;
}

/* ========================================
       Speed Lines (radial burst)
       ======================================== */
.speed-lines {
  position: fixed;
  inset: 0;
  z-index: 55;
  pointer-events: none;
  background: repeating-conic-gradient(
    rgba(0,0,0,0.12) 0deg 5deg,
    transparent 5deg 10deg
  );
  animation: speedLinesAnim 0.6s ease-out forwards;
}

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

/* ========================================
       Slash Marks
       ======================================== */
.slash-marks {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.slash-marks::before,
.slash-marks::after {
  content: '';
  position: absolute;
  top: 10%;
  left: 10%;
  width: 120%;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.9), transparent);
  animation: slashAnim 0.35s ease-out forwards;
}

.slash-marks::before {
  transform: rotate(35deg);
}

.slash-marks::after {
  transform: rotate(-25deg);
  animation-delay: 0.05s;
  top: 40%;
}

@keyframes slashAnim {
  0% { opacity: 1; transform: rotate(inherit) scaleX(0); }
  30% { opacity: 1; transform: rotate(inherit) scaleX(1); }
  100% { opacity: 0; transform: rotate(inherit) scaleX(1); }
}

/* ========================================
       HP Bar Shatter
       ======================================== */
.hp-shatter .hp-bar {
  animation: hpShatter 0.6s ease-out forwards;
}

@keyframes hpShatter {
  0% { transform: scale(1); filter: brightness(1); }
  15% { transform: scale(1.05) rotate(1deg); filter: brightness(2); }
  30% { transform: scale(0.98) rotate(-0.5deg); }
  50% { transform: scale(1.02); filter: brightness(0.8); }
  100% { transform: scale(1); filter: brightness(0.6); opacity: 0.5; }
}

/* HP bar cracks at low HP */
.hp-critical .hp-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 2;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='14'%3E%3Cpath d='M5 0 L15 7 L10 14 M25 0 L30 7 L22 14 M42 0 L50 7 L45 14' stroke='%23333' stroke-width='0.8' fill='none' opacity='0.4'/%3E%3C/svg%3E");
  pointer-events: none;
  border-radius: 7px;
}

/* Pulsing red vignette — enhanced */
#screen-battle.low-hp-vignette::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  z-index: 5;
  animation: vignetteEdge 1s ease-in-out infinite;
}

@keyframes vignetteEdge {
  0%, 100% { box-shadow: inset 0 0 40px rgba(239,68,68,0.15); }
  50% { box-shadow: inset 0 0 80px rgba(239,68,68,0.3); }
}

/* ========================================
       VS Screen Cinematic Upgrades
       ======================================== */
/* Letterbox bars */
#screen-vs.vs-cinematic::before,
#screen-vs.vs-cinematic::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 60px;
  background: #000;
  z-index: 2;
  animation: letterboxIn 0.4s ease-out forwards;
}

#screen-vs.vs-cinematic::before { top: 0; }
#screen-vs.vs-cinematic::after { bottom: 0; }

@keyframes letterboxIn {
  0% { transform: scaleY(0); }
  100% { transform: scaleY(1); }
}

/* Energy aura on VS monsters */
.vs-aura {
  position: relative;
}

.vs-aura-fire { filter: drop-shadow(0 0 20px var(--fire)) drop-shadow(0 0 40px var(--fire)); animation: vsAuraPulse 1s ease-in-out infinite !important; }
.vs-aura-water { filter: drop-shadow(0 0 20px var(--water)) drop-shadow(0 0 40px var(--water)); animation: vsAuraPulse 1s ease-in-out infinite !important; }
.vs-aura-earth { filter: drop-shadow(0 0 20px var(--earth)) drop-shadow(0 0 40px var(--earth)); animation: vsAuraPulse 1s ease-in-out infinite !important; }
.vs-aura-normal { filter: drop-shadow(0 0 20px var(--normal)) drop-shadow(0 0 40px var(--normal)); animation: vsAuraPulse 1s ease-in-out infinite !important; }

@keyframes vsAuraPulse {
  0%, 100% { filter: drop-shadow(0 0 15px currentColor); transform: translateX(0) scale(1); }
  50% { filter: drop-shadow(0 0 35px currentColor) drop-shadow(0 0 60px currentColor); transform: translateX(0) scale(1.05); }
}

/* VS text shockwave ring */
.vs-text.vs-shockwave::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  border: 3px solid var(--accent);
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: vsRingExpand 0.8s ease-out forwards;
  pointer-events: none;
  opacity: 0.6;
}

@keyframes vsRingExpand {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(8); opacity: 0; }
}

.vs-text {
  position: relative;
}

/* Lightning sparks between monsters */
#screen-vs.vs-sparks .vs-text::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -80px;
  right: -80px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: sparkFlicker 0.15s linear infinite alternate;
  transform: translateY(-50%);
}

@keyframes sparkFlicker {
  0% { opacity: 0.3; transform: translateY(-50%) scaleY(1); }
  100% { opacity: 1; transform: translateY(-50%) scaleY(3); }
}

/* ========================================
       Victory Screen Upgrades
       ======================================== */
/* Dark spotlight background */
.victory-spotlight {
  background: radial-gradient(ellipse at center, rgba(255,255,255,1) 0%, rgba(0,0,0,0.85) 100%) !important;
}

/* Golden aura on winner */
.golden-aura {
  position: relative;
  filter: drop-shadow(0 0 15px rgba(251,191,36,0.8));
  animation: goldenRays 2s linear infinite !important;
}

@keyframes goldenRays {
  0% { filter: drop-shadow(0 0 15px rgba(251,191,36,0.6)); }
  50% { filter: drop-shadow(0 0 30px rgba(251,191,36,1)) drop-shadow(0 0 50px rgba(249,115,22,0.5)); }
  100% { filter: drop-shadow(0 0 15px rgba(251,191,36,0.6)); }
}

/* Glitch text effect */
.glitch-text {
  animation: glitchText 0.8s ease-out !important;
}

@keyframes glitchText {
  0% { transform: translate(0); filter: none; }
  10% { transform: translate(-3px, 2px); clip-path: inset(20% 0 40% 0); }
  20% { transform: translate(3px, -2px); clip-path: inset(50% 0 10% 0); }
  30% { transform: translate(-2px, 1px); clip-path: inset(10% 0 60% 0); }
  40% { transform: translate(2px, -1px); clip-path: none; }
  50% { transform: translate(0); }
  100% { transform: translate(0); }
}

/* Minecraft-style hard shadow on cinematic text */
#cinematic-text.slam {
  text-shadow: 3px 3px 0 #222;
}

/* ========================================
       Cinematic Camera System
       ======================================== */
#screen-battle {
  transition: transform 0.15s cubic-bezier(0.2, 0, 0.3, 1);
}

#screen-battle.cinematic-zoom {
  transform: scale(var(--zoom-scale, 1.04));
  transition: transform 0.12s cubic-bezier(0.2, 0, 0.3, 1);
}

/* ========================================
       Kill-Cam Slow-Mo
       ======================================== */
#screen-battle.kill-cam {
  animation: killCamPulse 1.2s ease-out forwards;
}

@keyframes killCamPulse {
  0% {
    transform: scale(1.08);
    filter: saturate(0.3) contrast(1.3) brightness(0.9);
  }
  30% {
    transform: scale(1.12);
    filter: saturate(0.1) contrast(1.5) brightness(0.7);
  }
  60% {
    filter: saturate(0) contrast(1.8) brightness(0.5);
  }
  80% {
    transform: scale(1.15);
    filter: saturate(2) contrast(1.2) brightness(1.5);
  }
  100% {
    transform: scale(1);
    filter: saturate(1) contrast(1) brightness(1);
  }
}

/* ========================================
       Battle Intensity Background
       ======================================== */
#screen-battle.intensity-calm {
  box-shadow: inset 0 0 0 rgba(0,0,0,0);
}

#screen-battle.intensity-tense {
  box-shadow: inset 0 0 30px rgba(249,115,22,0.06);
  transition: box-shadow 1s ease;
}

#screen-battle.intensity-critical {
  animation: intensityCritical 1.2s ease-in-out infinite;
}

@keyframes intensityCritical {
  0%, 100% {
    box-shadow: inset 0 0 40px rgba(239,68,68,0.1);
    background-color: rgba(239,68,68,0.02);
  }
  50% {
    box-shadow: inset 0 0 80px rgba(239,68,68,0.2);
    background-color: rgba(239,68,68,0.05);
  }
}

#screen-battle.intensity-desperate {
  box-shadow: inset 0 0 100px rgba(239,68,68,0.3);
  background-color: rgba(0,0,0,0.05);
}

/* ========================================
       Crit Recoil
       ======================================== */
.avatar.recoil-crit {
  animation: recoilCrit 0.4s ease-out;
}

@keyframes recoilCrit {
  0% { transform: translateX(0); }
  20% { transform: translateX(18px) rotate(4deg) scale(0.96); }
  45% { transform: translateX(-8px) rotate(-2deg); }
  70% { transform: translateX(5px) rotate(0.5deg); }
  100% { transform: translateX(0) rotate(0) scale(1); }
}

/* ========================================
       Enhanced KO Animation
       ======================================== */
@keyframes avatarKO {
  0% {
    transform: scale(1);
    opacity: 1;
    filter: saturate(1) brightness(1);
  }
  10% {
    filter: saturate(0) brightness(3);
  }
  20% {
    filter: saturate(0) brightness(1);
  }
  40% {
    transform: scale(0.85) rotate(8deg) translateY(5px);
    opacity: 0.7;
    filter: saturate(0) brightness(0.5);
  }
  60% {
    transform: scale(0.7) rotate(15deg) translateY(10px);
    opacity: 0.4;
  }
  100% {
    transform: scale(0) rotate(40deg) translateY(30px);
    opacity: 0;
    filter: saturate(0) brightness(0);
  }
}

/* ========================================
       Enhanced Floating Damage Numbers
       ======================================== */
.float-crit {
  color: #FFD600;
  font-size: 2.8rem;
  text-shadow: 2px 2px 0 #222, 0 0 10px rgba(255,214,0,0.6);
  animation: floatUpCrit 1.4s ease-out forwards;
}

@keyframes floatUpCrit {
  0% {
    opacity: 1;
    transform: translate(-50%, 0) scale(0.3);
  }
  15% {
    transform: translate(-50%, -5px) scale(1.8);
  }
  30% {
    transform: translate(-50%, -15px) scale(1.1);
  }
  45% {
    transform: translate(-50%, -25px) scale(1.3);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -100px) scale(1);
  }
}

.float-effective {
  color: var(--fire);
  font-size: 1rem;
  top: 45%;
  text-shadow: 0 0 8px rgba(249,115,22,0.5);
  animation: floatUpBounce 1.5s ease-out forwards;
}

@keyframes floatUpBounce {
  0% { opacity: 1; transform: translate(-50%, 0) scale(0.5); }
  15% { transform: translate(-50%, -8px) scale(1.3); }
  25% { transform: translate(-50%, -3px) scale(1); }
  35% { transform: translate(-50%, -12px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -60px) scale(0.9); }
}

/* ========================================
       Enhanced Speed Lines
       ======================================== */
.speed-lines::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, transparent 30%, rgba(0,0,0,0.08) 100%);
}

@keyframes speedLinesAnim {
  0% { opacity: 1; transform: scale(0.6) rotate(0deg); }
  100% { opacity: 0; transform: scale(2.5) rotate(5deg); }
}

/* ========================================
       Victory Screen — Enhanced
       ======================================== */
.victory-spotlight {
  background: #ffffff !important;
  background-image: radial-gradient(circle, #e0e0e0 1px, transparent 1px) !important;
  background-size: 16px 16px !important;
}

.golden-aura {
  filter: drop-shadow(0 0 15px rgba(251,191,36,0.8));
  animation: goldenRaysEnhanced 2s linear infinite !important;
}

@keyframes goldenRaysEnhanced {
  0% {
    filter: drop-shadow(0 0 15px rgba(251,191,36,0.6)) drop-shadow(0 0 5px rgba(255,255,255,0.3));
    transform: scale(1);
  }
  25% { transform: scale(1.02); }
  50% {
    filter: drop-shadow(0 0 35px rgba(251,191,36,1)) drop-shadow(0 0 60px rgba(249,115,22,0.6)) drop-shadow(0 0 10px rgba(255,255,255,0.5));
    transform: scale(1.05);
  }
  75% { transform: scale(1.02); }
  100% {
    filter: drop-shadow(0 0 15px rgba(251,191,36,0.6)) drop-shadow(0 0 5px rgba(255,255,255,0.3));
    transform: scale(1);
  }
}

/* Glitch text — enhanced */
.glitch-text {
  animation: glitchTextEnhanced 1s ease-out !important;
}

@keyframes glitchTextEnhanced {
  0% { transform: translate(0) scale(1.5); filter: blur(4px); opacity: 0; }
  8% { transform: translate(-5px, 3px) scale(1.1); clip-path: inset(20% 0 40% 0); filter: blur(0); opacity: 1; }
  16% { transform: translate(5px, -3px) scale(0.98); clip-path: inset(50% 0 10% 0); }
  24% { transform: translate(-3px, 2px) scale(1.02); clip-path: inset(10% 0 60% 0); }
  32% { transform: translate(4px, -1px); clip-path: inset(40% 0 20% 0); }
  40% { transform: translate(-2px, 1px); clip-path: none; }
  50% { transform: translate(1px, -1px); }
  60% { transform: translate(0); }
  100% { transform: translate(0); }
}

/* ========================================
       VS Screen — Enhanced Dark Theme
       ======================================== */
#screen-vs {
  overflow: hidden;
}

#screen-vs.vs-cinematic {
  background: #ffffff;
  background-image: radial-gradient(circle, #e0e0e0 1px, transparent 1px);
  background-size: 16px 16px;
}

#screen-vs.vs-cinematic::before,
#screen-vs.vs-cinematic::after {
  height: 50px;
  background: #222;
  border: none;
}

/* Animated diagonal divider */
#screen-vs.vs-cinematic .vs-text::after {
  content: '';
  position: fixed;
  top: -10%;
  left: 50%;
  width: 2px;
  height: 120%;
  background: linear-gradient(to bottom, transparent, var(--accent), transparent);
  transform: rotate(15deg);
  animation: vsDividerGlow 1s ease-in-out infinite alternate;
  pointer-events: none;
}

@keyframes vsDividerGlow {
  0% { opacity: 0.3; box-shadow: 0 0 10px var(--accent); }
  100% { opacity: 0.8; box-shadow: 0 0 30px var(--accent), 0 0 60px var(--accent); }
}

/* Enhanced aura pulse */
@keyframes vsAuraPulse {
  0%, 100% {
    filter: drop-shadow(0 0 15px currentColor) drop-shadow(0 0 5px currentColor);
    transform: translateX(0) scale(1);
  }
  50% {
    filter: drop-shadow(0 0 40px currentColor) drop-shadow(0 0 70px currentColor) drop-shadow(0 0 100px currentColor);
    transform: translateX(0) scale(1.08);
  }
}

/* ========================================
       Responsive — mobile friendly
       ======================================== */
@media (max-width: 500px) {
  .lobby-title {
    font-size: 2rem;
  }
  .monster-grid {
    grid-template-columns: 1fr;
  }
  .room-code-big {
    font-size: 3rem;
  }
  .victory-title {
    font-size: 2.2rem;
  }
  .avatar {
    width: 80px;
    height: 80px;
    font-size: 1.6rem;
  }
  .hp-bar {
    height: 18px;
  }
  .monster-card-image {
    width: 90px;
    height: 90px;
  }
  .vs-monster img {
    width: 100px;
    height: 100px;
  }
  #cinematic-text {
    font-size: 2.2rem;
  }
  .vs-monster {
    font-size: 3.5rem;
  }
  .vs-text {
    font-size: 2.5rem;
    margin: 0 15px;
  }
}

/* ========================================
       Scrollbar styling
       ======================================== */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* ========================================
       Level Badges
       ======================================== */
.monster-card-level {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #fef3c7;
  color: #b45309;
  font-family: 'Fredoka', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
  letter-spacing: 0.5px;
}

.level-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 6px;
  border-radius: 5px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ========================================
       Victory XP Display
       ======================================== */
.victory-xp {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: #b45309;
  margin-bottom: 12px;
  text-align: center;
}

/* ========================================
       Player ID Section
       ======================================== */
.player-id-section {
  opacity: 0.6;
  transition: opacity 0.2s;
}

.player-id-section:hover {
  opacity: 1;
}

.player-id-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.player-id-text {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.link-account-row {
  display: flex;
  gap: 8px;
}

.link-account-row .lobby-input {
  flex: 1;
  margin-bottom: 0;
  font-size: 0.85rem;
}

.btn-small {
  padding: 8px 14px;
  border-radius: 8px;
  border: 2px solid #d1d5db;
  background: #ffffff;
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}

.btn-small:hover {
  background: #f3f4f6;
  color: var(--text);
}
