/* ===== Lumea lui Pufi — design kid-friendly 3-6 ani ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --sun: #FFD166;
  --peach: #FF9F7F;
  --sky: #7EC8F7;
  --grass: #8BD17C;
  --pink: #FF9FB2;
  --lilac: #C3AEF5;
  --cream: #FFF9EC;
  --ink: #4A3F55;
  --white: #FFFFFF;
}

html, body { height: 100%; overflow: hidden; }
body {
  font-family: "Comic Sans MS", "Chalkboard SE", "Segoe UI", "Trebuchet MS", sans-serif;
  background: linear-gradient(180deg, #AEE3FF 0%, #DFF4FF 55%, var(--cream) 100%);
  color: var(--ink);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 1100px; margin: 0 auto; }

/* ===== Top bar ===== */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(255,255,255,.75);
  border-bottom: 4px solid rgba(255,209,102,.6);
  backdrop-filter: blur(6px); z-index: 5;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mascot { font-size: 34px; animation: bob 2.4s ease-in-out infinite; }
.brand-name { font-size: 22px; font-weight: 800; color: var(--ink); letter-spacing: .5px; }
@keyframes bob { 0%,100% { transform: translateY(0) } 50% { transform: translateY(-5px) } }

#top-actions { display: flex; gap: 10px; }
.icon-btn {
  font-size: 24px; width: 52px; height: 52px; border-radius: 50%;
  border: 3px solid var(--white); background: var(--sun); cursor: pointer;
  box-shadow: 0 4px 0 rgba(0,0,0,.12); transition: transform .1s;
}
.icon-btn:active { transform: scale(.92); }
.icon-btn.off { filter: grayscale(1); opacity: .6; }

/* ===== Main screens ===== */
#screen-root { flex: 1; position: relative; overflow: hidden; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 16px; animation: pop-in .35s ease; overflow: auto; }
@keyframes pop-in { from { opacity: 0; transform: scale(.96) } to { opacity: 1; transform: scale(1) } }

