/* ==========================================================================
   Retro Gen-3 Pokémon Style Wedding Battle Engine — Stylesheet
   Mobile-First, Isolated in /play/
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Montserrat:wght@400;600;700;800&family=Cinzel:wght@600;700&display=swap');

:root {
  --pk-bg-dark: #0f1318;
  --pk-panel-bg: #1e262f;
  --pk-panel-border: #d4af37;
  --pk-panel-inner: #0b0e12;
  --pk-gold: #d4af37;
  --pk-gold-light: #fde047;
  --pk-rose: #f43f5e;
  --pk-rose-light: #fda4af;
  --pk-green: #22c55e;
  --pk-yellow: #eab308;
  --pk-text-white: #f8fafc;
  --pk-text-muted: #94a3b8;
  --pk-font-pixel: 'Press Start 2P', monospace, sans-serif;
  --pk-font-sans: 'Montserrat', sans-serif;
  --pk-font-serif: 'Cinzel', serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body.game-body {
  margin: 0 !important;
  padding: 0 !important;
  padding-bottom: 0 !important;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background-color: var(--pk-bg-dark) !important;
  background: var(--pk-bg-dark) !important;
  color: var(--pk-text-white);
  font-family: var(--pk-font-sans);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow: hidden;
}

/* App & Arcade Frame Container - Full Mobile Screen Span */
.game-container {
  width: 100%;
  max-width: 520px;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 6px 8px 8px;
  margin: 0 auto;
  position: relative;
  box-sizing: border-box;
}

/* Header bar */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 6px;
  border-bottom: 1px solid rgba(212, 175, 55, 0.2);
  margin-bottom: 6px;
  flex-shrink: 0;
}

