/* ===================================================================
   Alphabet Friends — Phase 1
   Kid-first UI: big targets, high contrast, rounded, colorblind-safe,
   no reading required to navigate, respects reduced motion.
   =================================================================== */

:root {
  --bg1: #6a4cc9;
  --bg2: #5b3fb5;
  --card-back: #ffffff;
  --ink: #2b2140;
  --pink: #ef476f;
  --yellow: #ffd166;
  --green: #06d6a0;
  --blue: #118ab2;
  --purple: #7c5cff;
  --radius: 22px;
  --shadow: 0 8px 0 rgba(0,0,0,0.16);
  --tap: 88px; /* minimum comfortable touch target */
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;          /* no pull-to-refresh / bounce from little hands */
  font-family: "Baloo 2", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;        /* no long-press callout menu */
  touch-action: manipulation;
}

body {
  background: radial-gradient(circle at 30% 20%, var(--bg1), var(--bg2));
  background-attachment: fixed;
}

/* ---------- screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.screen.active { display: flex; }

/* ---------- home ---------- */
.home-inner {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  width: min(560px, 92vw);
}
.logo { text-align: center; color: #fff; }
.logo-letters { font-size: clamp(56px, 16vw, 120px); font-weight: 800; line-height: 1; }
.logo-letters span { color: var(--c); display: inline-block; transform: rotate(calc(var(--r,0) * 1deg)); }
.logo-letters span:nth-child(1){ --r:-8 }
.logo-letters span:nth-child(2){ --r:6 }
.logo-letters span:nth-child(3){ --r:-5 }
.logo-letters span:nth-child(4){ --r:9 }
.logo h1 { font-size: clamp(26px, 7vw, 46px); margin: 8px 0 0; letter-spacing: .5px; }

.big-btn {
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(26px, 6vw, 38px);
  color: #fff;
  padding: 22px 30px;
  width: 100%;
  min-height: var(--tap);
  display: flex; align-items: center; justify-content: center; gap: 14px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform .08s ease;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 4px 0 rgba(0,0,0,.16); }
.big-btn.play { background: var(--green); }
.big-btn.zoo { background: var(--yellow); color: var(--ink); }
.big-btn-emoji { font-size: 1.2em; }

.parent-gear {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 16px;
  width: 54px; height: 54px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.18); color: #fff;
  font-size: 26px; cursor: pointer;
}

