/* ==========================================================================
   RIGGED! — AAA Visual Shell
   Cinematic dark theme with glassmorphism, glow effects, and premium polish
   ========================================================================== */

/* --------------------------------------------------------------------------
   RESET & BASE
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #0a0a1a;
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection {
  background: rgba(255, 51, 51, 0.35);
  color: #fff;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* Focus visible for accessibility */
:focus-visible {
  outline: 2px solid #ff6b6b;
  outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   CANVAS LAYERS & VFX OVERLAYS
   -------------------------------------------------------------------------- */
.layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#bg-canvas {
  z-index: 0;
}

#fx-canvas {
  z-index: 50;
}

#flash-overlay {
  position: fixed;
  inset: 0;
  z-index: 45;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.08s ease-out;
}

#flash-overlay.flash-red {
  background: radial-gradient(circle, rgba(255, 50, 50, 0.5) 0%, rgba(255, 0, 0, 0.15) 100%);
  opacity: 1;
}

#flash-overlay.flash-gold {
  background: radial-gradient(circle, rgba(255, 217, 61, 0.5) 0%, rgba(255, 180, 0, 0.15) 100%);
  opacity: 1;
}

#flash-overlay.flash-white {
  background: rgba(255, 255, 255, 0.35);
  opacity: 1;
}

#crack-overlay {
  position: fixed;
  inset: 0;
  z-index: 46;
  pointer-events: none;
  background-image: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

#crack-overlay.active {
  opacity: 1;
  animation: crack 0.6s ease-out forwards;
}

/* --------------------------------------------------------------------------
   APP CONTAINER
   -------------------------------------------------------------------------- */
#app {
  max-width: 500px;
  width: 100%;
  padding: 0 16px;
  position: relative;
  z-index: 10;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   SCREEN MANAGEMENT
   -------------------------------------------------------------------------- */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  flex: 1;
  padding: 40px 0 20px;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.35s ease-out;
}

/* --------------------------------------------------------------------------
   TYPOGRAPHY
   -------------------------------------------------------------------------- */
.logo {
  font-size: 4.5rem;
  font-weight: 900;
  letter-spacing: -3px;
  color: #fff;
  text-shadow:
    0 0 40px rgba(255, 51, 51, 0.5),
    0 0 80px rgba(255, 51, 51, 0.2),
    0 0 120px rgba(255, 51, 51, 0.1);
  margin-bottom: 4px;
  user-select: none;
  animation: fadeSlideDown 0.6s ease-out;
}

.logo span {
  color: #ff6b6b;
  text-shadow:
    0 0 30px rgba(255, 107, 107, 0.7),
    0 0 60px rgba(255, 107, 107, 0.3);
}

.tagline {
  color: #666;
  font-size: 1.05rem;
  font-style: italic;
  letter-spacing: 0.5px;
  margin-bottom: 28px;
  animation: fadeSlideUp 0.6s ease-out 0.15s both;
}

h2 {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 24px;
  letter-spacing: -0.5px;
}

h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: #ccc;
}

/* --------------------------------------------------------------------------
   TITLE SCREEN
   -------------------------------------------------------------------------- */
#title-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
  margin-bottom: 32px;
  font-size: 0.9rem;
  color: #888;
  animation: fadeSlideUp 0.6s ease-out 0.3s both;
}

#title-stats .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

#title-stats .stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fff;
}

#title-stats .stat-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #555;
}

.title-buttons {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  animation: fadeSlideUp 0.6s ease-out 0.55s both;
}

.back-link {
  color: #555;
  font-size: 0.85rem;
  text-decoration: none;
  margin-top: 40px;
  transition: color 0.3s ease;
  animation: fadeIn 0.6s ease-out 0.7s both;
}

.back-link:hover {
  color: #aaa;
}

/* --------------------------------------------------------------------------
   BUTTONS
   -------------------------------------------------------------------------- */
.btn {
  padding: 14px 36px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  min-height: 44px;
  min-width: 44px;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, transparent 50%);
  pointer-events: none;
}

.btn:hover {
  transform: translateY(-2px);
}

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

