/* Shared look for every Cozy Kid Games page. Game-specific styles live in each game's folder. */
:root {
  --bg1: #fff6e5;
  --bg2: #e6f4ff;
  --ink: #3b3355;
  --muted: #7a7194;
  --accent: #ff7a59;
  --accent-dark: #e85d3c;
  --purple: #7c6cf2;
  --purple2: #a78bfa;
  --match: #5fd38d;
  --star: #ffc93c;
  --star-off: #e4e0ee;
  --shadow: 0 6px 0 rgba(59, 51, 85, 0.15), 0 10px 24px rgba(59, 51, 85, 0.12);
  --radius: 18px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Baloo 2", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, var(--bg1) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow-x: hidden;
}

button { font-family: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; }

/* ---------- screens ---------- */
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: flex; flex-direction: column; align-items: center; }

/* ---------- site header ---------- */
.site-header { width: 100%; max-width: 720px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.2rem; }
.brand img { border-radius: 9px; }
.all-games { text-decoration: none; color: var(--muted); font-weight: 700; font-size: 1rem; background: #fff; padding: 6px 14px; border-radius: 999px; box-shadow: 0 3px 0 rgba(59, 51, 85, 0.1); }

/* ---------- game home (level select) ---------- */
.home { justify-content: center; padding: 16px 16px 40px; gap: 6px; }

.title {
  margin: 0;
  font-size: clamp(2.6rem, 9vw, 4.2rem);
  font-weight: 800;
  line-height: 1;
  text-align: center;
  color: var(--purple);
  text-shadow: 0 4px 0 rgba(124, 108, 242, 0.18);
}
.title span { color: var(--accent); }
.subtitle { margin: 4px 0 22px; font-size: 1.25rem; color: var(--muted); text-align: center; }

.levels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 560px;
}
.level-btn {
  position: relative;
  border: 0;
  border-radius: 22px;
  padding: 16px 12px 12px;
  background: #fff;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.15s ease;
}
.level-btn:hover:not(:disabled) { transform: translateY(-3px); }
.level-btn:active:not(:disabled) { transform: translateY(2px); }
.level-btn .emoji { font-size: 2.4rem; line-height: 1.1; }
.level-btn .name { font-size: 1.35rem; font-weight: 800; }
.level-btn .count { font-size: 0.95rem; color: var(--muted); }
.level-btn .stars { font-size: 1.3rem; letter-spacing: 2px; }
.level-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.level-btn:disabled .emoji { filter: grayscale(1); }
.level-btn .lock { position: absolute; top: 8px; right: 10px; font-size: 1.2rem; }
.star-on { color: var(--star); }
.star-off { color: var(--star-off); }

/* ---------- about text ---------- */
.about { width: 100%; max-width: 640px; margin-top: 40px; display: grid; gap: 14px; user-select: text; }
.about section { background: rgba(255, 255, 255, 0.6); border-radius: 18px; padding: 14px 18px; }
.about h2 { margin: 0 0 4px; font-size: 1.25rem; color: var(--purple); }
.about p { margin: 0; font-size: 1.02rem; line-height: 1.55; color: #5b5375; }
.about a { color: var(--accent-dark); }

/* ---------- footer ---------- */
.home-footer { margin-top: 28px; font-size: 1rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.home-footer a { color: var(--muted); }

/* ---------- game screen bar ---------- */
.game { padding: 12px 16px 16px; }
.bar {
  width: 100%;
  max-width: 720px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.bar-side { display: flex; gap: 10px; }
.bar-info { text-align: center; }
.level-name { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.moves { font-size: 1.15rem; color: var(--muted); }
.moves strong { color: var(--accent); font-size: 1.35rem; }

.icon-btn {
  width: 56px; height: 56px;
  border: 0; border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow);
  font-size: 1.6rem;
  display: grid; place-items: center;
  transition: transform 0.15s ease, opacity 0.15s ease;
}
.icon-btn:active { transform: translateY(2px) scale(0.96); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }

/* ---------- overlays (finish + parent gate) ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(59, 51, 85, 0.45);
  display: grid; place-items: center;
  padding: 16px;
  z-index: 10;
  animation: fade 0.3s ease;
}
.overlay[hidden] { display: none; }
.panel {
  background: #fff;
  border-radius: 28px;
  padding: 24px 22px 22px;
  width: 100%;
  max-width: 400px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  animation: rise 0.4s cubic-bezier(.3, 1.5, .6, 1);
}
.panel h2 { margin: 6px 0 0; font-size: 2rem; line-height: 1.15; }
.finish-sub { margin: 4px 0 18px; color: var(--muted); font-size: 1.15rem; }

.big-stars { display: flex; justify-content: center; gap: 8px; font-size: 3.6rem; line-height: 1; min-height: 3.8rem; }
.big-stars span { opacity: 0; transform: scale(0.2) rotate(-30deg); }
.big-stars span.show { animation: starPop 0.5s cubic-bezier(.3, 1.8, .6, 1) forwards; }
.big-stars span.off { filter: grayscale(1); }
.big-stars span.off.show { animation-name: starPopOff; }
@keyframes starPop { to { opacity: 1; transform: scale(1) rotate(0); } }
@keyframes starPopOff { to { opacity: 0.25; transform: scale(0.85) rotate(0); } }

.panel-buttons { display: grid; gap: 10px; }
.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 16px;
  font-size: 1.3rem;
  font-weight: 700;
  background: #f1eefb;
  box-shadow: 0 4px 0 rgba(59, 51, 85, 0.12);
  transition: transform 0.12s ease;
}
.btn:active { transform: translateY(2px); }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-dark); }
.btn[hidden] { display: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px) scale(0.9); opacity: 0; } }

/* ---------- ad slot (results screen only) ---------- */
.ad-slot { margin-top: 22px; padding-top: 12px; border-top: 2px dashed #ece8f6; animation: fade 0.4s ease; }
.ad-slot[hidden] { display: none; }
.ad-label { font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: #a59fb8; margin-bottom: 6px; }
.ad-content { min-height: 50px; max-height: 110px; overflow: hidden; display: grid; place-items: center; }
.ad-content ins { display: block; width: 100%; }
.house-ad {
  display: flex; align-items: center; gap: 12px;
  width: 100%; max-width: 340px; min-height: 64px;
  border: 0; border-radius: 14px; padding: 8px 12px;
  background: #f7f5fc; text-align: left; font-size: 1rem; line-height: 1.25;
}
.house-ad img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; flex: none; }
.house-ad .house-only-img { width: 100%; height: auto; max-height: 100px; object-fit: contain; }

/* ---------- parent gate ---------- */
.gate { z-index: 12; }
.gate-panel { display: grid; gap: 12px; }
.hold-btn { position: relative; overflow: hidden; touch-action: none; }
.hold-fill { position: absolute; inset: 0; width: 0; background: rgba(255, 255, 255, 0.35); }
.hold-btn.holding .hold-fill { width: 100%; transition: width 3s linear; }
.hold-text { position: relative; }

/* ---------- confetti ---------- */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 11; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
  .confetti { display: none; }
}
