/* ==========================================================================
   KOSPI Gacha World - Styles & Theme
   ========================================================================== */

/* 1. Global Reset & Custom Variables */
:root {
  --color-bg-dark: #0d041c;
  --color-bg-panel: rgba(24, 8, 44, 0.7);
  --color-primary: #ff007f;     /* Neon Pink */
  --color-secondary: #00f0ff;   /* Neon Cyan */
  --color-accent: #ffb700;      /* Neon Amber/Gold */
  --color-green: #00ff66;       /* Cyber Green */
  --color-dark-purple: #18082c;
  --color-text-light: #ffffff;
  --color-text-muted: #a092b3;
  --font-title: 'Outfit', 'Noto Sans KR', sans-serif;
  --font-body: 'Noto Sans KR', sans-serif;
  --card-width: 290px;
  --card-height: 425px;
  --transition-smooth: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  --neon-shadow-primary: 0 0 10px rgba(255, 0, 127, 0.6), 0 0 20px rgba(255, 0, 127, 0.3);
  --neon-shadow-secondary: 0 0 10px rgba(0, 240, 255, 0.6), 0 0 20px rgba(0, 240, 255, 0.3);
  --neon-shadow-gold: 0 0 10px rgba(255, 183, 0, 0.6), 0 0 20px rgba(255, 183, 0, 0.3);
}

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

body {
  background-color: var(--color-bg-dark);
  color: var(--color-text-light);
  font-family: var(--font-body);
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--color-bg-dark);
}
::-webkit-scrollbar-thumb {
  background: #3e1f5c;
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* 2. Background Ambient Glow Effects */
.ambient-glow {
  position: fixed;
  width: 50vw;
  height: 50vw;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
  filter: blur(120px);
  opacity: 0.3;
}
.bg-glow-1 {
  background: radial-gradient(circle, var(--color-primary) 0%, transparent 70%);
  top: -10%;
  left: -10%;
  animation: floatGlow 15s ease-in-out infinite alternate;
}
.bg-glow-2 {
  background: radial-gradient(circle, var(--color-secondary) 0%, transparent 70%);
  bottom: 0%;
  right: -10%;
  animation: floatGlow 18s ease-in-out infinite alternate-reverse;
}

@keyframes floatGlow {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(80px, 50px) scale(1.2); }
}

/* 3. Header Styling */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  border-bottom: 2px stroke rgba(255, 0, 127, 0.2);
  background: rgba(13, 4, 28, 0.85);
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
  z-index: 10;
}

.header-logo {
  display: flex;
  flex-direction: column;
}

.neon-title {
  font-family: var(--font-title);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: var(--neon-shadow-primary);
  position: relative;
  animation: blinkNeon 4s infinite alternate;
}

.logo-sub {
  font-size: 0.8rem;
  color: var(--color-secondary);
  font-weight: 700;
  letter-spacing: 4px;
  margin-top: 2px;
  text-transform: uppercase;
}

@keyframes blinkNeon {
  0%, 18%, 22%, 25%, 53%, 57%, 100% {
    text-shadow: 0 0 4px #fff, 0 0 10px var(--color-primary), 0 0 20px var(--color-primary), 0 0 40px var(--color-primary);
  }
  20%, 24%, 55% {
    text-shadow: none;
  }
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 15px;
}

.credits-display {
  display: flex;
  flex-direction: column;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 5px 15px;
  border-radius: 8px;
  min-width: 100px;
  text-align: center;
}

.credits-display .label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  letter-spacing: 1px;
}

.credits-display .value {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--color-secondary);
  text-shadow: var(--neon-shadow-secondary);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 10px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-smooth);
}

.icon-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  box-shadow: var(--neon-shadow-primary);
  transform: translateY(-2px);
}

/* 4. Game Layout Grid */
.game-container {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 30px;
  padding: 30px 40px;
  max-width: 1200px;
  margin: 0 auto;
  flex: 1;
  align-items: start;
}

