/* ==========================================================
   Zarok — tüm oyunların ortak stili
   Renkler aşağıdaki değişkenlerden gelir; tema değiştirmek için
   sadece burayı düzenlemek yeterli.
   ========================================================== */

:root {
  --bg-top: #fff6df;
  --bg-bottom: #ffd99e;
  --ink: #2b2140;
  --ink-soft: #6b5f80;
  --card: #ffffff;
  --card-ink: #2b2140;
  --primary: #ff7a1a;
  --primary-dark: #c95a00;
  --teal: #1fa595;
  --teal-dark: #13766b;
  --shadow: rgba(43, 33, 64, 0.18);
  --overlay: rgba(30, 20, 50, 0.45);
  --radius: 22px;
  --gutter: 16px;
  --z-icon: 64px; /* üst bar düğmeleri (dokunma hedefi ≥64 px) */
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-top: #1b1840;
    --bg-bottom: #2d2363;
    --ink: #fff6e6;
    --ink-soft: #cfc6ea;
    --card: #3a3070;
    --card-ink: #fff6e6;
    --shadow: rgba(0, 0, 0, 0.35);
    --overlay: rgba(5, 3, 20, 0.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg-top: #1b1840;
  --bg-bottom: #2d2363;
  --ink: #fff6e6;
  --ink-soft: #cfc6ea;
  --card: #3a3070;
  --card-ink: #fff6e6;
  --shadow: rgba(0, 0, 0, 0.35);
  --overlay: rgba(5, 3, 20, 0.6);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: "Baloo 2", "Nunito", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--bg-top);
  background-image: linear-gradient(180deg, var(--bg-top), var(--bg-bottom));
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
:focus-visible { outline: 4px solid #3d7cff; outline-offset: 3px; }

/* ---------- Üst bar ---------- */
.z-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px var(--gutter);
  padding-top: max(10px, env(safe-area-inset-top));
}
.z-topbar h1 {
  flex: 1;
  margin: 0;
  font-size: clamp(1.25rem, 5vw, 1.9rem);
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
}
.z-icon-btn {
  flex: none;
  width: var(--z-icon);
  height: var(--z-icon);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--card);
  color: var(--card-ink);
  font-size: 1.75rem;
  text-decoration: none;
  box-shadow: 0 5px 0 var(--shadow);
  transition: transform 0.08s, box-shadow 0.08s;
}
.z-icon-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--shadow); }

/* ---------- Düğmeler ---------- */
.z-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  min-height: 60px;
  padding: 0 28px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 1.35rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 6px 0 var(--primary-dark);
  transition: transform 0.08s, box-shadow 0.08s;
}
.z-btn:active { transform: translateY(5px); box-shadow: 0 1px 0 var(--primary-dark); }
.z-btn.alt { background: var(--teal); box-shadow: 0 6px 0 var(--teal-dark); }
.z-btn.alt:active { box-shadow: 0 1px 0 var(--teal-dark); }
.z-btn.ghost { background: var(--card); color: var(--card-ink); box-shadow: 0 6px 0 var(--shadow); }
.z-btn.ghost:active { box-shadow: 0 1px 0 var(--shadow); }

/* ---------- Kutlama penceresi ---------- */
.z-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background: var(--overlay);
  animation: z-fade 0.2s ease-out;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.z-overlay > .z-dialog { margin: auto; }
.z-overlay.z-arming .z-actions { pointer-events: none; }
.z-dialog {
  width: min(420px, 100%);
  padding: 26px 22px 24px;
  border-radius: 28px;
  background: var(--card);
  color: var(--card-ink);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: z-pop 0.4s cubic-bezier(0.2, 1.6, 0.4, 1);
}
.z-dialog h2 { margin: 0; font-size: 2.6rem; line-height: 1.1; }
.z-dialog p { margin: 4px 0 6px; font-size: 1.25rem; color: var(--ink-soft); white-space: pre-line; }
.z-stars { margin: 4px 0 18px; font-size: 3rem; letter-spacing: 6px; }
.z-star { display: inline-block; filter: grayscale(1) opacity(0.3); }
.z-star.on { filter: none; animation: z-star 0.5s backwards; }
.z-actions { display: flex; flex-direction: column; gap: 14px; }

/* Alçak ekranlar (yatay telefon): kutlama penceresi (Zarok.win) sığsın,
   düğmeler yan yana. Oyunların kendi pencerelerine dokunmaz. */
@media (max-height: 500px) {
  .z-win .z-dialog { width: min(600px, 100%); padding: 12px 16px 14px; }
  .z-win .z-dialog h2 { font-size: 1.9rem; }
  .z-win .z-dialog p { margin: 0 0 2px; font-size: 1.05rem; }
  .z-win .z-stars { font-size: 2.2rem; margin: 0 0 10px; }
  .z-win .z-actions { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 10px; }
  .z-win .z-actions .z-btn { flex: 1 1 auto; min-height: 54px; padding: 0 16px; font-size: 1.15rem; white-space: nowrap; }
}

/* ---------- Kısa mesaj ---------- */
.z-toast {
  position: fixed;
  left: 50%;
  top: 22%;
  z-index: 40;
  padding: 10px 26px;
  border-radius: 999px;
  background: var(--card);
  color: var(--card-ink);
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 6px 0 var(--shadow);
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 10px) scale(0.9);
  transition: opacity 0.2s, transform 0.2s;
}
.z-toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }

.z-confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* ---------- Görsel (emoji ya da çizim) ---------- */
.z-art { display: block; line-height: 1; }
img.z-art { width: 100%; height: 100%; object-fit: contain; -webkit-user-drag: none; }

@keyframes z-fade { from { opacity: 0; } }
@keyframes z-pop { from { transform: scale(0.6); opacity: 0; } }
@keyframes z-star { from { transform: scale(0) rotate(-90deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
