/* ==========================================================================
   ROMANTIC JIGSAW PUZZLE - LUXURY STYLESHEET
   Design: Velvet Night & Rose Gold Glassmorphism
   Target: Desktop & Mobile Responsive
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-dark: #0d0611;
  --bg-gradient: radial-gradient(circle at 50% 0%, #290d23 0%, #150718 55%, #0a030d 100%);
  --surface-glass: rgba(30, 13, 32, 0.75);
  --surface-glass-card: rgba(40, 16, 42, 0.65);
  --surface-border: rgba(255, 120, 160, 0.22);
  --surface-border-hover: rgba(255, 120, 160, 0.45);
  
  --primary-rose: #ff4d79;
  --primary-rose-glow: rgba(255, 77, 121, 0.45);
  --primary-gradient: linear-gradient(135deg, #ff5c8a 0%, #e02251 100%);
  
  --gold-accent: #f4c067;
  --gold-gradient: linear-gradient(135deg, #fce09b 0%, #d89b34 100%);
  --gold-glow: rgba(244, 192, 103, 0.4);

  --text-main: #fff5f8;
  --text-muted: #d8b7c7;
  --text-subtle: #9d7b8f;
  
  --board-bg: #1a0b1f;
  --shadow-lux: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 25px rgba(255, 77, 121, 0.2);
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 8px;
  
  --font-family: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
  --transition-smooth: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Base Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  font-family: var(--font-family);
  background: var(--bg-dark);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-main);
  overflow-x: hidden;
  direction: rtl;
  text-align: right;
  line-height: 1.5;
}

/* Background Ambient Canvas */
#ambient-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 0;
  opacity: 0.65;
}

/* Main App Wrapper */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Screen Transitions */
.screen {
  display: none;
  width: 100%;
  min-height: 100vh;
  opacity: 0;
  transition: opacity 0.35s ease;
}

.screen.active {
  display: flex;
  flex-direction: column;
  opacity: 1;
}

/* ==========================================================================
   BUTTONS & COMMON COMPONENTS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 22px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  user-select: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 8px 24px var(--primary-rose-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(255, 77, 121, 0.6);
}

.btn-primary:active {
  transform: translateY(1px);
}

.btn-secondary {
  background: var(--surface-glass-card);
  color: var(--text-main);
  border: 1px solid var(--surface-border);
  backdrop-filter: blur(12px);
}

.btn-secondary:hover {
  border-color: var(--primary-rose);
  background: rgba(60, 24, 62, 0.75);
  transform: translateY(-2px);
}

.btn-large {
  padding: 14px 38px;
  font-size: 1.2rem;
  border-radius: var(--radius-lg);
}

.pulse-glow {
  animation: pulseGlow 2.4s infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 8px 24px var(--primary-rose-glow);
  }
  50% {
    box-shadow: 0 8px 36px rgba(255, 77, 121, 0.8), 0 0 15px rgba(244, 192, 103, 0.4);
  }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ==========================================================================
   1. START SCREEN STYLES
   ========================================================================== */

.start-content {
  max-width: 1050px;
  margin: 0 auto;
  padding: 30px 20px 60px;
  width: 100%;
}

.app-header {
  text-align: center;
  margin-bottom: 35px;
}

.romantic-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px;
  background: rgba(255, 77, 121, 0.12);
  border: 1px solid rgba(255, 77, 121, 0.35);
  border-radius: 999px;
  color: #ff9cb7;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.main-title {
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 900;
  background: linear-gradient(135deg, #ffffff 30%, #ffb6c7 70%, #f4c067 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto;
}

/* Config Sections */
.config-section {
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 28px;
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.1rem;
}

.section-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text-main);
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.gallery-card {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  background: #1e0b1f;
  transition: var(--transition-smooth);
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.gallery-card:hover {
  transform: translateY(-4px);
  border-color: var(--surface-border-hover);
  box-shadow: 0 12px 25px rgba(0, 0, 0, 0.5);
}

.gallery-card:hover img {
  transform: scale(1.06);
}

.gallery-card.selected {
  border-color: var(--primary-rose);
  box-shadow: 0 0 25px var(--primary-rose-glow), 0 0 10px rgba(244, 192, 103, 0.4);
  transform: scale(1.02);
}

.gallery-card .card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  opacity: 0;
  transform: scale(0.5);
  transition: var(--transition-smooth);
}