/* 5. Gacha Machine Panel */
.machine-panel {
  background: var(--color-bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 25px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.machine-glass-wrapper {
  width: 100%;
  max-width: 290px;
  position: relative;
  aspect-ratio: 3/4;
}

.gacha-machine-svg {
  filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
  transition: transform 0.15s ease-in-out;
}

/* SVG Gacha Machine Animations */
.gacha-machine-svg.shaking {
  animation: machineShake 0.4s infinite;
}

@keyframes machineShake {
  0% { transform: translate(0, 0) rotate(0deg); }
  20% { transform: translate(-3px, 2px) rotate(-1deg); }
  40% { transform: translate(3px, -1px) rotate(1deg); }
  60% { transform: translate(-2px, -2px) rotate(0.5deg); }
  80% { transform: translate(2px, 3px) rotate(-0.5deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

/* Rotating handle transition */
#gacha-lever-handle {
  transform-origin: 0px 0px;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.machine-capsule {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.1s ease;
}
.gacha-machine-svg.shaking .machine-capsule {
  animation: capsuleScatter 0.3s infinite alternate;
}

@keyframes capsuleScatter {
  0% { transform: translate(0, 0) rotate(var(--r, 0deg)); }
  100% { transform: translate(calc(var(--x, 5px) - 2px), calc(var(--y, -5px) + 2px)) rotate(calc(var(--r, 0deg) + 20deg)); }
}

/* Control Buttons below Machine */
.machine-controls {
  display: flex;
  gap: 15px;
  width: 100%;
  margin-top: 20px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  padding: 12px 24px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary), #d2006b);
  color: #fff;
  box-shadow: var(--neon-shadow-primary);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.15);
  box-shadow: 0 0 15px var(--color-primary), 0 0 30px var(--color-primary);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
}

.btn-secondary {
  background: linear-gradient(135deg, var(--color-secondary), #00b8c4);
  color: #0d041c;
  box-shadow: var(--neon-shadow-secondary);
}
.btn-secondary:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.15);
  box-shadow: 0 0 15px var(--color-secondary), 0 0 30px var(--color-secondary);
}
.btn-secondary:disabled {
  background: #332047;
  color: rgba(255,255,255,0.2);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--color-secondary);
  color: var(--color-secondary);
}
.btn-outline:hover {
  background: rgba(0, 240, 255, 0.1);
  box-shadow: var(--neon-shadow-secondary);
}

.pulse {
  animation: pulseButton 1.5s infinite;
}

@keyframes pulseButton {
  0% { box-shadow: 0 0 0 0 rgba(255, 0, 127, 0.7); }
  70% { box-shadow: 0 0 0 12px rgba(255, 0, 127, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 0, 127, 0); }
}

.machine-status-msg {
  margin-top: 15px;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.4;
  height: 40px;
}

/* 6. Card Stage Panel */
.stage-panel {
  background: var(--color-bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  min-height: 540px;
  height: auto;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
}

#stage-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.stage-window {
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
  z-index: 2;
  padding: 20px;
}

.stage-placeholder {
  max-width: 400px;
  text-align: center;
}

.placeholder-icon {
  font-size: 4rem;
  margin-bottom: 15px;
  animation: floatEmoji 3s ease-in-out infinite;
}

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

.stage-placeholder h3 {
  font-size: 1.5rem;
  margin-bottom: 10px;
  color: #fff;
  font-weight: 800;
}

.stage-placeholder p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.tip-box {
  margin-top: 25px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.15);
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 0.8rem;
}
.tip-box span {
  color: var(--color-accent);
  font-weight: bold;
}

/* 7. Capsule Draw Animation */
.capsule-container {
  display: none;
  position: absolute;
  z-index: 4;
}

.gacha-capsule {
  width: 85px;
  height: 130px;
  position: relative;
  cursor: pointer;
  filter: drop-shadow(0 10px 25px rgba(0,0,0,0.6));
}

.capsule-top, .capsule-bottom {
  position: absolute;
  width: 100%;
  height: 50%;
  left: 0;
  border: 3px solid #11052C;
}

