/* Reset & Luxury Iridescent Pearl & Platinum Silver Theme - Hebrew RTL */
:root {
  --warm-bg: #f8fafc;
  --warm-card-bg: rgba(255, 255, 255, 0.98);
  --warm-peach: #94a3b8;
  --warm-amber: #64748b;
  --warm-gold: #cbd5e1;
  --gold-gradient: linear-gradient(135deg, #ffffff 0%, #cbd5e1 50%, #64748b 100%);
  --gold-border: linear-gradient(135deg, #ffffff, #94a3b8, #334155);

  --girl-pink: #f43f5e;
  --girl-warm-pink: #fb7185;
  --girl-bg-gradient: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);

  --boy-blue: #0284c7;
  --boy-warm-blue: #38bdf8;
  --boy-bg-gradient: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);

  --joke-purple: #9333ea;
  --joke-green: #10b981;

  --text-main: #0f172a;
  --text-muted: #475569;
  --font-heading: 'Rubik', 'Fredoka', sans-serif;
  --font-body: 'Heebo', 'Outfit', sans-serif;

  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;

  --shadow-warm: 0 20px 50px rgba(15, 23, 42, 0.08);
  --shadow-silver: 0 12px 35px rgba(148, 163, 184, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  font-family: var(--font-body);
  background-color: var(--warm-bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  direction: rtl;
}

/* Ambient Background & Sunburst Rays (Frosted Pearl, Soft Rose & Sky Aurora) */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

#bgStardustCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(85px);
  opacity: 0.65;
  animation: floatWarmOrb 12s infinite alternate ease-in-out;
}

.orb-warm-gold {
  width: 500px;
  height: 500px;
  background: #f1f5f9;
  top: -80px;
  right: -60px;
}

.orb-rose-peach {
  width: 520px;
  height: 520px;
  background: #fce7f3;
  bottom: -100px;
  left: -60px;
  animation-delay: -5s;
  opacity: 0.5;
}

.orb-cream-amber {
  width: 440px;
  height: 440px;
  background: #e2e8f0;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-delay: -2.5s;
  opacity: 0.45;
}

.orb-soft-sky {
  width: 520px;
  height: 520px;
  background: #e0f2fe;
  top: -60px;
  left: -60px;
  animation-delay: -7s;
  opacity: 0.5;
}

@keyframes floatWarmOrb {
  0% { transform: translateY(0) scale(1) rotate(0deg); }
  50% { transform: translateY(40px) scale(1.1) rotate(15deg); }
  100% { transform: translateY(-30px) scale(1.15) rotate(-10deg); }
}

.sunburst-rays {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140vmax;
  height: 140vmax;
  margin-top: -70vmax;
  margin-left: -70vmax;
  background: repeating-conic-gradient(
    from 0deg,
    rgba(203, 213, 225, 0.09) 0deg 15deg,
    transparent 15deg 30deg
  );
  animation: rotateRays 90s linear infinite;
}

@keyframes rotateRays {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* App Container */
.app-container {
  width: 100%;
  max-width: 960px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  z-index: 1;
}

/* Topbar Toolbar */
.app-topbar {
  width: 100%;
  max-width: 520px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.action-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: space-between;
  width: 100%;
}

.btn-icon, .btn-secondary, .btn-primary {
  font-family: var(--font-body);
  font-weight: 700;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.btn-icon {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 8px 8px;
  font-size: 0.84rem;
  color: #334155;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  flex: 1;
  white-space: nowrap;
}

.btn-icon:hover, .btn-secondary:hover {
  background: #f1f5f9;
  transform: translateY(-2px);
}

.btn-secondary {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 8px 8px;
  font-size: 0.84rem;
  color: #334155;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  flex: 1;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #334155, #0f172a);
  color: white;
  padding: 14px 32px;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.25);
}

.btn-primary:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 15px 35px rgba(15, 23, 42, 0.35);
}

/* MAIN GAME CARD FRAME - IRIDESCENT PEARL & PLATINUM SILVER */
.main-card-frame {
  width: 100%;
  max-width: 520px;
  background: var(--warm-card-bg);
  border: 4px solid #cbd5e1;
  border-radius: var(--radius-xl);
  padding: 24px 18px 20px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-decorations .decor-sparkle {
  position: absolute;
  font-size: 1.6rem;
  z-index: 10;
  pointer-events: none;
  animation: floatSparkle 3s infinite alternate ease-in-out;
}

.decor-sparkle.top-left { top: -14px; right: -10px; }
.decor-sparkle.top-right { top: -14px; left: -10px; animation-delay: -1s; }
.decor-sparkle.bottom-left { bottom: -14px; right: -10px; animation-delay: -2s; }
.decor-sparkle.bottom-right { bottom: -14px; left: -10px; animation-delay: -1.5s; }

@keyframes floatSparkle {
  0% { transform: scale(1) rotate(0deg); }
  100% { transform: scale(1.25) rotate(15deg); }
}

.card-header {
  text-align: center;
  margin-bottom: 12px;
}

.card-header h2 {
  font-family: var(--font-heading);
  font-size: 1.9rem;
  color: #1e293b;
  margin-bottom: 4px;
  font-weight: 800;
  white-space: nowrap;
}

.card-header p {
  font-size: 0.96rem;
  color: #475569;
  font-weight: 500;
  white-space: nowrap;
}

/* Suspense Status Banner */
.suspense-status-banner {
  width: 100%;
  max-width: 460px;
  min-height: 38px;
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  border-radius: 20px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.86rem;
  color: #334155;
  margin-bottom: 14px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.3s ease;
}

.suspense-status-banner.tension-pulse {
  background: #ffe4e6;
  border-color: #fda4af;
  color: #e11d48;
}

/* 4-IN-A-ROW 4x4 BOARD */
.tictactoe-board-wrapper {
  position: relative;
  padding: 0;
  width: 100%;
  display: flex;
  justify-content: center;
}

.tictactoe-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 50%, #f1f5f9 100%);
  padding: 12px;
  border-radius: var(--radius-lg);
  border: 5px solid #cbd5e1;
  box-shadow: inset 0 6px 15px rgba(15, 23, 42, 0.04), 0 15px 35px rgba(0,0,0,0.06);
  position: relative;
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1 / 1;
}

.tictactoe-board.board-4x4 {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  width: 100%;
  max-width: 460px;
  aspect-ratio: 1 / 1;
}

.ttt-cell {
  position: relative;
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 40%, #f1f5f9 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08), inset 0 2px 4px rgba(255,255,255,0.9);
  border: 3px solid #cbd5e1;
  overflow: hidden;
  transition: all 0.4s ease;
}

/* PULSING LIQUID ROSE-SILVER HALO ON WINNING 4 COINS (NO UGLY STRIKETHROUGH LINE) */
.ttt-cell.winning-cell-highlight {
  border-color: #fb7185;
  box-shadow: 0 0 25px rgba(251, 113, 133, 0.8), inset 0 0 15px rgba(255, 255, 255, 0.95);
  animation: winningCellShimmer 1s infinite alternate ease-in-out;
  transform: scale(1.05);
  z-index: 5;
}

@keyframes winningCellShimmer {
  0% {
    box-shadow: 0 0 15px rgba(251, 113, 133, 0.6), inset 0 0 10px rgba(255, 255, 255, 0.8);
    transform: scale(1.03);
  }
  100% {
    box-shadow: 0 0 30px rgba(244, 63, 94, 0.95), 0 0 50px rgba(203, 213, 225, 0.8), inset 0 0 16px rgba(255, 255, 255, 1);
    transform: scale(1.08);
  }
}

.ttt-under-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-align: center;
  padding: 4px;
}

