/* Janken Masters - Built from modules 2026-02-12T17:12:06Z */

/* === 01-variables.css === */
/* ===== CSS VARIABLES ===== */
:root {
  /* Safe area */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  
  /* Colors */
  --bg-dark: #212529;
  --bg-darker: #16181c;
  --bg-card: #2d333b;
  --border: #444c56;
  --red: #e63946;
  --green: #2a9d8f;
  --blue: #4895ef;
  --yellow: #f4d35e;
  --purple: #9b5de5;
  --cyan: #00d4ff;
  --text: #e8e8e8;
  --text-dim: #7a7a9a;
  
  /* Mobile First (< 360px) - Small phones */
  --card-w: 50px;
  --card-h: 70px;
  --zone-w: 66px;
  --spell-size: 28px;  /* 9 spells */
  --font-xs: 14px;
  --font-sm: 16px;
  --font-md: 18px;
  --font-lg: 22px;
  --font-xl: 28px;
  --gap: 4px;
  --pad: 6px;
}
/* === 02-base.css === */
/* ===== PERFORMANCE OPTIMIZATIONS v2.1.56 ===== */
/* GPU acceleration hints for animated elements */
.card,
.battle-zone,
.spell-btn,
.element-divine,
.element-unknown,
.element-dark,
.modal-overlay,
.turn-intro,
.battle-intro {
  will-change: transform, opacity;
  transform: translateZ(0);
  backface-visibility: hidden;
}

/* Reduce motion for users who prefer it */
/* 🔧 v2.1.78: Removed blanket reduced-motion rule that killed ALL game animations on desktop.
   Games rely on animations for core gameplay feedback (clash, damage, spells, etc.)
   Only reduce non-essential decorative animations to ensure consistent experience
   across mobile and PC regardless of OS accessibility settings. */
@media (prefers-reduced-motion: reduce) {
  /* Decorative-only: logo float, lobby glows, waiting pulses */
  .logo-float, .menu-tagline, .online-dot,
  .search-pulse, .waiting-pulse-anim {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

/* Mobile (360px - 480px) */
@media (min-width: 360px) {
  :root {
    --card-w: 56px;
    --card-h: 78px;
    --zone-w: 74px;
    --spell-size: 30px;  /* 9 spells */
    --font-xs: 15px;
    --font-sm: 17px;
    --font-md: 19px;
    --font-lg: 24px;
    --font-xl: 32px;
    --gap: 6px;
    --pad: 8px;
  }
}

/* Large Mobile (480px - 600px) */
@media (min-width: 480px) {
  :root {
    --card-w: 68px;
    --card-h: 95px;
    --zone-w: 88px;
    --spell-size: 36px;  /* 9 spells */
    --font-xs: 16px;
    --font-sm: 18px;
    --font-md: 20px;
    --font-lg: 26px;
    --font-xl: 36px;
    --gap: 8px;
    --pad: 10px;
  }
}

/* Tablet (600px - 900px) - LARGER CARDS */
@media (min-width: 600px) {
  :root {
    --card-w: 105px;
    --card-h: 147px;
    --zone-w: 130px;
    --spell-size: 42px;  /* 9 spells */
    --font-xs: 18px;
    --font-sm: 20px;
    --font-md: 24px;
    --font-lg: 30px;
    --font-xl: 42px;
    --gap: 10px;
    --pad: 14px;
  }
}

/* Desktop (900px+) - More spacious layout */
@media (min-width: 900px) {
  :root {
    --card-w: 80px;
    --card-h: 112px;
    --zone-w: 105px;
    --spell-size: 40px;  /* 9 spells */
    --font-xs: 16px;
    --font-sm: 18px;
    --font-md: 20px;
    --font-lg: 26px;
    --font-xl: 36px;
    --gap: 12px;
    --pad: 14px;
  }
}

/* Large Desktop (1200px+) - Comfortable spacing */
@media (min-width: 1200px) {
  :root {
    --card-w: 85px;
    --card-h: 119px;
    --zone-w: 110px;
    --spell-size: 42px;  /* 9 spells */
    --font-xs: 16px;
    --font-sm: 18px;
    --font-md: 20px;
    --font-lg: 26px;
    --font-xl: 38px;
    --gap: 14px;
    --pad: 16px;
  }
}

/* ===== BASE STYLES ===== */
* { 
  font-family: 'VT323', monospace; 
  -webkit-tap-highlight-color: transparent; 
  -webkit-user-select: none; 
  user-select: none; 
  box-sizing: border-box; 
}

/* Title font - Jersey 10 for game title */
.font-title, h1, h2, .title, .game-title {
  font-family: 'Jersey 10', cursive !important;
}

/* Studio font - Anton */
.font-studio {
  font-family: 'Anton', sans-serif !important;
  text-transform: uppercase;
}

html, body { 
  margin: 0; 
  padding: 0; 
  overflow: hidden; 
  position: fixed; 
  width: 100%; 
  height: 100%; 
  background: var(--bg-darker); 
  color: var(--text); 
}

body {
  padding: var(--sat) var(--sar) var(--sab) var(--sal);
  background: linear-gradient(180deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%);
  background-attachment: fixed;
}

/* NES.css Overrides */
.nes-container.is-dark { background: var(--bg-dark); border-color: var(--border); }
.nes-container.with-title > .title { background: var(--bg-darker); color: var(--yellow); font-size: var(--font-sm); }
.nes-btn { font-size: var(--font-sm); padding: var(--pad); }
.nes-input.is-dark { background: var(--bg-darker); color: var(--text); font-size: var(--font-sm); }

/* Lobby name input - larger and bold */
#player-name {
  font-size: clamp(20px, 5vw, 32px) !important;
  font-weight: bold !important;
  text-align: center;
  padding: 12px 16px !important;
  letter-spacing: 2px;
  text-transform: uppercase;
  height: auto !important;
  /* Pixel rounded corners */
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
  /* White border glow animation */
  animation: input-glow 2s ease-in-out infinite;
}

@keyframes input-glow {
  0%, 100% {
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  }
  50% {
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 5px rgba(255, 255, 255, 0.3);
  }
}
/* === 03-intro.css === */
/* ===== INTRO SCREENS ===== */
.intro-screen {
  background: #000 !important;
  z-index: 9999;
  /* Override max-width for intro screens - always fullscreen */
  max-width: 100% !important;
  width: 100% !important;
  left: 0 !important;
  right: 0 !important;
  transform: none !important;
}

/* Splash Screen (Logo) */
.splash-content {
  text-align: center;
  animation: fade-in 1s ease-out;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.studio-logo {
  animation: logo-float 3s ease-in-out infinite;
  font-size: clamp(80px, 20vw, 150px);
}

.studio-logo .iconify {
  font-size: inherit;
}

.studio-name {
  font-size: clamp(48px, 14vw, 120px);
  color: #ffffff;
  margin-top: 20px;
  letter-spacing: 2px;
  line-height: 0.85;
  text-shadow: 0 0 10px rgba(255,255,255,0.5), 0 0 20px rgba(255,255,255,0.3);
}

@keyframes logo-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

/* Warning Screen */
.warning-content {
  text-align: center;
  max-width: 90%;
  width: 500px;
  padding: 30px;
  animation: fade-in 1s ease-out;
}

.warning-icon {
  animation: warning-blink 1s ease-in-out infinite;
  font-size: clamp(50px, 12vw, 80px) !important;
}

.warning-title {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(28px, 7vw, 48px);
  color: var(--yellow);
  margin: 25px 0 20px;
  letter-spacing: 2px;
}

.warning-text {
  font-size: clamp(16px, 4vw, 24px);
  color: var(--text-dim);
  line-height: 1.8;
}

@keyframes warning-blink {
  0%, 100% { opacity: 1; }

50% { transform: scale(1.05); }
}
  50% { opacity: 0.5; }
}

/* Search Animation */
.search-spin {
  display: inline-block;
  animation: search-pulse 1.5s ease-in-out infinite;
}

/* Searching animated dots */
.searching-dots span {
  opacity: 0;
  animation: dot-blink 1.2s infinite;
}
.searching-dots span:nth-child(1) { animation-delay: 0s; }
.searching-dots span:nth-child(2) { animation-delay: 0.3s; }
.searching-dots span:nth-child(3) { animation-delay: 0.6s; }

@keyframes dot-blink {
  0%, 20% { opacity: 0; }
  30%, 70% { opacity: 1; }
  80%, 100% { opacity: 0; }
}

@keyframes search-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 1; }
  50% { transform: scale(1.2) rotate(15deg); opacity: 0.7; }
}

/* Title Screen */
.title-content {
  text-align: center;
  padding: 20px;
  backface-visibility: hidden;
  transform: translateZ(0);
}

.title-logo-container {
  margin-bottom: clamp(10px, 3vw, 20px);
}

.title-logo {
  display: flex;
  justify-content: center;
  line-height: 0.9;
}

.title-word {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(69px, 23vw, 145px);
  font-weight: bold;
  color: #f4d35e;
  -webkit-text-stroke: 2px #dc2626;
  paint-order: stroke fill;
  text-shadow: 
    3px 3px 0 #dc2626,
    5px 5px 0 #8b0000;
  letter-spacing: 2px;
  display: inline-block;
}

/* Animation สำหรับตอนเริ่มเกมครั้งแรก */
.title-word.animate {
  opacity: 0;
  transform: scale(0);
  animation: word-popup 0.5s ease-out forwards;
  animation-delay: calc(var(--i) * 0.4s + 0.3s);
}

@keyframes word-popup {
  0% { 
    opacity: 0; 
    transform: scale(0) rotate(-10deg); 
  }
  60% { 
    opacity: 1; 
    transform: scale(1.2) rotate(3deg); 
  }
  80% { 
    transform: scale(0.95) rotate(-2deg); 
  }
  100% { 
    opacity: 1; 
    transform: scale(1) rotate(0deg); 
  }
}

.title-edition {
  font-size: clamp(14px, 3.5vw, 22px);
  color: var(--cyan);
  margin-top: 15px;
  letter-spacing: clamp(2px, 0.5vw, 4px);
}

.title-edition.animate {
  opacity: 0;
  animation: fade-in-up 0.5s ease-out forwards;
  animation-delay: 1.2s;
}

/* Tagline animation */
.title-tagline {
  font-size: clamp(31px, 7.8vw, 50px);
  color: #ffffff;
  opacity: 0;
}

.title-tagline.animate {
  animation: tagline-fade-up-blink 2s ease-out forwards;
  animation-delay: 1.2s;
}

/* Animation: Fade up + subtle pulse (no harsh blink) */
@keyframes tagline-fade-up-blink {
  0% { 
    opacity: 0; 
    transform: translateY(20px); 
  }
  25% { 
    opacity: 1; 
    transform: translateY(0); 
  }
  100% { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

.janken-master-text {
  display: inline-block;
  color: var(--yellow);
  font-weight: bold;
}

.janken-master-text.animate {
  /* ใช้ animation เดียวกับ parent แล้ว ไม่ต้องมี animation แยก */
}

@keyframes fade-in-up {
  from { 
    opacity: 0; 
    transform: translateY(20px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

@keyframes glow-pulse {
  0%, 100% { text-shadow: 0 0 5px var(--cyan); }
  50% { text-shadow: 0 0 20px var(--cyan), 0 0 30px var(--cyan); }
}

/* Floating Icons */
/* Title Clash Animation - Elements collide from left & right */
.title-clash-container {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  height: clamp(120px, 30vw, 200px);
  margin-bottom: clamp(5px, 2vw, 10px);
  overflow: visible;
}

.title-clash-container.animate {
  opacity: 0;
  animation: fade-in 0.3s ease-out forwards;
  animation-delay: 1.2s;
}

/* 🎮 v2.1.65: Battle-style title clash icons */
.tc-icon {
  position: absolute;
  font-size: clamp(50px, 15vw, 100px);
  color: #ffffff;
  filter: drop-shadow(0 0 15px rgba(200,200,210,0.6));
  z-index: 2;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  will-change: transform, opacity;
}

.tc-icon.fly-left {
  animation: tc-from-left 0.8s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}
.tc-icon.fly-right {
  animation: tc-from-right 0.8s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

@keyframes tc-from-left {
  0%   { transform: translate(-350%, -50%) scale(0.5) rotate(-30deg); opacity: 0; }
  40%  { transform: translate(-80%, -50%) scaleY(0.8) scaleX(1.4) rotate(5deg); opacity: 1; }
  70%  { transform: translate(-60%, -50%) scaleY(1.1) scaleX(0.9) rotate(-3deg); }
  100% { transform: translate(-55%, -50%) scale(1) rotate(0deg); opacity: 1; }
}
@keyframes tc-from-right {
  0%   { transform: translate(250%, -50%) scale(0.5) rotate(30deg); opacity: 0; }
  40%  { transform: translate(-20%, -50%) scaleY(0.8) scaleX(1.4) rotate(-5deg); opacity: 1; }
  70%  { transform: translate(-40%, -50%) scaleY(1.1) scaleX(0.9) rotate(3deg); }
  100% { transform: translate(-45%, -50%) scale(1) rotate(0deg); opacity: 1; }
}

.tc-icon.impact-squash {
  animation: tc-impact-squash 0.12s ease-out forwards !important;
}
@keyframes tc-impact-squash {
  0%   { transform: translate(-50%, -50%) scaleX(1) scaleY(1); }
  50%  { transform: translate(-50%, -50%) scaleX(1.5) scaleY(0.5); }
  100% { transform: translate(-50%, -50%) scaleX(1.3) scaleY(0.7); }
}

.tc-icon.recoil-left {
  animation: tc-recoil-left 0.15s ease-out forwards !important;
}
.tc-icon.recoil-right {
  animation: tc-recoil-right 0.15s ease-out forwards !important;
}
@keyframes tc-recoil-left {
  0%   { transform: translate(-50%, -50%) scaleX(1.3) scaleY(0.7); }
  40%  { transform: translate(-65%, -50%) scaleX(0.9) scaleY(1.1); }
  100% { transform: translate(-60%, -50%) scale(1); }
}
@keyframes tc-recoil-right {
  0%   { transform: translate(-50%, -50%) scaleX(1.3) scaleY(0.7); }
  40%  { transform: translate(-35%, -50%) scaleX(0.9) scaleY(1.1); }
  100% { transform: translate(-40%, -50%) scale(1); }
}

.tc-icon.shatter {
  animation: tc-shatter 0.4s ease-out forwards;
}
@keyframes tc-shatter {
  0%   { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  15%  { transform: translate(-50%, -50%) scale(1.5) rotate(0deg); }
  30%  { transform: translate(-50%, -50%) scale(1.8) rotate(15deg); }
  100% { transform: translate(-50%, -50%) scale(0) rotate(720deg); opacity: 0; }
}

.tc-icon.winner-glow {
  animation: tc-winner-pulse 0.3s ease-out;
}
@keyframes tc-winner-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50%      { transform: translate(-50%, -50%) scale(1.2); }
}

.tc-icon.bounce-left {
  animation: tc-bounce-left 0.4s ease-out forwards;
}
.tc-icon.bounce-right {
  animation: tc-bounce-right 0.4s ease-out forwards;
}
@keyframes tc-bounce-left {
  0%   { transform: translate(-50%, -50%) scale(1); }
  20%  { transform: translate(-30%, -50%) scale(1.4); }
  100% { transform: translate(-400%, -50%) scale(0.3) rotate(-60deg); opacity: 0; }
}
@keyframes tc-bounce-right {
  0%   { transform: translate(-50%, -50%) scale(1); }
  20%  { transform: translate(-70%, -50%) scale(1.4); }
  100% { transform: translate(300%, -50%) scale(0.3) rotate(60deg); opacity: 0; }
}

/* Shockwave rings (700ms) */
.tc-ring {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 0; height: 0;
  border-radius: 50%;
  border: 10px solid rgba(200,200,210,0.7);
  box-shadow: 0 0 8px rgba(200,200,210,0.4);
  pointer-events: none;
  z-index: 10;
}
.tc-ring.ring-0 { animation: tc-ring-expand 560ms ease-out forwards; border-width: 8px; }
.tc-ring.ring-1 { animation: tc-ring-expand 560ms ease-out 140ms forwards; border-width: 5px; }
.tc-ring.ring-2 { animation: tc-ring-expand 560ms ease-out 280ms forwards; border-width: 3px; }
@keyframes tc-ring-expand {
  0%   { width: 0; height: 0; opacity: 1; }
  100% { width: 300px; height: 300px; opacity: 0; }
}

/* 8-bit shatter particles for title clash */
.tc-particle {
  position: absolute;
  left: 50%; top: 50%;
  width: 6px; height: 6px;
  border-radius: 0;
  image-rendering: pixelated;
  pointer-events: none;
  z-index: 15;
  animation: tc-particle-fly 0.35s steps(5) forwards;
}
@keyframes tc-particle-fly {
  0%, 19%  { transform: translate(0, 0); opacity: 1; }
  20%, 39% { transform: translate(calc(var(--tx) * 0.25), calc(var(--ty) * 0.25)); }
  40%, 59% { transform: translate(calc(var(--tx) * 0.5), calc(var(--ty) * 0.5)); }
  60%, 79% { transform: translate(calc(var(--tx) * 0.75), calc(var(--ty) * 0.75)); opacity: 0.6; }
  80%, 100% { transform: translate(var(--tx), var(--ty)); opacity: 0; }
}

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

/* v2.1.136: Class-based shake to avoid forced reflow jitter */
.tc-shaking {
  animation: tc-shake 0.25s ease-out !important;
}

/* Title Menu */
.title-menu {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 3vw, 20px);
  align-items: center;
}

.title-menu.animate {
  opacity: 0;
  animation: fade-in-up 0.5s ease-out forwards;
  animation-delay: 1.6s;
}

.title-btn {
  min-width: clamp(180px, 50vw, 250px);
  font-family: 'Jersey 10', cursive;
  font-size: clamp(20px, 5vw, 32px) !important;
  padding: clamp(10px, 2.5vw, 14px) clamp(20px, 5vw, 30px) !important;
  transition: transform 0.15s, opacity 0.15s;
  letter-spacing: 1px;
  border: 3px solid;
  color: #fff;
  cursor: pointer;
  /* Pixel rounded corners */
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

.title-btn.is-success {
  background: #166534;
  border-color: #22c55e;
}

.title-btn.is-primary {
  background: #1e40af;
  border-color: #3b82f6;
}

.title-btn.is-error {
  background: #7f1d1d;
  border-color: #ef4444;
}

#btn-decline-challenge {
  background: #854d0e;
  border-color: #f4d35e;
  color: #f4d35e;
}

.title-btn.is-warning {
  background: #854d0e;
  border-color: #f59e0b;
}

.title-btn:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

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

.title-footer {
  margin-top: clamp(20px, 5vw, 40px);
  font-size: clamp(14px, 3vw, 18px);
  color: var(--text-dim);
}

.title-footer.animate {
  opacity: 0;
  animation: fade-in-up 0.5s ease-out forwards;
  animation-delay: 1.8s;
}

/* START Text (tap anywhere) */
.title-start-text {
  margin-top: clamp(30px, 6vw, 50px);
  text-align: center;
}

.title-start-text.animate {
  opacity: 0;
  animation: fade-in-up 0.5s ease-out forwards;
  animation-delay: 1.6s;
}

.start-blink {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(24px, 6vw, 36px);
  color: #ffffff;
  letter-spacing: 3px;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  animation: blink-anim 1s ease-in-out infinite;
}

@keyframes blink-anim {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* Pulse glow for START button */
.pulse-glow {
  animation: pulse-glow-anim 2s ease-in-out infinite;
}

@keyframes pulse-glow-anim {
  0%, 100% { 
    box-shadow: 0 0 10px #22c55e, 0 0 20px #22c55e40;
  }
  50% { 
    box-shadow: 0 0 20px #22c55e, 0 0 40px #22c55e80, 0 0 60px #22c55e40;
  }
}
/* === 04-menu.css === */
/* ===== MAIN MENU SCREEN ===== */
#screen-main-menu {
  background: linear-gradient(180deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%) !important;
}

#screen-title {
  background: linear-gradient(180deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%) !important;
}

#screen-player-list,
#screen-waiting {
  background: linear-gradient(180deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%) !important;
}

#challenge-received-modal,
#challenge-sent-modal {
  background: linear-gradient(180deg, rgba(10,10,10,0.95) 0%, rgba(26,26,46,0.95) 50%, rgba(10,10,10,0.95) 100%) !important;
}

.menu-logo-container {
  text-align: center;
  margin-bottom: clamp(30px, 6vw, 50px);
}

.menu-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: 0.9;
}

.menu-title-word {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(52px, 14.4vw, 86px);
  font-weight: bold;
  color: #f4d35e;
  -webkit-text-stroke: 2px #dc2626;
  paint-order: stroke fill;
  text-shadow: 
    2px 2px 0 #dc2626,
    4px 4px 0 #8b0000;
  letter-spacing: 2px;
}

.menu-tagline {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(16px, 4vw, 22px);
  color: #ffffff;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
  margin-top: clamp(8px, 2vw, 12px);
  letter-spacing: 2px;
}

.main-menu-buttons {
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 3vw, 22px);
  align-items: center;
}