.capsule-top {
  top: 0;
  background: linear-gradient(to bottom, #ff007f 0%, #a20051 100%);
  border-radius: 6px 6px 0 0;
  border-bottom: 1.5px solid rgba(255,255,255,0.2);
  clip-path: polygon(
    0% 100%, 
    0% 8px, 
    5% 0%, 10% 8px, 15% 0%, 20% 8px, 25% 0%, 30% 8px, 35% 0%, 40% 8px, 45% 0%, 50% 8px, 55% 0%, 60% 8px, 65% 0%, 70% 8px, 75% 0%, 80% 8px, 85% 0%, 90% 8px, 95% 0%, 100% 8px,
    100% 100%
  );
}

.capsule-bottom {
  bottom: 0;
  background: linear-gradient(to bottom, #ffffff 0%, #dddddd 100%);
  border-radius: 0 0 6px 6px;
  border-top: 1.5px solid rgba(255,255,255,0.2);
  clip-path: polygon(
    0% 0%,
    100% 0%,
    100% calc(100% - 8px),
    95% 100%, 90% calc(100% - 8px), 85% 100%, 80% calc(100% - 8px), 75% 100%, 70% calc(100% - 8px), 65% 100%, 60% calc(100% - 8px), 55% 100%, 50% calc(100% - 8px), 45% 100%, 40% calc(100% - 8px), 35% 100%, 30% calc(100% - 8px), 25% 100%, 20% calc(100% - 8px), 15% 100%, 10% calc(100% - 8px), 5% 100%, 0% calc(100% - 8px)
  );
}

.capsule-glowing-core {
  position: absolute;
  width: 32px;
  height: 48px;
  background: #fff;
  border: 2px solid #11052C;
  border-radius: 4px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  box-shadow: 0 0 15px #fff, 0 0 25px var(--color-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.capsule-glowing-core::after {
  content: '📈';
  font-size: 1.1rem;
}

/* Drop-roll & Hover Animation for Capsule */
.gacha-capsule.dropping {
  animation: capsuleDrop 1s cubic-bezier(0.25, 0.8, 0.25, 1.2) forwards;
}

@keyframes capsuleDrop {
  0% {
    transform: translate(-250px, 150px) scale(0.3) rotate(0deg);
  }
  40% {
    transform: translate(0px, 0px) scale(1) rotate(720deg);
  }
  50% {
    transform: translateY(-20px) scale(1.1);
  }
  60% {
    transform: translateY(0) scale(1);
  }
  75% {
    transform: scale(1.05);
  }
  90%, 100% {
    transform: scale(1);
  }
}

.gacha-capsule.hover-float {
  animation: floatCapsule 2.5s ease-in-out infinite;
}

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

/* Capsule Breaking Open */
.gacha-capsule.opening .capsule-top {
  animation: capsuleOpenTop 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}
.gacha-capsule.opening .capsule-bottom {
  animation: capsuleOpenBottom 0.6s cubic-bezier(0.25, 0.8, 0.25, 1) forwards;
}
.gacha-capsule.opening .capsule-glowing-core {
  animation: capsuleCoreBlast 0.6s ease-out forwards;
}

@keyframes capsuleOpenTop {
  100% { transform: translateY(-60px) rotate(-15deg); opacity: 0; }
}
@keyframes capsuleOpenBottom {
  100% { transform: translateY(60px) rotate(15deg); opacity: 0; }
}
@keyframes capsuleCoreBlast {
  0% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(8); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(15); opacity: 0; }
}

/* 8. 3D Trading Card System */
.card-display-wrapper {
  display: none; /* Controlled via JS */
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.card-container {
  width: var(--card-width);
  height: auto;
  perspective: 1200px; /* Essential for 3D */
  z-index: 10;
}

.card-inner {
  width: 100%;
  height: auto;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  cursor: pointer;
}

/* When active, JavaScript controls the actual mouse tilting. This hover transition applies to flips */
.card-inner.flipped {
  transform: rotateY(180deg);
}

.card-front, .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.6);
}

