/* ========================================
   PUZZLX - YAPBOZ OYUNU STİLLERİ
   ======================================== */

:root {
  --bg-dark: #0a0b14;
  --bg-card: rgba(255,255,255,0.06);
  --bg-card-hover: rgba(255,255,255,0.10);
  --border: rgba(255,255,255,0.12);
  --border-hover: rgba(255,255,255,0.25);

  --accent-1: #7c4dff;
  --accent-2: #e040fb;
  --accent-3: #40c4ff;
  --accent-grad: linear-gradient(135deg, #7c4dff, #e040fb);
  --accent-grad-2: linear-gradient(135deg, #40c4ff, #7c4dff);

  --text-primary: #f0f0ff;
  --text-secondary: rgba(240,240,255,0.6);
  --text-muted: rgba(240,240,255,0.35);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-glow: 0 0 40px rgba(124,77,255,0.3);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.4);

  --gap: 16px;
  --font: 'Outfit', sans-serif;

  --topbar-h: 64px;
}

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

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

body {
  font-family: var(--font);
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100%;
  overflow-x: hidden;
  position: relative;
}

/* ========== SCREENS ========== */
.screen {
  display: none;
  min-height: 100vh;
  padding-bottom: 40px;
  position: relative;
  overflow: hidden;
}
.screen.active { display: block; }

/* ========== BG ORBS ========== */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: floatOrb 10s ease-in-out infinite alternate;
}
.orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, #7c4dff, transparent 70%);
  top: -100px; left: -100px;
  animation-delay: 0s;
}
.orb-2 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, #e040fb, transparent 70%);
  top: 30%; right: -80px;
  animation-delay: -3s;
}
.orb-3 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, #40c4ff, transparent 70%);
  bottom: -80px; left: 40%;
  animation-delay: -6s;
}

@keyframes floatOrb {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, 40px) scale(1.1); }
}

/* ========== HEADER ========== */
.app-header {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 40px 20px 10px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.logo-icon { font-size: 2.2rem; }
.logo-text {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--text-primary);
}
.logo-accent {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-sub {
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 400;
}

/* ========== SECTION TITLE ========== */
.section-title {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 28px 20px 16px;
}
.section-title h1 {
  font-size: clamp(1.4rem, 4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.section-title p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ========== GALLERY GRID ========== */
.gallery-grid {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--gap);
  padding: 0 20px;
  max-width: 900px;
  margin: 0 auto;
}

.gallery-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid var(--border);
  cursor: pointer;
  position: relative;
  aspect-ratio: 1;
  transition: transform 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
  background: var(--bg-card);
}
.gallery-card:hover {
  transform: translateY(-4px) scale(1.02);
  border-color: var(--border-hover);
  box-shadow: 0 12px 40px rgba(124,77,255,0.35);
}
.gallery-card.selected {
  border-color: var(--accent-1);
  box-shadow: 0 0 0 3px rgba(124,77,255,0.4), var(--shadow-glow);
}
.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: filter 0.25s ease;
}
.gallery-card:hover img {
  filter: brightness(1.1);
}
.gallery-card .card-label {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 20px 10px 8px;
  text-align: center;
}
.gallery-card .selected-check {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  background: var(--accent-grad);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  opacity: 0;
  transform: scale(0.5);
  transition: opacity 0.2s, transform 0.2s;
}
.gallery-card.selected .selected-check {
  opacity: 1;
  transform: scale(1);
}

/* ========== UPLOAD ========== */
.upload-section {
  position: relative;
  z-index: 10;
  padding: 16px 20px;
  max-width: 900px;
  margin: 0 auto;
}
.upload-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--bg-card);
  transition: background 0.25s, border-color 0.25s;
}
.upload-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-1);
}
.upload-icon { font-size: 1.8rem; }
.upload-title {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
}
.upload-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ========== SELECTED PREVIEW ========== */
.selected-preview {
  position: relative;
  z-index: 10;
  max-width: 420px;
  margin: 20px auto 0;
  padding: 0 20px;
}
.selected-preview.hidden { display: none; }

.preview-card {
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid rgba(124,77,255,0.4);
  box-shadow: var(--shadow-glow);
  margin-bottom: 20px;
}
.preview-card img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
}
.preview-info {
  padding: 10px 14px;
  background: rgba(124,77,255,0.1);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ========== DIFFICULTY ========== */
.difficulty-section {
  margin-bottom: 20px;
}
.difficulty-section h2 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-secondary);
}
.difficulty-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  cursor: pointer;
  font-family: var(--font);
  transition: all 0.2s ease;
}
.diff-btn:hover {
  border-color: var(--accent-1);
  background: rgba(124,77,255,0.1);
}
.diff-btn.active {
  border-color: var(--accent-1);
  background: rgba(124,77,255,0.2);
  box-shadow: 0 0 20px rgba(124,77,255,0.25);
}
.diff-icon { font-size: 1.4rem; }
.diff-label { font-size: 0.85rem; font-weight: 600; }
.diff-desc { font-size: 0.72rem; color: var(--text-secondary); }