/* Play button — red/orange gradient with glow */
.btn-play {
  background: linear-gradient(135deg, #ff3333 0%, #ff6b35 100%);
  color: #fff;
  font-size: 1.3rem;
  padding: 18px 64px;
  border-radius: 16px;
  box-shadow:
    0 4px 24px rgba(255, 51, 51, 0.4),
    0 0 60px rgba(255, 51, 51, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.15);
  animation: fadeSlideUp 0.6s ease-out 0.4s both, glow 3s ease-in-out infinite;
}

.btn-play:hover {
  box-shadow:
    0 6px 32px rgba(255, 51, 51, 0.55),
    0 0 80px rgba(255, 51, 51, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-3px);
}

.btn-play:active {
  box-shadow:
    0 2px 12px rgba(255, 51, 51, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* Shop button — purple gradient */
.btn-shop {
  background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(108, 92, 231, 0.3);
}

.btn-shop:hover {
  box-shadow: 0 6px 28px rgba(108, 92, 231, 0.45);
}

/* Back button — gray gradient */
.btn-back {
  background: linear-gradient(135deg, #2d2d3d 0%, #3a3a4e 100%);
  color: #aaa;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.btn-back:hover {
  color: #ddd;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
}

/* Secondary — transparent with border */
.btn-secondary {
  background: transparent;
  color: #aaa;
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

/* Small variant */
.btn-sm {
  padding: 10px 22px;
  font-size: 0.85rem;
  border-radius: 10px;
  min-height: 40px;
}

/* --------------------------------------------------------------------------
   GAME SELECT CARDS
   -------------------------------------------------------------------------- */
.game-cards {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  margin-bottom: 28px;
}

.select-card {
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 28px 24px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  text-align: center;
  user-select: none;
  animation: fadeSlideUp 0.5s ease-out both;
}

.select-card:nth-child(1) { animation-delay: 0.1s; }
.select-card:nth-child(2) { animation-delay: 0.2s; }
.select-card:nth-child(3) { animation-delay: 0.3s; }
.select-card:nth-child(4) { animation-delay: 0.4s; }

.select-card:hover {
  border-color: rgba(255, 107, 107, 0.35);
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-4px);
  box-shadow:
    0 8px 32px rgba(255, 51, 51, 0.12),
    0 0 0 1px rgba(255, 107, 107, 0.1);
}

.select-card:active {
  transform: scale(0.98);
}

.card-icon {
  font-size: 2.8rem;
  font-weight: 900;
  color: #ff6b6b;
  text-shadow: 0 0 30px rgba(255, 107, 107, 0.4);
  margin-bottom: 12px;
  line-height: 1;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
  letter-spacing: -0.3px;
}

.card-desc {
  font-size: 0.88rem;
  color: #777;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   HUD (IN-GAME TOP BAR)
   -------------------------------------------------------------------------- */
#hud {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 10px 16px;
  background: rgba(10, 10, 26, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 16px;
  font-size: 0.85rem;
  font-weight: 700;
}

.hud-coins {
  color: #ffd93d;
  text-shadow: 0 0 12px rgba(255, 217, 61, 0.3);
}

.hud-round {
  color: #e0e0e0;
}

.hud-record {
  color: #00ff88;
  text-shadow: 0 0 12px rgba(0, 255, 136, 0.3);
}

/* --------------------------------------------------------------------------
   AI PANEL (AVATAR + SPEECH BUBBLE)
   -------------------------------------------------------------------------- */
#ai-panel {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  margin-bottom: 16px;
  min-height: 72px;
}

#ai-avatar {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 51, 51, 0.25);
  box-shadow: 0 0 20px rgba(255, 51, 51, 0.15);
}

#ai-avatar.cheating {
  animation: avatarPulse 1.2s ease-in-out infinite;
}

#ai-avatar.angry {
  animation: avatarRage 0.3s ease-in-out infinite;
}

#ai-bubble {
  position: relative;
  flex: 1;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 16px;
  min-height: 48px;
  display: flex;
  align-items: center;
}

/* Speech bubble triangle */
#ai-bubble::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 18px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 8px solid rgba(255, 255, 255, 0.08);
}

#ai-bubble::after {
  content: '';
  position: absolute;
  left: -6px;
  top: 19px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid rgba(255, 255, 255, 0.04);
}

#ai-dialogue {
  font-size: 0.9rem;
  color: #bbb;
  font-style: italic;
  line-height: 1.4;
  transition: opacity 0.3s ease;
}

#ai-dialogue.fade-out {
  opacity: 0;
}