.gallery-card.selected .card-badge {
  opacity: 1;
  transform: scale(1);
}

.gallery-card .card-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 18px 10px 8px;
  background: linear-gradient(to top, rgba(10, 3, 12, 0.92) 0%, rgba(10, 3, 12, 0) 100%);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
}

/* Custom Upload Bar */
.custom-upload-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 120, 160, 0.12);
}

.upload-note {
  font-size: 0.9rem;
  color: var(--text-subtle);
}

/* Difficulty Cards */
.difficulty-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.diff-card {
  position: relative;
  background: var(--surface-glass-card);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  cursor: pointer;
  transition: var(--transition-smooth);
  display: flex;
  flex-direction: column;
}

.diff-card input[type="radio"] {
  position: absolute;
  opacity: 0;
}

.diff-card:hover {
  border-color: var(--surface-border-hover);
  background: rgba(55, 20, 58, 0.7);
  transform: translateY(-2px);
}

.diff-card.active {
  border-color: var(--gold-accent);
  background: rgba(65, 22, 60, 0.85);
  box-shadow: 0 0 20px var(--gold-glow);
}

.diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.diff-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-main);
}

.diff-card.active .diff-name {
  color: var(--gold-accent);
}

.diff-badge {
  font-size: 0.85rem;
  font-weight: 700;
  padding: 2px 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-muted);
}

.diff-pieces {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary-rose);
  margin-bottom: 0;
}

.diff-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Start Action Box */
.start-action-box {
  text-align: center;
  margin-top: 15px;
}

/* ==========================================================================
   2. GAME SCREEN STYLES
   ========================================================================== */

#game-screen {
  background: var(--bg-dark);
}

/* Sticky HUD */
.game-hud {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(20, 8, 22, 0.92);
  border-bottom: 1px solid var(--surface-border);
  backdrop-filter: blur(16px);
  padding: 8px 16px 6px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.hud-top-row {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hud-controls-group,
.hud-actions-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-hud {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 6px 12px;
  font-size: 0.9rem;
  border-radius: var(--radius-sm);
  gap: 5px;
}

.btn-hud:hover {
  background: rgba(255, 77, 121, 0.2);
  border-color: var(--primary-rose);
}

.hud-stats-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--surface-border);
  padding: 5px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
}

.stat-label {
  color: var(--text-subtle);
  font-size: 0.85rem;
}

.timer-pill .stat-value {
  color: var(--gold-accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
}

.progress-pill .stat-value {
  color: var(--primary-rose);
}

/* Progress Bar */
.hud-progress-bar-wrap {
  width: 100%;
  max-width: 1300px;
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  margin: 6px auto 4px;
  overflow: hidden;
}

.hud-progress-fill {
  height: 100%;
  background: linear-gradient(to left, var(--primary-rose), var(--gold-accent));
  transition: width 0.35s ease;
  box-shadow: 0 0 10px var(--primary-rose);
}

/* Sub-ticker */
.hud-sub-ticker {
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-subtle);
  padding-top: 2px;
}

.badge-mini {
  background: rgba(255, 77, 121, 0.12);
  color: #ff99b3;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}

.status-hint {
  color: var(--text-muted);
  font-weight: 600;
}

/* Main Play Area */
.game-play-area {
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  padding: 16px;
  display: grid;
  grid-template-columns: 240px 1fr 340px;
  gap: 20px;
  align-items: start;
  flex: 1;
}

/* ==========================================================================
   REFERENCE PREVIEW PANEL (صورة الحل الأصلية)
   ========================================================================== */

.reference-panel {
  width: 100%;
}

.reference-card {
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}

.ref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.ref-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.btn-ref-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text-main);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-ref-toggle:hover {
  background: var(--primary-rose);
}

.ref-img-wrapper {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.ref-img-wrapper img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.3s ease;
}

.ref-img-wrapper:hover img {
  transform: scale(1.04);
}

.ref-overlay-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(10, 3, 12, 0.85);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  color: #ff9cb7;
}

/* ==========================================================================
   BOARD COLUMN (لوحة تركيب الأحجية)
   ========================================================================== */

.board-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.board-outer-frame {
  position: relative;
  padding: 10px;
  background: linear-gradient(145deg, rgba(50, 18, 48, 0.8) 0%, rgba(20, 8, 22, 0.95) 100%);
  border: 2px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lux);
  max-width: 100%;
  display: inline-block;
  user-select: none;
}

