/* ============================================================
   Gamekid — дизайн система v2
   Деца 1-6 г. · големи touch targets · висока четимост
   ============================================================ */
:root {
  /* Цветова палитра — топла, играеща, класическа за деца */
  --bg: #fff7f0;
  --bg-alt: #ffeede;
  --card: #ffffff;
  --primary: #ff7a59;
  --primary-dark: #e85c39;
  --primary-light: #ffb59d;
  --accent: #4ecdc4;
  --accent-dark: #35b3ab;
  --accent2: #ffd93d;
  --accent2-dark: #e6bc1f;
  --purple: #a78bfa;
  --pink: #ff8fb1;
  --blue: #6cb4ee;
  --text: #3a3a3a;
  --muted: #8a8a8a;
  --success: #6bcb77;
  --success-dark: #4fae5b;
  --danger: #ff6b6b;

  /* Радиуси — повече забележимо „детски" */
  --radius: 22px;
  --radius-lg: 32px;
  --radius-sm: 14px;

  /* Сенки — меки, слоести */
  --shadow: 0 6px 20px rgba(0,0,0,.08);
  --shadow-lift: 0 14px 34px rgba(0,0,0,.14);
  --shadow-inner: inset 0 -4px 0 rgba(0,0,0,.08);

  /* Типография */
  --font: 'Comic Sans MS', 'Chalkboard SE', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background:
    radial-gradient(circle at 12% 18%, rgba(255,217,61,.16) 0%, transparent 34%),
    radial-gradient(circle at 88% 82%, rgba(78,205,196,.16) 0%, transparent 34%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  box-sizing: border-box;
}

/* За страници с вертикален каталог/скрол (portal, tales, parents) */
html:has(.catalog-page), body:has(.catalog-page),
html:has(.scrollable-page), body:has(.scrollable-page) {
  display: block;
  min-height: 100dvh;
  height: auto !important;
  overflow-y: auto !important;
  overscroll-behavior-y: auto;
  padding: 14px 12px calc(60px + env(safe-area-inset-bottom, 24px)) 12px !important;
}

.catalog-page {
  margin: 0 auto;
  padding-bottom: calc(50px + env(safe-area-inset-bottom, 24px));
}

/* Когато сме в самостоятелна игра — забрана за паразитен скрол на екрана */
html:has(.app:not(.catalog-page)), body:has(.app:not(.catalog-page)) {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
}

.app { max-width: 900px; width: 100%; }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px;
  width: 100%;
  text-align: center;
}

/* ---------- Заглавия ---------- */
h1 { margin: 0 0 6px; font-size: 34px; color: var(--text); }
h2 { margin: 0 0 14px; font-size: 22px; color: var(--primary); }
.subtitle { margin: 0 0 20px; color: var(--muted); font-size: 17px; }

/* ---------- Бутони ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 14px 30px;
  font-size: 18px;
  font-weight: bold;
  font-family: var(--font);
  cursor: pointer;
  box-shadow: 0 5px 0 var(--primary-dark), var(--shadow);
  transition: transform .1s, box-shadow .1s, filter .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--primary-dark); }
.btn.secondary { background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%); box-shadow: 0 5px 0 var(--accent-dark), var(--shadow); }
.btn.secondary:active { box-shadow: 0 1px 0 var(--accent-dark); }
.btn.warn { background: linear-gradient(180deg, var(--accent2) 0%, var(--accent2-dark) 100%); color: #5a4a0a; box-shadow: 0 5px 0 var(--accent2-dark), var(--shadow); }
.btn.warn:active { box-shadow: 0 1px 0 var(--accent2-dark); }
.btn.ghost { background: transparent; border: 3px solid var(--primary); color: var(--primary); box-shadow: none; }
.btn.ghost:active { transform: translateY(2px); box-shadow: none; }
.btn[disabled] { opacity: .45; pointer-events: none; }

/* ---------- Навигационни кръгли бутони ---------- */
.nav-btn {
  background: #fff;
  border: 3px solid var(--primary);
  border-radius: 50%;
  width: 58px; height: 58px;
  font-size: 24px; font-weight: bold;
  color: var(--primary);
  cursor: pointer;
  box-shadow: var(--shadow);
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .12s;
}
.nav-btn:active { transform: scale(.92); }
.nav-btn:disabled { opacity: .35; pointer-events: none; }