/* --------------------------------------------------------------------------
   BOARD CANVAS
   -------------------------------------------------------------------------- */
#board-canvas {
  display: block;
  max-width: 100%;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 16px;
  box-shadow:
    0 4px 32px rgba(0, 0, 0, 0.4),
    0 0 60px rgba(255, 51, 51, 0.06);
  margin-bottom: 16px;
}

#board-canvas.shake {
  animation: shake 0.4s ease-in-out;
}

#board-canvas.shake-hard {
  animation: shakeHard 0.5s ease-in-out;
}

/* --------------------------------------------------------------------------
   CHEAT BAR (PLAYER COUNTER-CHEATS)
   -------------------------------------------------------------------------- */
#cheat-bar {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
  margin-bottom: 16px;
  min-height: 40px;
}

.cheat-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  color: #ccc;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  user-select: none;
  min-height: 44px;
}

.cheat-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.cheat-btn.active {
  border-color: rgba(0, 255, 136, 0.5);
  box-shadow: 0 0 16px rgba(0, 255, 136, 0.15);
  color: #00ff88;
  background: rgba(0, 255, 136, 0.06);
}

.cheat-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.cheat-btn .cheat-icon {
  font-size: 1rem;
}

.cheat-btn .cheat-count {
  font-size: 0.7rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  padding: 1px 6px;
  border-radius: 8px;
  min-width: 18px;
  text-align: center;
}

/* --------------------------------------------------------------------------
   GAME CONTROLS (BOTTOM)
   -------------------------------------------------------------------------- */
#game-controls {
  display: flex;
  gap: 12px;
  justify-content: center;
  width: 100%;
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   SHOP SCREEN
   -------------------------------------------------------------------------- */
.shop-title {
  font-size: 1.8rem;
  background: linear-gradient(135deg, #a29bfe, #6c5ce7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}

.shop-coins-display {
  color: #ffd93d;
  font-size: 1.2rem;
  font-weight: 800;
  margin-bottom: 24px;
  text-shadow: 0 0 16px rgba(255, 217, 61, 0.3);
}

.shop-section-title {
  width: 100%;
  margin: 24px 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 215, 0, 0.15);
  color: #ffd93d;
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.shop-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  transition: all 0.3s ease;
  animation: fadeSlideUp 0.4s ease-out both;
}

.shop-item:nth-child(1) { animation-delay: 0.05s; }
.shop-item:nth-child(2) { animation-delay: 0.1s; }
.shop-item:nth-child(3) { animation-delay: 0.15s; }
.shop-item:nth-child(4) { animation-delay: 0.2s; }
.shop-item:nth-child(5) { animation-delay: 0.25s; }
.shop-item:nth-child(6) { animation-delay: 0.3s; }
.shop-item:nth-child(7) { animation-delay: 0.35s; }
.shop-item:nth-child(8) { animation-delay: 0.4s; }

.shop-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(108, 92, 231, 0.25);
}

.shop-item.premium {
  border-color: rgba(255, 215, 0, 0.2);
  background: rgba(255, 215, 0, 0.02);
}

.shop-item.premium:hover {
  border-color: rgba(255, 215, 0, 0.4);
  box-shadow: 0 0 24px rgba(255, 215, 0, 0.08);
}

.shop-item-icon {
  font-size: 1.8rem;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

.shop-item-info {
  flex: 1;
  text-align: left;
}

.shop-item-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  margin-bottom: 2px;
}

.shop-item-desc {
  font-size: 0.75rem;
  color: #666;
  line-height: 1.3;
}

.shop-buy {
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #6c5ce7, #a29bfe);
  color: #fff;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  min-height: 44px;
  min-width: 44px;
}

.shop-buy:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.35);
}

.shop-buy:active {
  transform: scale(0.95);
}