.puzzle-board-container {
  position: relative;
  background: var(--board-bg);
  border-radius: var(--radius-md);
  overflow: visible;
  touch-action: none; /* Crucial for mobile touch drag without page pan */
}

/* Ghost Image Helper */
.board-ghost-img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
  opacity: 0.18;
  filter: grayscale(40%) contrast(110%);
  transition: opacity 0.3s ease;
  display: none;
  z-index: 1;
}

.board-ghost-img.active {
  display: block;
}

/* Canvas for board grid lines / slots */
.board-grid-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.8;
}

/* Locked pieces container on board */
.board-pieces-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 3;
}

.board-drop-target {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
}

/* ==========================================================================
   PIECES DOCK / TRAY (حاوية قطع الأحجية المتبقية)
   ========================================================================== */

.pieces-dock-column {
  width: 100%;
}

.pieces-dock-card {
  background: var(--surface-glass);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
}

.dock-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dock-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dock-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
}

.dock-counter-badge {
  background: var(--primary-gradient);
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.btn-dock-action {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-muted);
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-dock-action:hover {
  background: var(--primary-rose);
  color: white;
}

/* Pieces Tray Scrollable Grid */
.pieces-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-items: center;
  max-height: 520px;
  overflow-y: auto;
  padding: 8px 4px;
  min-height: 180px;
  background: rgba(10, 4, 12, 0.5);
  border-radius: var(--radius-sm);
  scrollbar-width: thin;
  scrollbar-color: var(--primary-rose) rgba(255, 255, 255, 0.05);
}

.pieces-tray::-webkit-scrollbar {
  width: 6px;
}

.pieces-tray::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
}

.pieces-tray::-webkit-scrollbar-thumb {
  background: var(--primary-rose);
  border-radius: 3px;
}

.tray-piece-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.1);
  transition: border-color 0.2s ease;
  touch-action: none;
}

/* ==========================================================================
   INDIVIDUAL JIGSAW PIECE STYLES & INTERACTION
   ========================================================================== */

.puzzle-piece {
  display: inline-block;
  cursor: grab;
  touch-action: none;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28), box-shadow 0.2s ease;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
}

.puzzle-piece:hover {
  transform: scale(1.04);
  filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.6)) drop-shadow(0 0 6px var(--primary-rose-glow));
}

.puzzle-piece.selected {
  transform: scale(1.08);
  filter: drop-shadow(0 0 12px var(--gold-accent)) drop-shadow(0 0 4px #fff);
  animation: pulsePiece 1.5s infinite;
}

@keyframes pulsePiece {
  0%, 100% {
    filter: drop-shadow(0 0 10px var(--gold-accent));
  }
  50% {
    filter: drop-shadow(0 0 18px var(--primary-rose));
  }
}

/* Active Dragging Piece */
.puzzle-piece.dragging {
  cursor: grabbing !important;
  z-index: 999999 !important;
  pointer-events: auto !important;
  transform: scale(1.08) !important;
  filter: drop-shadow(0 16px 28px rgba(0, 0, 0, 0.75)) drop-shadow(0 0 12px var(--primary-rose)) !important;
  transition: none !important;
}

/* Piece Snapped & Locked on Board */
.puzzle-piece.locked {
  position: absolute;
  cursor: default !important;
  pointer-events: none !important;
  filter: none !important;
  transition: transform 0.2s ease;
  z-index: 10 !important;
}

/* Mini sparkle ring on snap */
.snap-sparkle {
  position: absolute;
  pointer-events: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--gold-accent);
  box-shadow: 0 0 15px var(--gold-accent), 0 0 30px var(--primary-rose);
  transform: translate(-50%, -50%) scale(0.2);
  opacity: 1;
  animation: snapBurst 0.6s ease-out forwards;
  z-index: 999;
}

@keyframes snapBurst {
  0% {
    transform: translate(-50%, -50%) scale(0.2);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(2.2);
    opacity: 0;
  }
}

/* ==========================================================================
   3. WIN MODAL & CELEBRATION STYLES
   ========================================================================== */

.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 99999;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 3, 12, 0.88);
  backdrop-filter: blur(16px);
}