.main-menu-buttons .menu-btn:nth-child(1) { animation-delay: 0s; }
.main-menu-buttons .menu-btn:nth-child(2) { animation-delay: 0.3s; }
.main-menu-buttons .menu-btn:nth-child(3) { animation-delay: 0.6s; }
.main-menu-buttons .menu-btn:nth-child(4) { animation-delay: 0.9s; }

.menu-btn {
  min-width: clamp(220px, 60vw, 300px);
  font-family: 'Jersey 10', cursive;
  font-size: clamp(22px, 5vw, 30px) !important;
  padding: clamp(12px, 3vw, 16px) clamp(24px, 6vw, 40px) !important;
  transition: opacity 0.15s, box-shadow 0.15s;
  letter-spacing: 1px;
  border: 3px solid;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  /* Pixel rounded corners */
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

.menu-btn.is-success {
  background: linear-gradient(180deg, #166534 0%, #14532d 100%);
  border-color: #22c55e;
  animation: menu-blink-success 1.5s ease-in-out infinite;
}

.menu-btn.is-warning {
  background: linear-gradient(180deg, #854d0e 0%, #713f12 100%);
  border-color: #f59e0b;
  animation: menu-blink-warning 1.5s ease-in-out infinite;
}

.menu-btn.is-primary {
  background: linear-gradient(180deg, #1e40af 0%, #1e3a8a 100%);
  border-color: #3b82f6;
  animation: menu-blink-primary 1.5s ease-in-out infinite;
}

.menu-btn.is-error {
  background: linear-gradient(180deg, #7f1d1d 0%, #6b1a1a 100%);
  border-color: #ef4444;
  animation: menu-blink-error 1.5s ease-in-out infinite;
}

@keyframes menu-blink-success {
  0%, 100% { border-color: #22c55e; opacity: 0.85; }
  50% { border-color: #86efac; opacity: 1; }
}

@keyframes menu-blink-warning {
  0%, 100% { border-color: #f59e0b; opacity: 0.85; }
  50% { border-color: #fcd34d; opacity: 1; }
}

@keyframes menu-blink-primary {
  0%, 100% { border-color: #3b82f6; opacity: 0.85; }
  50% { border-color: #93c5fd; opacity: 1; }
}

@keyframes menu-blink-watch {
  0%, 100% { border-color: #14b8a6; opacity: 0.85; }
  50% { border-color: #5eead4; opacity: 1; }
}

@keyframes menu-blink-error {
  0%, 100% { border-color: #ef4444; opacity: 0.85; }
  50% { border-color: #fca5a5; opacity: 1; }
}

.menu-btn:hover {
  opacity: 0.85;
}

.menu-btn:active {
  opacity: 0.7;
}

/* Tap pop animation for touch devices */
@keyframes btn-tap-pop {
  0% { opacity: 1; }
  40% { opacity: 0.7; }
  100% { opacity: 1; }
}
.btn-tapped {
  animation: btn-tap-pop 0.25s ease-out;
}

.menu-footer {
  margin-top: clamp(30px, 6vw, 50px);
  font-size: clamp(14px, 3vw, 18px);
  color: var(--text-dim);
  text-align: center;
}
/* === 05-lobby.css === */
/* ===== LOBBY NAME INPUT ===== */
.lobby-name-section {
  text-align: center;
  margin-bottom: clamp(20px, 4vw, 30px);
}

.lobby-name-label {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(16px, 4vw, 22px);
  color: var(--text-dim);
  display: block;
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.lobby-name-input {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(20px, 5vw, 28px);
  text-align: center;
  background: transparent;
  border: none;
  border-bottom: 3px solid #666;
  color: #fff;
  padding: 8px 16px;
  width: clamp(180px, 50vw, 250px);
  outline: none;
  letter-spacing: 2px;
  transition: border-color 0.2s;
}

.lobby-name-input:focus {
  border-bottom-color: #22c55e;
}

.lobby-online-count {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(14px, 3.5vw, 18px);
  color: #22c55e;
  margin-top: clamp(15px, 3vw, 20px);
  letter-spacing: 1px;
  text-align: center;
}

/* 🏆 v2.1.136: Lobby stats bar */
.lobby-stats-bar {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(14px, 3.5vw, 18px);
  text-align: center;
  margin-top: 8px;
  letter-spacing: 1px;
  min-height: 20px;
}

/* Rules Modal */
.rules-modal {
  max-width: min(95vw, 600px);
  max-height: 85vh;
  overflow-y: auto;
  background: transparent !important;
  border: none !important;
  padding: clamp(16px, 4vw, 24px) !important;
}

.rules-content {
  text-align: left;
  font-family: 'Noto Sans', sans-serif;
  font-size: clamp(14px, 3.5vw, 18px);
  line-height: 1.7;
}

.rules-content h3 {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(22px, 5.5vw, 30px);
  margin-bottom: 12px;
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.rules-content h3 .iconify {
  font-size: 1.1em;
}

.rules-content p {
  margin: 8px 0;
  color: #e0e0e0;
  font-size: clamp(13px, 3.2vw, 17px);
  display: flex;
  align-items: center;
  gap: 6px;
}

.rules-content p .iconify {
  font-size: 1.2em;
  flex-shrink: 0;
}

.rules-content .spell-line {
  padding-left: 8px;
}

.rules-content .sub-note {
  color: #888;
  font-size: clamp(11px, 2.8vw, 14px);
  padding-left: 24px;
  margin-top: 2px;
}

/* Rules Back Button */
.rules-back-btn {
  width: 100%;
  font-family: 'Jersey 10', cursive;
  font-size: clamp(20px, 5vw, 28px) !important;
  padding: clamp(10px, 2.5vw, 14px) clamp(20px, 5vw, 30px) !important;
  background: #b45309;
  color: #fff;
  border: 3px solid #fbbf24;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  letter-spacing: 1px;
  margin-top: 16px;
  /* Pixel rounded corners */
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

.rules-back-btn:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

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

/* Fade Animations */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.fade-out {
  animation: fade-out 0.3s ease-out forwards;
}

/* Battle Intro Overlay */
.battle-intro-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.battle-intro-overlay.show {
  opacity: 1;
}

.battle-intro-overlay.fade-out {
  opacity: 0;
  transition: opacity 0.3s ease-out;
  animation: none;
}

/* v2.1.56: Remove screen-shake from overlay - background stays still */
/* Text already has shake built into spinSlam animation */
.battle-intro-overlay.screen-shake {
  /* No animation on overlay - only text shakes */
}

/* v2.1.53: Container for 2-line layout */
.battle-intro-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: 0.9;
}

/* v2.1.53: Battle intro text - reduced 30% from original */
.battle-intro-text {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(56px, 21vw, 140px);
  font-weight: bold;
  color: #f4d35e;
  -webkit-text-stroke: 2px #dc2626;
  paint-order: stroke fill;
  text-shadow: 
    3px 3px 0 #dc2626,
    5px 5px 0 #8b0000;
  letter-spacing: 4px;
}

/* v2.1.53: JANKEN word - SPIN SLAM (no glow) */
.battle-word-janken {
  animation: spinSlam 0.75s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* v2.1.53: BATTLE word - SPIN SLAM delayed (no glow) */
.battle-word-battle {
  opacity: 0;
  animation: spinSlam 0.75s cubic-bezier(0.22, 0.61, 0.36, 1) 0.12s forwards;
}

/* v2.1.53: SPIN SLAM Animation - Spin + Zoom + Impact + Shake */
@keyframes spinSlam {
  0% {
    transform: scale(4) translateY(-100px) rotate(-180deg);
    opacity: 0;
  }
  30% {
    transform: scale(0.85) translateY(10px) rotate(5deg);
    opacity: 1;
  }
  40% {
    transform: scale(1.1) translateX(-10px) rotate(-3deg);
  }
  50% {
    transform: scale(1.02) translateX(10px) rotate(3deg);
  }
  60% {
    transform: scale(1) translateX(-7px) rotate(-2deg);
  }
  70% {
    transform: translateX(7px) rotate(2deg);
  }
  80% {
    transform: translateX(-4px) rotate(-1deg);
  }
  90% {
    transform: translateX(3px);
  }
  100% {
    transform: scale(1) translateX(0) rotate(0deg);
    opacity: 1;
  }
}

/* v2.1.53: Screen Shake Animation */
10% { transform: translate(-8px, -4px); }
  20% { transform: translate(8px, 3px); }
  30% { transform: translate(-6px, 4px); }
  40% { transform: translate(6px, -3px); }
  50% { transform: translate(-5px, 2px); }
  60% { transform: translate(5px, -2px); }
  70% { transform: translate(-3px, 1px); }
  80% { transform: translate(3px, -1px); }
  90% { transform: translate(-2px, 0); }
}

/* Pray Warning Animations */
50% { 
    transform: scale(1.15); 
    filter: drop-shadow(0 0 40px #ffd700) drop-shadow(0 0 60px #ff8c00);
  }
}

50% { opacity: 0.3; }
}

@keyframes card-shake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(-3px) rotate(-2deg); }
  75% { transform: translateX(3px) rotate(2deg); }
}

@keyframes damage-pulse {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ===== LAYOUT ===== */
.app-container { 
  width: 100%; 
  height: 100%; 
  display: flex; 
  flex-direction: column; 
  background: transparent;
  max-width: 100%;
  margin: 0 auto;
}

/* Center game area on large screens - More spacious */
@media (min-width: 900px) {
  .app-container {
    max-width: 520px;
    box-shadow: 0 0 60px rgba(0,0,0,0.8);
  }
}

/* Wider on larger desktops */
@media (min-width: 1200px) {
  .app-container {
    max-width: 560px;
  }
}

@media (min-width: 1400px) {
  .app-container {
    max-width: 600px;
  }
}

.screen { 
  position: absolute; 
  inset: 0; 
  display: flex; 
  flex-direction: column; 
  transition: opacity 0.3s;
  z-index: 100;  /* Ensure screens are on top */
}

@media (min-width: 900px) {
  /* No max-width cap — full screen like mobile */
}

.screen-hidden { display: none; opacity: 0; visibility: hidden; pointer-events: none; }

/* Game screen needs padding for top-bar */
#screen-game {
  padding-top: calc(var(--sat) + 48px);
  background: linear-gradient(180deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%);
}

/* ===== UTILITIES ===== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--gap); }
.gap-2 { gap: calc(var(--gap) * 1.5); }
.p-1 { padding: var(--pad); }
.p-2 { padding: calc(var(--pad) * 1.5); }
.mb-1 { margin-bottom: var(--gap); }
.mb-2 { margin-bottom: calc(var(--gap) * 2); }
.mt-1 { margin-top: var(--gap); }
.mt-2 { margin-top: calc(var(--gap) * 2); }
.text-center { text-align: center; }
.text-xs { font-size: var(--font-xs); }
.text-sm { font-size: var(--font-sm); }
.text-md { font-size: var(--font-md); }
.text-lg { font-size: var(--font-lg); }
.text-xl { font-size: var(--font-xl); }
.w-full { width: 100%; }
.hidden { display: none !important; }
.text-yellow { color: var(--yellow); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-cyan { color: var(--cyan); }
.text-dim { color: var(--text-dim); }

/* Heartbeat animation for opponent card */
15% { transform: scale(1.3); }
  30% { transform: scale(1); }
  45% { transform: scale(1.2); }
  60% { transform: scale(1); }
}
/* 🔰 v2.1.133: Card Ghost — empty zone placeholder */
.card-ghost {
  width: 60%; height: 70%;
  border: 1px dashed #3a3a55;
  border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.card-ghost .iconify { font-size: 20px; color: #3a3a55; }

.battle-zone.active .card-ghost {
  border-color: #f4d35e50;
  animation: ghost-pulse 1.5s ease-in-out infinite;
}
.battle-zone.active .card-ghost .iconify { color: #f4d35e60; }

@keyframes ghost-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* 🔰 v2.1.133: Card Back — opponent placed card (brown stripe + JKM) */
.opp-card-back {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg, #5a3a1a, #5a3a1a 4px, #4a2e12 4px, #4a2e12 8px
  );
  border: 1px solid #7a5a30;
  display: flex;
  align-items: center;
  justify-content: center;
  image-rendering: pixelated;
  z-index: 1;
}
.opp-card-back .jkm {
  font-family: 'Jersey 10', cursive;
  font-size: 18px;
  color: #f4d35e;
  text-shadow: 2px 2px 0 #2a1a08, 0 0 8px #f4d35e40;
  letter-spacing: 3px;
  background: #4a2e12cc;
  padding: 2px 6px;
}

/* 🎴 v2.1.136: Bot placement uses same Arc Toss as PVP (JS animation) */

/* 🔰 v2.1.133: Card Flip Reveal — opponent card flip during battle */
/* 🔰 v2.1.138n: Slam Flip — hurl down + squash on land */
/* 🔰 v2.1.138w: Slam Flip — crossfade transition + screen shake impact */
.flip-reveal-container {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
}
/* crossfade: both faces visible, opacity animated */
.flip-reveal-container .opp-card-back {
  position: absolute; inset: 0;
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
  z-index: 2;
}
.flip-reveal-container .card-front-reveal {
  position: absolute; inset: 0;
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
  transform: rotateY(180deg);
  z-index: 1;
  opacity: 0;
}
.flip-reveal-container .card-front-reveal .pixel-card {
  position: absolute !important; inset: 0;
  width: auto !important; height: auto !important;
}
/* Slam motion */
.flip-reveal-container.do-flip {
  animation: cardSlamFlip 0.45s cubic-bezier(0.9,0,1,0.1) forwards;
}
@keyframes cardSlamFlip {
  0%   { transform: rotateY(0deg) translateY(-18px) scaleY(0.9); }
  40%  { transform: rotateY(90deg) translateY(0) scaleX(0.5); }
  62%  { transform: rotateY(180deg) scaleX(1.14) scaleY(0.86); }
  78%  { transform: rotateY(180deg) scaleX(0.96) scaleY(1.04); }
  100% { transform: rotateY(180deg) scale(1); }
}
/* crossfade: back fades out through the 90° window */
.flip-reveal-container.do-flip .opp-card-back {
  animation: cfBackOut 0.45s ease-in-out forwards;
}
@keyframes cfBackOut {
  0%,  35% { opacity: 1; }
  55%, 100% { opacity: 0; }
}
/* crossfade: front fades in just after midpoint */
.flip-reveal-container.do-flip .card-front-reveal {
  animation: cfFrontIn 0.45s ease-in-out forwards;
}
@keyframes cfFrontIn {
  0%,  40% { opacity: 0; }
  60%, 100% { opacity: 1; }
}
/* screen shake on the battle-zone parent — triggered via JS class */
@keyframes cardRevealShake {
  0%   { transform: translateX(0)   translateY(0); }
  15%  { transform: translateX(-5px) translateY(-3px); }
  30%  { transform: translateX(5px)  translateY(2px); }
  45%  { transform: translateX(-3px) translateY(-2px); }
  60%  { transform: translateX(3px)  translateY(1px); }
  75%  { transform: translateX(-2px) translateY(0); }
  100% { transform: translateX(0)   translateY(0); }
}
.card-reveal-shake {
  animation: cardRevealShake 0.28s ease-out forwards !important;
}

/* Legacy compat — hide old style */
.opp-card-icon {
  display: none;
}

/* ===== LOBBY ===== */
#screen-lobby {
  background: linear-gradient(180deg, #0a0a0a 0%, #1a1a2e 50%, #0a0a0a 100%) !important;
}

.lobby-content {
  width: 100%;
  max-width: 320px;
  padding: 0 var(--pad);
}

@media (min-width: 480px) { .lobby-content { max-width: 380px; } }
@media (min-width: 600px) { .lobby-content { max-width: 480px; } }
@media (min-width: 900px) { .lobby-content { max-width: 480px; } }  /* PC - match container */
@media (min-width: 1200px) { .lobby-content { max-width: 520px; } } /* Desktop */

/* Player List Screen - MAXIMUM WIDTH on PC/Desktop */
@media (min-width: 900px) { 
  #screen-player-list .lobby-content { max-width: 800px; }  /* จำกัดให้พอดี */
  .player-list-item {
    padding: 16px 24px !important;
    gap: 24px !important;
  }
  .player-list-item > div:first-child {
    max-width: 60% !important;
  }
}
@media (min-width: 1200px) { 
  #screen-player-list .lobby-content { max-width: 900px; }
  .player-list-item {
    padding: 18px 28px !important;
    gap: 32px !important;
  }
}
@media (min-width: 1400px) { 
  #screen-player-list .lobby-content { max-width: 1000px; }
  .player-list-item {
    padding: 20px 32px !important;
    gap: 40px !important;
  }
}
@media (min-width: 1600px) { 
  #screen-player-list .lobby-content { max-width: 1100px; }
}
@media (min-width: 1920px) { 
  #screen-player-list .lobby-content { max-width: 1200px; }
}

/* Lobby Logo - Like Title Screen */
.lobby-logo-container {
  text-align: center;
  margin-bottom: 20px;
}

.lobby-logo-line {
  display: flex;
  justify-content: center;
  line-height: 0.85;
}

.lobby-title-word {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(44px, 14vw, 80px);
  font-weight: bold;
  color: #f4d35e;
  -webkit-text-stroke: 2px #dc2626;
  paint-order: stroke fill;
  text-shadow: 
    3px 3px 0 #dc2626,
    5px 5px 0 #8b0000;
  letter-spacing: 2px;
}

.lobby-tagline {
  font-size: clamp(12px, 3vw, 16px);
  color: #ffffff;
  margin-top: 10px;
  opacity: 0;
  animation: tagline-fade-up-blink 2s ease-out forwards;
}

.lobby-master-text {
  color: var(--yellow);
  font-weight: bold;
}

/* Lobby Input Box */
.lobby-input-box {
  background: #111;
  border: 4px solid var(--border);
  padding: var(--pad);
  margin-bottom: 20px;
  /* Pixel rounded corners - same as buttons */
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

/* Lobby Button - Minimal Pixel Style */
.lobby-btn {
  width: 100%;
  font-family: 'Jersey 10', cursive;
  font-size: clamp(20px, 5vw, 30px) !important;
  padding: clamp(10px, 2.5vw, 14px) clamp(16px, 4vw, 24px) !important;
  background: #166534;
  color: #fff;
  border: 3px solid #22c55e;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 1px;
  /* Pixel rounded corners */
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

.lobby-btn:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

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

/* Lobby Back Button - Minimal Pixel Style */
.lobby-back-btn {
  width: 100%;
  font-family: 'Jersey 10', cursive;
  font-size: clamp(18px, 4vw, 26px) !important;
  padding: clamp(10px, 2.5vw, 14px) clamp(20px, 5vw, 30px) !important;
  background: #374151;  /* Grey */
  color: #fff;
  border: 3px solid #6b7280;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 1px;
  margin-top: 12px;
  /* Sharp pixel corners - 90% cut */
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

.lobby-back-btn:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

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

/* Player List Item Hover Effect */
.player-list-item {
  transition: border-color 0.2s;
}

.player-list-item:hover {
  border-color: #3b82f6 !important;
}

/* Challenge Button Hover/Active Effects */
.btn-challenge {
  transition: transform 0.15s, opacity 0.15s;
}

.btn-challenge:hover {
  transform: scale(1.05);
  opacity: 0.9;
}

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

/* Online Count Display */
.online-count-display {
  text-align: center;
  font-size: clamp(14px, 3.5vw, 20px);
  color: #22c55e;
  margin-top: 12px;
  font-weight: bold;
  text-shadow: 0 0 10px #22c55e, 0 0 20px #22c55e;
  animation: online-glow 2s ease-in-out infinite;
}

@keyframes online-glow {
  0%, 100% { text-shadow: 0 0 10px #22c55e, 0 0 20px #22c55e; }
  50% { text-shadow: 0 0 20px #22c55e, 0 0 40px #22c55e, 0 0 60px #22c55e; }
}

.lobby-logo {
  text-align: center;
  padding: 10px 0;
}

.lobby-title {
  font-size: var(--font-xl);
  text-shadow: 2px 2px 0 var(--red);
}
/* === 06-game.css === */
/* ===== HP SECTION ===== */
.hp-section {
  padding: var(--pad);
  background: transparent;
}

.hp-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.hp-label {
  font-size: calc(var(--font-sm) * 1.2);
  font-weight: bold;
  color: #fff;
  white-space: nowrap;
  min-width: 84px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

.hp-bar-container {
  flex: 1;
  height: clamp(17px, 3.6vw, 26px);
  background: var(--bg-darker);
  border: 2px solid #4a7a1f;
  position: relative;
  border-radius: 0;
  transition: border-color 0.6s, box-shadow 0.6s;
  overflow: hidden;
}

/* Glow border states */
.hp-bar-container.bar-healthy {
  border-color: #8ace3a;
  box-shadow: 0 0 6px rgba(138,206,58,0.4), 0 0 12px rgba(138,206,58,0.15);
}
.hp-bar-container.bar-warning {
  border-color: #f6e44c;
  box-shadow: 0 0 8px rgba(246,228,76,0.5), 0 0 16px rgba(246,228,76,0.2);
}
.hp-bar-container.bar-danger {
  border-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245,158,11,0.5), 0 0 16px rgba(245,158,11,0.2);
}
.hp-bar-container.bar-critical {
  border-color: #ff4444;
  box-shadow: 0 0 10px rgba(255,50,50,0.6), 0 0 20px rgba(192,27,27,0.3);
}

.hp-fill {
  height: 100%;
  background: #8ace3a;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1), background-color 0.6s ease;
  border-radius: 0;
}
.hp-fill.hp-healthy { background: #8ace3a; }
.hp-fill.hp-warning { background: #f6e44c; }
.hp-fill.hp-danger { background: #f59e0b; }
.hp-fill.hp-critical { background: #c01b1b; animation: hp-flash 0.5s step-end infinite; }

@keyframes hp-flash {
  0%, 100% { background: #c01b1b; }
  50% { background: #ff4444; }
}

/* 🎴 v2.1.136: Deck depletion warning */
.deck-warning {
  color: #f59e0b !important;
  animation: deck-pulse 2s ease-in-out infinite;
}
.deck-critical {
  color: #ef4444 !important;
  animation: deck-pulse-critical 1s ease-in-out infinite;
}
@keyframes deck-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
@keyframes deck-pulse-critical {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== BATTLE ARENA ===== */
.battle-arena { 
  flex: 1; 
  display: flex; 
  flex-direction: column; 
  justify-content: center; 
  align-items: center; 
  padding: var(--pad); 
  min-height: 0;
  overflow: hidden;
  position: relative;
  perspective: 800px;
  background-color: #1a472a; /* Fallback color */
}

/* 3D Tilt Background Layer */
.arena-bg-3d {
  position: absolute;
  inset: -15px; /* Oversized to prevent edge peeking on tilt */
  background: var(--arena-bg, linear-gradient(135deg, #1a2a1a 0%, #2a3a2a 50%, #1a2a1a 100%)) center center / cover no-repeat;
  background-color: #1a2a2a; /* Fallback if both image and var fail */
  transform: rotateX(var(--tilt-x, 0deg)) rotateY(var(--tilt-y, 0deg));
  transform-style: preserve-3d;
  will-change: transform;
  transition: transform 0.15s ease-out;
  z-index: 0;
  pointer-events: none;
}

/* Dark overlay for better card visibility */
.battle-arena::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 1;
}

/* All content above bg + overlay */
.battle-arena > *:not(.arena-bg-3d) {
  position: relative;
  z-index: 2;
}

.battle-row { 
  display: flex; 
  justify-content: center; 
  gap: var(--gap); 
  width: 100%; 
  max-width: calc(var(--zone-w) * 3 + var(--gap) * 4);
  position: relative;
  z-index: 1;
}

.zone-wrapper { 
  flex: 1; 
  max-width: var(--zone-w); 
  display: flex; 
  flex-direction: column; 
  align-items: center; 
}

.zone-label { 
  font-size: var(--font-xs); 
  color: #fff; 
  margin: 3px 0;
  text-shadow: 0 0 4px rgba(0,0,0,0.8), 0 1px 2px rgba(0,0,0,0.9);
}

.battle-zone { 
  aspect-ratio: 5/7; 
  width: 100%; 
  background: #0e0e1a; 
  border: 2px solid #2a2a3a;
  position: relative; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer;
  font-size: var(--font-lg);
  transition: border-color 0.15s, box-shadow 0.15s;
  overflow: hidden;
  contain: paint;
  image-rendering: pixelated;
}

/* v2.1.132 FIX: Cards in zones pinned to edges — prevents flex layout shift on mobile */
.battle-zone .pixel-card { pointer-events: none; position: absolute !important; inset: 0; width: auto !important; height: auto !important; }
.battle-zone .pixel-card:hover { transform: none !important; }
.battle-zone .pixel-card:active { transform: none !important; }

@media (min-width: 600px) {
  .battle-zone { border-width: 3px; }
}

.battle-zone.active { 
  border-color: #f4d35e;
  box-shadow: 0 0 0 1px #f4d35e30;
  background: #141420;
  animation: zone-waiting 0.8s steps(2) infinite;
}

@keyframes zone-waiting {
  0%, 100% { 
    border-color: #f4d35e;
  }
  50% { 
    border-color: #fff;
  }
}

.battle-zone.has-card { 
  border-color: #3a3a5a;
  animation: none; 
}
.battle-zone.select-reflect { cursor: pointer; }
.battle-zone.reflected { 
  background: #0e0e1a;
  border-color: #4a3a6a;
  box-shadow: inset 2px 2px 0 #5a4a7a, inset -2px -2px 0 #2a1a3a;
}

50% { opacity: 0.6; } }

.battle-divider {
  display: flex;
  align-items: center;
  gap: var(--gap);
  width: 100%;
  max-width: calc(var(--zone-w) * 3 + var(--gap) * 4);
  padding: var(--gap) 0;
  position: relative;
  z-index: 1;
}

.battle-divider-line {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,0.3);
  box-shadow: 0 0 5px rgba(255,255,255,0.2);
}

/* ===== CARDS ===== */
.pixel-card { 
  width: var(--card-w); 
  height: var(--card-h); 
  position: relative; 
  cursor: pointer; 
  transition: transform 0.15s;
  flex-shrink: 0;
}

.pixel-card:hover { transform: translateY(-6px); }
.pixel-card:active { transform: scale(0.95); }

@media (hover: none) {
  .pixel-card:hover { transform: none; }
}

.card-face { 
  position: absolute; 
  inset: 0; 
  display: flex; 
  flex-direction: column; 
  border: 1px solid rgba(255,255,255,0.1); 
  transition: opacity 0.3s;
}

/* Element card borders */
.element-rock { border-color: #8a8abe; }
.element-paper { border-color: #5aaafe; }
.element-scissors { border-color: #ff6070; }
.element-divine { border-color: #ffd700; }
.element-unknown { border-color: #9b5de5; }

.card-back { 
  background: var(--purple); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
}

.card-back-pattern { 
  width: 60%; 
  height: 60%; 
  border: 2px dashed rgba(255,255,255,0.3); 
  display: flex; 
  align-items: center; 
  justify-content: center;
  font-size: var(--font-md);
  color: var(--yellow);
}

.card-front { display: flex; flex-direction: column; }
.element-rock { background: linear-gradient(180deg, #5a5a8e 0%, #2a2a4e 100%); }
.element-paper { background: linear-gradient(180deg, #3a8aee 0%, #1a3a6e 100%); }
.element-scissors { background: linear-gradient(180deg, #ee4050 0%, #6a1a2a 100%); }
/* v2.1.56: Optimized - use opacity instead of filter:brightness for better Chrome performance */
.element-divine { background: linear-gradient(180deg, #ffcc22 0%, #7a5500 100%); animation: divine-bg 2s ease-in-out infinite; }
.element-unknown { background: linear-gradient(180deg, #8a44dd 0%, #2a1050 100%); animation: unknown-bg 2s ease-in-out infinite; }

/* v2.1.56: Optimized keyframes - opacity is GPU accelerated, filter is not */
@keyframes divine-bg { 0%,100% { opacity: 0.9; } 50% { opacity: 1; } }
@keyframes unknown-bg { 0%,100% { opacity: 1; } 50% { opacity: 0.85; } }

.card-header { 
  background: transparent; 
  padding: 2px 4px; 
  display: flex; 
  justify-content: space-between; 
  font-size: var(--font-xs); 
  color: #ffffff; 
}

.card-body { flex: 1; display: flex; align-items: center; justify-content: center; }
.card-icon { font-size: clamp(16px, 5vw, 28px); }

/* v2.1.118: Zone cards are larger - scale up icon */
.battle-zone .card-icon { font-size: clamp(22px, 7vw, 42px); }
.card-footer { 
  background: transparent; 
  padding: 1px 2px; 
  text-align: center; 
  font-size: calc(var(--font-xs) - 4px); 
  color: #ffffff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-flipped .card-back { opacity: 0; }
.card-flipped .card-front { opacity: 1; }
.card-back { opacity: 1; }
.card-front { opacity: 0; }

.card-divine-glow { animation: divine-glow 1.5s infinite; }
/* v2.1.57: Divine card golden border */
.card-divine-glow .card-front,
.element-divine {
  border-color: #ffcc22 !important;
}
.card-unknown-glow { animation: unknown-glow 2s infinite; }
@keyframes divine-glow { 0%,100% { box-shadow: 0 0 2px rgba(255,215,0,0.4); } 50% { box-shadow: 0 0 5px rgba(255,140,0,0.4); } }
@keyframes unknown-glow { 0%,100% { box-shadow: 0 0 3px rgba(119,51,204,0.4), 0 0 6px rgba(138,68,221,0.1); } 50% { box-shadow: 0 0 6px rgba(153,68,255,0.4), 0 0 10px rgba(138,68,221,0.2); } }

/* v2.1.54: DARK card - Pure black with white glow */
.element-dark { 
  background: linear-gradient(180deg, #222222 0%, #000000 100%) !important; 
  animation: dark-bg 2s infinite; 
}
.element-dark .card-icon { color: #ffffff !important; filter: drop-shadow(0 0 8px #ffffff); }
.element-dark .card-header { color: #ffffff; }
.element-dark .card-footer { color: #ffffff; }

/* v2.1.57: DARK reveal - purple overlay (Unknown look) fades out to reveal black underneath */
.element-dark.dark-reveal {
  position: relative;
}
.element-dark.dark-reveal::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #8a44dd 0%, #2a1050 100%);
  z-index: 1;
  opacity: 1;
  transition: opacity 0.8s ease-out;
  pointer-events: none;
}
.element-dark.dark-reveal .card-icon {
  color: #ffffff !important;
  filter: none !important;
  transition: color 0.8s ease-out, filter 0.8s ease-out;
  position: relative;
  z-index: 2;
}
.element-dark.dark-reveal .card-header,
.element-dark.dark-reveal .card-footer {
  color: #ffffff !important;
  transition: color 0.8s ease-out;
  position: relative;
  z-index: 2;
}

/* Final state: gray overlay fades out */
.element-dark.dark-reveal.dark-revealed::before {
  opacity: 0;
}
.element-dark.dark-reveal.dark-revealed .card-icon {
  color: #ffffff !important;
  filter: drop-shadow(0 0 8px #ffffff) !important;
}
.element-dark.dark-reveal.dark-revealed .card-header,
.element-dark.dark-reveal.dark-revealed .card-footer {
  color: #ffffff !important;
}

/* v2.1.56: Optimized - use opacity instead of filter */
@keyframes dark-bg { 
  0%,100% { opacity: 1; } 
  50% { opacity: 0.85; } 
}

.card-dark-glow { animation: dark-glow 2s infinite; }
@keyframes dark-glow { 
  0%,100% { box-shadow: 0 0 3px rgba(255,255,255,0.35), 0 0 6px rgba(255,255,255,0.15); } 
  50% { box-shadow: 0 0 8px rgba(255,255,255,0.4), 0 0 14px rgba(255,255,255,0.2); } 
}

/* v2.1.54: Eclipse combo - VOID/ABYSS transform to DARK style with fade */
.card-eclipse-transform {
  transition: all 0.8s ease-out;
}

/* Eclipse fade - background fades to dark */
.card-eclipse-fade .card-front {
  transition: background 0.8s ease-out, filter 0.8s ease-out;
}

.card-eclipse-fade .card-icon .iconify {
  transition: color 0.8s ease-out, filter 0.8s ease-out;
}

.card-eclipse-fade .card-footer,
.card-eclipse-fade .card-header {
  transition: color 0.8s ease-out;
}

/* Eclipse active glow on unknown cards */
.card-eclipse-active {
  animation: eclipse-glow 0.8s ease-in-out infinite alternate;
}
@keyframes eclipse-glow {
  0% { box-shadow: 0 0 10px #ffffff, 0 0 20px rgba(255,255,255,0.5); }
  100% { box-shadow: 0 0 25px #ffffff, 0 0 50px rgba(255,255,255,0.8), 0 0 75px rgba(255,255,255,0.4); }
}

/* 🌟 v2.1.61: GOD LIGHT active glow on Divine cards - white core style */
.card-godlight-active {
  animation: godlight-glow 0.8s ease-in-out infinite alternate;
}
@keyframes godlight-glow {
  0% { box-shadow: 0 0 20px #ffffff, 0 0 40px rgba(255,255,255,0.6), 0 0 60px rgba(255,215,0,0.4); }
  100% { box-shadow: 0 0 35px #ffffff, 0 0 70px rgba(255,255,255,0.8), 0 0 100px rgba(255,215,0,0.5); }
}

/* 🌟 v2.1.61: Divine Blessing text pulse */
@keyframes godlight-text-pulse {
  0% { opacity: 0.8; transform: scale(1); }
  100% { opacity: 1; transform: scale(1.05); }
}

/* Silver Card (Level 4) */
.card-silver {
  border: 1px solid #c0c0c0 !important;
  box-shadow: 0 0 10px #c0c0c0, 0 0 20px rgba(192, 192, 192, 0.5), inset 0 0 10px rgba(192, 192, 192, 0.2);
  animation: silver-glow 2s ease-in-out infinite;
}
.card-silver .card-front {
  filter: brightness(0.9) contrast(1.1);
}
@keyframes silver-glow {
  0%, 100% { box-shadow: 0 0 10px #c0c0c0, 0 0 20px rgba(192, 192, 192, 0.3); }
  50% { box-shadow: 0 0 15px #e0e0e0, 0 0 30px rgba(192, 192, 192, 0.6), 0 0 40px rgba(255, 255, 255, 0.3); }
}

/* Gold Card (Level 5) */
.card-gold {
  border: 1px solid #ffd700 !important;
  box-shadow: 0 0 15px #ffd700, 0 0 30px rgba(255, 215, 0, 0.5), inset 0 0 10px rgba(255, 215, 0, 0.2);
  animation: gold-glow 2s ease-in-out infinite;
}
.card-gold .card-front {
  filter: brightness(0.85) contrast(1.15);
}
@keyframes gold-glow {
  0%, 100% { box-shadow: 0 0 15px #ffd700, 0 0 30px rgba(255, 215, 0, 0.3); }
  50% { box-shadow: 0 0 20px #ffec8b, 0 0 40px rgba(255, 215, 0, 0.6), 0 0 60px rgba(255, 200, 0, 0.4); }
}

/* v2.1.134: Battle result — static, no animation */
.winner-card { filter: brightness(1.2) saturate(1.15) !important; animation: none !important; }
.loser-card { filter: grayscale(100%) brightness(0.5) !important; animation: none !important; }
@keyframes winner { 0%,100% { transform: scale(1); } 50% { transform: scale(1); } }
.remove-btn { 
  position: absolute; 
  top: -10px; 
  right: -10px; 
  width: clamp(28px, 6vw, 40px); 
  height: clamp(28px, 6vw, 40px); 
  background: var(--red); 
  color: white; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: clamp(18px, 5vw, 28px); 
  font-weight: bold;
  cursor: pointer; 
  z-index: 20; 
  border: 3px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  transition: transform 0.15s, background 0.15s;
}

.remove-btn:hover {
  transform: scale(1.15);
  background: #ff4444;
}

.remove-btn:active {
  transform: scale(0.95);
  background: #cc0000;
}

/* Flying card animation */
.pixel-card.flying {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
  animation: card-float 0.3s ease-out;
}

@keyframes card-float {
  0% { 
    transform: scale(1) rotate(0deg); 
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
  }
  50% { 
    transform: scale(1.1) rotate(-3deg); 
    filter: drop-shadow(0 12px 24px rgba(0,0,0,0.5));
  }
  100% { 
    transform: scale(1) rotate(0deg); 
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
  }
}
/* === 07-spells-effects.css === */
/* ===== SPELLS ===== */
.spells-bar { 
  flex-wrap: wrap;
  display: flex; 
  justify-content: center; 
  gap: var(--gap); 
  padding: var(--pad); 
  background: transparent; 
  position: relative;
  z-index: 5;
}

.spell-btn { 
  width: var(--spell-size); 
  height: var(--spell-size); 
  background: var(--bg-darker); 
  border: 2px solid var(--border); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  cursor: pointer; 
  font-size: clamp(16px, 4vw, 24px); 
  transition: all 0.15s;
  position: relative;
  z-index: 5;
}

.spell-btn:active { transform: scale(0.95); }
.spell-btn.used { opacity: 0.3; cursor: not-allowed; animation: none !important; }
.spell-btn.disabled { opacity: 0.5; cursor: not-allowed; }

/* Count badge for multi-use spells (Power, Reflect) */
.spell-count-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  background: #ff4444;
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Jersey 10', cursive;
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
  z-index: 10;
}

/* Slow blink when available (not used, not selected) */
/* v2.1.56: Optimized - slower animations (3s instead of 2s) for better Chrome performance */
/* v2.1.135: Idle = static (no animation), Active = 0.3s + scale like combo/trinity */
.spell-btn[data-spell="forge"]:not(.used):not(.active) { border-color: #f59e0b; box-shadow: 0 0 3px rgba(245,158,11,0.4); }
.spell-btn[data-spell="power"]:not(.used):not(.active) { border-color: #ff4444; box-shadow: 0 0 3px rgba(255,68,68,0.4); }
.spell-btn[data-spell="reflect"]:not(.used):not(.active) { border-color: #c084fc; box-shadow: 0 0 3px rgba(192,132,252,0.4); }
.spell-btn[data-spell="destroy"]:not(.used):not(.active) { border-color: #fff; box-shadow: 0 0 3px rgba(255,255,255,0.4); }
.spell-btn[data-spell="heal"]:not(.used):not(.active) { border-color: #2a9d8f; box-shadow: 0 0 3px rgba(42,157,143,0.4); }
.spell-btn[data-spell="pray"]:not(.used):not(.active) { border-color: var(--yellow); box-shadow: 0 0 3px rgba(244,211,94,0.4); }
.spell-btn[data-spell="sacrifice"]:not(.used):not(.active) { border-color: #8b0000; box-shadow: 0 0 3px rgba(139,0,0,0.4); }
.spell-btn[data-spell="combo"]:not(.used):not(.active) { border-color: #ff6b35; box-shadow: 0 0 3px rgba(255,107,53,0.4); opacity: 0.5; }

/* Active = 0.3s rapid blink + scale(1.05) — same feel as combo/trinity */
.spell-btn.active[data-spell="forge"] { border-color: #f59e0b; animation: spell-active-forge 0.3s ease-in-out infinite; background: rgba(245,158,11,0.2); }
.spell-btn.selected[data-spell="forge"]:not(.used) { border-color: #f59e0b; animation: spell-active-forge 0.3s ease-in-out infinite; background: rgba(245,158,11,0.25); }
.spell-btn.active[data-spell="power"] { border-color: #ff4444; animation: spell-active-power 0.3s ease-in-out infinite; background: rgba(255,68,68,0.2); }
.spell-btn.active[data-spell="reflect"] { border-color: #c084fc; animation: spell-active-reflect 0.3s ease-in-out infinite; background: rgba(192,132,252,0.2); }
.spell-btn.active[data-spell="destroy"] { border-color: #fff; animation: spell-active-destroy 0.3s ease-in-out infinite; background: rgba(255,255,255,0.1); }
.spell-btn.active[data-spell="heal"] { border-color: #2a9d8f; animation: spell-active-heal 0.3s ease-in-out infinite; background: rgba(42,157,143,0.2); }
.spell-btn.active[data-spell="pray"] { border-color: var(--yellow); animation: spell-active-pray 0.3s ease-in-out infinite; background: rgba(244,211,94,0.2); }
.spell-btn.active[data-spell="sacrifice"] { border-color: #8b0000; animation: spell-active-sacrifice 0.3s ease-in-out infinite; background: rgba(139,0,0,0.2); }
.spell-btn.active[data-spell="combo"] { border-color: #ff6b35; animation: spell-blink-fast-orange 0.3s ease-in-out infinite; background: rgba(255,107,53,0.2); opacity: 1 !important; }

/* TRINITY spell - green for harmony */
.spell-btn[data-spell="trinity"]:not(.used):not(.active) { border-color: #00ff88; box-shadow: 0 0 3px rgba(0,255,136,0.4); opacity: 0.5; }
.spell-btn.active[data-spell="trinity"] { border-color: #00ff88; animation: spell-blink-fast-harmony 0.3s ease-in-out infinite; background: rgba(0,255,136,0.2); opacity: 1 !important; }

/* v2.1.136: Active keyframes — 0.3s + scale(1.05) like combo/trinity */
@keyframes spell-active-forge {
  0%, 100% { box-shadow: 0 0 8px rgba(245,158,11,0.7); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(245,158,11,0.6), 0 0 28px rgba(245,158,11,0.3); transform: scale(1.05); }
}
@keyframes spell-active-power {
  0%, 100% { box-shadow: 0 0 8px rgba(255,68,68,0.7); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(255,68,68,0.6), 0 0 28px rgba(255,0,0,0.3); transform: scale(1.05); }
}
@keyframes spell-active-reflect {
  0%, 100% { box-shadow: 0 0 8px rgba(192,132,252,0.7); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(192,132,252,0.6), 0 0 28px rgba(168,85,247,0.3); transform: scale(1.05); }
}
@keyframes spell-active-destroy {
  0%, 100% { box-shadow: 0 0 8px rgba(255,255,255,0.7); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(255,255,255,0.6), 0 0 28px rgba(255,255,255,0.3); transform: scale(1.05); }
}
@keyframes spell-active-heal {
  0%, 100% { box-shadow: 0 0 8px rgba(42,157,143,0.7); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(42,157,143,0.6), 0 0 28px rgba(42,157,143,0.3); transform: scale(1.05); }
}
@keyframes spell-active-pray {
  0%, 100% { box-shadow: 0 0 8px rgba(244,211,94,0.7); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(244,211,94,0.6), 0 0 28px rgba(244,211,94,0.3); transform: scale(1.05); }
}
@keyframes spell-active-sacrifice {
  0%, 100% { box-shadow: 0 0 8px rgba(139,0,0,0.7); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(139,0,0,0.6), 0 0 28px rgba(139,0,0,0.3); transform: scale(1.05); }
}
@keyframes spell-blink-fast-orange {
  0%, 100% { box-shadow: 0 0 8px rgba(255,107,53,0.7); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(255,107,53,0.6), 0 0 28px rgba(255,107,53,0.3); transform: scale(1.05); }
}
@keyframes spell-blink-fast-harmony {
  0%, 100% { box-shadow: 0 0 8px rgba(0,255,136,0.7); transform: scale(1); }
  50% { box-shadow: 0 0 18px rgba(0,255,136,0.6), 0 0 28px rgba(0,255,136,0.3); transform: scale(1.05); }
}

/* ===== BATTLE CLASH ANIMATIONS ===== */
/* 🎮 v2.1.62: Added dark background for better visibility */
.clash-container {
  position: fixed;
  inset: 0;
  z-index: 8000;
  pointer-events: none;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.7);
  animation: clash-bg-fade 0.8s ease-out forwards;
}

@keyframes clash-bg-fade {
  0% { background: rgba(0, 0, 0, 0); }
  15% { background: rgba(0, 0, 0, 0.7); }
  85% { background: rgba(0, 0, 0, 0.7); }
  100% { background: rgba(0, 0, 0, 0); }
}

/* 🎮 v2.1.62: Reduced glow for better performance */
.clash-icon {
  position: absolute;
  font-size: clamp(72px, 21.6vw, 144px);
  filter: drop-shadow(0 0 15px rgba(255,255,255,0.8));
  z-index: 8001;
  --clash-scale: 1;
}

.clash-icon.player {
  animation: clash-from-bottom 0.18s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

.clash-icon.opponent {
  animation: clash-from-top 0.18s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}

/* 🎮 v2.1.62: Removed brightness filter for performance */
@keyframes clash-from-bottom {
  0% { 
    transform: translate(-50%, 300%) scale(calc(0.5 * var(--clash-scale, 1))) rotate(-30deg); 
    opacity: 0; 
  }
  40% { 
    /* Stretch vertically while flying up */
    transform: translate(-50%, 0%) scaleX(calc(0.8 * var(--clash-scale, 1))) scaleY(calc(1.4 * var(--clash-scale, 1))) rotate(5deg); 
    opacity: 1; 
  }
  70% { 
    transform: translate(-50%, -60%) scaleX(calc(1.1 * var(--clash-scale, 1))) scaleY(calc(0.9 * var(--clash-scale, 1))) rotate(-3deg); 
  }
  100% { 
    transform: translate(-50%, -50%) scale(var(--clash-scale, 1)) rotate(0deg); 
    opacity: 1; 
  }
}

/* 🎮 v2.1.62: Removed brightness filter for performance */
@keyframes clash-from-top {
  0% { 
    transform: translate(-50%, -400%) scale(calc(0.5 * var(--clash-scale, 1))) rotate(30deg); 
    opacity: 0; 
  }
  40% { 
    /* Stretch vertically while flying down */
    transform: translate(-50%, -100%) scaleX(calc(0.8 * var(--clash-scale, 1))) scaleY(calc(1.4 * var(--clash-scale, 1))) rotate(-5deg); 
    opacity: 1; 
  }
  70% { 
    transform: translate(-50%, -40%) scaleX(calc(1.1 * var(--clash-scale, 1))) scaleY(calc(0.9 * var(--clash-scale, 1))) rotate(3deg); 
  }
  100% { 
    transform: translate(-50%, -50%) scale(var(--clash-scale, 1)) rotate(0deg); 
    opacity: 1; 
  }
}

/* Impact Squash - flatten on collision */
/* 🎮 v2.1.62: Removed brightness filter for performance */
.clash-icon.impact-squash {
  animation: impact-squash 0.12s ease-out forwards !important;
}

@keyframes impact-squash {
  0% { transform: translate(-50%, -50%) scaleX(1) scaleY(1); }
  50% { transform: translate(-50%, -50%) scaleX(1.5) scaleY(0.5); }
  100% { transform: translate(-50%, -50%) scaleX(1.3) scaleY(0.7); }
}

/* Recoil - bounce back slightly before result */
.clash-icon.recoil-player {
  animation: recoil-down 0.15s ease-out forwards !important;
}

.clash-icon.recoil-opponent {
  animation: recoil-up 0.15s ease-out forwards !important;
}

@keyframes recoil-down {
  0% { transform: translate(-50%, -50%) scaleX(1.3) scaleY(0.7); }
  40% { transform: translate(-50%, -35%) scaleX(0.9) scaleY(1.1); }
  100% { transform: translate(-50%, -45%) scale(1); }
}

@keyframes recoil-up {
  0% { transform: translate(-50%, -50%) scaleX(1.3) scaleY(0.7); }
  40% { transform: translate(-50%, -65%) scaleX(0.9) scaleY(1.1); }
  100% { transform: translate(-50%, -55%) scale(1); }
}

/* Win animation - opponent shatters with explosion */
/* 🎮 v2.1.62: Removed brightness filter for performance */
.clash-icon.shatter {
  animation: icon-shatter 0.4s ease-out forwards;
}

@keyframes icon-shatter {
  0% { transform: translate(-50%, -50%) scale(1) rotate(0deg); opacity: 1; }
  15% { transform: translate(-50%, -50%) scale(1.5) rotate(0deg); }
  30% { transform: translate(-50%, -50%) scale(1.8) rotate(15deg); }
  100% { transform: translate(-50%, -50%) scale(0) rotate(720deg); opacity: 0; }
}

/* Lose animation - player icon shatters */
/* 🎮 v2.1.62: Removed brightness filter, use opacity instead */
.clash-icon.defeated {
  animation: icon-defeated 0.4s ease-out forwards;
}

@keyframes icon-defeated {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  20% { transform: translate(-50%, -50%) scale(0.8); opacity: 0.5; }
  40% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0) rotate(-720deg); opacity: 0; }
}

/* Draw animation - both bounce back with spark */
/* 🎮 v2.1.62: Removed brightness filter for performance */
.clash-icon.bounce-down {
  animation: bounce-back-down 0.4s ease-out forwards;
}

.clash-icon.bounce-up {
  animation: bounce-back-up 0.4s ease-out forwards;
}

@keyframes bounce-back-down {
  0% { transform: translate(-50%, -50%) scale(1); }
  20% { transform: translate(-50%, -90%) scale(1.4); }
  100% { transform: translate(-50%, 300%) scale(0.3) rotate(60deg); opacity: 0; }
}

@keyframes bounce-back-up {
  0% { transform: translate(-50%, -50%) scale(1); }
  20% { transform: translate(-50%, -10%) scale(1.4); }
  100% { transform: translate(-50%, -400%) scale(0.3) rotate(-60deg); opacity: 0; }
}

/* Impact effect - radial burst */
.clash-impact {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,1) 0%, rgba(255,255,100,0.8) 30%, transparent 70%);
  animation: impact-wave 0.3s ease-out forwards;
  z-index: 8000;
}

@keyframes impact-wave {
  0% { width: 0; height: 0; opacity: 1; }
  50% { opacity: 0.8; }
  100% { width: 400px; height: 400px; opacity: 0; }
}

/* Shatter particles */
/* ===== 8-BIT BATTLE PARTICLES ===== */
/* 🎮 v2.1.62: 8-bit style shatter particles */
.shatter-particle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 0;
  background: currentColor;
  image-rendering: pixelated;
  /* No box-shadow for 8-bit style */
  animation: particle-fly 0.35s steps(5) forwards;
}

@keyframes particle-fly {
  0%, 19% { transform: translate(0, 0); opacity: 1; }
  20%, 39% { transform: translate(calc(var(--tx) * 0.25), calc(var(--ty) * 0.25)); }
  40%, 59% { transform: translate(calc(var(--tx) * 0.5), calc(var(--ty) * 0.5)); }
  60%, 79% { transform: translate(calc(var(--tx) * 0.75), calc(var(--ty) * 0.75)); opacity: 0.6; }
  80%, 100% { transform: translate(var(--tx), var(--ty)); opacity: 0; }
}

/* 🎮 v2.1.62: 8-bit zone particle burst */
@keyframes zone-particle-burst {
  0%, 19% { transform: translate(0, 0); opacity: 1; }
  20%, 39% { transform: translate(calc(var(--tx) * 0.25), calc(var(--ty) * 0.25)); }
  40%, 59% { transform: translate(calc(var(--tx) * 0.5), calc(var(--ty) * 0.5)); }
  60%, 79% { transform: translate(calc(var(--tx) * 0.75), calc(var(--ty) * 0.75)); opacity: 0.6; }
  80%, 100% { transform: translate(var(--tx), var(--ty)); opacity: 0; }
}

/* Clash Flash Overlay */
.clash-flash {
  position: absolute;
  inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
}

.clash-flash.active {
  animation: clash-flash-anim 0.15s steps(3);
}

@keyframes clash-flash-anim {
  0%, 100% { opacity: 0; }
  33% { opacity: 0.35; }
  66% { opacity: 0.15; }
}

/* Winner glow pulse during clash */
/* 🎮 v2.1.62: Removed drop-shadow, use scale only */
.clash-icon.winner-glow {
  animation: winner-pulse 0.3s ease-out;
}

@keyframes winner-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.2); }
}

/* ===== SPELL EFFECT OVERLAYS ===== */
.spell-effect-overlay {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* Effect position - top half (opponent's side) */
.spell-effect-overlay.effect-top {
  top: 0;
  height: 45%;
}

/* Effect position - bottom half (player's side) */
.spell-effect-overlay.effect-bottom {
  bottom: 0;
  height: 45%;
}

/* Full screen effect (default for sacrifice, destroy) */
.spell-effect-overlay:not(.effect-top):not(.effect-bottom) {
  inset: 0;
}

/* SACRIFICE Effect - Blood red */
.sacrifice-overlay {
  background: rgba(139, 0, 0, 0);
  animation: sacrifice-flash 2s ease-out forwards;
}

.sacrifice-overlay .effect-icon {
  font-size: clamp(80px, 20vw, 150px);
  color: #8b0000;
  animation: blood-pulse 0.3s ease-in-out infinite;
  filter: drop-shadow(0 0 30px #8b0000) drop-shadow(0 0 60px #ff0000);
}

@keyframes sacrifice-flash {
  0% { background: rgba(139, 0, 0, 0); }
  10% { background: rgba(139, 0, 0, 0.6); }
  20% { background: rgba(139, 0, 0, 0.2); }
  30% { background: rgba(139, 0, 0, 0.5); }
  40% { background: rgba(139, 0, 0, 0.1); }
  50% { background: rgba(139, 0, 0, 0.4); }
  70% { background: rgba(139, 0, 0, 0.2); }
  100% { background: rgba(139, 0, 0, 0); }
}

@keyframes blood-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

/* Cards flying back animation */
.card-fly-back {
  animation: fly-to-center 0.5s ease-in forwards;
}

@keyframes fly-to-center {
  0% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0.3) rotate(360deg); opacity: 0; }
}

/* Cards flying out animation */
.card-fly-out {
  animation: fly-from-center 0.5s ease-out forwards;
}

@keyframes fly-from-center {
  0% { transform: translate(var(--tx), var(--ty)) scale(0.3) rotate(-360deg); opacity: 0; }
  100% { transform: translate(0, 0) scale(1) rotate(0deg); opacity: 1; }
}

/* DESTROY Effect - Black with white outline - SCARY */
.destroy-overlay {
  background: rgba(0, 0, 0, 0);
  animation: destroy-flash 1.5s ease-out forwards;
}

.destroy-overlay .effect-icon {
  font-size: clamp(120px, 30vw, 200px);
  color: #000;
  animation: destroy-pulse 0.15s ease-in-out infinite;
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px #fff) drop-shadow(0 0 10px #fff) drop-shadow(0 0 20px #fff);
}

@keyframes destroy-flash {
  0% { background: rgba(255, 255, 255, 0); }
  10% { background: rgba(255, 255, 255, 0.8); }
  20% { background: rgba(0, 0, 0, 0.6); }
  40% { background: rgba(255, 255, 255, 0.3); }
  60% { background: rgba(0, 0, 0, 0.4); }
  100% { background: rgba(0, 0, 0, 0); }
}

@keyframes destroy-pulse {
  0%, 100% { transform: scale(1) rotate(0deg); }
  50% { transform: scale(1.3) rotate(10deg); }
}

/* POWER Effect - Red blade with rise up and fade out */
.power-overlay {
  background: transparent;
}

.power-overlay .effect-icon {
  font-size: clamp(80px, 20vw, 150px);
  color: #ff4444;
  animation: blade-rise 1.5s ease-out forwards;
  filter: drop-shadow(0 0 20px #ff0000) drop-shadow(0 0 40px #ff4444);
}

@keyframes blade-rise {
  0% { 
    transform: translateY(50px) scale(0.5); 
    opacity: 0;
    filter: drop-shadow(0 0 10px #ff0000);
  }
  30% { 
    transform: translateY(0) scale(1.2); 
    opacity: 1;
    filter: drop-shadow(0 0 40px #ff0000) drop-shadow(0 0 80px #ff4444);
  }
  60% { 
    transform: translateY(-20px) scale(1); 
    opacity: 1;
    filter: drop-shadow(0 0 30px #ff0000) drop-shadow(0 0 60px #ff4444);
  }
  100% { 
    transform: translateY(-50px) scale(0.8); 
    opacity: 0;
    filter: drop-shadow(0 0 5px #ff0000);
  }
}

/* REFLECT Effect - Bright purple shield */
.reflect-overlay {
  background: transparent;
}

.reflect-overlay .effect-icon {
  font-size: clamp(80px, 20vw, 150px);
  color: #c084fc;
  animation: shield-pulse 0.4s ease-in-out infinite;
  filter: drop-shadow(0 0 30px #c084fc) drop-shadow(0 0 60px #a855f7);
}

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

/* ===== COMBO Effect - 3 icons spin and merge ===== */
/* v2.1.62: Optimized COMBO Effect - reduced GPU load ~60% */
.combo-effect-container {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  animation: effect-bg-fade 1.1s ease-out forwards;
}

@keyframes effect-bg-fade {
  0%, 70% { opacity: 1; }
  100% { opacity: 0; }
}

.combo-ring {
  position: relative;
  width: 200px;
  height: 200px;
  animation: combo-spin 0.5s linear infinite;
  will-change: transform;
}

.combo-ring.merge {
  animation: combo-spin 0.3s linear infinite, combo-shrink 0.2s ease-in forwards;
}

.combo-ring.hidden { opacity: 0; display: none; }

@keyframes combo-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes combo-shrink {
  to { transform: rotate(360deg) scale(0); }
}

.combo-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-80px) rotate(calc(-1 * var(--angle)));
  filter: drop-shadow(0 0 15px #ff8800);
  will-change: transform, opacity;
}

.combo-spell-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: combo-icon-expand 0.55s ease-out forwards;
  filter: drop-shadow(0 0 30px #ff8800);
  will-change: transform, opacity;
}

@keyframes combo-icon-expand {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  40% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

.combo-particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: combo-particle-fly 0.6s ease-out forwards;
}

@keyframes combo-particle-fly {
  0% { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-150px); opacity: 0; }
}

/* v2.1.62: Optimized TRINITY Effect - reduced GPU load ~60% */
.trinity-effect-container {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  animation: effect-bg-fade 1.1s ease-out forwards;
}

.trinity-ring {
  position: relative;
  width: 200px;
  height: 200px;
  animation: trinity-spin 0.5s linear infinite;
  will-change: transform;
}

.trinity-ring.merge {
  animation: trinity-spin 0.3s linear infinite, trinity-shrink 0.2s ease-in forwards;
}

.trinity-ring.hidden { opacity: 0; display: none; }

@keyframes trinity-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes trinity-shrink {
  to { transform: rotate(360deg) scale(0); }
}

.trinity-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-80px) rotate(calc(-1 * var(--angle)));
  filter: drop-shadow(0 0 15px #00ff88);
  will-change: transform, opacity;
}

.trinity-spell-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0);
  animation: trinity-icon-expand 0.55s ease-out forwards;
  filter: drop-shadow(0 0 30px #00ff88);
  will-change: transform, opacity;
}

@keyframes trinity-icon-expand {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  40% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
}

.trinity-particle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px currentColor;
  animation: trinity-particle-fly 0.6s ease-out forwards;
}

@keyframes trinity-particle-fly {
  0% { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(var(--angle)) translateY(-150px); opacity: 0; }
}

/* ===== PRAY Effect - Divine card appears and flies ===== */
.godhand-effect-container {
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  background: rgba(252, 211, 77, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: godhand-bg 2.5s ease-out forwards;
}

@keyframes godhand-bg {
  0% { background: rgba(252, 211, 77, 0); }
  20% { background: rgba(252, 211, 77, 0.4); }
  80% { background: rgba(252, 211, 77, 0.2); }
  100% { background: rgba(252, 211, 77, 0); }
}

.godhand-card {
  width: clamp(120px, 30vw, 180px);
  height: clamp(168px, 42vw, 252px);
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 4px solid #fcd34d;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: godhand-glow 0.5s ease-in-out infinite alternate;
  box-shadow: 0 0 40px #fcd34d, 0 0 80px #fcd34d, 0 0 120px rgba(252, 211, 77, 0.5);
}

.godhand-card-inner {
  text-align: center;
}

.godhand-card-text {
  font-size: clamp(20px, 5vw, 32px);
  font-weight: bold;
  color: #fcd34d;
  text-shadow: 2px 2px 0 #000;
  margin-top: 10px;
}

@keyframes godhand-glow {
  0% { box-shadow: 0 0 40px #fcd34d, 0 0 80px #fcd34d; transform: scale(1); }
  100% { box-shadow: 0 0 60px #fcd34d, 0 0 120px #fcd34d, 0 0 180px rgba(252, 211, 77, 0.5); transform: scale(1.05); }
}

.godhand-card.fly-to-hand {
  animation: godhand-fly 1s ease-in forwards;
}

@keyframes godhand-fly {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.8) translateY(20vh); opacity: 0.8; }
  100% { transform: scale(0.3) translateY(50vh); opacity: 0; }
}

.godhand-ray {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 150px;
  background: linear-gradient(to top, transparent, #fcd34d, transparent);
  transform-origin: center bottom;
  animation: godhand-ray-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes godhand-ray-pulse {
  0% { opacity: 0.3; height: 100px; }
  100% { opacity: 0.8; height: 200px; }
}

/* 🔰 v2.1.132: Fusion spell icon — single centered icon per zone */
.spell-fusion-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.95;
  animation: spell-icon-blink-glow 1.2s ease-in-out infinite;
  z-index: 20;
  pointer-events: none;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle, rgba(245,158,11,0.25) 0%, transparent 70%);
  border-radius: 50%;
  font-size: 34px;
}

/* Fusion appear animation — spin+scale when combo changes */
.spell-fusion-icon.fusion-appear {
  animation: spell-fusion-appear 0.5s ease-out forwards, spell-icon-blink-glow 1.2s ease-in-out 0.5s infinite;
}

/* 480px+: spell icon +15% */
@media (min-width: 480px) {
  .spell-fusion-icon { width: 41px; height: 41px; font-size: 39px; }
}

@keyframes spell-fusion-appear {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-180deg); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.3) rotate(0deg); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(0.9); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0.95; }
}

/* v2.1.132: Blink+Glow animation for spell icons */
@keyframes spell-icon-blink-glow {
  0%, 100% { opacity: 0.5; filter: brightness(0.8); }
  50% { opacity: 1; filter: brightness(1.5); }
}



/* shield-float removed — uses spell-icon-float-top */

/* ===== DESTROY TARGET EFFECT ===== */
.destroy-target {
  animation: destroy-target-pulse 0.15s ease-in-out infinite !important;
  box-shadow: 0 0 15px #e63946, 0 0 30px #ff0000 !important;
  border-color: #e63946 !important;
}

@keyframes destroy-target-pulse {
  0%, 100% { 
    box-shadow: 0 0 10px #e63946, 0 0 20px #ff0000;
    transform: scale(1);
  }
  50% { 
    box-shadow: 0 0 20px #e63946, 0 0 40px #ff0000, 0 0 60px #ff6b35;
    transform: scale(1.05);
  }
}

@keyframes destroy-warning-pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.15); opacity: 1; }
}
@keyframes destroy-creep-sub {
  0% { letter-spacing: 2px; opacity: 0.5; }
  100% { letter-spacing: 12px; opacity: 0.9; }
}
/* === 08-battle-ui.css === */
/* ===== TURN RESULT MODAL (Enhanced) ===== */
.turn-result-detail {
  background: transparent;
  border: none;
  padding: var(--pad);
  margin: var(--gap) 0;
  text-align: left;
}

/* Result Modal - Full width, transparent (uses overlay black background) */
.result-modal-box {
  width: 95vw;
  max-width: 500px;
  padding: var(--pad);
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

.damage-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--font-md);
}

.damage-line:last-child {
  border-bottom: none;
}

.damage-line .zone-label {
  color: #ffffff;
  font-weight: bold;
  min-width: 80px;
}

.damage-line .damage-value {
  font-weight: bold;
  min-width: 100px;
  text-align: right;
  font-size: clamp(18px, 4vw, 24px);
}

.damage-line .damage-value.win { color: var(--green); }
.damage-line .damage-value.lose { color: var(--red); }
.damage-line .damage-value.draw { color: var(--yellow); }

.total-damage {
  margin-top: var(--gap);
  padding-top: var(--gap);
  border-top: 1px solid var(--border);
  font-size: var(--font-md);
}

.spell-info { 
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%; 
  transform: translateX(-50%); 
  background: var(--bg-dark); 
  border: 3px solid var(--cyan); 
  padding: calc(var(--pad) * 0.8) calc(var(--pad) * 1.2); 
  font-size: var(--font-xs); 
  color: var(--text); 
  z-index: 500; 
  max-width: 280px;
  width: max-content;
  text-align: center;
  line-height: 1.6;
  animation: spell-info-pop 0.2s ease-out;
  pointer-events: none;
}

.spell-info::after {
  content: '';
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid var(--cyan);
}

@keyframes spell-info-pop {
  0% { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.9); }
  100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* ===== HAND ===== */
.hand-section { 
  flex-shrink: 0; 
  background: transparent;
}

.hand-header { 
  display: flex; 
  justify-content: space-between; 
  padding: calc(var(--pad) * 0.5) var(--pad); 
  background: rgba(45, 51, 59, 0.5); 
  font-size: var(--font-xs);
}

.hand-container { 
  display: flex; 
  justify-content: center; 
  gap: var(--gap); 
  padding: var(--pad); 
  min-height: calc(var(--card-h) + var(--pad) * 2); 
  background: var(--bg-darker);
  flex-wrap: wrap;
  overflow-y: auto;
  max-height: calc(var(--card-h) * 1.4);
}

/* PC/Tablet: Force single row for hand cards */
@media (min-width: 600px) {
  .hand-container {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
  }
}

/* ===== BUTTONS ===== */
.btn { 
  background: var(--blue); 
  color: var(--text); 
  border: 3px solid var(--border); 
  padding: var(--pad) calc(var(--pad) * 1.5); 
  font-size: var(--font-sm); 
  cursor: pointer;
  min-height: 44px; /* Touch target */
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.btn:active { filter: brightness(0.8); }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-yellow { background: var(--yellow); color: #000; }
.btn:disabled { background: #444; color: #666; cursor: not-allowed; }

/* BATTLE Text - Title style (no button bg/border) */
/* v2.1.115: Dark gray bg + pixel corners + border blink */
.btn-go {
  background: linear-gradient(180deg, #3a3a3a 0%, #2a2a2a 100%) !important;
  border-width: 3px !important;
  border-style: solid !important;
  border-color: #f4d35e;
  padding: 4px 14px;
  font-family: 'Jersey 10', cursive;
  font-size: calc(var(--font-lg) * 1.2);
  font-weight: bold;
  color: #f4d35e;
  -webkit-text-stroke: 1px #dc2626;
  paint-order: stroke fill;
  text-shadow: 2px 2px 0 #dc2626, 3px 3px 0 #8b0000;
  letter-spacing: 1px;
  cursor: pointer;
  min-width: auto;
  text-align: center;
  animation: btn-border-blink 0.15s step-end infinite;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  outline: none;
  /* Pixel rounded corners */
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

.btn-go:focus { outline: none; }
.btn-go:focus-visible { outline: none; }

.btn-go .sword-icon {
  font-size: 24px;
  display: inline-flex;
  filter: drop-shadow(2px 2px 0 #dc2626) drop-shadow(1px 1px 0 #8b0000);
}

/* Border blink — gold ↔ dark gold */
@keyframes btn-border-blink {
  0%   { border-color: #f4d35e; }
  50%  { border-color: #8b6914; }
}

/* Disabled / Wait — Static Flicker */
.btn-go:disabled {
  background: linear-gradient(180deg, #333 0%, #2a2a2a 100%) !important;
  color: #555 !important;
  -webkit-text-stroke: 1px #333;
  text-shadow: 2px 2px 0 #333, 3px 3px 0 #222 !important;
  border-color: #444 !important;
  cursor: default;
  animation: battle-static 3s step-end infinite !important;
}
.btn-go:disabled .go-text {
  animation: none !important;
}
.btn-go:disabled .sword-icon {
  filter: none !important;
  opacity: 0.4;
}

@keyframes battle-static {
  0%, 100% { opacity: 0.5; transform: translateX(0); }
  47% { opacity: 0.5; }
  48% { opacity: 0.2; transform: translateX(1px); }
  49% { opacity: 0.6; transform: translateX(-1px); }
  50% { opacity: 0.5; transform: translateX(0); }
}

/* Ready button - border blink when enabled */
#btn-ready:not(:disabled) {
  animation: btn-border-blink 0.15s step-end infinite;
}
#btn-ready:not(:disabled) .go-text {
  display: inline-block;
}

/* v2.1.115: WAIT / SYNCING as animated text instead of disabled button */
.btn-go-waiting {
  background: transparent !important;
  border-color: transparent !important;
  /* Keep border-width + padding same as .btn-go to prevent layout shift */
  clip-path: none;
  animation: none !important;
  cursor: default;
  pointer-events: none;
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.wait-text {
  font-family: 'Jersey 10', cursive;
  font-size: inherit;
  color: #fff;
  letter-spacing: 2px;
  display: inline-flex;
  align-items: baseline;
}

.wait-dots {
  display: inline-flex;
  gap: 2px;
  margin-left: 2px;
}

.wait-dots .dot {
  font-family: 'Jersey 10', cursive;
  font-size: inherit;
  color: #fff;
  animation: dot-blink 1.2s step-end infinite;
}
.wait-dots .dot:nth-child(1) { animation-delay: 0s; }
.wait-dots .dot:nth-child(2) { animation-delay: 0.3s; }
.wait-dots .dot:nth-child(3) { animation-delay: 0.6s; }

/* ===== EFFECTS ===== */
.damage-num { 
  position: fixed; 
  font-size: clamp(52px, 15vw, 90px); 
  font-weight: bold;
  font-family: 'Jersey 10', cursive;
  pointer-events: none; 
  z-index: 200; 
  text-shadow: 2px 2px 0 #000, -1px -1px 0 #000; 
  transform: translate(-50%, -50%);
}

/* Damage (red with yellow outline) - shake animation */
.damage-num.red { 
  color: #ff0000;
  animation: dmg-shake 0.6s forwards;
  text-shadow: 
    -2px -2px 0 #ffd700,
    2px -2px 0 #ffd700,
    -2px 2px 0 #ffd700,
    2px 2px 0 #ffd700,
    -2px 0 0 #ffd700,
    2px 0 0 #ffd700,
    0 -2px 0 #ffd700,
    0 2px 0 #ffd700,
    0 0 20px #ff0000,
    0 0 40px #ff0000;
}

/* Heal (green) - same color as HP bar */
.damage-num.green { 
  color: #2a9d8f; 
  animation: heal-glow 0.6s forwards;
  text-shadow: 
    -2px -2px 0 #fff,
    2px -2px 0 #fff,
    -2px 2px 0 #fff,
    2px 2px 0 #fff,
    -2px 0 0 #fff,
    2px 0 0 #fff,
    0 -2px 0 #fff,
    0 2px 0 #fff,
    0 0 20px rgba(42, 157, 143, 0.6),
    0 0 40px rgba(42, 157, 143, 0.4),
    0 0 60px rgba(42, 157, 143, 0.3);
}

/* Draw (yellow) - Title style: yellow + red stroke + red shadow */
.damage-num.yellow { 
  color: #f4d35e; 
  -webkit-text-stroke: 2px #dc2626;
  paint-order: stroke fill;
  animation: draw-pulse 0.5s forwards;
  text-shadow: 
    3px 3px 0 #dc2626,
    5px 5px 0 #8b0000;
}

/* Reflect (white) - bold with black shadow */
.damage-num.white { 
  color: #ffffff; 
  font-weight: bold;
  animation: draw-pulse 0.5s forwards;
  text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
}

/* v2.1.114: White Core for REFLECT cost (-1 HP) — matches shield icon style */
.damage-num.blue { 
  color: #ffffff; 
  font-weight: bold;
  animation: dmg-whitecore 0.7s forwards;
  text-shadow: 
    -2px -2px 0 #4a1a8a,
    2px -2px 0 #4a1a8a,
    -2px 2px 0 #4a1a8a,
    2px 2px 0 #4a1a8a,
    0 0 10px #fff,
    0 0 20px #c084fc,
    0 0 40px #c084fc,
    0 0 60px rgba(192, 132, 252, 0.4);
}

@keyframes dmg-whitecore {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; }
  12% { transform: translate(-50%, -55%) scale(1.3); opacity: 1;
    text-shadow: -2px -2px 0 #4a1a8a, 2px -2px 0 #4a1a8a, -2px 2px 0 #4a1a8a, 2px 2px 0 #4a1a8a,
      0 0 15px #fff, 0 0 30px #c084fc, 0 0 50px #c084fc, 0 0 80px rgba(192,132,252,0.5); }
  25% { transform: translate(-50%, -58%) scale(1); }
  70% { transform: translate(-50%, -85%) scale(0.9); opacity: 0.8; }
  100% { transform: translate(-50%, -130%) scale(0.5); opacity: 0; }
}

@keyframes draw-pulse { 
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; } 
  10% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  50% { transform: translate(-50%, -50%) scale(1.1); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(1); opacity: 0; } 
}

@keyframes dmg-shake { 
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; } 
  10% { transform: translate(-50%, -50%) scale(1.5); opacity: 1; }
  20% { transform: translate(-55%, -50%) scale(1.3); }
  30% { transform: translate(-45%, -50%) scale(1.3); }
  40% { transform: translate(-52%, -50%) scale(1.2); }
  50% { transform: translate(-48%, -50%) scale(1.2); }
  60% { transform: translate(-51%, -50%) scale(1.05); }
  70% { transform: translate(-49%, -50%) scale(1.05); }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(1); opacity: 0; } 
}

@keyframes heal-glow { 
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; } 
  10% { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  20% { 
    text-shadow: 
      -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff, 3px 3px 0 #fff,
      -4px 0 0 #fff, 4px 0 0 #fff, 0 -4px 0 #fff, 0 4px 0 #fff,
      0 0 30px rgba(0, 255, 136, 0.7), 0 0 60px rgba(0, 255, 136, 0.5); 
  }
  40% { 
    text-shadow: 
      -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff, 3px 3px 0 #fff,
      -4px 0 0 #fff, 4px 0 0 #fff, 0 -4px 0 #fff, 0 4px 0 #fff,
      0 0 15px rgba(0, 255, 136, 0.5), 0 0 30px rgba(0, 255, 136, 0.3); 
  }
  60% { 
    text-shadow: 
      -3px -3px 0 #fff, 3px -3px 0 #fff, -3px 3px 0 #fff, 3px 3px 0 #fff,
      -4px 0 0 #fff, 4px 0 0 #fff, 0 -4px 0 #fff, 0 4px 0 #fff,
      0 0 25px rgba(0, 255, 136, 0.6), 0 0 50px rgba(0, 255, 136, 0.4); 
  }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -70%) scale(1); opacity: 0; } 
}

.shake { animation: shake 0.4s; }
@keyframes shake { 
  0%,100% { transform: translateX(0); } 
  20%,60% { transform: translateX(-4px); } 
  40%,80% { transform: translateX(4px); } 
}

.confetti { 
  position: fixed; 
  width: 8px; 
  height: 8px; 
  pointer-events: none; 
  z-index: 5;
  animation: fall 2s forwards; 
}
@keyframes fall { 
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; } 
  100% { transform: translateY(100vh) rotate(720deg); opacity: 0; } 
}
/* === 09-modals-layout.css === */
/* ===== MODAL ===== */
.modal-overlay { 
  position: fixed; 
  inset: 0; 
  background: rgba(0,0,0,0.9);  /* 90% black */
  display: flex; 
  align-items: center; 
  justify-content: center; 
  z-index: 1000; 
  padding: var(--pad); 
}

/* Game over modal needs very high z-index */
#modal-gameover {
  z-index: 10002;
}

/* Rules modal needs higher z-index (shows on title screen) */
#modal-rules {
  z-index: 10001;
}

.modal-box { 
  background: var(--bg-dark); 
  border: 4px solid var(--border); 
  padding: calc(var(--pad) * 1.5); 
  max-width: min(90vw, 380px); 
  width: 100%; 
}

@media (min-width: 600px) {
  .modal-box { max-width: 420px; padding: calc(var(--pad) * 2); }
}

/* ===== TURN INTRO (v2.1.53: SPIN SLAM + Screen Shake) ===== */
.turn-intro { 
  position: fixed; 
  inset: 0; 
  background: rgba(0, 0, 0, 0.85); 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.2s ease-out;
}

.turn-intro.show {
  opacity: 1;
}

.turn-intro.fade-out {
  opacity: 0;
  transition: opacity 0.3s ease-out;
}

/* v2.1.56: Remove screen-shake from overlay - background stays still */
/* Text already has shake built into spinSlamLight animation */
.turn-intro.screen-shake {
  /* No animation on overlay - only text shakes */
}

.turn-intro-text { 
  font-family: 'Jersey 10', cursive;
  font-size: clamp(86px, 29vw, 180px); 
  font-weight: bold;
  color: #f4d35e;
  -webkit-text-stroke: 2px #dc2626;
  paint-order: stroke fill;
  text-shadow: 
    3px 3px 0 #dc2626,
    5px 5px 0 #8b0000;
  letter-spacing: 2px;
  animation: spinSlamLight 0.65s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

/* v2.1.53: SPIN SLAM Light - For Turn Intro (slightly lighter shake) */
@keyframes spinSlamLight {
  0% {
    transform: scale(3.5) translateY(-80px) rotate(-150deg);
    opacity: 0;
  }
  35% {
    transform: scale(0.9) translateY(8px) rotate(4deg);
    opacity: 1;
  }
  45% {
    transform: scale(1.08) translateX(-7px) rotate(-2deg);
  }
  55% {
    transform: scale(1.02) translateX(7px) rotate(2deg);
  }
  65% {
    transform: scale(1) translateX(-5px) rotate(-1deg);
  }
  75% {
    transform: translateX(5px) rotate(1deg);
  }
  85% {
    transform: translateX(-3px);
  }
  100% {
    transform: scale(1) translateX(0) rotate(0deg);
    opacity: 1;
  }
}

/* ===== GOODBYE TEXT (Janken Master Style) ===== */
/* Base class - ต้นแบบสำหรับ title, turn, battle */
.jm-text,
.goodbye-text { 
  font-family: 'Jersey 10', cursive;
  font-size: clamp(36px, 10vw, 52px);
  font-weight: bold;
  color: #f4d35e;
  -webkit-text-stroke: 2px #dc2626;
  paint-order: stroke fill;
  text-shadow: 
    3px 3px 0 #dc2626,
    5px 5px 0 #8b0000;
  letter-spacing: 2px;
}

/* ===== TOP BAR (Fixed) ===== */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--sat) + 44px);
  padding-top: var(--sat);
  padding-left: calc(var(--sal) + 8px);
  padding-right: calc(var(--sar) + 8px);
  background: transparent;
  border-bottom: none;
  display: none; /* Hidden by default, shown in game screen */
  align-items: center;
  justify-content: space-between;
  z-index: 10000;
}
.top-bar-left {
  display: flex;
  align-items: center;
  gap: 4px;
}
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}
.top-bar-btn {
  width: clamp(32px, 8vw, 40px);
  height: clamp(32px, 8vw, 40px);
  background: transparent;
  border: none !important;
  border-radius: 4px;
  color: var(--text);
  font-size: clamp(14px, 4vw, 18px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  /* v2.1.138: Force-override NES.css pixel borders */
  box-shadow: none !important;
  outline: none !important;
  -webkit-appearance: none;
  image-rendering: auto;
}
.top-bar-btn::before,
.top-bar-btn::after {
  display: none !important;
  box-shadow: none !important;
  border: none !important;
}
.top-bar-btn:focus,
.top-bar-btn:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}
.top-bar-btn:active {
  box-shadow: none !important;
  transform: scale(0.95);
}
.top-bar-btn.muted { opacity: 0.5; }
#gameboy-btn { font-family: 'VT323', monospace; font-weight: bold; }
#gameboy-btn.active { 
  color: #9bbc0f; 
  border-color: #9bbc0f; 
  text-shadow: 0 0 5px #9bbc0f;
  background: rgba(155, 188, 15, 0.2);
}

/* 🖥️ v2.1.122: CRT Filter Toggle */
#crt-btn { font-family: 'VT323', monospace; font-weight: 900; font-size: clamp(16px, 4.3vw, 20px); }
#crt-btn.active { 
  color: #00ff88; 
  border-color: #00ff88; 
  text-shadow: 0 0 5px #00ff88;
  background: rgba(0, 255, 136, 0.15);
}

/* CRT Overlay — v2.1.134: scrolling scanlines + rolling band + vignette + vivid */
.crt-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  pointer-events: none;
}

.crt-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 1px,
    rgba(0, 0, 0, 0.10) 1px,
    rgba(0, 0, 0, 0.10) 2px
  );
  background-size: 100% 4px;
  animation: crt-scanline-scroll 8s linear infinite;
  z-index: 1;
}

.crt-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.4) 85%,
    rgba(0, 0, 0, 0.7) 100%
  );
  z-index: 4;
}

.crt-band {
  position: fixed;
  inset: 0;
  z-index: 9501;
  pointer-events: none;
  background: linear-gradient(
    0deg,
    transparent 0%,
    transparent 80%,
    rgba(255, 255, 255, 0.03) 88%,
    rgba(0, 0, 0, 0.08) 92%,
    transparent 100%
  );
  animation: crt-band-sweep 5s linear infinite;
}

@keyframes crt-scanline-scroll {
  0% { background-position: 0 0; }
  100% { background-position: 0 200px; }
}

@keyframes crt-band-sweep {
  0% { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}

/* 🖥️ v2.1.136: CRT Film Grain */
.crt-grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: 9502;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: crt-grain-drift 0.6s steps(4) infinite;
}

@keyframes crt-grain-drift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-3%, -2%); }
  50%  { transform: translate(2%, 1%); }
  75%  { transform: translate(-1%, 3%); }
  100% { transform: translate(3%, -1%); }
}

body.crt-vivid {
  filter: saturate(1.3) contrast(1.1);
}

/* ☢️ v2.1.136: Fallout PIP-Boy Filter */
#gb-btn, #bw-btn { font-family: 'VT323', monospace; font-weight: 900; font-size: clamp(16px, 4.3vw, 20px); }
#gb-btn.active { 
  color: #9bbc0f; 
  text-shadow: 0 0 5px #9bbc0f;
  background: rgba(155, 188, 15, 0.15);
}
#bw-btn.active { 
  color: #ccc; 
  text-shadow: 0 0 5px rgba(255,255,255,0.5);
  background: rgba(200, 200, 200, 0.12);
}

body.gb-mode {
  filter: sepia(1) hue-rotate(45deg) saturate(5) brightness(0.65) contrast(1.2);
}
body.bw-mode {
  filter: grayscale(1) brightness(0.88) contrast(1.2);
}

/* Fallout green phosphor overlay */
/* ⬛ v2.1.138: BW = CRT but grayscale + heavy grain */
.bw-overlay {
  position: fixed;
  inset: 0;
  z-index: 9500;
  pointer-events: none;
}

/* Scanlines — identical to CRT */
.bw-overlay::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px,
    transparent 1px,
    rgba(0, 0, 0, 0.10) 1px,
    rgba(0, 0, 0, 0.10) 2px
  );
  background-size: 100% 4px;
  animation: crt-scanline-scroll 8s linear infinite;
  z-index: 1;
}

/* Vignette — identical to CRT */
.bw-overlay::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.4) 85%,
    rgba(0, 0, 0, 0.7) 100%
  );
  z-index: 4;
}

/* Film grain — heavy (3x CRT) */
.bw-grain {
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  z-index: 9502;
  pointer-events: none;
  opacity: 0.18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: crt-grain-drift 0.3s steps(4) infinite;
}

/* Rolling band — identical to CRT */
.bw-band {
  position: fixed;
  inset: 0;
  z-index: 9501;
  pointer-events: none;
  background: linear-gradient(
    0deg,
    transparent 0%,
    transparent 80%,
    rgba(255, 255, 255, 0.03) 88%,
    rgba(0, 0, 0, 0.08) 92%,
    transparent 100%
  );
  animation: crt-band-sweep 5s linear infinite;
}

/* Phosphor glow removed — B&W mode */
body.gb-mode .pixel-card,
body.gb-mode .battle-zone,
body.gb-mode .spell-btn,
body.gb-mode .nes-btn,
body.bw-mode .pixel-card,
body.bw-mode .battle-zone,
body.bw-mode .spell-btn,
body.bw-mode .nes-btn {
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.2);
}

/* 🎮 GB (Game Boy) Filter — v2.1.138 */
.gb-overlay {
  position: fixed;
  inset: 0;
  z-index: 9400;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.10) 0px,
    rgba(0, 0, 0, 0.10) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: multiply;
}
.gb-grain {
  position: fixed;
  inset: 0;
  z-index: 9401;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 150px 150px;
  animation: bw-grain-drift 0.4s steps(3) infinite;
}

.top-bar-turn {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(14px, 4vw, 18px);
  color: var(--yellow);
  font-weight: bold;
  padding: 0 8px;
}
.top-bar-ping {
  height: clamp(32px, 8vw, 40px);
  padding: 0 10px;
  font-family: 'Jersey 10', monospace;
  font-size: clamp(12px, 3vw, 16px);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  color: #22c55e;
  border: 2px solid #22c55e;
}

/* ===== LANDSCAPE WARNING ===== */
.landscape-warning { 
  display: none; 
  position: fixed; 
  inset: 0; 
  background: var(--bg-darker); 
  flex-direction: column;
  align-items: center; 
  justify-content: center; 
  z-index: 9999;
  text-align: center;
  padding: 20px;
}

/* Show warning only on small landscape screens */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 900px) { 
  .landscape-warning { display: flex; } 
  .app-container { display: none !important; } 
}

/* Desktop landscape is always OK */
@media (min-width: 900px) {
  .landscape-warning { display: none !important; }
  .app-container { display: flex !important; }
}

audio { display: none; }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-darker); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
/* === 10-alerts.css === */
/* ===== GAME ALERT SYSTEM ===== */
/* ===== SIMPLE GAME ALERT - No icons, no animations, clean design ===== */
.game-alert-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: var(--pad);
}

.game-alert-box {
  background: transparent;
  max-width: min(90vw, 500px);
  width: 100%;
  text-align: center;
}

.game-alert-header {
  display: none;  /* Hide icon */
}

.game-alert-icon {
  display: none;  /* Hide icon */
}

.game-alert-content {
  padding: 0;
}

.game-alert-title {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(42px, 12vw, 72px);
  color: #e63946;
  margin-bottom: 16px;
  letter-spacing: 2px;
  line-height: 1.2;
}

.game-alert-message {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(24px, 6vw, 36px);
  color: #ffffff;
  line-height: 1.5;
  margin-bottom: 24px;
}

.game-alert-input-wrap {
  margin-bottom: 24px;
}

.game-alert-input {
  width: 100%;
  background: #1a1a1a;
  border: 3px solid #ef4444;
  color: #fff;
  padding: 12px 16px;
  font-family: 'Jersey 10', cursive;
  font-size: clamp(16px, 4vw, 20px);
  text-align: center;
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

.game-alert-input:focus {
  outline: none;
  border-color: #ef4444;
}

.game-alert-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
}

.game-alert-btn {
  padding: 12px 36px;
  font-family: 'Jersey 10', cursive;
  font-size: clamp(22px, 6vw, 32px);
  color: #fff;
  background: #7f1d1d;
  border: 3px solid #ef4444;
  cursor: pointer;
  transition: opacity 0.15s;
  clip-path: polygon(
    0 4px, 4px 4px, 4px 0,
    calc(100% - 4px) 0, calc(100% - 4px) 4px, 100% 4px,
    100% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 100%,
    4px 100%, 4px calc(100% - 4px), 0 calc(100% - 4px)
  );
}

.game-alert-btn:hover {
  opacity: 0.85;
}

.game-alert-btn:active {
  transform: scale(0.97);
}

.game-alert-btn-ok {
  /* Same red style */
}

.game-alert-btn-cancel {
  /* Same red style */
}

/* Placement Countdown Animations */
@keyframes countdown-pulse {
  0%, 100% { 
    transform: scale(1); 
    filter: brightness(1);
  }
  50% { 
    transform: scale(1.1); 
    filter: brightness(1.3);
  }
}

25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

@keyframes hurry-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes penalty-shake {
  0%, 100% { transform: translate(-50%, -50%) rotate(0deg); }
  25% { transform: translate(-50%, -50%) rotate(-5deg); }
  50% { transform: translate(-50%, -50%) rotate(5deg); }
  75% { transform: translate(-50%, -50%) rotate(-3deg); }
}

/* Countdown Element Styles */
.countdown-number {
  font-family: 'Jersey 10', cursive !important;
  color: #f4d35e;
  font-weight: bold;
  -webkit-text-stroke: 2px #dc2626;
  paint-order: stroke fill;
  text-shadow: 
    3px 3px 0 #dc2626,
    5px 5px 0 #8b0000;
  animation: countdown-pulse 1s ease-in-out infinite;
  letter-spacing: 2px;
  will-change: transform;
}

.countdown-message {
  font-family: 'Jersey 10', cursive !important;
  font-size: clamp(40px, 10vw, 72px);
  color: #f4d35e;
  font-weight: bold;
  margin-top: 4px;
  line-height: 1.2;
  -webkit-text-stroke: 2px #dc2626;
  paint-order: stroke fill;
  text-shadow: 
    3px 3px 0 #dc2626,
    5px 5px 0 #8b0000;
  animation: hurry-pulse 0.6s ease-in-out infinite;
  letter-spacing: 2px;
  will-change: transform;
}

/* Challenge Modal Button Styles */
#btn-accept-challenge:hover,
#btn-decline-challenge:hover,
#btn-cancel-challenge:hover {
  opacity: 0.85;
}

#btn-accept-challenge:active,
#btn-decline-challenge:active,
#btn-cancel-challenge:active {
  transform: scale(0.97);
}

/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */
/* 💥 EXPLOSION & PENALTY ANIMATIONS */
/* ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ */

50% {
    transform: translate(-50%, -50%) scale(1.5) rotate(180deg);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.5) rotate(360deg);
    opacity: 0;
  }
}

30% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0.8;
  }
  100% {
    transform: translate(-50%, -50%) scale(5);
    opacity: 0;
  }
}

100% {
    transform: translate(-50%, -50%) scale(4);
    opacity: 0;
  }
}

@keyframes damage-rise {
  0% {
    transform: translate(-50%, -50%) scale(0.5);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 1;
  }
  40% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -150%) scale(0.8);
    opacity: 0;
  }
}

@keyframes zone-shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* 🎮 8-BIT PIXEL EXPLOSION ANIMATIONS */
50% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(3);
    opacity: 0;
  }
}

100% {
    transform: translate(-50%, -50%) scale(3.5);
    opacity: 0;
    border-width: 2px;
  }
}

@keyframes pixel-zone-shake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-8px, 0); }
  50% { transform: translate(8px, 0); }
  75% { transform: translate(-4px, 0); }
  100% { transform: translate(0, 0); }
}
/* 🎨 Glow Animations */
50% {
    filter: drop-shadow(0 0 20px #fbbf24) drop-shadow(0 0 30px #fbbf24);
  }
}

50% {
    filter: drop-shadow(0 0 20px #ef4444) drop-shadow(0 0 30px #ef4444);
  }
}

@keyframes glow-red-soft {
  0%, 100% {
    text-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
  }
  50% {
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.8), 0 0 30px rgba(239, 68, 68, 0.6);
  }
}

/* Hourglass spin animation - หมุนทุก 0.5 วินาที */
@keyframes hourglass-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.hourglass-spin {
  display: inline-block;
  animation: hourglass-spin 0.5s linear infinite;
}

/* Golden glow text for countdown */
.golden-glow-text {
  color: #f4d35e;
  text-shadow: 0 0 10px #f4d35e, 0 0 20px #fbbf24, 0 0 30px #fbbf24;
  animation: golden-text-pulse 1.5s ease-in-out infinite;
}

@keyframes golden-text-pulse {
  0%, 100% {
    text-shadow: 0 0 10px #f4d35e, 0 0 20px #fbbf24;
  }
  50% {
    text-shadow: 0 0 15px #f4d35e, 0 0 30px #fbbf24, 0 0 40px #ffd700;
  }
}

/* Bonus time notification animation */
@keyframes bonus-time-pop {
  0% {
    transform: translateX(-50%) scale(0) rotate(-10deg);
    opacity: 0;
    filter: brightness(1);
  }
  50% {
    transform: translateX(-50%) scale(1.3) rotate(5deg);
    opacity: 1;
    filter: brightness(1.3);
  }
  70% {
    transform: translateX(-50%) scale(0.9) rotate(-2deg);
    filter: brightness(1.1);
  }
  100% {
    transform: translateX(-50%) scale(1) rotate(0deg);
    opacity: 1;
    filter: brightness(1);
  }
}

/* Bonus time glow pulse */
@keyframes bonus-glow-pulse {
  0%, 100% {
    text-shadow: 
      0 1px 0 #22c55e,
      0 2px 0 #16a34a,
      0 3px 0 #15803d,
      0 4px 0 #166534,
      0 5px 0 #14532d,
      0 6px 10px rgba(0, 0, 0, 0.5),
      0 0 30px rgba(74, 222, 128, 0.8),
      0 0 60px rgba(74, 222, 128, 0.6),
      0 0 90px rgba(74, 222, 128, 0.4);
  }
  50% {
    text-shadow: 
      0 1px 0 #22c55e,
      0 2px 0 #16a34a,
      0 3px 0 #15803d,
      0 4px 0 #166534,
      0 5px 0 #14532d,
      0 6px 10px rgba(0, 0, 0, 0.5),
      0 0 50px rgba(74, 222, 128, 1),
      0 0 80px rgba(74, 222, 128, 0.8),
      0 0 120px rgba(74, 222, 128, 0.6);
  }
}

/* Explode card animation for DESTROY penalty */
@keyframes explode-card {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  30% {
    transform: scale(1.2);
    opacity: 1;
  }
  60% {
    transform: scale(1.5);
    opacity: 0.8;
    filter: brightness(2);
  }
  100% {
    transform: scale(2);
    opacity: 0;
    filter: brightness(3);
  }
}

/* Shake animation for centered warnings */
20% { transform: translateX(calc(-50% - 10px)); }
  40% { transform: translateX(calc(-50% + 10px)); }
  60% { transform: translateX(calc(-50% - 5px)); }
  80% { transform: translateX(calc(-50% + 5px)); }
}

/* Red glow text for DUEL */
.red-glow-text {
  color: #ef4444;
  text-shadow: 0 0 10px #ef4444, 0 0 20px #ef4444;
  animation: glow-red-soft 2s ease-in-out infinite;
}

/* 3D DUEL text animation */
50% {
    transform: scale(1.03);
    opacity: 1;
  }
}

/* 3D WAITING text animation */
@keyframes waiting-pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.03);
    opacity: 1;
  }
}

to {
    transform: translateY(0);
    opacity: 1;
  }
}

.result-modal {
  font-family: 'Silkscreen', monospace;
}

.damage-number {
  pointer-events: none;
  user-select: none;
}

/* v2.1.136: Spell orbs removed — active state shown by button blink */
/* Winner icon fade out animation */
.clash-icon.winner-fade-out {
  animation: winner-fade-out 0.3s ease-out forwards !important;
}

@keyframes winner-fade-out {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.1); filter: brightness(1.5); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
}

/* Clear Cache Button - Title Screen */
.clear-cache-link {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  cursor: pointer;
  z-index: 100;
  padding: 5px 10px;
  transition: color 0.2s, background 0.2s;
  border-radius: 4px;
}

.clear-cache-link:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.clear-cache-link:active {
  background: rgba(255, 255, 255, 0.2);
}
/* === 11-tma.css === */
/* ===== TMA (Telegram Mini App) Compact Mode ===== */
.tma-mode .top-bar {
  height: 36px;
  padding-top: 0;
  top: 62px;
}

.tma-mode #screen-game {
  padding-top: 98px;
}

.tma-mode .hp-section {
  padding: 5px 8px;
}

.tma-mode .hp-section .flex {
  font-size: 12px;
}

.tma-mode #opponent-name,
.tma-mode #player-name-disp {
  font-size: 14px !important;
}

.tma-mode .hp-bar-container {
  height: 19px;
}

.tma-mode .hp-label {
  font-size: 14px !important;
  min-width: 72px;
}

.tma-mode .hp-row {
  gap: 6px;
}
.tma-mode .battle-arena {
  padding: 2px;
}

.tma-mode .zone-label {
  margin: 1px 0;
  font-size: 10px;
}

.tma-mode .battle-divider {
  margin: 2px 0;
}

.tma-mode #battle-status {
  font-size: 10px;
  padding: 2px 8px;
}

.tma-mode .spells-bar {
  padding: 4px 6px;
  gap: 3%;
  margin-top: 2px;
}

.tma-mode .spell-btn {
  width: 24px;
  height: 24px;
  min-width: 24px;
  font-size: 14px;
}

.tma-mode .hand-section {
  padding: 0;
}

.tma-mode .hand-container {
  padding: 3px;
  gap: 3px;
}

.tma-mode .mb-1 { margin-bottom: 2px; }

.tma-mode .btn-go {
  padding: 3px 10px;
  font-size: 18px;
  min-width: auto;
}

.tma-mode .player-row,
.tma-mode .opponent-row {
  margin-top: 4px;
  margin-bottom: 4px;
}

/* TMA: Hide fullscreen button (Telegram handles it) */
.tma-mode #fullscreen-btn {
  display: none;
}
/* ===== FORGE SPELL v2.1.131 (aligned with POWER/REFLECT pattern) ===== */
.text-gold { color: #f59e0b; }
.select-forge { cursor: pointer; }

/* v2.1.132: Old individual spell icon classes removed — fusion system */

/* 🌀 v2.1.138m: Card draw spiral animation */
@keyframes jkm-card-draw {
  0%   { opacity: 0; transform: translate(60px, -60px) rotate(180deg) scale(0.3); }
  50%  { opacity: 1; transform: translate(-4px, 4px) rotate(-10deg) scale(1.1); }
  75%  { transform: translate(2px, -2px) rotate(4deg) scale(0.96); }
  100% { opacity: 1; transform: translate(0, 0) rotate(0deg) scale(1); }
}

/* ========== v2.1.138s: AUTH BAR + LEADERBOARD + HISTORY ========== */

/* Auth bar */
#jkm-auth-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; background: #0a0a14;
  border-bottom: 1px solid #1a1a2e;
  font-family: 'Jersey 10', cursive; font-size: 13px;
  min-height: 36px; flex-shrink: 0;
}
.auth-user { display: flex; align-items: center; gap: 6px; }
.auth-guest { color: #444; font-size: 11px; }
.auth-avatar { width: 22px; height: 22px; border-radius: 50%; border: 1px solid #333; }
.auth-avatar-icon { font-size: 16px; }
.auth-name { color: #f4d35e; font-size: 13px; }
.auth-actions { display: flex; align-items: center; gap: 6px; }
.auth-btn {
  padding: 3px 10px; background: #1a1a2e; border: 1px solid #2a2a4e;
  border-radius: 3px; color: #aaa; font-size: 12px; cursor: pointer;
  font-family: 'Jersey 10', cursive; letter-spacing: 1px;
  transition: background 0.15s;
}
.auth-btn:hover { background: #2a2a4e; color: #fff; }
.auth-login { border-color: #4285f4; color: #4285f4; }
.auth-login:hover { background: #1a1a3e; }
.auth-logout { border-color: #e63946; color: #e63946; }
.auth-logout:hover { background: #2a1a1e; }

/* Modal */
#jkm-modal {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,0.85); align-items: center; justify-content: center;
  padding: 16px;
}
#jkm-modal-content {
  background: #0d0d1a; border: 1px solid #2a2a4e;
  border-radius: 6px; width: 100%; max-width: 480px;
  max-height: 80vh; overflow: hidden;
  display: flex; flex-direction: column;
  font-family: 'Jersey 10', cursive;
}
.jkm-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid #1a1a2e;
  background: #080810; flex-shrink: 0;
}
.jkm-modal-title { color: #f4d35e; font-size: 16px; letter-spacing: 2px; }
.jkm-modal-close {
  background: none; border: 1px solid #333; border-radius: 3px;
  color: #666; cursor: pointer; padding: 2px 8px; font-size: 14px;
  font-family: 'Jersey 10', cursive;
}
.jkm-modal-close:hover { color: #fff; border-color: #666; }
.jkm-loading, .jkm-empty {
  padding: 24px; text-align: center; color: #444; font-size: 14px;
}
.jkm-table-wrap { overflow-y: auto; flex: 1; }
.jkm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.jkm-table th {
  padding: 8px 10px; background: #080810; color: #555;
  font-size: 11px; letter-spacing: 1px; text-align: left;
  position: sticky; top: 0; border-bottom: 1px solid #1a1a2e;
}
.jkm-table td { padding: 7px 10px; border-bottom: 1px solid #0f0f1e; }
.jkm-table tr:hover td { background: #0f0f1e; }
.lb-rank { color: #f4d35e; width: 36px; font-size: 16px; }
.lb-name { color: #eee; display: flex; align-items: center; gap: 6px; }
.lb-avatar { width: 18px; height: 18px; border-radius: 50%; }
.lb-wins { color: #9bbc0f; font-weight: bold; }
.lb-losses { color: #e63946; }
.lb-draws { color: #888; }
.lb-rate { color: #f4d35e; }
.lb-you { color: #555; font-size: 10px; }
.lb-me td { background: #0a0a18 !important; }

/* History stats */
.hist-stats {
  display: flex; gap: 0; border-bottom: 1px solid #1a1a2e;
  flex-shrink: 0;
}
.hist-stat {
  flex: 1; padding: 10px 6px; text-align: center;
  display: flex; flex-direction: column; gap: 2px;
  font-size: 18px; border-right: 1px solid #1a1a2e;
}
.hist-stat:last-child { border-right: none; }
.hist-stat span { font-size: 10px; color: #555; letter-spacing: 1px; }
.hist-stat.win { color: #9bbc0f; }
.hist-stat.loss { color: #e63946; }
.hist-stat.draw { color: #888; }
.hist-stat.total { color: #f4d35e; }
.hist-opp { color: #eee; }
.hist-result { font-size: 11px; }
.hist-date { color: #444; font-size: 11px; }
.hist-win td { }
.hist-loss td { }
.hist-win .hist-result { color: #9bbc0f; }
.hist-loss .hist-result { color: #e63946; }
.hist-draw .hist-result { color: #888; }

/* Toast */
.jkm-toast {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  background: #0d0d1a; border: 1px solid #2a2a4e;
  padding: 8px 20px; border-radius: 4px; color: #f4d35e;
  font-family: 'Jersey 10', cursive; font-size: 14px;
  z-index: 10000; pointer-events: none;
  animation: toast-in 0.2s ease, toast-out 0.3s ease 2.7s forwards;
}
@keyframes toast-in  { from { opacity:0; transform: translateX(-50%) translateY(8px); } }
@keyframes toast-out { to   { opacity:0; } }

/* ============================================================
   👁 WATCH MODE — v3.0
   Applied via body.watch-mode when spectating via /?spectate=
   Hides player-only interactive elements, expands layout
   ============================================================ */
.watch-mode .hand-section { display: none !important; }
.watch-mode .spells-bar { display: none !important; }
.watch-mode #btn-ready { display: none !important; }
.watch-mode #spell-status { display: none !important; }
.watch-mode #placement-countdown { display: none !important; }

/* Give battle arena more vertical space when hand/spells hidden */
.watch-mode .battle-arena {
  flex: 1 1 auto !important;
}

/* Watch mode: show spectate indicator badge */
.watch-mode-badge {
  position: fixed;
  top: 8px; left: 50%; transform: translateX(-50%);
  background: rgba(244,211,94,0.12);
  border: 1px solid rgba(244,211,94,0.35);
  color: #f4d35e;
  font-family: 'Jersey 10', cursive;
  font-size: clamp(10px, 2.5vw, 13px);
  padding: 3px 12px;
  z-index: 9000;
  pointer-events: none;
  letter-spacing: 1px;
}

/* ============================================================
   SPECTATE LOBBY v2.1.150 — spec-room-card grid
   Used by game.js _specRenderRooms() on /spectate path
   ============================================================ */
.spec-empty {
  font-family: 'Jersey 10', cursive;
  color: #444;
  text-align: center;
  padding: 40px 16px;
  font-size: clamp(14px, 4vw, 20px);
  letter-spacing: 1px;
}
.spec-room-card {
  background: linear-gradient(180deg, #0e0e1a, #08080f);
  border: 1px solid #2a2a3a;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}
.spec-room-card:hover, .spec-room-card:active {
  border-color: #f4d35e;
  background: linear-gradient(180deg, #1a1220, #100e1a);
}
.spec-room-vs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.spec-name {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(18px, 5vw, 26px);
  letter-spacing: 1px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spec-name.p1name { color: #22c55e; text-align: left; }
.spec-name.p2name { color: #ef4444; text-align: right; }
.spec-vs-word {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(13px, 3.5vw, 18px);
  color: #f4d35e;
  flex-shrink: 0;
  padding: 0 6px;
}
.spec-hp-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.spec-hp-bar-wrap {
  flex: 1;
  height: 6px;
  background: #1a1a2e;
  overflow: hidden;
}
.spec-hp-bar-wrap.p1 { border-radius: 3px 0 0 3px; }
.spec-hp-bar-wrap.p2 { border-radius: 0 3px 3px 0; transform: scaleX(-1); }
.spec-hp-fill {
  height: 100%;
  transition: width 0.3s;
}
.spec-room-meta {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(10px, 2.5vw, 13px);
  color: #555;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.spec-watch-btn {
  font-family: 'Jersey 10', cursive;
  font-size: clamp(13px, 3.5vw, 16px);
  background: transparent;
  border: 1px solid #444;
  color: #f4d35e;
  padding: 6px 16px;
  cursor: pointer;
  width: 100%;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color 0.15s, background 0.15s;
}
.spec-room-card:hover .spec-watch-btn {
  border-color: #f4d35e;
  background: rgba(244,211,94,0.08);
}

/* ── v2.1.157: Spectate broadcast enhancements ───────────────────────── */

/* HP section critical pulse — whole section glows when HP ≤ 20% */
@keyframes hp-section-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(255,50,50,0); }
  50%       { box-shadow: 0 0 18px rgba(255,50,50,0.5), 0 0 35px rgba(192,27,27,0.25); }
}
.hp-section.hp-section-critical {
  animation: hp-section-pulse 0.9s ease-in-out infinite;
  border-radius: 4px;
}

/* Room ID broadcast badge */
#room-id-display {
  font-family: 'Jersey 10', cursive !important;
  font-size: clamp(10px, 2.5vw, 14px) !important;
  color: rgba(255,255,255,0.7) !important;
  letter-spacing: 0.5px !important;
  padding: 3px 8px !important;
  background: rgba(0,0,0,0.65) !important;
  border: 1px solid rgba(255,60,60,0.4) !important;
}
#room-id-display::before {
  content: '';
  display: inline-block;
  width: 7px; height: 7px;
  background: #ff3c3c;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
  animation: live-blink 1s ease-in-out infinite;
}
@keyframes live-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}