.shop-buy:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.shop-buy.premium-buy {
  background: linear-gradient(135deg, #ffd93d, #f0a500);
  color: #1a1a2e;
}

.shop-buy.premium-buy:hover {
  box-shadow: 0 4px 16px rgba(255, 217, 61, 0.35);
}

/* --------------------------------------------------------------------------
   RESULT OVERLAY
   -------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

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

.overlay-content {
  text-align: center;
  padding: 40px 32px;
  max-width: 380px;
  width: 100%;
  transform: scale(0.9);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.overlay.active .overlay-content {
  transform: scale(1);
  opacity: 1;
}

#result-title {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: -1px;
  margin-bottom: 8px;
}

#result-title.win {
  color: #ffd93d;
  text-shadow:
    0 0 40px rgba(255, 217, 61, 0.5),
    0 0 80px rgba(255, 217, 61, 0.2);
  animation: winGlow 2s ease-in-out infinite;
}

#result-title.loss {
  color: #ff3333;
  text-shadow:
    0 0 40px rgba(255, 51, 51, 0.5),
    0 0 80px rgba(255, 51, 51, 0.2);
}

#result-title.draw {
  color: #e0e0e0;
  text-shadow:
    0 0 30px rgba(255, 255, 255, 0.3);
}

#result-subtitle {
  color: #888;
  font-size: 1rem;
  margin-bottom: 20px;
  font-style: italic;
}

.coins-earned {
  color: #ffd93d;
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 28px;
  text-shadow: 0 0 16px rgba(255, 217, 61, 0.3);
  animation: coinBounce 0.6s ease-out;
}

#result-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   CHEAT LABELS (IN-GAME NOTIFICATIONS)
   -------------------------------------------------------------------------- */
.cheat-label {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  animation: cheatReveal 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin: 2px 4px;
}

.cheat-label.bad {
  background: rgba(255, 51, 51, 0.12);
  color: #ff6b6b;
  border: 1px solid rgba(255, 51, 51, 0.2);
}

.cheat-label.blocked {
  background: rgba(0, 255, 136, 0.1);
  color: #00ff88;
  border: 1px solid rgba(0, 255, 136, 0.2);
  text-decoration: line-through;
}

.cheat-label.info {
  background: rgba(108, 92, 231, 0.12);
  color: #a29bfe;
  border: 1px solid rgba(108, 92, 231, 0.2);
}

/* --------------------------------------------------------------------------
   CROSS-PROMO FOOTER
   -------------------------------------------------------------------------- */
.cross-promo {
  width: 100%;
  max-width: 500px;
  padding: 32px 16px 24px;
  text-align: center;
  position: relative;
  z-index: 10;
}

.cross-promo > p {
  color: #444;
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.cross-promo > p a {
  color: #666;
  text-decoration: none;
  transition: color 0.3s ease;
}

.cross-promo > p a:hover {
  color: #ff6b6b;
}

.promo-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.promo-links a {
  color: #555;
  text-decoration: none;
  font-size: 0.8rem;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
}

.promo-links a:hover {
  color: #ff6b6b;
  border-color: rgba(255, 107, 107, 0.2);
  background: rgba(255, 107, 107, 0.04);
  transform: translateY(-1px);
}

/* --------------------------------------------------------------------------
   ANIMATIONS
   -------------------------------------------------------------------------- */

/* Fade In */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Fade + Slide Up */
@keyframes fadeSlideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade + Slide Down */
@keyframes fadeSlideDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pop In (scale bounce) */
@keyframes popIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  70% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Screen Shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10% { transform: translateX(-6px); }
  20% { transform: translateX(6px); }
  30% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  50% { transform: translateX(-3px); }
  60% { transform: translateX(3px); }
  70% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
  90% { transform: translateX(-1px); }
}

/* Hard Shake (with rotation) */
@keyframes shakeHard {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  10% { transform: translate(-8px, 2px) rotate(-1.5deg); }
  20% { transform: translate(8px, -2px) rotate(1.5deg); }
  30% { transform: translate(-7px, 3px) rotate(-1deg); }
  40% { transform: translate(7px, -1px) rotate(1deg); }
  50% { transform: translate(-5px, 2px) rotate(-0.5deg); }
  60% { transform: translate(5px, -1px) rotate(0.5deg); }
  70% { transform: translate(-3px, 1px) rotate(-0.3deg); }
  80% { transform: translate(3px, 0) rotate(0.3deg); }
  90% { transform: translate(-1px, 0) rotate(0deg); }
}

/* Pulse */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* Glow (box-shadow pulse for play button) */
@keyframes glow {
  0%, 100% {
    box-shadow:
      0 4px 24px rgba(255, 51, 51, 0.4),
      0 0 60px rgba(255, 51, 51, 0.15),
      inset 0 1px 0 rgba(255, 255, 255, 0.15);
  }
  50% {
    box-shadow:
      0 4px 32px rgba(255, 51, 51, 0.55),
      0 0 80px rgba(255, 51, 51, 0.25),
      inset 0 1px 0 rgba(255, 255, 255, 0.2);
  }
}

/* Float (gentle up-down) */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* Spin */
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Glitch (position jitter + color offset) */
@keyframes glitch {
  0%, 100% { transform: translate(0); }
  10% { transform: translate(-2px, 1px); filter: hue-rotate(30deg); }
  20% { transform: translate(2px, -1px); filter: hue-rotate(-30deg); }
  30% { transform: translate(-1px, 2px); filter: hue-rotate(60deg); }
  40% { transform: translate(1px, -2px); filter: none; }
  50% { transform: translate(-2px, -1px); filter: hue-rotate(-60deg); }
  60% { transform: translate(2px, 1px); filter: none; }
  70% { transform: translate(0, -2px); filter: hue-rotate(30deg); }
  80% { transform: translate(-1px, 0); filter: none; }
  90% { transform: translate(1px, 1px); filter: hue-rotate(-30deg); }
}

/* Crack Expansion */
@keyframes crack {
  0% {
    opacity: 0;
    transform: scale(0.8);
    filter: brightness(2);
  }
  30% {
    opacity: 1;
    filter: brightness(1.5);
  }
  100% {
    opacity: 0.8;
    transform: scale(1);
    filter: brightness(1);
  }
}

/* Avatar Pulse (when AI is cheating) */
@keyframes avatarPulse {
  0%, 100% {
    border-color: rgba(255, 51, 51, 0.25);
    box-shadow: 0 0 20px rgba(255, 51, 51, 0.15);
  }
  50% {
    border-color: rgba(255, 51, 51, 0.7);
    box-shadow: 0 0 32px rgba(255, 51, 51, 0.4);
  }
}

/* Avatar Rage (when AI is angry) */
@keyframes avatarRage {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-2px, 1px) rotate(-2deg); }
  50% { transform: translate(2px, -1px) rotate(2deg); }
  75% { transform: translate(-1px, 2px) rotate(-1deg); }
}