.confetti-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.win-card {
  position: relative;
  z-index: 2;
  background: linear-gradient(150deg, rgba(45, 16, 45, 0.95) 0%, rgba(20, 7, 24, 0.98) 100%);
  border: 2px solid rgba(255, 120, 160, 0.4);
  border-radius: 24px;
  padding: 32px 28px;
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8), 0 0 35px rgba(255, 77, 121, 0.35);
  animation: winCardPop 0.5s cubic-bezier(0.18, 0.89, 0.32, 1.28) forwards;
}

@keyframes winCardPop {
  0% {
    transform: scale(0.8);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.win-heart-icon-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.win-heart-icon {
  font-size: 3.2rem;
  display: block;
  animation: heartBeat 1.2s infinite;
}

@keyframes heartBeat {
  0%, 100% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.15);
  }
  50% {
    transform: scale(1.05);
  }
  75% {
    transform: scale(1.2);
  }
}

.win-title {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 900;
  color: #fff;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #ffffff 40%, #ffb8ca 70%, #f4c067 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.win-subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* Full completed image preview in win modal */
.win-image-preview-frame {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 20px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(255, 77, 121, 0.3);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.win-full-img {
  width: 100%;
  height: auto;
  display: block;
}

/* Win Stats Grid */
.win-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.win-stat-box {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 10px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.win-stat-icon {
  font-size: 1.2rem;
  margin-bottom: 2px;
}

.win-stat-name {
  font-size: 0.75rem;
  color: var(--text-subtle);
  margin-bottom: 4px;
}

.win-stat-val {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--gold-accent);
}

/* Win Action buttons */
.win-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* Lightbox Modal */
.lightbox-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 100000;
  background: rgba(0, 0, 0, 0.9);
  backdrop-filter: blur(8px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lightbox-modal.active {
  display: flex;
}

.lightbox-content {
  position: relative;
  max-width: 90vw;
  max-height: 90vh;
}

.lightbox-content img {
  max-width: 100%;
  max-height: 85vh;
  border-radius: var(--radius-md);
  box-shadow: 0 0 35px rgba(255, 77, 121, 0.4);
}

.lightbox-close {
  position: absolute;
  top: -15px;
  left: -15px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-rose);
  color: white;
  border: none;
  font-size: 1.2rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   RESPONSIVE DESIGN (هواتف وشاشات صغيرة)
   ========================================================================== */

/* Tablets & Small Laptops */
@media (max-width: 1100px) {
  .game-play-area {
    grid-template-columns: 200px 1fr 280px;
    gap: 14px;
  }
}

/* Mobile Devices (الهواتف الذكية) */
@media (max-width: 900px) {
  .start-content {
    padding: 20px 14px 40px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .difficulty-options {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .diff-card {
    padding: 14px;
  }

  /* Game screen layout for mobile */
  .game-play-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    gap: 14px;
  }

  /* Solution Preview appears cleanly above board or collapsible */
  .reference-panel {
    order: 1;
    width: 100%;
    max-width: 440px;
  }

  .reference-card {
    padding: 8px 12px;
  }

  .ref-header {
    margin-bottom: 6px;
    padding-bottom: 4px;
  }

  .ref-img-wrapper {
    max-height: 120px;
    display: flex;
    justify-content: center;
    background: #000;
  }

  .ref-img-wrapper img {
    height: 120px;
    width: auto;
    object-fit: contain;
  }

  /* Board is in middle */
  .board-column {
    order: 2;
    width: 100%;
  }

  .board-outer-frame {
    padding: 6px;
  }

  /* Pieces tray is below board */
  .pieces-dock-column {
    order: 3;
    width: 100%;
    max-width: 440px;
  }

  .pieces-tray {
    max-height: 240px;
    gap: 8px;
    padding: 6px;
  }

  .hud-top-row {
    flex-wrap: wrap;
    justify-content: space-between;
  }

  .hud-stats-group {
    order: 3;
    width: 100%;
    justify-content: space-around;
    padding-top: 4px;
  }

  .btn-hud .hud-label {
    display: none; /* Icon-only on very small mobile for compactness */
  }

  .btn-hud {
    padding: 6px 10px;
  }

  .win-stats-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .win-actions {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .main-title {
    font-size: 1.8rem;
  }
  
  .subtitle {
    font-size: 0.95rem;
  }

  .btn-large {
    width: 100%;
    padding: 12px 20px;
    font-size: 1.1rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