/* Card Back Design */
.card-back {
  background: radial-gradient(circle, #2d0c4d 0%, #110522 100%);
  border: 4px solid var(--color-primary);
  box-shadow: var(--neon-shadow-primary);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2;
}

.card-back-pattern {
  position: absolute;
  width: 100%;
  height: 100%;
  opacity: 0.1;
  background-image: radial-gradient(#fff 1px, transparent 1px), radial-gradient(#fff 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}

.card-back-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
}

.logo-orb {
  width: 80px;
  height: 80px;
  background: var(--color-bg-dark);
  border: 3px solid var(--color-secondary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--neon-shadow-secondary);
}

.logo-emoji {
  font-size: 2.5rem;
}

.card-back-logo .logo-text {
  font-family: var(--font-title);
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 1px;
  text-shadow: var(--neon-shadow-primary);
}

/* Card Front Design */
.card-front {
  background: linear-gradient(135deg, #1b0e3b 0%, #0e051e 100%);
  border: 4px solid #fff; /* Replaced dynamically based on rarity */
  transform: rotateY(180deg); /* Start rotated */
  display: flex;
  flex-direction: column;
  padding: 12px;
  color: #fff;
  position: relative;
  z-index: 1;
  height: auto;
  min-height: var(--card-height);
}

/* Foil overlay effect */
.holo-shine {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.4) 30%,
    rgba(255, 0, 127, 0.25) 45%,
    rgba(0, 240, 255, 0.25) 55%,
    rgba(255, 255, 255, 0.4) 70%,
    transparent 100%
  );
  background-size: 250% 250%;
  background-position: 0% 0%;
  pointer-events: none;
  mix-blend-mode: color-dodge;
  opacity: 0;
  z-index: 5;
  transition: opacity 0.3s ease;
}

/* holographic glitter when hovered */
.card-inner:hover .holo-shine {
  opacity: 0.65;
}

/* Card Rarity Aesthetics */
.card-front.rarity-ssr {
  border-color: #ffd700;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.5), inset 0 0 15px rgba(255, 215, 0, 0.2);
}
.card-front.rarity-sr {
  border-color: #e0e0e0;
  box-shadow: 0 0 15px rgba(224, 224, 224, 0.4);
}
.card-front.rarity-r {
  border-color: #ff3c00;
  box-shadow: 0 0 15px rgba(255, 60, 0, 0.4);
}
.card-front.rarity-uc {
  border-color: #00ff66;
  box-shadow: 0 0 12px rgba(0, 255, 102, 0.3);
}
.card-front.rarity-c {
  border-color: #00f0ff;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}
.card-front.rarity-ur {
  border-color: #7b1fa2;
  box-shadow: 0 0 25px rgba(123, 31, 162, 0.7), inset 0 0 20px rgba(123, 31, 162, 0.3);
  animation: cardGlitchGlow 1.5s infinite alternate;
}

@keyframes cardGlitchGlow {
  0% { box-shadow: 0 0 15px rgba(123, 31, 162, 0.5); }
  100% { box-shadow: 0 0 35px rgba(255, 0, 127, 0.8), 0 0 10px rgba(0, 240, 255, 0.8); }
}

/* Card Header (Name, Code, Rarity) */
.card-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.card-title-group {
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  color: #fff;
}

.card-code {
  font-family: var(--font-title);
  font-size: 0.6rem;
  color: var(--color-text-muted);
  letter-spacing: 0.5px;
}

.card-rarity-badge {
  font-family: var(--font-title);
  font-size: 0.85rem;
  font-weight: 900;
  padding: 2px 8px;
  border-radius: 6px;
  color: #000;
  text-shadow: none;
}

.card-rarity-badge.ssr { background: linear-gradient(135deg, #ffe066, #f5b041); color: #0d041c; box-shadow: 0 0 5px rgba(255, 215, 0, 0.5); }
.card-rarity-badge.sr { background: linear-gradient(135deg, #ffffff, #b2babb); color: #0d041c; }
.card-rarity-badge.r { background: linear-gradient(135deg, #ff5733, #c70039); color: #fff; }
.card-rarity-badge.uc { background: linear-gradient(135deg, #58d68d, #27ae60); color: #fff; }
.card-rarity-badge.c { background: linear-gradient(135deg, #5dedf5, #2980b9); color: #0d041c; }
.card-rarity-badge.ur { background: linear-gradient(135deg, #af7ac5, #7d3c98); color: #fff; animation: glitchText 1s infinite alternate; }

/* Card Illustration Area */
.card-image-area {
  flex: 1;
  min-height: 100px;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 8px;
  overflow: hidden;
}

/* Card Element Backdrop colors based on types */
.card-image-area::before {
  content: '';
  position: absolute;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  filter: blur(25px);
  opacity: 0.5;
  z-index: 1;
}

.card-front.type-lightning .card-image-area::before { background: var(--color-secondary); }
.card-front.type-fire .card-image-area::before { background: var(--color-primary); }
.card-front.type-steel .card-image-area::before { background: #bbb; }
.card-front.type-wind .card-image-area::before { background: #85c1e9; }
.card-front.type-grass .card-image-area::before { background: var(--color-green); }
.card-front.type-water .card-image-area::before { background: #3498db; }
.card-front.type-bio .card-image-area::before { background: #e74c3c; }
.card-front.type-glitch .card-image-area::before { background: #9b59b6; }

.card-illust-emoji {
  font-size: 4rem;
  z-index: 2;
  animation: floatCardEmoji 4s ease-in-out infinite;
}

@keyframes floatCardEmoji {
  0%, 100% { transform: scale(1) translateY(0); filter: drop-shadow(0 5px 5px rgba(0,0,0,0.5)); }
  50% { transform: scale(1.08) translateY(-8px); filter: drop-shadow(0 15px 12px rgba(0,0,0,0.3)); }
}

/* Decorative Card element symbol in bottom right of illustration */
.card-element-symbol {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  z-index: 3;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Card Stats & Meters */
.card-stats-panel {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
  background: rgba(0, 0, 0, 0.2);
  padding: 6px;
  border-radius: 8px;
}

.stat-row {
  display: flex;
  align-items: center;
  font-size: 0.7rem;
}

.stat-row .stat-label {
  width: 65px;
  color: var(--color-text-muted);
  font-weight: 700;
}

.stat-row .stat-bar-outer {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
  margin: 0 8px;
}

.stat-row .stat-bar-inner {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease-out;
}

.stat-row.atk .stat-bar-inner { background: linear-gradient(90deg, #ff0055, #ff5733); }
.stat-row.def .stat-bar-inner { background: linear-gradient(90deg, #00c3ff, #0055ff); }
.stat-row.hp .stat-bar-inner { background: linear-gradient(90deg, #00ff66, #27ae60); }

.stat-row .stat-value {
  width: 45px;
  text-align: right;
  font-family: var(--font-title);
  font-weight: 700;
  color: #fff;
}

/* Card Special Skill & Flavor Description */
.card-skill-box {
  background: rgba(255, 255, 255, 0.05);
  border-left: 3px solid var(--color-primary);
  border-radius: 4px;
  padding: 6px 8px;
  margin-bottom: 8px;
  font-size: 0.75rem;
}

.card-skill-title {
  font-weight: 900;
  color: var(--color-secondary);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.card-skill-title::before {
  content: '★';
  color: var(--color-accent);
}

.card-skill-desc {
  color: var(--color-text-light);
  line-height: 1.3;
}

.card-flavor-text {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  font-style: italic;
  line-height: 1.4;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 5px;
}

.card-footer-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.55rem;
  color: rgba(255,255,255,0.3);
  margin-top: auto;
}

/* Card options (Copy & Reset buttons) */
.card-options {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  width: 100%;
}

/* 9. Bottom Drawer: Card Collection Book */
.collection-drawer {
  width: 100%;
  background: rgba(18, 6, 38, 0.95);
  border-top: 2px solid var(--color-primary);
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
  z-index: 9;
  position: sticky;
  bottom: 0;
  margin-top: auto;
}

.drawer-toggle {
  width: 100%;
  background: transparent;
  border: none;
  color: #fff;
  padding: 12px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  outline: none;
  position: relative;
}

.drawer-toggle .toggle-icon {
  font-size: 0.8rem;
  transition: transform 0.3s ease;
  margin-bottom: 5px;
  color: var(--color-primary);
}

.collection-drawer.expanded .drawer-toggle .toggle-icon {
  transform: rotate(180deg);
}

.drawer-toggle .toggle-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
}

.progress-bar-container {
  width: 200px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transition: width 0.5s ease;
}

.drawer-content {
  max-height: 0;
  overflow-y: auto;
  transition: max-height 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  background: rgba(13, 4, 28, 0.95);
}

.collection-drawer.expanded .drawer-content {
  max-height: 250px;
  padding: 20px 40px 30px;
}

.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 15px;
}

/* Micro-card inside grid */
.grid-card-slot {
  aspect-ratio: 1 / 1.4;
  background: rgba(0, 0, 0, 0.4);
  border: 2px dashed rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
  position: relative;
  overflow: hidden;
  padding: 10px;
}

.grid-card-slot.locked {
  cursor: not-allowed;
}

.grid-card-slot.locked .mini-card-inner {
  filter: brightness(0.2) grayscale(1);
}

.grid-card-slot.locked::before {
  content: '🔒';
  font-size: 1.5rem;
  position: absolute;
  z-index: 3;
  opacity: 0.6;
}

.grid-card-slot:not(.locked):hover {
  transform: translateY(-5px) scale(1.03);
  border-style: solid;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
}

.grid-card-slot.slot-ssr:not(.locked) { border-color: #ffd700; }
.grid-card-slot.slot-sr:not(.locked) { border-color: #e0e0e0; }
.grid-card-slot.slot-r:not(.locked) { border-color: #ff3c00; }
.grid-card-slot.slot-uc:not(.locked) { border-color: #00ff66; }
.grid-card-slot.slot-c:not(.locked) { border-color: #00f0ff; }
.grid-card-slot.slot-ur:not(.locked) { border-color: #7b1fa2; }

.mini-card-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 100%;
}

.mini-emoji {
  font-size: 2.2rem;
  margin-top: 10px;
}

.mini-name {
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 5px;
}

.mini-rarity-badge {
  font-family: var(--font-title);
  font-size: 0.55rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 4px;
  position: absolute;
  top: 6px;
  left: 6px;
}

/* 10. Rules Modal & Overlays */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(13, 4, 28, 0.8);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #1c0e35;
  border: 2px solid var(--color-primary);
  border-radius: 20px;
  max-width: 550px;
  width: 90%;
  padding: 30px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.8), var(--neon-shadow-primary);
  position: relative;
  transform: translateY(-20px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 1.8rem;
  cursor: pointer;
  transition: var(--transition-smooth);
}
.modal-close:hover {
  color: var(--color-primary);
}

.modal-content h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 20px;
  text-shadow: var(--neon-shadow-primary);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 10px;
}

.modal-body {
  overflow-y: auto;
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.6;
}

.modal-body h3 {
  font-size: 1.05rem;
  margin: 20px 0 10px;
  color: var(--color-secondary);
}

.modal-body p {
  margin-bottom: 10px;
}

.rarity-legend {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 15px 0;
  background: rgba(0,0,0,0.25);
  padding: 12px;
  border-radius: 10px;
}

.rarity-legend li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  font-family: var(--font-title);
  font-size: 0.7rem;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
  min-width: 38px;
  text-align: center;
  color: #000;
}
.badge.ssr { background: #ffd700; }
.badge.sr { background: #e0e0e0; }
.badge.r { background: #ff5733; color: #fff; }
.badge.uc { background: #58d68d; color: #fff; }
.badge.c { background: #5dedf5; }
.badge.ur { background: #af7ac5; color: #fff; }

.modal-body ol {
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-footer {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}

/* 11. Toast Notifications */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(24, 8, 44, 0.95);
  border: 1px solid var(--color-secondary);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  z-index: 110;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: var(--neon-shadow-secondary);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 12. Glitch & Animation Utilities */
@keyframes glitchText {
  0% { text-shadow: 1px 1px 0 rgba(255,0,127,0.5), -1px -1px 0 rgba(0,240,255,0.5); }
  100% { text-shadow: -1px 1px 0 rgba(255,0,127,0.5), 1px -1px 0 rgba(0,240,255,0.5); }
}

/* 13. Responsive Media Queries */
@media (max-width: 900px) {
  .game-container {
    position: relative;
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 20px;
  }
  
  .app-header {
    padding: 15px 20px;
  }
  
  .stage-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    bottom: 20px;
    min-height: unset;
    height: calc(100% - 40px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(0.92);
    background: rgba(13, 4, 28, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 20px;
    z-index: 20;
    margin: 0;
  }

  .stage-panel.active {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
  }

  .stage-placeholder {
    display: none !important;
  }
}

@media (max-width: 500px) {
  .neon-title {
    font-size: 1.4rem;
  }
  
  .logo-sub {
    font-size: 0.7rem;
    letter-spacing: 2px;
  }
  
  .header-controls {
    gap: 8px;
  }
  
  .credits-display {
    min-width: 80px;
    padding: 3px 8px;
  }
  
  .credits-display .value {
    font-size: 1rem;
  }
  
  .collection-drawer.expanded .drawer-content {
    padding: 15px 15px 25px;
  }
  
  .collection-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 10px;
  }
  
  .mini-emoji {
    font-size: 1.6rem;
  }
  
  .mini-name {
    font-size: 0.65rem;
  }
  .filter-btn {
    padding: 4px 7px;
    font-size: 0.65rem;
  }
  #collection-search-input {
    max-width: 100%;
    font-size: 16px; /* iOS Auto-zoom prevention (must be >= 16px) */
  }
}

/* Horizontal scroll for filter chips on mobile */
@media (max-width: 600px) {
  .rarity-filters {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }
  .rarity-filters::-webkit-scrollbar {
    display: none;
  }
  .filter-btn {
    flex-shrink: 0;
  }
}

/* Scale down card dimensions on ultra-small mobile viewports */
@media (max-width: 350px) {
  :root {
    --card-width: 250px;
    --card-height: 366px;
  }
  .card-title {
    font-size: 1rem;
  }
  .card-illust-emoji {
    font-size: 3rem;
  }
}

/* ==========================================================================
   Collection Search and Filters Styling
   ========================================================================== */
.collection-search-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  background: #0d041c; /* Solid matching background to cover scrolling cards */
  padding: 10px 0;
  z-index: 10;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

@media (min-width: 600px) {
  .collection-search-bar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

#collection-search-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #fff;
  padding: 8px 12px;
  font-size: 0.85rem;
  width: 100%;
  max-width: 250px;
  outline: none;
  transition: var(--transition-smooth);
}

#collection-search-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 8px rgba(255, 0, 127, 0.4);
}

.rarity-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--color-text-muted);
  padding: 5px 12px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition-smooth);
  font-family: var(--font-title);
  font-weight: 700;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.filter-btn.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  box-shadow: var(--neon-shadow-primary);
}

.collection-no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-style: italic;
}

/* 14. Legal Disclaimer Footer */
.app-disclaimer {
  max-width: 1200px;
  width: 100%;
  margin: 10px auto 30px auto;
  padding: 0 40px;
  font-size: 0.7rem;
  color: var(--color-text-muted);
  line-height: 1.6;
  text-align: center;
  opacity: 0.6;
}

.app-disclaimer p {
  margin-bottom: 6px;
}

.app-disclaimer strong {
  color: var(--color-secondary);
}

@media (max-width: 900px) {
  .app-disclaimer {
    padding: 0 20px;
    margin-bottom: 40px;
  }
}

/* ==========================================================================
   15. Gacha Continuation System Styles
   ========================================================================== */
.credits-display-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.credits-display.credit-warning {
  border-color: var(--color-primary);
  box-shadow: 0 0 10px rgba(255, 0, 127, 0.4);
  animation: pulseWarning 1.5s infinite ease-in-out;
}

@keyframes pulseWarning {
  0%, 100% { border-color: rgba(255, 0, 127, 0.3); box-shadow: none; }
  50% { border-color: var(--color-primary); box-shadow: 0 0 10px rgba(255, 0, 127, 0.6); }
}

.imf-btn {
  background: linear-gradient(135deg, var(--color-primary), #900048);
  border: 1px solid var(--color-primary);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  display: none; /* Hidden by default */
  align-items: center;
  gap: 4px;
  box-shadow: var(--neon-shadow-primary);
  transition: var(--transition-smooth);
  animation: imfPulse 1s infinite alternate;
}

.imf-btn.active {
  display: flex; /* Show when active */
}

.imf-btn:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

@keyframes imfPulse {
  0% { box-shadow: 0 0 5px rgba(255, 0, 127, 0.5); }
  100% { box-shadow: 0 0 15px rgba(255, 0, 127, 0.9), 0 0 5px #fff; }
}

.dividend-display {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(24, 8, 44, 0.55);
  border: 1px dashed rgba(0, 255, 102, 0.25);
  padding: 5px 12px;
  border-radius: 8px;
  min-width: 140px;
  transition: var(--transition-smooth);
}

.dividend-display:hover {
  border-color: var(--color-green);
  background: rgba(24, 8, 44, 0.8);
}

.dividend-label {
  font-size: 0.65rem;
  color: var(--color-text-muted);
  letter-spacing: 1px;
}

.dividend-value {
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--color-green);
  text-shadow: 0 0 5px rgba(0, 255, 102, 0.4);
  flex-grow: 1;
}

.btn-dividend {
  background: #2a1b40;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--color-text-muted);
  font-size: 0.7rem;
  font-weight: bold;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: not-allowed;
  transition: var(--transition-smooth);
}

.btn-dividend.claimable {
  background: linear-gradient(135deg, var(--color-green), #00b344);
  border-color: var(--color-green);
  color: #0d041c;
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 255, 102, 0.4);
}

.btn-dividend.claimable:hover {
  filter: brightness(1.15);
  transform: scale(1.05);
}

.machine-pity-display {
  margin-top: 10px;
  font-size: 0.8rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 4px 12px;
  border-radius: 6px;
  color: var(--color-text-muted);
  display: inline-block;
  letter-spacing: 0.5px;
}

.machine-pity-display strong {
  color: var(--color-accent);
  text-shadow: 0 0 5px rgba(255, 183, 0, 0.4);
  font-family: var(--font-title);
  font-size: 0.9rem;
}

