/* =========================================================
   style.css - Aklın Ters Köşesi
   Mobil öncelikli, elle çizilmiş defter estetiği.
   ========================================================= */

:root {
  --ink: #2f2a45;
  --ink-soft: #6b6488;
  --paper: #fffdf7;
  --lilac: #efe7ff;
  --mint: #dff7ef;
  --purple: #7c5cff;
  --purple-dk: #5b3fd6;
  --yellow: #ffc93c;
  --coral: #ff7a7a;
  --green: #35c48f;
  --line: rgba(47, 42, 69, 0.16);
  --shadow: 0 6px 0 rgba(47, 42, 69, 0.12);
  --radius: 22px;
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
  --font-body: ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  --scene-unit: 3.6px; /* JS ile güncellenir: sahne genişliği / 100 */
}

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

html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--lilac);
  overscroll-behavior: none;
  touch-action: manipulation;
}

body {
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 12%, #ffe9f3 0%, transparent 42%),
    radial-gradient(circle at 88% 18%, #e2f7ff 0%, transparent 40%),
    radial-gradient(circle at 50% 100%, #e8ffe9 0%, transparent 45%),
    var(--lilac);
}

.stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
}

/* Masaüstünde telefon oranında ortalanmış gövde */
.phone {
  position: relative;
  width: min(100vw, 500px);
  height: 100dvh;
  max-height: 940px;
  background: var(--paper);
  border-radius: 0;
  overflow: visible;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
@media (min-width: 540px) and (min-height: 700px) {
  .phone { border-radius: 34px; box-shadow: 0 24px 60px rgba(47,42,69,.22), 0 0 0 10px #fff; height: min(92dvh, 900px); }
}

/* ---------------- Ekranlar ---------------- */
.screen {
  position: absolute; inset: 0;
  display: none;
  flex-direction: column;
  padding: calc(10px + env(safe-area-inset-top)) 14px calc(10px + env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -0.02em; }

/* ---------------- Tipografi / logo ---------------- */
.logo {
  font-size: clamp(34px, 10vw, 46px);
  line-height: .95; font-weight: 800; text-align: center;
  color: var(--ink);
}
.logo span { color: var(--purple); display: inline-block; transform: rotate(-3deg); }
.logo.sm { font-size: 26px; }
.tagline { text-align: center; color: var(--ink-soft); margin: 10px 0 26px; font-size: 15px; }

/* ---------------- Butonlar ---------------- */
.btn {
  font-family: var(--font-display);
  font-size: 17px; font-weight: 700;
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 13px 18px;
  min-height: 48px;
  background: #fff; color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .08s ease, box-shadow .08s ease, background .15s ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 rgba(47,42,69,.12); }
.btn-primary { background: var(--purple); color: #fff; border-color: var(--purple-dk); box-shadow: 0 6px 0 var(--purple-dk); }
.btn-primary:active { box-shadow: 0 2px 0 var(--purple-dk); }
.btn-primary.big { font-size: 22px; padding: 18px; width: 100%; }
.btn-ghost { background: #fff; }
.btn-soft { background: var(--mint); font-size: 15px; padding: 12px 10px; flex: 1; }
.btn-danger { background: #ffe4e4; border-color: var(--coral); color: #a33; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, .icon-btn:focus-visible, .lvl:focus-visible, [data-obj-id]:focus-visible {
  outline: 4px solid #1f9cff; outline-offset: 3px;
}

.icon-btn {
  width: 44px; height: 44px; min-width: 44px;
  border-radius: 14px; border: 2.5px solid var(--ink);
  background: #fff; font-size: 19px; cursor: pointer; line-height: 1;
  display: grid; place-items: center; color: var(--ink);
}
.icon-btn:active { transform: translateY(2px); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 2.5px solid var(--ink); border-radius: 999px;
  background: #fff; padding: 7px 14px; font-weight: 800; min-height: 40px;
  font-family: var(--font-display);
}
.pill.tappable { cursor: pointer; }
.ico { font-size: 16px; }

/* ---------------- Açılış ---------------- */
.boot-inner { margin: auto; text-align: center; width: 100%; padding: 0 12px; }
.boot-mino { width: 150px; height: 150px; margin: 0 auto 6px; animation: float 3.2s ease-in-out infinite; }
#btnBootStart { width: 70%; margin: 0 auto; font-size: 20px; }

/* ---------------- Menü ---------------- */
.menu-top { display: flex; justify-content: space-between; align-items: center; }
.menu-hero { text-align: center; margin: auto 0 18px; }
.mino-slot { display: block; margin: 0 auto; }
.mino-slot.lg { width: 128px; height: 128px; animation: float 3.4s ease-in-out infinite; }
.mino-slot.sm { width: 44px; height: 44px; flex: 0 0 44px; }
.menu-sub { color: var(--ink-soft); margin: 6px 0 0; font-weight: 700; }
.menu-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.menu-row { display: flex; gap: 10px; }
.menu-row .btn { flex: 1; }
.footnote { text-align: center; color: var(--ink-soft); font-size: 12px; margin: 8px 0 0; }

/* ---------------- Bölüm seçme ---------------- */
.bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.bar h2 { flex: 1; font-size: 22px; }
.level-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
  overflow-y: auto; padding: 4px 2px 20px; flex: 1;
  -webkit-overflow-scrolling: touch;
}
.lvl {
  aspect-ratio: 1; border-radius: 16px; border: 3px solid var(--ink);
  background: #fff; font-family: var(--font-display); font-weight: 800; font-size: 18px;
  display: grid; place-items: center; cursor: pointer; position: relative; color: var(--ink);
  box-shadow: 0 4px 0 rgba(47,42,69,.12);
}
.lvl.done { background: var(--mint); }
.lvl.done::after { content: "✓"; position: absolute; top: 2px; right: 6px; font-size: 12px; color: var(--green); }
.lvl.current { background: var(--yellow); transform: rotate(-2deg); }
.lvl.locked { background: #f1f0f6; color: #b6b2c6; border-color: var(--line); box-shadow: none; cursor: not-allowed; }

/* ---------------- Oyun: HUD ---------------- */
.hud { display: flex; align-items: center; gap: 8px; }
.hud-badge {
  border: 3px solid var(--ink); border-radius: 16px; background: var(--yellow);
  padding: 4px 12px; text-align: center; cursor: pointer; font-family: var(--font-display);
  line-height: 1.05; min-height: 44px; color: var(--ink); transform: rotate(-2deg);
}
.hud-badge small { display: block; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.hud-badge b { font-size: 19px; }
.hud-mid { flex: 1; display: flex; justify-content: center; }
.hud-right { display: flex; gap: 6px; }

/* ---------------- Soru kartı ---------------- */
.question-card {
  display: flex; gap: 10px; align-items: center;
  background: #fff; border: 3px dashed var(--ink); border-radius: var(--radius);
  padding: 10px 12px; margin: 10px 0 8px; box-shadow: var(--shadow);
}
.instruction { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.35; }

/* Cümle içindeki sürüklenebilir kelimeler */
.chip {
  display: inline-block; padding: 5px 9px; margin: 1px 0; min-width: 24px; text-align: center;
  border-radius: 9px;
  background: #fff6d8; border-bottom: 3px solid var(--yellow);
  cursor: grab; touch-action: none; font-weight: 800; color: var(--ink);
}
.chip.no-drag { cursor: pointer; }
.chip-slot { display: inline-block; }

/* ---------------- Sahne ---------------- */
.scene-wrap { position: relative; flex: 1; min-height: 0; margin-bottom: 6px; }
.scene {
  position: absolute; inset: 0;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, #f7f3ff 0%, #ffffff 60%, #f4fff8 100%);
  border: 3px solid var(--ink);
  box-shadow: var(--shadow);
  overflow: visible;
  touch-action: none;
}
.scene.night { background: linear-gradient(180deg, #2b2450 0%, #3b3168 100%); }
.scene.night .obj.text { color: #fff; }

.obj {
  position: absolute;
  transform: translate(-50%, -50%);
  display: grid; place-items: center;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
  transition: filter .15s ease;
}
.obj.draggable { cursor: grab; }
.obj.dragging { cursor: grabbing; filter: drop-shadow(0 12px 10px rgba(47,42,69,.25)); z-index: 999 !important; }
.obj.text {
  font-family: var(--font-display); font-weight: 800; color: var(--ink);
  padding: 4px 10px; min-width: 44px; min-height: 44px; line-height: 1;
}
.obj.shape { border: 3px solid var(--ink); }
.obj.shape.circle { border-radius: 50%; }
.obj.shape.rect { border-radius: 12px; }
.sprite-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.obj.hidden-obj { display: none; }
.obj.behind { filter: brightness(.86) saturate(.7); }
.obj.filled::after {
  content: ""; position: absolute; left: 12%; right: 12%; bottom: 12%; height: 46%;
  background: rgba(56, 189, 248, .45); border-radius: 0 0 14px 14px;
}
.hitbox-debug .obj { outline: 1.5px dashed #ff2d55; }

/* Mino konuşma balonu */
.bubble {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 9px 14px; border-radius: 16px;
  font-size: 14px; font-weight: 700; max-width: 88%; text-align: center;
  animation: pop .25s ease;
  z-index: 40;
}

/* ---------------- Alt çubuklar ---------------- */
.gesture-bar { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 6px; min-height: 0; }
.gesture-bar:empty { display: none; }
.gesture-bar .btn { padding: 9px 14px; font-size: 14px; min-height: 44px; background: #fff2c9; }
.action-bar { display: flex; gap: 8px; }
#btnHint.glow { animation: glow 1.1s ease-in-out infinite; }

/* ---------------- Overlay / sheet ---------------- */
.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(47, 42, 69, .45);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; backdrop-filter: blur(2px);
}
.overlay[hidden] { display: none; }
.sheet {
  width: min(100%, 460px);
  background: var(--paper); border: 3px solid var(--ink); border-radius: 26px;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px;
  animation: sheetUp .26s cubic-bezier(.2,.9,.3,1.2);
  max-height: 88dvh; overflow-y: auto;
}
.sheet h3 { font-size: 24px; text-align: center; }
.sheet .muted { text-align: center; color: var(--ink-soft); margin: -4px 0 4px; font-size: 14px; }
.sheet.celebrate { text-align: center; align-items: stretch; }
.reward { font-weight: 800; color: var(--purple); text-align: center; margin: 0; }

.row-toggle {
  display: flex; justify-content: space-between; align-items: center;
  border: 2.5px solid var(--line); border-radius: 16px; padding: 12px 14px; font-weight: 700; min-height: 48px;
}
.row-toggle input { width: 24px; height: 24px; accent-color: var(--purple); }

.howto { margin: 0; padding-left: 20px; line-height: 1.5; font-size: 14px; }
.howto li { margin-bottom: 7px; }

.daily-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.day {
  border: 2.5px solid var(--line); border-radius: 14px; padding: 8px 4px; text-align: center;
  font-size: 12px; font-weight: 700; background: #fff;
}
.day b { display: block; font-size: 11px; color: var(--ink-soft); }
.day .gift { font-size: 20px; display: block; }
.day.claimed { background: var(--mint); border-color: var(--green); }
.day.today { border-color: var(--purple); box-shadow: 0 0 0 3px rgba(124,92,255,.2); }

.ach-list { display: flex; flex-direction: column; gap: 8px; }
.ach {
  display: flex; gap: 10px; align-items: center;
  border: 2.5px solid var(--line); border-radius: 16px; padding: 10px 12px; background: #fff;
}
.ach .badge { font-size: 22px; filter: grayscale(1); opacity: .4; }
.ach.unlocked { border-color: var(--green); background: var(--mint); }
.ach.unlocked .badge { filter: none; opacity: 1; }
.ach small { display: block; color: var(--ink-soft); font-weight: 600; }
.ach strong { font-family: var(--font-display); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px;
  font-weight: 700; z-index: 400; animation: pop .2s ease; max-width: 90vw; text-align: center;
}
.toast[hidden] { display: none; }

/* ---------------- Sürükleme katmanı + efekt tuvali ---------------- */
#dragLayer { position: fixed; inset: 0; pointer-events: none; z-index: 150; }
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 180; width: 100%; height: 100%; }

/* ---------------- Debug ---------------- */
.debug {
  position: fixed; right: 8px; top: 8px; z-index: 500;
  background: rgba(255,255,255,.96); border: 2px solid var(--ink); border-radius: 14px;
  padding: 8px; font-size: 11px; display: flex; flex-direction: column; gap: 5px; width: 172px;
}
.debug[hidden] { display: none; }
.debug-row { display: flex; gap: 4px; }
.debug button, .debug input {
  flex: 1; font-size: 11px; padding: 5px 4px; border: 1.5px solid var(--ink);
  border-radius: 7px; background: #fff; cursor: pointer; min-width: 0;
}

/* ---------------- Animasyonlar ---------------- */
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes glow { 0%,100% { box-shadow: var(--shadow); } 50% { box-shadow: 0 0 0 6px rgba(255,201,60,.5), var(--shadow); } }
@keyframes wiggle {
  0%,100% { transform: translate(-50%,-50%) rotate(0); }
  25% { transform: translate(-50%,-50%) rotate(-7deg); }
  75% { transform: translate(-50%,-50%) rotate(7deg); }
}
@keyframes bounceUp {
  0% { transform: translate(-50%,-50%) scale(1); }
  40% { transform: translate(-50%,-70%) scale(1.12); }
  100% { transform: translate(-50%,-50%) scale(1); }
}
@keyframes cardIn { from { transform: translateX(60px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes cardOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(-60px); opacity: 0; } }
@keyframes flyAway { to { transform: translate(-50%,-50%) translate(120px, -220px) rotate(25deg); opacity: 0; } }

.wiggle { animation: wiggle .32s ease; }
.bounce { animation: bounceUp .5s ease; }
.scene.card-in { animation: cardIn .28s ease; }
.scene.card-out { animation: cardOut .22s ease forwards; }
.fly { animation: flyAway 1s ease forwards; }

/* Yanlış hamlede sahne kenarı kısa süre uyarır (renk körlüğü için desen de var) */
.scene.nudge { box-shadow: 0 0 0 4px rgba(255,122,122,.6), var(--shadow); }

/* ---------------- Erişilebilirlik ---------------- */
body.high-contrast {
  --paper: #ffffff; --ink: #000000; --ink-soft: #333; --line: #000;
  --lilac: #ffffff; --mint: #dfffe9; --yellow: #ffd400;
}
body.high-contrast .scene { background: #fff; }

body.reduced-motion *, body.reduced-motion *::before, body.reduced-motion *::after {
  animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important;
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* Küçük ekran ayarları */
@media (max-height: 640px) {
  .question-card { padding: 8px 10px; }
  .instruction { font-size: 14px; }
  .mino-slot.sm { width: 36px; height: 36px; flex-basis: 36px; }
  .btn-soft { font-size: 13px; padding: 10px 6px; }
}