.screen h1 { font-size: clamp(26px, 5vw, 40px); margin-bottom: 8px; text-shadow: 2px 2px 0 #fff; }
.screen .subtitle { font-size: 18px; margin-bottom: 20px; opacity: .8; }

/* ===== Bottom dock ===== */
#dock {
  display: flex; justify-content: space-around; gap: 4px;
  background: rgba(255,255,255,.85); border-top: 4px solid rgba(255,159,127,.5);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 5;
}
.dock-btn {
  flex: 1; max-width: 110px; border: none; background: transparent; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; border-radius: 16px; font-family: inherit; color: var(--ink);
  transition: transform .12s, background .2s;
}
.dock-btn:active { transform: scale(.9); }
.dock-btn.active { background: var(--sun); box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.dock-ic { font-size: 28px; }
.dock-tx { font-size: 13px; font-weight: 700; }

/* ===== Home ===== */
.home-hero { text-align: center; }
.hero-mascot { font-size: 90px; display: inline-block; animation: bob 2s ease-in-out infinite; }
.menu-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 14px; width: 100%; max-width: 640px; margin-top: 20px; }
.menu-card {
  border: 4px solid var(--white); border-radius: 24px; padding: 18px 8px;
  background: var(--white); cursor: pointer; display: flex; flex-direction: column;
  align-items: center; gap: 8px; font-family: inherit; color: var(--ink);
  box-shadow: 0 6px 0 rgba(0,0,0,.08); transition: transform .12s;
}
.menu-card:active { transform: scale(.94); }
.menu-card .mc-ic { font-size: 44px; }
.menu-card .mc-tx { font-size: 17px; font-weight: 800; }
.menu-card.c1 { background: #FFF3D6; } .menu-card.c2 { background: #E3F4FF; }
.menu-card.c3 { background: #E8F9E4; } .menu-card.c4 { background: #FFE9ED; }
.menu-card.c5 { background: #F1EAFF; }

/* ===== Avatar ===== */
.avatar-stage {
  background: radial-gradient(circle at 50% 35%, #fff 0%, #E3F4FF 70%);
  border: 4px solid var(--white); border-radius: 28px; padding: 20px;
  width: min(320px, 80vw); box-shadow: 0 8px 0 rgba(0,0,0,.07);
  display: flex; justify-content: center; margin-bottom: 14px;
}
.avatar-preview { font-size: 120px; line-height: 1; animation: bob 2.2s ease-in-out infinite; }
.avatar-options { width: 100%; max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.opt-group { text-align: center; }
.opt-group .og-label { font-size: 15px; font-weight: 800; margin-bottom: 6px; display: block; }
.opt-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.opt-btn {
  width: 56px; height: 56px; border-radius: 50%; border: 4px solid var(--white);
  cursor: pointer; font-size: 26px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 0 rgba(0,0,0,.1); transition: transform .1s;
}
.opt-btn:active { transform: scale(.88); }
.opt-btn.selected { outline: 4px solid var(--sun); transform: scale(1.1); }

/* ===== World ===== */
#world-canvas-wrap { position: absolute; inset: 0; }
#world-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.world-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: rgba(255,255,255,.9); border-radius: 999px; padding: 8px 18px;
  font-size: 15px; font-weight: 700; pointer-events: none; box-shadow: 0 3px 0 rgba(0,0,0,.08);
}
#world-found { position: absolute; top: 54px; left: 50%; transform: translateX(-50%); font-size: 15px; font-weight: 700; background: rgba(255,255,255,.8); padding: 4px 14px; border-radius: 999px; pointer-events: none; }

/* ===== Build ===== */
.build-wrap { display: flex; flex-direction: column; width: 100%; height: 100%; }
.build-palette { display: flex; gap: 10px; justify-content: center; padding: 10px 4px; flex-wrap: wrap; align-items: center; }
.swatch { width: 48px; height: 48px; border-radius: 14px; border: 4px solid #fff; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.12); transition: transform .1s; }
.swatch:active { transform: scale(.88); }
.swatch.selected { outline: 4px solid var(--ink); transform: scale(1.12); }
.build-tool { border: 3px solid #fff; border-radius: 14px; background: #eee; width: 48px; height: 48px; font-size: 22px; cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.12); }
.build-tool.selected { outline: 4px solid var(--ink); }
#build-canvas { flex: 1; width: 100%; touch-action: none; border-radius: 18px; background: #E9F6FF; cursor: crosshair; }

/* ===== Color ===== */
.color-wrap { display: flex; flex-direction: column; width: 100%; height: 100%; }
.color-palette { display: flex; gap: 10px; justify-content: center; padding: 10px 4px; flex-wrap: wrap; align-items: center; }
#color-svg-wrap { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
#color-svg-wrap svg { max-height: 100%; max-width: 100%; touch-action: manipulation; }
#color-svg-wrap svg .zone { cursor: pointer; stroke: #4A3F55; stroke-width: 4; transition: fill .2s; }

/* ===== Games ===== */
.game-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 16px; width: 100%; max-width: 560px; }
.game-question { font-size: clamp(20px, 4vw, 28px); font-weight: 800; text-align: center; margin-bottom: 18px; background: #fff; padding: 12px 22px; border-radius: 999px; box-shadow: 0 4px 0 rgba(0,0,0,.08); }
.game-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; width: 100%; max-width: 480px; }
.game-grid.three { grid-template-columns: repeat(3, 1fr); max-width: 560px; }
.choice-btn {
  aspect-ratio: 1; border: 4px solid #fff; border-radius: 24px; background: #fff;
  font-size: clamp(40px, 9vw, 64px); cursor: pointer; display: flex; align-items: center;
  justify-content: center; box-shadow: 0 5px 0 rgba(0,0,0,.08); transition: transform .12s;
  font-family: inherit; font-weight: 800; color: var(--ink);
}
.choice-btn:active { transform: scale(.92); }
.choice-btn.correct { background: #C8F7C5; animation: cheer .5s ease; }
.choice-btn.wrong { background: #FFD9D9; animation: shake .4s ease; }
@keyframes cheer { 0%{transform:scale(1)} 40%{transform:scale(1.15) rotate(-4deg)} 70%{transform:scale(1.1) rotate(4deg)} 100%{transform:scale(1.05)} }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }
.game-stars { font-size: 30px; margin-top: 16px; letter-spacing: 4px; }
.game-back { position: absolute; top: 14px; left: 14px; z-index: 3; }

/* ===== Parent overlay ===== */
#parent-overlay, #break-overlay {
  position: fixed; inset: 0; background: rgba(74,63,85,.55); z-index: 50;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
#parent-overlay.hidden, #break-overlay.hidden, .hidden { display: none !important; }
#parent-card, .break-card {
  background: var(--cream); border-radius: 28px; border: 5px solid var(--sun);
  width: 100%; max-width: 480px; max-height: 88dvh; overflow-y: auto; padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
#parent-gate { text-align: center; }
.gate-emoji { font-size: 56px; margin-bottom: 8px; }
#parent-gate h2 { margin-bottom: 6px; }
#parent-gate p { margin-bottom: 18px; opacity: .75; }
#gate-hold {
  position: relative; width: 100%; padding: 18px; font-size: 19px; font-weight: 800;
  border-radius: 18px; border: none; background: #E8E0F5; color: var(--ink);
  cursor: pointer; overflow: hidden; font-family: inherit;
}
#gate-fill { position: absolute; inset: 0; width: 0%; background: var(--lilac); transition: none; }
#gate-label { position: relative; z-index: 1; }
.link-btn { background: none; border: none; color: #8a7f99; text-decoration: underline; cursor: pointer; margin-top: 14px; font-size: 15px; font-family: inherit; }

#parent-panel h2 { margin-bottom: 14px; }
.p-section { background: #fff; border-radius: 16px; padding: 14px 16px; margin-bottom: 12px; }
.p-section h3 { font-size: 16px; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 16px; }
.row input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--grass); }
.opts { gap: 10px; }
.opts button {
  flex: 1; padding: 12px 6px; border-radius: 14px; border: 3px solid #ddd;
  background: #f6f2ff; font-family: inherit; font-size: 15px; font-weight: 700; cursor: pointer; color: var(--ink);
}
.opts button.selected { border-color: var(--lilac); background: var(--lilac); color: #fff; }
#stats-rows .stat-row { display: flex; justify-content: space-between; padding: 5px 0; font-size: 15px; border-bottom: 1px dashed #eee; }
.safe-list { list-style: none; font-size: 15px; line-height: 1.9; }
.big-primary {
  width: 100%; padding: 16px; margin-top: 6px; border-radius: 18px; border: none;
  background: var(--grass); color: #fff; font-size: 19px; font-weight: 800;
  font-family: inherit; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.12);
}
.big-primary:active { transform: scale(.97); }

/* ===== Break ===== */
.break-card { text-align: center; }
.break-moon { font-size: 72px; animation: bob 3s ease-in-out infinite; }
.break-card h2 { margin: 12px 0 8px; }
.break-card p { font-size: 17px; line-height: 1.5; }

/* ===== Story ===== */
.story-card {
  background: var(--cream); border: 5px solid var(--sun); border-radius: 28px;
  padding: 24px; width: 100%; max-width: 520px; text-align: center;
  box-shadow: 0 10px 0 rgba(0,0,0,.08);
}
.story-title { font-size: 22px; font-weight: 800; margin-bottom: 14px; }
.story-art { font-size: clamp(56px, 12vw, 84px); line-height: 1.3; margin-bottom: 16px; min-height: 100px; }
.story-hero { display: inline-block; animation: bob 2s ease-in-out infinite; }
.story-text { font-size: 19px; line-height: 1.55; margin-bottom: 20px; }
.story-nav { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.story-btn {
  border: 3px solid #e5ddf0; background: #fff; border-radius: 16px;
  padding: 12px 18px; font-size: 17px; font-weight: 800; font-family: inherit;
  color: var(--ink); cursor: pointer; box-shadow: 0 3px 0 rgba(0,0,0,.08);
}
.story-btn:active { transform: scale(.94); }
.story-btn.primary { background: var(--grass); color: #fff; border-color: var(--grass); }
.story-dots { margin-top: 14px; font-size: 18px; color: var(--sun); letter-spacing: 6px; }

/* ===== Memory ===== */
.mem-card { transition: transform .25s; }
.mem-card.mem-done { background: #C8F7C5 !important; }

/* ===== Toast ===== */
#toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 24px; border-radius: 999px;
  font-size: 17px; font-weight: 700; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: pop-in .25s ease;
}

@media (max-width: 480px) {
  .brand-name { font-size: 18px; }
  .dock-tx { font-size: 11px; }
  .dock-ic { font-size: 24px; }
}
