/**
 * @file games/chrono-heist/game.css
 * @description Enterprise Tier-1 Theme & Layout Stylesheet for "Chrono Heist: Quantum Overdrive".
 * Standardized to KASINO SSOT Design Tokens, 3D CSS perspective, Flex/Grid architecture, 60 FPS animations.
 */

:root {
  --ch-bg-void: #030508;
  --ch-bg-dark: #07090E;
  --ch-bg-surface: #0E121D;
  --ch-bg-panel: #151B2B;
  --ch-border: #1F293D;
  --ch-border-neon: rgba(0, 245, 160, 0.4);

  --ch-neon-green: #00F5A0;
  --ch-neon-cyan: #00D9F5;
  --ch-neon-purple: #8B5CF6;
  --ch-neon-amber: #F59E0B;
  --ch-neon-rose: #EC4899;
  --ch-neon-danger: #EF4444;

  --ch-font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ch-font-display: 'Outfit', sans-serif;
  --ch-font-mono: 'JetBrains Mono', monospace;

  --ch-glow-green: 0 0 15px rgba(0, 245, 160, 0.5);
  --ch-glow-cyan: 0 0 15px rgba(0, 217, 245, 0.5);
  --ch-glow-purple: 0 0 15px rgba(139, 92, 246, 0.5);
  --ch-glow-amber: 0 0 15px rgba(245, 158, 11, 0.5);
}

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

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--ch-bg-void);
  font-family: var(--ch-font-sans);
  color: #F8FAFC;
  user-select: none;
  -webkit-user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* =========================================================================
   STAGE WRAPPER & BACKGROUND
   ========================================================================= */

#game-stage-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: radial-gradient(circle at 50% 45%, #0d1522 0%, #06080d 65%, #020305 100%);
  overflow: hidden;
  transition: filter 0.3s ease;
}

.stage-ambient-bg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  z-index: 0;
  opacity: 0.92;
  transition: opacity 0.5s ease, filter 0.5s ease;
}

/* Ambient Scanlines & Vignette */
.stage-scanlines {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.35) 50%),
              radial-gradient(circle at center, transparent 40%, rgba(2, 4, 8, 0.8) 100%);
  background-size: 100% 4px, 100% 100%;
  pointer-events: none;
  z-index: 1;
}

/* Chrono-Shift Reverse Time Vignette */
.chrono-shift-vignette {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 120;
  background: radial-gradient(circle at center, transparent 30%, rgba(0, 217, 245, 0.45) 85%, #00F5A0 100%);
  opacity: 0;
  transition: opacity 0.25s ease;
  mix-blend-mode: screen;
}

.chrono-shift-vignette.active {
  opacity: 1;
}

/* Singularity Void Arena Mode (Hold & Win) */
#game-stage-wrapper.singularity-void-active .stage-ambient-bg {
  filter: brightness(0.3) saturate(2) hue-rotate(240deg);
}

/* =========================================================================
   TOP BAR HUD
   ========================================================================= */

.game-top-bar {
  position: relative;
  z-index: 10;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: linear-gradient(180deg, rgba(7, 9, 14, 0.95) 0%, rgba(7, 9, 14, 0) 100%);
  border-bottom: 1px solid rgba(31, 41, 61, 0.6);
}