/* ---------- Звезди ---------- */
.star-row { font-size: 30px; letter-spacing: 8px; margin: 10px 0; }
.star-row .done { color: var(--accent2); text-shadow: 0 2px 6px rgba(255,217,61,.5); }
.star-row .todo { color: #e3e3e3; }

/* ---------- Плочки / клетки ---------- */
.tile {
  background: var(--card);
  border: 3px solid #eee;
  border-radius: var(--radius);
  padding: 18px 8px;
  font-size: 24px; font-weight: bold;
  font-family: var(--font);
  cursor: pointer;
  user-select: none;
  transition: transform .12s, border-color .15s, background .15s;
}
.tile:hover { border-color: var(--primary); transform: translateY(-2px); }
.tile.matched { border-color: var(--success); background: #f0fff4; }
.tile.wrong { border-color: var(--danger); animation: shake .4s; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-6px)} 75%{transform:translateX(6px)} }

/* ---------- Етикети ---------- */
.badge {
  display: inline-block;
  background: linear-gradient(180deg, var(--accent2) 0%, var(--accent2-dark) 100%);
  color: #5a4a0a;
  border-radius: 999px;
  padding: 5px 16px;
  font-size: 14px; font-weight: bold;
  margin-bottom: 12px;
}
.hint { font-size: 16px; color: var(--muted); margin-bottom: 18px; }

/* ---------- Прогрес ---------- */
.progress-bar { height: 12px; background: #eee; border-radius: 999px; overflow: hidden; margin: 14px 0; }
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent) 0%, var(--primary) 100%); width: 0; transition: width .45s cubic-bezier(.34,1.4,.64,1); }

/* ---------- Canvas ---------- */
canvas { display: block; margin: 0 auto; border-radius: var(--radius); background: #fff; touch-action: none; box-shadow: var(--shadow); }

/* ---------- Помощни ---------- */
.emoji { line-height: 1.1; }
.grow-in { animation: growIn .35s cubic-bezier(.34,1.56,.64,1) backwards; }
@keyframes growIn { from { transform: scale(0); } }
.pop { animation: pop .45s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { 0%{transform:scale(1)} 45%{transform:scale(1.12) rotate(-4deg)} 100%{transform:scale(1)} }
.float-up { animation: floatUp .9s ease-out forwards; }
@keyframes floatUp { to { transform: translateY(-60px); opacity: 0; } }

/* Нови физически Juice & Nudge анимации */
.gk-squash {
  animation: squashAnim .22s cubic-bezier(.25,1.5,.5,1) !important;
}
@keyframes squashAnim {
  0% { transform: scale(1, 1); }
  40% { transform: scale(1.18, 0.82); }
  75% { transform: scale(0.92, 1.08); }
  100% { transform: scale(1, 1); }
}

.gk-nudge {
  animation: nudgePulse 1.4s ease-in-out infinite !important;
  border-color: #ffd166 !important;
  box-shadow: 0 0 16px rgba(255,209,102,0.85) !important;
}
@keyframes nudgePulse {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.08) translateY(-4px); }
}

/* Респонсивни правила за Landscape таблети и iPad */
@media (orientation: landscape) and (max-height: 580px) {
  .app {
    padding: 4px 10px;
  }
  .hud {
    margin-bottom: 2px;
  }
}

/* Красиви плавни сенки и интерактивност */
.card, .item, .opt, .cell, .goal-card, .puzzle-card {
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:active, .item:active, .opt:active {
  transform: scale(0.94);
}

/* ---------- Празднучно конфети ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 9998; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

/* ---------- Голям екран за поздрав ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 9990;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255,247,240,.92);
  animation: fadeIn .25s;
}
@keyframes fadeIn { from { opacity: 0; } }
.celebrate .big { font-size: 90px; animation: pop .6s cubic-bezier(.34,1.56,.64,1); }
.celebrate .msg { font-size: 34px; font-weight: bold; color: var(--primary); margin-top: 14px; }
.celebrate .sub { font-size: 20px; color: var(--muted); margin-top: 6px; }

/* ---------- Грешка ---------- */
.shake-screen { animation: shake .4s; }