.ttt-symbol {
  font-size: 2.8rem;
  line-height: 1;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.ttt-symbol-label {
  font-family: var(--font-heading);
  font-size: 0.84rem;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}

.ttt-under-content.girl-cell .ttt-symbol-label {
  color: var(--girl-pink);
  text-shadow: 0 1px 3px rgba(244, 63, 94, 0.25);
}

.ttt-under-content.boy-cell .ttt-symbol-label {
  color: var(--boy-blue);
  text-shadow: 0 1px 3px rgba(2, 132, 199, 0.25);
}

.ttt-under-content.joke-twins-cell .ttt-symbol-label {
  color: var(--joke-purple);
  font-size: 0.76rem;
  font-weight: 800;
}

.ttt-under-content.joke-alien-cell .ttt-symbol-label {
  color: var(--joke-green);
  font-size: 0.76rem;
  font-weight: 800;
}

.scratch-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  cursor: pointer;
  touch-action: none;
  transition: opacity 0.4s ease;
  z-index: 2;
}

/* BALLOONS FESTIVE ANIMATION */
.balloon-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  overflow: hidden;
}

.balloon {
  position: absolute;
  bottom: -100px;
  width: 60px;
  height: 75px;
  border-radius: 50% 50% 50% 50% / 40% 40% 60% 60%;
  animation: floatUpBalloon 6s linear forwards;
}