.game-logo-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-logo {
  font-family: var(--ch-font-display);
  font-size: 1.35rem;
  font-weight: 900;
  letter-spacing: 1.5px;
  background: linear-gradient(90deg, #FFFFFF 0%, var(--ch-neon-green) 50%, var(--ch-neon-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 20px rgba(0, 245, 160, 0.3);
}

.game-badge-heist {
  font-family: var(--ch-font-mono);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid var(--ch-neon-purple);
  color: #C084FC;
  letter-spacing: 1px;
}

.top-center-stats {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Multiplier Meter Badge with Progressive Visual Tiers */
.top-multiplier-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: rgba(14, 18, 29, 0.9);
  border: 1px solid var(--ch-neon-cyan);
  border-radius: 6px;
  box-shadow: 0 0 10px rgba(0, 217, 245, 0.25);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.top-multiplier-meter.pulsing {
  transform: scale(1.15);
}

/* Tier 1: Cyan (x1 - x3) */
.top-multiplier-meter.tier-cyan {
  border-color: var(--ch-neon-cyan);
  box-shadow: 0 0 12px rgba(0, 217, 245, 0.4);
}
.top-multiplier-meter.tier-cyan .multiplier-meter-val {
  color: var(--ch-neon-cyan);
  text-shadow: 0 0 8px var(--ch-neon-cyan);
}

/* Tier 2: Violet Overload (x4 - x9) */
.top-multiplier-meter.tier-violet {
  border-color: var(--ch-neon-purple);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.6);
  background: rgba(21, 15, 38, 0.9);
}
.top-multiplier-meter.tier-violet .multiplier-meter-val {
  color: #C084FC;
  text-shadow: 0 0 10px #A855F7;
}

/* Tier 3: Golden Core (x10 - x24) */
.top-multiplier-meter.tier-gold {
  border-color: var(--ch-neon-amber);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.7);
  background: rgba(35, 23, 7, 0.9);
}
.top-multiplier-meter.tier-gold .multiplier-meter-val {
  color: #FDE68A;
  text-shadow: 0 0 12px #F59E0B;
}

/* Tier 4: Prismatic Quantum Overdrive (x25+) */
.top-multiplier-meter.tier-prismatic {
  border-color: #FFFFFF;
  box-shadow: 0 0 25px rgba(255, 255, 255, 0.8), 0 0 45px rgba(0, 245, 160, 0.6);
  background: linear-gradient(135deg, rgba(14, 18, 29, 0.95), rgba(76, 29, 149, 0.95));
  animation: prismaticGlow 2s ease-in-out infinite alternate;
}
.top-multiplier-meter.tier-prismatic .multiplier-meter-val {
  background: linear-gradient(90deg, #FFFFFF, #00F5A0, #00D9F5, #C084FC);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}

@keyframes prismaticGlow {
  0% { box-shadow: 0 0 20px rgba(0, 245, 160, 0.7); }
  50% { box-shadow: 0 0 30px rgba(0, 217, 245, 0.85); }
  100% { box-shadow: 0 0 40px rgba(139, 92, 246, 0.9); }
}

.multiplier-meter-label {
  font-family: var(--ch-font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: #94A3B8;
  letter-spacing: 1px;
}

.multiplier-meter-val {
  font-family: var(--ch-font-mono);
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--ch-neon-cyan);
}

/* Free Spins / Respins Counter Pill */
.bonus-counter-pill {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--ch-neon-amber);
  border-radius: 6px;
  box-shadow: var(--ch-glow-amber);
}

.bonus-counter-pill.active {
  display: flex;
}

.bonus-counter-title {
  font-family: var(--ch-font-display);
  font-size: 0.75rem;
  font-weight: 800;
  color: #FDE68A;
  letter-spacing: 1px;
}

.bonus-counter-val {
  font-family: var(--ch-font-mono);
  font-size: 1rem;
  font-weight: 900;
  color: var(--ch-neon-amber);
}

/* =========================================================================
   MAIN PLAY AREA (GRID + LIVING HACKER AVATAR)
   ========================================================================= */

.game-main-content {
  position: relative;
  z-index: 5;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  gap: 20px;
  overflow: hidden;
}

/* 2.5D Living Hacker Avatar Container */
#hacker-avatar-container {
  position: relative;
  width: 220px;
  height: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  pointer-events: none;
  transition: transform 0.35s ease, filter 0.35s ease;
}

.avatar-graphic {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 15px rgba(0, 245, 160, 0.3));
  animation: avatarIdleBreathe 4s ease-in-out infinite alternate;
  transition: transform 0.3s ease, filter 0.3s ease;
}

@keyframes avatarIdleBreathe {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-8px) scale(1.015); }
}