/* Confetti Fall */
@keyframes confettiFall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Coin Bounce */
@keyframes coinBounce {
  0% {
    transform: translateY(-20px) scale(0.5);
    opacity: 0;
  }
  50% {
    transform: translateY(4px) scale(1.1);
    opacity: 1;
  }
  70% {
    transform: translateY(-2px) scale(0.98);
  }
  100% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

/* Slide In Left */
@keyframes slideInLeft {
  from {
    transform: translateX(-40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide In Right */
@keyframes slideInRight {
  from {
    transform: translateX(40px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Win Glow (golden pulse for result title) */
@keyframes winGlow {
  0%, 100% {
    text-shadow:
      0 0 40px rgba(255, 217, 61, 0.5),
      0 0 80px rgba(255, 217, 61, 0.2);
  }
  50% {
    text-shadow:
      0 0 60px rgba(255, 217, 61, 0.7),
      0 0 120px rgba(255, 217, 61, 0.35),
      0 0 160px rgba(255, 217, 61, 0.15);
  }
}

/* Cheat Reveal (dramatic pill entrance) */
@keyframes cheatReveal {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(10px);
  }
  60% {
    transform: scale(1.15) translateY(-2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Blind Fog (fog overlay animation) */
@keyframes blindFog {
  0% {
    opacity: 0;
    backdrop-filter: blur(0);
  }
  30% {
    opacity: 1;
    backdrop-filter: blur(20px);
  }
  70% {
    opacity: 1;
    backdrop-filter: blur(20px);
  }
  100% {
    opacity: 0;
    backdrop-filter: blur(0);
  }
}

/* Think Dots (loading indicator) */
@keyframes thinkDots {
  0% { content: '.'; }
  33% { content: '..'; }
  66% { content: '...'; }
}

/* Thinking animation helper */
.thinking::after {
  content: '.';
  animation: thinkDots 1.2s steps(1) infinite;
}

/* --------------------------------------------------------------------------
   UTILITY / HELPER CLASSES
   -------------------------------------------------------------------------- */
.hidden {
  display: none !important;
}

.text-gold {
  color: #ffd93d;
}

.text-red {
  color: #ff3333;
}

.text-green {
  color: #00ff88;
}

.text-purple {
  color: #a29bfe;
}

.animate-pop {
  animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.animate-shake {
  animation: shake 0.4s ease-in-out;
}

.animate-shake-hard {
  animation: shakeHard 0.5s ease-in-out;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

.animate-glitch {
  animation: glitch 0.6s ease-in-out;
}

.animate-slide-left {
  animation: slideInLeft 0.4s ease-out;
}

.animate-slide-right {
  animation: slideInRight 0.4s ease-out;
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Blind overlay (used by AI blind cheat) */
.blind-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(10, 10, 26, 0.95) 0%, rgba(10, 10, 26, 0.98) 100%);
  border-radius: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ff6b6b;
  font-weight: 800;
  font-size: 1.3rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: blindFog 4s ease-in-out forwards;
  pointer-events: none;
}

/* Fog overlay for the board area */
.board-wrapper {
  position: relative;
  width: 100%;
}

/* --------------------------------------------------------------------------
   LEADERBOARD MODAL (generic styling for JS-created modals)
   -------------------------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 42;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  background: rgba(20, 20, 40, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 28px 24px;
  max-width: 420px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-content h2 {
  text-align: center;
  margin-bottom: 16px;
}

.leaderboard-entry {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.2s ease;
}

.leaderboard-entry:nth-child(odd) {
  background: rgba(255, 255, 255, 0.02);
}

.leaderboard-entry .rank {
  font-weight: 800;
  font-size: 1rem;
  color: #555;
  min-width: 28px;
  text-align: center;
}

.leaderboard-entry:nth-child(1) .rank { color: #ffd93d; font-size: 1.2rem; }
.leaderboard-entry:nth-child(2) .rank { color: #c0c0c0; font-size: 1.1rem; }
.leaderboard-entry:nth-child(3) .rank { color: #cd7f32; font-size: 1.05rem; }

.leaderboard-entry .name {
  flex: 1;
  font-weight: 600;
  color: #ddd;
}

.leaderboard-entry .score {
  font-weight: 800;
  color: #ff6b6b;
}

/* --------------------------------------------------------------------------
   TOAST NOTIFICATIONS
   -------------------------------------------------------------------------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 12px 24px;
  background: rgba(20, 20, 40, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #e0e0e0;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 60;
  opacity: 0;
  transition: all 0.3s ease;
  white-space: nowrap;
  pointer-events: none;
}

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

.toast.success {
  border-color: rgba(0, 255, 136, 0.25);
  color: #00ff88;
}

.toast.error {
  border-color: rgba(255, 51, 51, 0.25);
  color: #ff6b6b;
}

/* --------------------------------------------------------------------------
   RESPONSIVE
   -------------------------------------------------------------------------- */

/* Small phones */
@media (max-width: 380px) {
  .logo {
    font-size: 3.5rem;
    letter-spacing: -2px;
  }

  .btn-play {
    padding: 16px 48px;
    font-size: 1.15rem;
  }

  .title-buttons {
    flex-direction: column;
    gap: 8px;
    width: 100%;
  }

  .title-buttons .btn {
    width: 100%;
  }

  #result-title {
    font-size: 2.2rem;
  }

  .select-card {
    padding: 20px 18px;
  }

  .card-icon {
    font-size: 2.2rem;
  }
}

/* Standard mobile */
@media (max-width: 500px) {
  #app {
    padding: 0 12px;
  }

  .screen {
    padding: 28px 0 16px;
  }

  #hud {
    font-size: 0.78rem;
    padding: 8px 12px;
  }

  .shop-item {
    padding: 12px 14px;
  }
}

/* Tablet and up */
@media (min-width: 600px) {
  .game-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  .select-card {
    /* equal height within grid */
  }

  .logo {
    font-size: 5.5rem;
  }

  .tagline {
    font-size: 1.15rem;
  }
}

/* Desktop */
@media (min-width: 900px) {
  body {
    justify-content: center;
  }

  .logo {
    font-size: 6rem;
  }
}

/* --------------------------------------------------------------------------
   REDUCED MOTION
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* --------------------------------------------------------------------------
   HIGH CONTRAST / FORCED COLORS
   -------------------------------------------------------------------------- */
@media (forced-colors: active) {
  .btn {
    border: 2px solid ButtonText;
  }

  .select-card {
    border: 2px solid ButtonText;
  }
}
