/**
 * DefGames Tablet Zero-Scroll Oyun Stili (Game Layout v2.0)
 * Kurallar:
 * - [FIX-002] html, body { height: 100dvh; overflow: hidden; } Sıfır Kaydırma.
 * - [FIX-005] user-select: none, notranslate
 * - Emil Kowalski 0-gecikme mikro-etkileşimler
 */

:root {
  --bg-yellow: #fde047;
  --bg-yellow-deep: #eab308;
  --pink-board: #ec4899;
  --pink-deep: #be185d;
  --paper: #fffdf5;
  --green: #22c55e;
  --green-dark: #15803d;
  --red: #ef4444;
  --red-dark: #b91c1c;
  --ink: #1f2937;
  --muted: #6b7280;
  --gold: #f59e0b;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  box-sizing: border-box;
  padding: 6px 10px 8px;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 50% 20%, #fef08a 0%, var(--bg-yellow) 55%, var(--bg-yellow-deep) 100%);
  touch-action: manipulation;
  display: flex;
  flex-direction: column;
}

button {
  font: inherit;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.app {
  width: 100%;
  max-width: 100%;
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-titles {
  display: flex;
  flex-direction: column;
}

/* Köpek Maskotu & Konuşma Balonu (Sol Üst Köşe) */
.dog-mascot-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dog-avatar-wrap {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  position: relative;
  filter: drop-shadow(0 3px 6px rgba(113, 63, 18, 0.25));
  animation: dogBounce 2.5s ease-in-out infinite alternate;
}

@keyframes dogBounce {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-3px) rotate(2deg); }
}

.dog-tail {
  transform-origin: 74px 68px;
  animation: dogWag 0.5s ease-in-out infinite alternate;
}

@keyframes dogWag {
  from { transform: rotate(-10deg); }
  to { transform: rotate(16deg); }
}

.dog-bubble {
  position: relative;
  background: #ffffff;
  border: 2px solid #ca8a04;
  border-radius: 14px;
  padding: 5px 12px;
  box-shadow: 0 3px 8px rgba(202, 138, 4, 0.2);
  display: flex;
  align-items: center;
}

.dog-bubble-text {
  font-size: 13px;
  font-weight: 800;
  color: #713f12;
  white-space: nowrap;
  letter-spacing: -.01em;
}

.dog-bubble-tail {
  position: absolute;
  left: -7px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-right: 7px solid #ca8a04;
}

.dog-bubble-tail::after {
  content: "";
  position: absolute;
  left: 2px;
  top: -4px;
  width: 0;
  height: 0;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-right: 6px solid #ffffff;
}