/* Avatar Enterprise Reactive States */
.avatar-aiming .avatar-graphic {
  transform: translateY(-6px) scale(1.04) rotate(-2deg);
  filter: drop-shadow(0 0 30px #EF4444) brightness(1.3);
}

.avatar-near-miss .avatar-graphic {
  animation: avatarGlitchShake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes avatarGlitchShake {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  30%, 70% { transform: translate3d(4px, 0, 0); }
  50% { transform: translate3d(-4px, 0, 0); }
}

.avatar-overdrive .avatar-graphic {
  transform: translateY(-12px) scale(1.06);
  filter: drop-shadow(0 0 45px #F59E0B) brightness(1.4);
}

.avatar-victory .avatar-graphic {
  transform: translateY(-14px) scale(1.08);
  filter: drop-shadow(0 0 45px #00F5A0) brightness(1.35);
}

/* Canvas Container */
#game-canvas-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(920px, calc(100vw - 280px));
  height: min(600px, calc(100vh - 160px));
}

#game-canvas-container canvas {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain;
  border-radius: 12px;
  filter: drop-shadow(0 0 25px rgba(0, 245, 160, 0.15));
}

/* Screen Shake Physics */
.screen-shake-subtle {
  animation: shakeSubtle 0.25s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.screen-shake-heavy {
  animation: shakeHeavy 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

.screen-shake-rotary {
  animation: shakeRotary 0.65s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shakeSubtle {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-2px, 0, 0); }
  40%, 60% { transform: translate3d(2px, 0, 0); }
}

@keyframes shakeHeavy {
  10%, 90% { transform: translate3d(-4px, -2px, 0); }
  20%, 80% { transform: translate3d(5px, 3px, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, -3px, 0); }
  40%, 60% { transform: translate3d(6px, 2px, 0); }
}

@keyframes shakeRotary {
  10%, 90% { transform: translate3d(-5px, 0, 0) rotate(-1.5deg); }
  30%, 70% { transform: translate3d(6px, 0, 0) rotate(1.5deg); }
  50% { transform: translate3d(-6px, 0, 0) rotate(-1deg); }
}

/* =========================================================================
   STAGE 1: THE BREACH 3D SERVER TERMINALS
   ========================================================================= */

#pick-click-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 5, 8, 0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.35s ease;
  perspective: 1200px;
}

#pick-click-overlay.active {
  display: flex;
  opacity: 1;
}

.breach-header {
  text-align: center;
  margin-bottom: 24px;
}

.breach-title {
  font-family: var(--ch-font-display);
  font-size: 2.1rem;
  font-weight: 900;
  color: #FFFFFF;
  letter-spacing: 2px;
  text-shadow: 0 0 15px var(--ch-neon-cyan);
}

.breach-subtitle {
  font-family: var(--ch-font-mono);
  font-size: 0.92rem;
  color: var(--ch-neon-green);
  margin-top: 6px;
  letter-spacing: 1px;
}

.breach-picks-left {
  display: inline-block;
  margin-top: 10px;
  padding: 4px 16px;
  background: rgba(0, 245, 160, 0.15);
  border: 1px solid var(--ch-neon-green);
  border-radius: 20px;
  font-family: var(--ch-font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--ch-neon-green);
  box-shadow: 0 0 10px rgba(0, 245, 160, 0.3);
}

.breach-terminals-grid {
  display: grid;
  grid-template-columns: repeat(3, 190px);
  grid-gap: 24px;
  transform-style: preserve-3d;
}

/* 3D Server Terminal Card */
.server-terminal-card {
  position: relative;
  width: 190px;
  height: 200px;
  background: linear-gradient(145deg, #151B2B, #0E121D);
  border: 1.5px solid var(--ch-border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 16px;
  transform-style: preserve-3d;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), border-color 0.2s ease, box-shadow 0.2s ease;
  user-select: none;
}

.server-terminal-card:not(.revealed):hover {
  transform: translateY(-10px) rotateX(12deg) scale(1.05);
  border-color: var(--ch-neon-green);
  box-shadow: 0 14px 30px rgba(0, 245, 160, 0.35);
}

.server-terminal-card:not(.revealed):active {
  transform: translateY(-2px) scale(0.98);
}

/* Golden Super Breach Variant */
.server-terminal-card.super-breach-terminal {
  border-color: var(--ch-neon-amber);
  background: linear-gradient(145deg, #2b1f0e, #130d07);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.4);
}

.server-terminal-card.super-breach-terminal:not(.revealed):hover {
  border-color: #FFFBEB;
  box-shadow: 0 14px 35px rgba(245, 158, 11, 0.6);
}

.terminal-icon {
  width: 76px;
  height: 76px;
  margin-bottom: 12px;
  transition: transform 0.35s ease;
}

.server-terminal-card:not(.revealed):hover .terminal-icon {
  transform: scale(1.1) rotate(-3deg);
}

.terminal-status-tag {
  font-family: var(--ch-font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: #94A3B8;
  letter-spacing: 1px;
}

.server-terminal-card.revealed {
  border-color: var(--ch-neon-cyan);
  box-shadow: 0 0 25px rgba(0, 217, 245, 0.5);
  cursor: default;
  pointer-events: none;
  background: linear-gradient(145deg, #0e1828, #070c16);
  animation: revealCardFlip 0.45s ease-out;
}

@keyframes revealCardFlip {
  0% { transform: rotateY(90deg); opacity: 0; }
  100% { transform: rotateY(0deg); opacity: 1; }
}

.server-terminal-card.revealed .terminal-prize-title {
  font-family: var(--ch-font-display);
  font-size: 1.15rem;
  font-weight: 800;
  color: #FFFFFF;
  margin-top: 6px;
  text-align: center;
}

.server-terminal-card.revealed .terminal-prize-val {
  font-family: var(--ch-font-mono);
  font-size: 1.05rem;
  font-weight: 900;
  color: var(--ch-neon-green);
  margin-top: 4px;
}

/* =========================================================================
   WARP PORTAL STAGE TRANSITION FX
   ========================================================================= */

.vault-warp-portal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 150;
  background: radial-gradient(circle at center, rgba(0, 245, 160, 0.85) 0%, rgba(0, 217, 245, 0.7) 35%, rgba(139, 92, 246, 0.5) 65%, #030508 100%);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.4s ease, transform 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

.vault-warp-portal.active {
  opacity: 1;
  transform: scale(1.8);
}

/* =========================================================================
   CONTROLS BAR & CELEBRATION MOUNT POINTS
   ========================================================================= */

#controls-root {
  position: relative;
  z-index: 20;
  width: 100%;
}

#celebration-root {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 200;
}

/* Multiplier Badge in Controls Bar */
.js-multiplier-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border-radius: 4px;
  background: rgba(0, 217, 245, 0.2);
  border: 1px solid var(--ch-neon-cyan);
  color: var(--ch-neon-cyan);
  font-family: var(--ch-font-mono);
  font-weight: 800;
  font-size: 0.85rem;
  box-shadow: 0 0 8px rgba(0, 217, 245, 0.4);
  transition: transform 0.15s ease;
}

.js-multiplier-badge.pulse {
  transform: scale(1.25);
  border-color: #FFFFFF;
  color: #FFFFFF;
}

/* =========================================================================
   RESPONSIVE DESIGN (TABLET & MOBILE)
   ========================================================================= */

@media (max-width: 1100px) {
  #hacker-avatar-container {
    width: 140px;
    height: 380px;
  }
  #game-canvas-container {
    width: calc(100vw - 180px);
  }
}

@media (max-width: 820px) {
  #hacker-avatar-container {
    display: none;
  }
  #game-canvas-container {
    width: 98vw;
    height: calc(100vh - 150px);
  }
  .breach-terminals-grid {
    grid-template-columns: repeat(2, 140px);
    grid-gap: 14px;
  }
  .server-terminal-card {
    width: 140px;
    height: 155px;
  }
  .terminal-icon {
    width: 54px;
    height: 54px;
  }
}