.game-header-logo {
  font-family: var(--pk-font-serif);
  color: var(--pk-gold);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon-btn {
  background: rgba(30, 38, 47, 0.8);
  border: 1px solid rgba(212, 175, 55, 0.35);
  color: var(--pk-gold);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.2s ease;
  text-decoration: none;
}

.header-icon-btn:hover, .header-icon-btn:active {
  background: var(--pk-gold);
  color: #121518;
  transform: scale(1.05);
}

/* ==========================================================================
   1. CHARACTER SELECT SCREEN
   ========================================================================== */
.screen {
  display: none;
  width: 100%;
  flex: 1;
  min-height: 0;
  flex-direction: column;
  animation: screenFadeIn 0.35s ease;
}

.screen.active {
  display: flex;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.select-hero-card {
  background: linear-gradient(180deg, #182028 0%, #0d1217 100%);
  border: 2px solid var(--pk-gold);
  border-radius: 18px;
  padding: 16px 12px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.7), inset 0 0 15px rgba(212, 175, 55, 0.1);
  display: flex;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
}

.pixel-badge {
  display: inline-block;
  align-self: center;
  background: linear-gradient(135deg, #b45309, var(--pk-gold));
  color: #0b0e12;
  font-family: var(--pk-font-pixel);
  font-size: 0.52rem;
  padding: 5px 12px;
  border-radius: 20px;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
  box-shadow: 0 3px 10px rgba(212, 175, 55, 0.3);
}

.select-title {
  font-family: var(--pk-font-serif);
  font-size: 1.4rem;
  color: var(--pk-gold);
  margin: 0 0 2px;
}

.select-subtitle {
  font-size: 0.78rem;
  color: var(--pk-text-muted);
  margin-bottom: 12px;
  line-height: 1.3;
}

.character-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  flex: 1;
  min-height: 0;
  margin-bottom: 12px;
}

.character-card {
  background: rgba(22, 28, 35, 0.9);
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-radius: 16px;
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.character-card:hover, .character-card:active {
  border-color: var(--pk-gold);
  background: rgba(45, 56, 68, 0.9);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(212, 175, 55, 0.25);
}

.character-card.selected {
  border-color: var(--pk-gold);
  background: linear-gradient(180deg, rgba(212, 175, 55, 0.15), rgba(15, 19, 24, 0.8));
  box-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
}

.character-card.selected::after {
  content: '✓ CHOSEN';
  position: absolute;
  top: 6px;
  right: 6px;
  font-family: var(--pk-font-pixel);
  font-size: 0.45rem;
  background: var(--pk-gold);
  color: #0b0e12;
  padding: 2px 5px;
  border-radius: 6px;
  font-weight: bold;
}

.char-avatar-img {
  width: auto;
  max-width: 105px;
  height: clamp(120px, 26vh, 185px);
  object-fit: contain;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}

.char-name {
  font-family: var(--pk-font-serif);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--pk-text-white);
  margin-bottom: 2px;
}

.char-role {
  font-size: 0.65rem;
  color: var(--pk-gold);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.start-battle-btn {
  width: 100%;
  background: linear-gradient(135deg, #d97706, var(--pk-gold));
  color: #0b0e12;
  border: none;
  padding: 12px 14px;
  border-radius: 12px;
  font-family: var(--pk-font-pixel);
  font-size: 0.65rem;
  letter-spacing: 1px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 5px 18px rgba(212, 175, 55, 0.4);
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.start-battle-btn:hover, .start-battle-btn:active {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(212, 175, 55, 0.6);
  color: #000;
}

.start-battle-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ==========================================================================
   2. GEN-3 POKEMON BATTLE ARENA (MOBILE-FIRST FULL SPAN)
   ========================================================================== */
.battle-frame {
  background: #090c10;
  border: 2px solid var(--pk-panel-border);
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex: 1;
  height: 100%;
  min-height: 0;
  flex-direction: column;
  position: relative;
  box-shadow: 0 12px 35px rgba(0,0,0,0.8), 0 0 20px rgba(212, 175, 55, 0.15);
}

/* Battlefield Background (Royal Festive Wedding Mandap Stage) */
.battlefield {
  flex: 1;
  min-height: 260px;
  position: relative;
  background: 
    radial-gradient(ellipse 90% 65% at 50% 68%, #1f5038 0%, #153c29 45%, #0f271b 80%, #0a1811 100%),
    linear-gradient(180deg, #0d141e 0%, #152230 35%, #182820 60%, #0d1e16 100%);
  overflow: hidden;
  border-bottom: 2px solid rgba(212, 175, 55, 0.4);
}

/* Festive Fairy Lights & Starry Night Sky */
.battlefield::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 42%;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(253,224,71,0.95) 2px, transparent 3px),
    radial-gradient(circle at 25% 30%, rgba(244,63,94,0.95) 2.5px, transparent 3.5px),
    radial-gradient(circle at 40% 18%, rgba(253,224,71,0.95) 2.5px, transparent 3.5px),
    radial-gradient(circle at 55% 28%, rgba(56,189,248,0.95) 2px, transparent 3px),
    radial-gradient(circle at 70% 16%, rgba(253,224,71,0.95) 2.5px, transparent 3.5px),
    radial-gradient(circle at 85% 26%, rgba(244,63,94,0.95) 2.5px, transparent 3.5px),
    radial-gradient(circle at 95% 18%, rgba(253,224,71,0.95) 2px, transparent 3px),
    radial-gradient(circle at 18% 50%, rgba(255,255,255,0.4) 1px, transparent 1px),
    radial-gradient(circle at 82% 45%, rgba(255,255,255,0.4) 1px, transparent 1px);
  background-size: 100% 100%;
  opacity: 0.85;
}

/* Grand Diagonal Festive Stage Carpet / Dais Floor (Connects Player & Opponent) */
.battlefield::after {
  content: '';
  position: absolute;
  top: 35%;
  left: -15%;
  right: -15%;
  bottom: -10%;
  background: radial-gradient(ellipse at 50% 60%, rgba(212, 175, 55, 0.2) 0%, rgba(36, 99, 67, 0.38) 45%, transparent 75%);
  border-top: 1.5px dashed rgba(212, 175, 55, 0.35);
  pointer-events: none;
  transform: rotate(-4deg);
}

/* Retro Scanline effect overlay */
.battle-scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.16) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 10;
  opacity: 0.4;
}

/* Battle Platforms (Decorated Festive Dais - Locked to Shared Baselines) */
.platform-opponent {
  position: absolute;
  bottom: 50%;
  right: clamp(22px, 7vw, 42px);
  width: clamp(110px, 28vw, 135px);
  height: 32px;
  background: radial-gradient(ellipse at center, #2d7a53 0%, #15452c 65%, rgba(10, 30, 19, 0.6) 100%);
  border-radius: 50%;
  border-bottom: 2px solid #d4af37;
  box-shadow: 0 4px 12px rgba(0,0,0,0.7), 0 0 10px rgba(212, 175, 55, 0.3);
}

.platform-player {
  position: absolute;
  bottom: 4px;
  left: clamp(10px, 3vw, 24px);
  width: clamp(170px, 45vw, 225px);
  height: 50px;
  background: radial-gradient(ellipse at center, #2d7a53 0%, #15452c 65%, rgba(10, 30, 19, 0.6) 100%);
  border-radius: 50%;
  border-bottom: 3.5px solid #d4af37;
  box-shadow: 0 8px 20px rgba(0,0,0,0.85), 0 0 14px rgba(212, 175, 55, 0.4);
}

/* Sprites - Anchored Permanently to Platform Baselines */
.sprite-opponent-container {
  position: absolute;
  bottom: calc(50% + 6px);
  right: clamp(30px, 9vw, 52px);
  width: clamp(85px, 22vw, 110px);
  height: clamp(115px, 23vh, 145px);
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: transform 0.3s ease;
}

.sprite-player-container {
  position: absolute;
  bottom: 14px;
  left: clamp(22px, 5vw, 38px);
  width: clamp(145px, 38vw, 195px);
  height: clamp(180px, 38vh, 250px);
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  transition: transform 0.3s ease;
}

.sprite-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,0.75));
}

/* Slide in animations on battle start */
.sprite-opponent-container.slide-in {
  animation: opponentSlideIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

.sprite-player-container.slide-in {
  animation: playerSlideIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
}

@keyframes opponentSlideIn {
  0% { transform: translateX(180px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

@keyframes playerSlideIn {
  0% { transform: translateX(-180px); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

/* Sprite Battle Actions */
.sprite-tackle {
  animation: spriteTackle 0.4s ease-in-out;
}

@keyframes spriteTackle {
  0% { transform: translate(0, 0); }
  40% { transform: translate(25px, -15px); }
  100% { transform: translate(0, 0); }
}

.sprite-shake {
  animation: spriteShake 0.45s ease-in-out;
}

@keyframes spriteShake {
  0%, 100% { transform: translate(0, 0); filter: brightness(1); }
  20% { transform: translate(-8px, 4px); filter: brightness(1.6) sepia(1) hue-rotate(-50deg); }
  40% { transform: translate(8px, -4px); filter: brightness(1.6); }
  60% { transform: translate(-5px, 2px); filter: brightness(1.3); }
  80% { transform: translate(5px, -2px); }
}

.sprite-heartbeat {
  animation: spriteHeartbeat 0.6s ease-in-out;
}

@keyframes spriteHeartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); filter: drop-shadow(0 0 15px rgba(244, 63, 94, 0.8)); }
}

/* ==========================================================================
   3. RETRO GEN-3 HUD BOXES
   ========================================================================== */
.hud-box {
  position: absolute;
  background: #f8fafc;
  color: #0f172a;
  border: 2.5px solid #334155;
  border-radius: 10px;
  padding: 6px 10px 7px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.6), inset 0 -2px 0 rgba(0,0,0,0.2);
  z-index: 6;
  width: clamp(160px, 44vw, 195px);
}

.hud-box-opponent {
  top: 14px;
  left: 12px;
  border-left: 5px solid var(--pk-rose);
}

.hud-box-player {
  bottom: 22px;
  right: 12px;
  border-right: 5px solid var(--pk-green);
}

.hud-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 3px;
}

.hud-name {
  font-family: var(--pk-font-pixel);
  font-size: 0.5rem;
  font-weight: bold;
  letter-spacing: 0.5px;
  color: #0f172a;
}

.hud-level {
  font-family: var(--pk-font-pixel);
  font-size: 0.42rem;
  color: #475569;
  background: #e2e8f0;
  padding: 2px 4px;
  border-radius: 4px;
}

.hud-bar-container {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-bar-label {
  font-family: var(--pk-font-pixel);
  font-size: 0.4rem;
  font-weight: bold;
  padding: 2px 3px;
  border-radius: 3px;
  min-width: 26px;
  text-align: center;
}

.hud-bar-label.love {
  background: var(--pk-rose);
  color: #fff;
}

.hud-bar-label.conf {
  background: var(--pk-green);
  color: #0f172a;
}

.hud-bar-track {
  flex: 1;
  height: 8px;
  background: #1e293b;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border: 1px solid #475569;
}

.hud-bar-fill {
  height: 100%;
  width: 0%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.4s ease;
  border-radius: 3px;
}

.hud-bar-fill.love {
  background: linear-gradient(90deg, #f43f5e, #fb7185);
  box-shadow: 0 0 6px rgba(244, 63, 94, 0.6);
}

.hud-bar-fill.conf {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.hud-bar-fill.conf.warning {
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.hud-bar-fill.conf.danger {
  background: linear-gradient(90deg, #ef4444, #f87171);
}

.hud-num {
  font-family: var(--pk-font-pixel);
  font-size: 0.4rem;
  color: #334155;
  text-align: right;
  margin-top: 2px;
}

/* ==========================================================================
   4. LOWER CONSOLE & DIALOGUE BOX
   ========================================================================== */
.battle-console {
  background: #0f1318;
  border-top: 2px solid var(--pk-panel-border);
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

/* Retro Typewriter Dialogue Box */
.dialogue-box {
  background: #182028;
  border: 1.5px solid #384554;
  border-radius: 10px;
  padding: 8px 10px;
  min-height: 50px;
  display: flex;
  align-items: center;
  position: relative;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.dialogue-box:hover {
  border-color: var(--pk-gold);
  background: #1f2a36;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.2);
}

.dialogue-box:active {
  transform: scale(0.99);
}

.dialogue-log-hint {
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: var(--pk-font-pixel);
  font-size: 0.38rem;
  color: var(--pk-gold);
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 2px 5px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  gap: 3px;
  opacity: 0.85;
  transition: opacity 0.2s ease;
}

.dialogue-box:hover .dialogue-log-hint {
  opacity: 1;
  background: var(--pk-gold);
  color: #0f1318;
}

.dialogue-text {
  font-family: var(--pk-font-pixel);
  font-size: 0.5rem;
  line-height: 1.6;
  color: var(--pk-text-white);
  letter-spacing: 0.5px;
  margin: 0;
  padding-right: 42px;
  word-break: break-word;
}

.dialogue-cursor {
  display: inline-block;
  width: 6px;
  height: 10px;
  background: var(--pk-gold);
  margin-left: 4px;
  animation: blink 0.7s infinite;
}

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

/* Classic Game Boy Advance Indicator Arrow */
.dialogue-advance-arrow {
  display: none;
  position: absolute;
  bottom: 5px;
  right: 8px;
  font-family: var(--pk-font-pixel);
  font-size: 0.55rem;
  color: var(--pk-gold);
  line-height: 1;
  animation: retroArrowBob 0.45s infinite alternate ease-in-out;
  pointer-events: none;
  user-select: none;
}

.dialogue-advance-arrow.active {
  display: inline-block;
}

@keyframes retroArrowBob {
  0% { transform: translateY(0); opacity: 0.65; }
  100% { transform: translateY(3px); opacity: 1; text-shadow: 0 0 6px rgba(212, 175, 55, 0.7); }
}

/* ==========================================================================
   Message History Log Modal Styles
   ========================================================================== */
.log-modal-card {
  max-width: 440px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 16px 14px 14px;
}

.log-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1.5px solid rgba(212, 175, 55, 0.3);
  padding-bottom: 8px;
  margin-bottom: 6px;
}

.log-modal-title {
  font-family: var(--pk-font-serif);
  font-size: 1.15rem;
  font-weight: bold;
  color: var(--pk-gold);
  display: flex;
  align-items: center;
  gap: 6px;
}

.log-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: var(--pk-gold);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.log-close-btn:hover, .log-close-btn:active {
  background: var(--pk-gold);
  color: #0b0e12;
}

.log-modal-subtitle {
  font-size: 0.68rem;
  color: var(--pk-text-muted);
  text-align: left;
  margin: 0 0 10px;
}

.message-log-list {
  flex: 1;
  overflow-y: auto;
  min-height: 180px;
  max-height: 50vh;
  background: rgba(11, 14, 18, 0.9);
  border: 1.5px solid #28333f;
  border-radius: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  overscroll-behavior: contain;
}

.message-log-list::-webkit-scrollbar {
  width: 5px;
}
.message-log-list::-webkit-scrollbar-track {
  background: #11161c;
}
.message-log-list::-webkit-scrollbar-thumb {
  background: var(--pk-gold);
  border-radius: 3px;
}

.log-entry {
  padding: 6px 8px;
  border-radius: 6px;
  background: #1a222c;
  border-left: 3px solid var(--pk-gold);
  font-family: var(--pk-font-pixel);
  font-size: 0.45rem;
  line-height: 1.6;
  color: #f1f5f9;
  word-break: break-word;
  animation: screenFadeIn 0.2s ease;
}

.log-entry.opponent {
  border-left-color: var(--pk-rose);
  background: #231a22;
}

.log-entry.negative {
  border-left-color: #ef4444;
  background: #271b1d;
}

.log-entry-time {
  font-size: 0.38rem;
  color: var(--pk-text-muted);
  margin-bottom: 2px;
  display: block;
}

/* Action Area (Moves Grid or Prompt) */
.action-area {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.move-btn {
  background: linear-gradient(180deg, #242f3b 0%, #171f28 100%);
  border: 1.5px solid #3e4e60;
  border-radius: 9px;
  padding: 8px 8px;
  color: var(--pk-text-white);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  min-height: 48px;
  transition: all 0.15s ease;
  position: relative;
  text-align: left;
}

.move-btn:hover:not(:disabled), .move-btn:active:not(:disabled) {
  border-color: var(--pk-gold);
  background: linear-gradient(180deg, #324050 0%, #1f2b38 100%);
  transform: translateY(-1.5px);
  box-shadow: 0 4px 10px rgba(212, 175, 55, 0.2);
}

.move-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.move-btn-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.move-btn-title {
  font-family: var(--pk-font-pixel);
  font-size: 0.46rem;
  color: var(--pk-gold-light);
  line-height: 1.3;
}

.move-btn-emoji {
  font-size: 0.85rem;
}

.move-btn-sub {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.58rem;
  color: var(--pk-text-muted);
}

.move-tag {
  font-family: var(--pk-font-pixel);
  font-size: 0.38rem;
  background: rgba(212, 175, 55, 0.2);
  color: var(--pk-gold);
  padding: 1px 4px;
  border-radius: 3px;
}

/* Visual FX Layer */
.vfx-layer {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 15;
  overflow: hidden;
}

.particle-item {
  position: absolute;
  font-size: 1.4rem;
  animation: floatParticle 1s ease-out forwards;
}

@keyframes floatParticle {
  0% { transform: scale(0.4) translateY(0); opacity: 1; }
  100% { transform: scale(1.3) translateY(-60px) rotate(20deg); opacity: 0; }
}

/* Screen Shake Effect */
.screen-shake {
  animation: screenShake 0.4s ease-in-out;
}

@keyframes screenShake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-5px, 5px); }
  50% { transform: translate(5px, -5px); }
  75% { transform: translate(-3px, -3px); }
}

/* ==========================================================================
   5. END GAME MODAL (VICTORY & DEFEAT)
   ========================================================================== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(8, 11, 15, 0.88);
  backdrop-filter: blur(6px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
  animation: screenFadeIn 0.3s ease;
}

.end-card {
  background: linear-gradient(180deg, #1b242e 0%, #0d1217 100%);
  border: 2.5px solid var(--pk-gold);
  border-radius: 20px;
  padding: 24px 18px;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  width: 100%;
  text-align: center;
  box-shadow: 0 15px 40px rgba(0,0,0,0.8), 0 0 30px rgba(212, 175, 55, 0.3);
}

.end-reward-box {
  margin: 14px 0 16px;
  padding: 12px;
  background: rgba(212, 175, 55, 0.08);
  border: 1.5px dashed var(--pk-gold);
  border-radius: 14px;
  animation: rewardGlow 2.5s infinite ease-in-out;
}

@keyframes rewardGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(212, 175, 55, 0.2); }
  50% { box-shadow: 0 0 20px rgba(212, 175, 55, 0.5); }
}

.end-reward-badge {
  font-family: var(--pk-font-pixel);
  font-size: 0.65rem;
  color: var(--pk-gold);
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

.end-reward-img-wrap {
  width: 100%;
  max-height: 240px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid rgba(212, 175, 55, 0.4);
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.end-reward-img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  display: block;
}

.end-reward-hint {
  font-size: 0.72rem;
  color: var(--pk-gold-light);
  margin-top: 8px;
  margin-bottom: 0;
  line-height: 1.4;
}

.end-secret-teaser {
  margin: 10px 0 16px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(212, 175, 55, 0.3);
  border-radius: 10px;
  font-size: 0.72rem;
  color: var(--pk-text-muted);
  line-height: 1.4;
}

.end-title {
  font-family: var(--pk-font-serif);
  font-size: 1.5rem;
  color: var(--pk-gold);
  margin: 10px 0 6px;
}

.end-desc {
  font-size: 0.85rem;
  color: var(--pk-text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

.end-stat-box {
  background: rgba(11, 14, 18, 0.8);
  border: 1px solid rgba(212, 175, 55, 0.3);
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-around;
  margin-bottom: 18px;
}

.end-stat-val {
  font-family: var(--pk-font-pixel);
  font-size: 0.8rem;
  color: var(--pk-gold-light);
  margin-top: 3px;
}

.end-stat-lbl {
  font-size: 0.65rem;
  color: var(--pk-text-muted);
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