/* ---------- game top bar ---------- */
.game-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.round-btn {
  width: 60px; height: 60px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.9);
  font-size: 30px; cursor: pointer; box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
}
.round-btn:active { transform: translateY(3px); }
.stage-pill {
  background: rgba(255,255,255,.9); color: var(--ink);
  font-weight: 800; font-size: clamp(18px, 5vw, 26px);
  padding: 10px 22px; border-radius: 999px; box-shadow: var(--shadow);
}
.zoo-count { color:#fff; font-weight:800; font-size:22px; }

/* ---------- board ---------- */
.board {
  flex: 1;
  min-height: 0;               /* allow the grid to shrink to fit */
  display: grid;
  gap: clamp(10px, 2.4vw, 20px);
  max-width: min(700px, 100%);
  width: 100%;
  margin: 0 auto;
}

.card {
  position: relative;
  min-width: 0;
  min-height: 0;              /* grid item stretches to fill its cell */
  perspective: 800px;
  cursor: pointer;
}
.card-inner {
  position: absolute; inset: 0;
  transform-style: preserve-3d;
  transition: transform .35s cubic-bezier(.4,1.4,.5,1);
  border-radius: var(--radius);
}
.card.flipped .card-inner,
.card.matched .card-inner { transform: rotateY(180deg); }

.card-face {
  position: absolute; inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.card-back {
  background: linear-gradient(160deg, var(--purple), #5b3fb5);
  color: #fff; font-size: 12vmin;
}
.card-back::after { content: "❓"; opacity: .85; }
.card-front {
  transform: rotateY(180deg);
  background: #fff;
  flex-direction: column;
}
.card-front .glyph {
  font-weight: 800;
  font-size: min(22vmin, 130px);
  line-height: 1;
  color: var(--ink);
}
.card.matched { animation: pop .4s ease; }
.card.matched .card-front { background: #eafff7; box-shadow: 0 0 0 5px var(--green), var(--shadow); }
.card.wrong .card-front { animation: shake .4s ease; }

@keyframes pop { 0%{transform:scale(1)} 40%{transform:scale(1.08)} 100%{transform:scale(1)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-7px)} 75%{transform:translateX(7px)} }

/* ---------- zoo map ---------- */
.zoo-grid {
  flex: 1; overflow-y: auto;
  padding: 4px 2px 24px;
  /* grassy grounds */
  background:
    linear-gradient(rgba(6,214,160,.12), rgba(6,214,160,.12));
  border-radius: 20px;
}

.zoo-banner {
  background: rgba(255,255,255,.92); color: var(--ink);
  border-radius: 18px; padding: 20px; margin-bottom: 14px;
  text-align: center; font-weight: 800; font-size: 22px;
  box-shadow: var(--shadow);
}
.zoo-banner small { display: block; font-weight: 600; font-size: 15px; opacity: .7; margin-top: 4px; }

/* the park grounds */
.park {
  background:
    radial-gradient(circle at 20% 0%, rgba(255,255,255,.35), transparent 40%),
    linear-gradient(180deg, #cdeecf, #b6e3bd);
  border-radius: 18px; padding: 12px;
}

/* walkway path dividing the areas */
.park-path {
  height: 22px; margin: 14px 4px; border-radius: 8px;
  background: repeating-linear-gradient(90deg, #d9ccb2 0 20px, #cfc0a2 20px 22px);
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.08);
}
.park-path::after {
  content: ""; position: absolute; left: 8px; right: 8px; top: 50%; height: 3px;
  transform: translateY(-50%);
  background: repeating-linear-gradient(90deg, #fff 0 12px, transparent 12px 26px);
  opacity: .8;
}

/* entrance + strolling visitors */
.park-entrance {
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(180deg, #bfe8ff, #d7f2e6);
  border-radius: 16px; padding: 10px 14px; min-height: 60px;
  box-shadow: inset 0 -6px 0 rgba(6,214,160,.15);
}
.park-entrance .gate { font-size: 40px; line-height: 1; }
.strollers { display: flex; flex-wrap: wrap; gap: 4px 8px; font-size: 26px; }
.stroller { animation: stroll 2.6s ease-in-out infinite; }
@keyframes stroll { 0%,100%{transform:translateX(0)} 50%{transform:translateX(6px)} }

/* signpost headers */
.park-sign {
  display: inline-block; background: var(--purple); color: #fff;
  font-weight: 800; font-size: 16px; padding: 6px 18px;
  border-radius: 999px; margin: 2px 0 10px; box-shadow: var(--shadow);
}

/* midway: rides & concession stands (side quests) */
.rides {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 10px; margin-bottom: 4px;
}
.ride {
  border: none; border-radius: 16px; padding: 12px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  background: #fff; box-shadow: var(--shadow); font-family: inherit;
}
.ride:active { transform: translateY(3px); }
.ride-emoji { font-size: 40px; line-height: 1; }
.ride-emoji.spin { animation: spin 3.5s linear infinite; }
.ride-emoji.bob { animation: bob 2s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ride-name { font-weight: 800; font-size: 13px; color: var(--ink); text-align: center; }
.ride-status { font-weight: 800; font-size: 12px; color: #8a7f6d; }
.ride-status.open { color: var(--green); }
.ride-bar { width: 82%; height: 8px; background: #e6dfd0; border-radius: 999px; overflow: hidden; }
.ride-bar i { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.ride.locked {
  background: repeating-linear-gradient(45deg, #f3eee4, #f3eee4 8px, #e9e2d3 8px, #e9e2d3 16px);
}

@keyframes bob { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }

/* roaming strip for escaped animals */
.zoo-roam {
  background: rgba(255,209,102,.28);
  border: 2px dashed var(--yellow);
  border-radius: 16px; padding: 10px 12px; margin-bottom: 14px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.roam-label { color: #fff; font-weight: 800; font-size: 15px; }
.loose-animal {
  border: none; background: #fff; border-radius: 14px;
  padding: 6px 10px; display: flex; flex-direction: column; align-items: center;
  box-shadow: var(--shadow); cursor: pointer;
  animation: hop 1.1s ease-in-out infinite;
}
.loose-emoji { font-size: 30px; }
.loose-tag { font-weight: 800; font-size: 13px; color: var(--pink); }
@keyframes hop { 0%,100%{transform:translateY(0) rotate(-3deg)} 50%{transform:translateY(-6px) rotate(3deg)} }

/* the pens */
.pens {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
  gap: 12px;
}
.pen {
  aspect-ratio: 1; border-radius: 16px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  position: relative;
  background: #eafff7;
  border: 3px solid #c8bead;                 /* fence */
  box-shadow: var(--shadow);
}
.pen-emoji { font-size: 36px; line-height: 1; }
.pen-tag { font-weight: 800; font-size: 15px; color: var(--ink); }
.pen.home { animation: pop .4s ease; }

/* not earned yet — empty, gated pen */
.pen.locked {
  background: repeating-linear-gradient(45deg, #efe9df, #efe9df 8px, #e6dfd2 8px, #e6dfd2 16px);
  border-style: dashed; opacity: .8;
}
.pen.locked .locked-emoji { filter: grayscale(1) brightness(.75); opacity: .35; }
.pen.locked .pen-tag { color: #8a7f6d; }

/* wandered out — open gate, animal is up in the roam strip */
.pen.loose {
  background: #fff6df; border-color: var(--yellow); border-style: dashed;
}
.pen.loose .pen-gate { font-size: 34px; }
.pen.loose::after {
  content: "escaped!"; position: absolute; top: 4px; right: 6px;
  font-size: 9px; font-weight: 800; color: var(--pink); text-transform: uppercase;
}

/* ---------- celebrate ---------- */
.celebrate {
  position: fixed; inset: 0; z-index: 40;
  display: none; align-items: center; justify-content: center;
  background: rgba(43,33,64,.55); backdrop-filter: blur(2px);
}
.celebrate.show { display: flex; }
.celebrate-card {
  background: #fff; border-radius: 30px; padding: 34px 30px;
  width: min(420px, 88vw); text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,.35);
  animation: rise .35s ease;
}
@keyframes rise { from{transform:translateY(30px);opacity:0} to{transform:translateY(0);opacity:1} }
.celebrate-emoji { font-size: 84px; line-height: 1; }
.celebrate-text { font-size: 30px; font-weight: 800; margin: 12px 0 22px; color: var(--ink); }

.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti span {
  position: absolute; top: -30px; font-size: 26px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: .9; }
}

/* lightweight in-game celebration (runaway animal comes home) */
.burst { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 44; }
.burst span {
  position: absolute; top: -30px; font-size: 26px;
  animation: fall linear forwards;
}
.toast {
  position: fixed; left: 50%; top: 16%; transform: translateX(-50%);
  background: #fff; color: var(--ink); font-weight: 800; font-size: 20px;
  padding: 12px 22px; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.3);
  z-index: 45; pointer-events: none; white-space: nowrap;
  animation: toastpop 2.1s ease forwards;
}
@keyframes toastpop {
  0% { opacity: 0; transform: translate(-50%, -12px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -12px); }
}

/* ---------- parent ---------- */
.parent-body { flex:1; overflow-y:auto; color:#fff; padding-bottom: 24px; }
.parent-body h2 { font-size: 20px; margin: 18px 4px 8px; }
.stat-row { display:flex; gap:12px; flex-wrap:wrap; margin-bottom: 8px; }
.stat-chip {
  background: rgba(255,255,255,.16); border-radius: 16px; padding: 12px 18px;
  min-width: 90px; text-align:center;
}
.stat-chip b { display:block; font-size: 28px; }
.stat-chip small { opacity:.85; }
.heat-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(60px,1fr)); gap:8px; }
.heat-cell {
  border-radius: 12px; padding: 8px 0; text-align:center;
  font-weight: 800; font-size: 20px; color: var(--ink);
  background: rgba(255,255,255,.9);
  position: relative;
}
.heat-cell small { display:block; font-weight:600; font-size:10px; opacity:.7; }
.parent-note { opacity:.85; font-size: 14px; line-height:1.5; margin-top: 16px; }
.parent-actions { margin-top: 18px; display:flex; gap:12px; flex-wrap:wrap;}
.ghost-btn {
  background: rgba(255,255,255,.16); color:#fff; border:2px solid rgba(255,255,255,.4);
  border-radius: 14px; padding: 12px 18px; font-family:inherit; font-weight:700; font-size:16px; cursor:pointer;
}

/* ---------- pinpad ---------- */
.pinpad {
  position: fixed; inset:0; z-index:50; display:none;
  align-items:center; justify-content:center; background: rgba(43,33,64,.6);
}
.pinpad.show { display:flex; }
.pinpad-card { background:#fff; border-radius:26px; padding:26px; width:min(320px,86vw); text-align:center; }
.pin-title { font-weight:800; font-size:22px; margin:0; color:var(--ink); }
.pin-sub { color:#7a708f; margin:4px 0 16px; }
.pin-dots { display:flex; gap:14px; justify-content:center; margin-bottom:18px; }
.pin-dots i { width:16px; height:16px; border-radius:50%; background:#e3def0; }
.pin-dots i.on { background: var(--purple); }
.pin-keys { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; }
.pin-keys button {
  font-family:inherit; font-weight:800; font-size:24px; padding:14px 0;
  border:none; border-radius:16px; background:#f1eefb; color:var(--ink); cursor:pointer;
}
.pin-keys button:active { background:#e3def0; }
.pin-cancel { margin-top:14px; background:none; border:none; color:#7a708f; font-family:inherit; font-size:16px; cursor:pointer; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .05ms !important; }
}