.eyebrow {
  color: #854d0e;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

h1 {
  margin: 1px 0 0;
  font-size: clamp(17px, 2.3vw, 24px);
  letter-spacing: -.03em;
  color: #713f12;
}

.header-right { display: flex; align-items: center; gap: 8px; }

.score {
  padding: 7px 13px;
  border-radius: 999px;
  background: #ffffff;
  border: 2px solid #fde047;
  color: #713f12;
  font-size: 13px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 8px rgba(0,0,0,0.06);
  white-space: nowrap;
}

.fullscreen-btn {
  border: 2px solid #ca8a04;
  background: #fef08a;
  color: #713f12;
  border-radius: 999px;
  padding: 7px 13px;
  font-weight: 800;
  font-size: 12.5px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.06);
  transition: transform .12s cubic-bezier(0.175, 0.885, 0.32, 1.275), background .15s;
  white-space: nowrap;
}
.fullscreen-btn:hover { background: #fde047; transform: translateY(-1px); }
.fullscreen-btn:active { transform: scale(0.96); }

.restart {
  border: 2px solid #eab308;
  background: #ffffff;
  color: #713f12;
  border-radius: 999px;
  padding: 7px 13px;
  font-weight: 800;
  font-size: 12.5px;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(0,0,0,0.06);
  transition: transform .12s cubic-bezier(0.175, 0.885, 0.32, 1.275), background .15s;
  white-space: nowrap;
}

.restart:hover { background: #fef9c3; transform: translateY(-1px); }
.restart:active { transform: scale(0.96); }

/* Pembe Oyun Tahtası - Ekrana Tam Yayılma */
.board {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #f472b6 0%, var(--pink-board) 50%, var(--pink-deep) 100%);
  border: 5px solid var(--pink-deep);
  border-radius: 20px;
  padding: 10px 14px;
  box-shadow: 0 16px 36px rgba(190, 24, 93, 0.32), inset 0 2px 0 rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Tablet & Masaüstü için 2 Kolonlu Tek Ekran Düzeni */
.board-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 41% 59%;
  gap: 12px;
  align-items: stretch;
  height: 100%;
}

.board-col-left {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  min-height: 0;
  gap: 8px;
}

.board-col-right {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.active-question-wrap {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.section-label {
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
  margin: 0 0 5px 2px;
  color: #fce7f3;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.active-question {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  border: 3px solid #fef08a;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 5px 0 #9d174d, 0 8px 16px rgba(0,0,0,0.12);
  overflow-y: auto;
}

.active-number {
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #fbcfe8;
  color: #831843;
  font: 800 26px Georgia, serif;
}

.active-copy { min-width: 0; padding-top: 1px; flex: 1; }

.active-kicker { color: #be185d; font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }

.active-text { margin: 6px 0 0; font: 700 clamp(17px, 2vw, 24px)/1.35 Georgia, serif; color: #111827; }

.active-placeholder { color: #6b7280; font-size: 14px; font-weight: 600; }

.result {
  flex: 0 0 auto;
  margin-top: 5px;
  font-size: 13.5px;
  font-weight: 800;
  text-align: center;
  min-height: 18px;
}

.result.good { color: var(--green-dark); }
.result.bad { color: var(--red-dark); }

.numbers-wrap {
  flex: 0 0 auto;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
}

.number-card {
  position: relative;
  height: 42px;
  border: 0;
  border-radius: 9px;
  background: #ffffff;
  color: #831843;
  font: 800 clamp(14px, 1.4vw, 17px) Georgia, serif;
  box-shadow: 0 3px 0 #f472b6, 0 4px 8px rgba(0,0,0,0.08);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  transition: transform .12s cubic-bezier(0.175, 0.885, 0.32, 1.275), background .15s;
}

.number-card:hover:not(:disabled) { transform: translateY(-2px); background: #fdf2f8; }
.number-card:active:not(:disabled) { transform: scale(0.95); }

.number-card.active {
  outline: 3px solid #fef08a;
  background: #fef08a;
  color: #713f12;
  box-shadow: 0 3px 0 #ca8a04;
  transform: translateY(-2px);
}

.number-card.done { background: #dcfce7; color: #14532d; box-shadow: 0 3px 0 #86efac; cursor: not-allowed; }
.number-card.done::after { content: "✓"; position: absolute; top: 1px; right: 3px; font-size: 11px; color: var(--green); font-weight: 900; }

.number-card.failed { background: #fee2e2; color: #7f1d1d; box-shadow: 0 3px 0 #fca5a5; cursor: not-allowed; }
.number-card.failed::after { content: "✕"; position: absolute; top: 1px; right: 3px; font-size: 11px; color: var(--red); font-weight: 900; }

.answers-section {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  position: relative;
  z-index: 1;
  padding: 10px 14px;
  border-radius: 16px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

.answers-heading {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.answers-heading h2 { margin: 0; font-size: 16px; color: #111827; }
.answers-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 11.5px; font-weight: 600; }

/* 5 Saniye Timer Rozeti */
.timer-badge {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  color: #92400e;
  font-weight: 800;
  font-size: 11.5px;
  animation: pulse 1s infinite alternate;
}

.timer-badge.active { display: inline-flex; }

.timer-seconds {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #d97706;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.answer-grid {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-content: stretch;
}

.answer-card {
  height: 100%;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 8px;
  border: 2px solid #86efac;
  border-radius: 11px;
  background: linear-gradient(145deg, #bbf7d0, #4ade80);
  color: #052e16;
  font-size: clamp(12.5px, 1.3vw, 15px);
  font-weight: 800;
  text-align: center;
  line-height: 1.24;
  box-shadow: 0 3px 0 #15803d;
  cursor: pointer;
  transition: transform .12s cubic-bezier(0.175, 0.885, 0.32, 1.275), outline .15s, background .15s, opacity .2s;
  animation: cardFadeIn .18s ease-out;
}

@keyframes cardFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.answer-card:hover:not(:disabled) { transform: translateY(-3px); filter: brightness(1.05); }
.answer-card:active:not(:disabled) { transform: scale(0.96); }

.answer-card.selected {
  outline: 4px solid #f59e0b;
  outline-offset: 2px;
  border-color: #b45309;
  background: linear-gradient(145deg, #fef08a, #fde047);
  color: #713f12;
  box-shadow: 0 4px 0 #b45309;
}

.answer-card.correct-selected {
  outline: 4px solid #22c55e;
  outline-offset: 2px;
  border-color: #15803d;
  background: linear-gradient(145deg, #86efac, #22c55e);
  color: #052e16;
  box-shadow: 0 4px 0 #15803d;
}

.answer-card.wrong-selected {
  border-color: #b91c1c;
  background: linear-gradient(145deg, #fca5a5, #ef4444);
  color: #ffffff;
  box-shadow: 0 4px 0 #7f1d1d;
}

.answer-card:disabled { cursor: default; }

/* Canvas Fireworks Overlay */
#fireworksCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 150;
}

/* Modallar */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}

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

.modal-card {
  background: #ffffff;
  padding: 24px 28px;
  border-radius: 24px;
  text-align: center;
  max-width: 320px;
  width: 90%;
  box-shadow: 0 20px 45px rgba(0,0,0,0.3);
  transform: scale(0.8);
  transition: transform .25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-card { transform: scale(1); }

.modal-title { font-size: 20px; font-weight: 900; color: #b91c1c; margin: 12px 0 4px; }
.modal-text { font-size: 14px; color: #4b5563; margin-bottom: 16px; font-weight: 600; line-height: 1.4; }

.modal-close {
  border: 0;
  background: #ef4444;
  color: #ffffff;
  font-weight: 800;
  padding: 10px 24px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b91c1c;
  transition: transform .12s, background .15s;
}

.modal-close:hover { background: #dc2626; }
.modal-close:active { transform: scale(0.96); }

.tear {
  animation: dropTear 1.2s infinite ease-in;
  transform-origin: top center;
}

@keyframes dropTear {
  0% { transform: translateY(0) scaleY(0.3); opacity: 0; }
  30% { opacity: 1; }
  100% { transform: translateY(28px) scaleY(1.2); opacity: 0; }
}

/* Kupa ve Madalya Bitiş Modalı */
.reward-overlay { z-index: 120; }

.reward-card {
  max-width: 380px;
  padding: 32px 28px 28px;
  border-radius: 28px;
  border: 4px solid #fef08a;
  box-shadow: 0 25px 60px rgba(0,0,0,0.35);
  position: relative;
}

.reward-icon-wrap {
  width: 140px;
  height: 140px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  animation: floatReward 2.8s ease-in-out infinite alternate;
}

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

.reward-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.badge-gold { background: #fef3c7; color: #b45309; border: 1.5px solid #f59e0b; }
.badge-silver { background: #f1f5f9; color: #475569; border: 1.5px solid #94a3b8; }
.badge-bronze { background: #ffedd5; color: #9a3412; border: 1.5px solid #f97316; }
.badge-star { background: #f3f4f6; color: #374151; border: 1.5px solid #d1d5db; }

.reward-title {
  font-size: 24px;
  font-weight: 900;
  color: #111827;
  margin: 4px 0 6px;
  letter-spacing: -.02em;
}

.reward-desc {
  font-size: 14px;
  color: #4b5563;
  margin-bottom: 20px;
  line-height: 1.45;
}

.reward-stats {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 22px;
}

.reward-stat-item {
  flex: 1;
  padding: 12px 14px;
  border-radius: 16px;
  background: #f9fafb;
  border: 1px solid rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.reward-stat-item.correct { background: #f0fdf4; border-color: #bbf7d0; }
.reward-stat-item.wrong { background: #fef2f2; border-color: #fecaca; }

.stat-num {
  font-size: 22px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.reward-stat-item.correct .stat-num { color: #15803d; }
.reward-stat-item.wrong .stat-num { color: #b91c1c; }

.stat-label {
  font-size: 11px;
  font-weight: 800;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.reward-restart-btn {
  width: 100%;
  border: 0;
  background: linear-gradient(145deg, #f59e0b, #d97706);
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  padding: 14px 24px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 0 #b45309, 0 8px 16px rgba(217, 119, 6, 0.35);
  transition: transform .12s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter .15s;
}

.reward-restart-btn:hover { filter: brightness(1.06); }
.reward-restart-btn:active { transform: scale(0.97); }

/* Ekranın Ortasında Oyuna Başla Overlay */
.start-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 20px;
}

.start-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.start-card {
  position: relative;
  background: #ffffff;
  border: 4px solid #fef08a;
  border-radius: 32px;
  padding: clamp(28px, 5vw, 44px) clamp(24px, 4vw, 36px);
  text-align: center;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 25px 60px rgba(113, 63, 18, 0.35), 0 8px 0 #ca8a04;
  transform: scale(1);
  transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.start-overlay.hidden .start-card { transform: scale(0.9); }

.start-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: linear-gradient(135deg, #fef08a 0%, #fde047 100%);
  border: 2px solid #ca8a04;
  font-size: 38px;
  box-shadow: 0 6px 16px rgba(202, 138, 4, 0.25);
  animation: floatIcon 3s ease-in-out infinite alternate;
}

@keyframes floatIcon {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(-6px) rotate(4deg); }
}

.start-eyebrow {
  color: #b45309;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .16em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.start-title {
  margin: 0 0 10px;
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 900;
  color: #713f12;
  letter-spacing: -.03em;
}

.start-desc {
  margin: 0 0 26px;
  font-size: 14.5px;
  font-weight: 600;
  color: #4b5563;
  line-height: 1.5;
}

.start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 16px 36px;
  border: 3px solid #fef08a;
  border-radius: 20px;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  font-size: clamp(19px, 3.5vw, 22px);
  font-weight: 900;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 6px 0 #b45309, 0 14px 28px rgba(217, 119, 6, 0.4);
  transition: transform 0.12s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.15s, box-shadow 0.12s;
}

.start-btn:hover {
  filter: brightness(1.06);
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #b45309, 0 18px 32px rgba(217, 119, 6, 0.45);
}

.start-btn:active {
  transform: translateY(3px) scale(0.96);
  box-shadow: 0 2px 0 #b45309, 0 6px 14px rgba(217, 119, 6, 0.3);
}

.start-btn-triangle {
  display: inline-block;
  width: 0;
  height: 0;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
  border-left: 13px solid #ffffff;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,0.25));
}

.active-question.question-enter {
  animation: questionPop .18s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes questionPop {
  from { transform: scale(0.97); opacity: 0.85; }
  to { transform: scale(1); opacity: 1; }
}

/* Tablet ve Geniş Ekranlar (>= 800px) */
@media (min-width: 800px) {
  .app { width: 100%; height: 100%; }
  .board-grid {
    grid-template-columns: 41% 59%;
    gap: 12px;
    align-items: stretch;
  }
  .board-col-left {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    min-height: 0;
    gap: 8px;
  }
  .number-grid {
    grid-template-columns: repeat(10, minmax(0, 1fr));
    gap: 6px;
  }
  .number-card {
    height: 42px;
    font-size: 16px;
  }
  .answers-section {
    padding: 10px 14px;
    height: 100%;
  }
  .answer-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    height: 100%;
  }
  .answer-card {
    height: 100%;
    min-height: 0;
    font-size: clamp(12.5px, 1.3vw, 15px);
  }
}

/* Orta Ekranlar (641px - 799px) */
@media (min-width: 641px) and (max-width: 799px) {
  .number-grid { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .answer-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Küçük Ekranlar (<= 640px) */
@media (max-width: 640px) {
  .number-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .answer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  header { flex-wrap: wrap; }
  .dog-bubble-text { font-size: 11px; }
}