.balloon::after {
  content: "";
  position: absolute;
  bottom: -12px;
  left: 50%;
  width: 2px;
  height: 16px;
  background: rgba(0,0,0,0.2);
  transform: translateX(-50%);
}

@keyframes floatUpBalloon {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-110vh) rotate(20deg); opacity: 0.8; }
}

/* REVEAL MODAL */
.reveal-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(14px);
}

.modal-content {
  position: relative;
  background: #ffffff;
  width: 100%;
  max-width: 480px;
  border-radius: var(--radius-xl);
  padding: 44px 32px 32px;
  text-align: center;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.3);
  transform: scale(0.8) translateY(20px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 6px solid #cbd5e1;
}

.reveal-modal.active .modal-content {
  transform: scale(1) translateY(0);
}

.reveal-ribbon {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, #475569, #1e293b);
  color: white;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 800;
  padding: 8px 28px;
  border-radius: 30px;
  box-shadow: 0 6px 16px rgba(71, 85, 105, 0.35);
  letter-spacing: 1px;
}

.reveal-badge-icon {
  font-size: 5.5rem;
  margin: 12px 0 16px;
}

.reveal-title {
  font-family: var(--font-heading);
  font-size: 2.6rem;
  margin-bottom: 12px;
  color: var(--girl-pink);
  font-weight: 900;
}

.reveal-message {
  font-size: 1.15rem;
  color: #334155;
  margin-bottom: 28px;
  line-height: 1.6;
  font-weight: 600;
}

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

/* Canvas Layers */
#sparklerCanvas, #confettiCanvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

#sparklerCanvas { z-index: 95; }
#confettiCanvas { z-index: 98; }

/* Responsive Mobile Rules */
@media (max-width: 600px) {
  .app-container {
    padding: 12px 10px;
    gap: 12px;
  }
  .main-card-frame {
    padding: 18px 12px 16px;
    border-radius: var(--radius-lg);
  }
  .card-decorations .decor-sparkle {
    font-size: 1.3rem;
  }
  .decor-sparkle.top-left { top: -10px; right: -6px; }
  .decor-sparkle.top-right { top: -10px; left: -6px; }
  .decor-sparkle.bottom-left { bottom: -10px; right: -6px; }
  .decor-sparkle.bottom-right { bottom: -10px; left: -6px; }

  .action-buttons {
    gap: 4px;
  }
  .btn-icon, .btn-secondary {
    padding: 6px 4px;
    font-size: 0.76rem;
  }
  .card-header h2 {
    font-size: 1.45rem;
  }
  .card-header p {
    font-size: 0.82rem;
    white-space: nowrap;
  }
  .suspense-status-banner {
    font-size: 0.78rem;
    padding: 4px 8px;
    min-height: 32px;
    margin-bottom: 10px;
  }
  .tictactoe-board.board-4x4 {
    width: 100%;
    max-width: calc(100vw - 44px);
    aspect-ratio: 1 / 1;
    gap: 6px;
    padding: 8px;
    border-width: 4px;
  }
  .ttt-cell {
    aspect-ratio: 1 / 1;
    border-width: 2.5px;
  }
  .ttt-symbol {
    font-size: 1.7rem;
  }
  .ttt-symbol-label {
    font-size: 0.62rem;
  }
}