/* ========== START BUTTON ========== */
.start-btn {
  width: 100%;
  padding: 16px;
  border-radius: var(--radius-md);
  border: none;
  background: var(--accent-grad);
  color: #fff;
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(124,77,255,0.45);
}
.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(124,77,255,0.55);
}
.start-btn:active { transform: scale(0.98); }
.btn-shine {
  position: absolute;
  top: -50%;
  left: -60%;
  width: 50%;
  height: 200%;
  background: rgba(255,255,255,0.15);
  transform: rotate(20deg);
  pointer-events: none;
  animation: btnShine 3s ease-in-out infinite;
}
@keyframes btnShine {
  0%   { left: -60%; }
  60%  { left: 130%; }
  100% { left: 130%; }
}

.outline-btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-hover);
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 10px;
}
.outline-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-1);
}

/* ========== GAME TOPBAR ========== */
.game-topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-h);
  background: rgba(10,11,20,0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-family: var(--font);
}
.icon-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: scale(1.08);
}

.game-stats {
  display: flex;
  align-items: center;
  gap: 20px;
}
.stat-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 1rem;
  font-weight: 600;
}
.stat-icon { font-size: 0.9rem; }

.game-actions {
  display: flex;
  gap: 8px;
}

/* ========== GAME AREA ========== */
.game-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px 16px;
  min-height: calc(100vh - var(--topbar-h) - 120px);
}

/* ========== PUZZLE BOARD ========== */
.puzzle-board {
  display: grid;
  gap: 3px;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius-md);
  padding: 6px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  width: min(90vw, 480px);
  height: min(90vw, 480px);
  position: relative;
}

.puzzle-piece {
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  position: relative;
  border: 1px solid rgba(255,255,255,0.08);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  background-size: cover;
  background-position: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.puzzle-piece:hover {
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  border-color: rgba(124,77,255,0.5);
  z-index: 2;
}
.puzzle-piece.dragging {
  cursor: grabbing;
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(124,77,255,0.5);
  border-color: var(--accent-1);
  opacity: 0.85;
  z-index: 10;
}
.puzzle-piece.correct {
  border-color: rgba(64,196,255,0.6);
  box-shadow: 0 0 12px rgba(64,196,255,0.3);
}
.puzzle-piece.hint-show { opacity: 0.5; }

/* drag-over highlight */
.puzzle-piece.drag-over {
  border-color: var(--accent-2);
  box-shadow: 0 0 18px rgba(224,64,251,0.45);
}

/* ========== REFERENCE PANEL ========== */
.reference-panel {
  position: relative;
  z-index: 10;
  max-width: 200px;
  margin: 0 auto 16px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.ref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}
.toggle-ref-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-secondary);
  transition: opacity 0.2s;
}
.toggle-ref-btn:hover { opacity: 0.7; }
.ref-img-wrap {
  max-height: 120px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.ref-img-wrap.collapsed { max-height: 0; }
.ref-img-wrap img {
  width: 100%;
  display: block;
  object-fit: cover;
}

/* ========== WIN SCREEN ========== */
#screen-win {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
#screen-win.active { display: flex; }

.win-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
}
#confetti-canvas {
  width: 100%;
  height: 100%;
}

.win-card {
  position: relative;
  z-index: 10;
  background: rgba(15,16,30,0.92);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  padding: 36px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6), var(--shadow-glow);
}
.win-emoji { font-size: 3.5rem; margin-bottom: 10px; }
.win-title {
  font-size: 2rem;
  font-weight: 800;
  background: var(--accent-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}
.win-subtitle {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 0.95rem;
}
.win-stats {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.win-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  border: 1px solid var(--border);
  min-width: 78px;
}
.win-stat-icon { font-size: 1.2rem; }
.win-stat-label { font-size: 0.72rem; color: var(--text-secondary); }
.win-stat-value { font-size: 1.05rem; font-weight: 700; color: var(--accent-3); }

.win-completed-img {
  width: 100%;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  border: 2px solid rgba(124,77,255,0.3);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.win-buttons { display: flex; flex-direction: column; gap: 10px; }

/* ========== TOAST ========== */
.toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(124,77,255,0.95);
  color: #fff;
  padding: 10px 24px;
  border-radius: 50px;
  font-size: 0.9rem;
  font-weight: 600;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 999;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ========== PROGRESS BAR ========== */
.progress-bar-wrap {
  position: relative;
  z-index: 10;
  padding: 0 20px;
  max-width: 500px;
  margin: 0 auto 16px;
}
.progress-bar-track {
  height: 4px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent-grad);
  border-radius: 4px;
  transition: width 0.4s ease;
}
.progress-label {
  text-align: right;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .puzzle-board {
    width: min(95vw, 420px);
    height: min(95vw, 420px);
  }
  .win-stats { gap: 10px; }
  .win-stat { min-width: 68px; padding: 10px 12px; }
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  :root { --gap: 20px; }
}

/* ========== SCROLLBAR ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(124,77,255,0.4);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(124,77,255,0.7); }

/* ========== ANIMASYONLAR ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.03); }
}

.screen.active > * {
  animation: fadeInUp 0.4s ease both;
}
.screen.active > *:nth-child(2) { animation-delay: 0.06s; }
.screen.active > *:nth-child(3) { animation-delay: 0.12s; }
.screen.active > *:nth-child(4) { animation-delay: 0.18s; }
.screen.active > *:nth-child(5) { animation-delay: 0.24s; }
