/* Shared look for the learning apps: bright, chunky, big tap targets, light and dark mode.
   App-specific styles go in app.css. Colors: --blue --green --red --purple --yellow (+ -soft, -ink). */

:root {
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Baloo 2", "Nunito", system-ui, sans-serif;
  --bg: #fffaf0; --surface: #ffffff; --surface-2: #fff1d9;
  --text: #2b2340; --muted: #6d6680; --border: #f1e0c6;
  --accent: #ff8a00; --accent-strong: #d96a00; --accent-ink: #ffffff;
  --good: #16a34a; --good-soft: #dcfce7; --bad: #e5484d;
  --blue: #1d7fe0; --blue-dark: #135ea9; --blue-soft: #e3f0ff; --blue-ink: #0f4f91;
  --green: #1ea55b; --green-dark: #137a41; --green-soft: #dcf6e6; --green-ink: #0f6a37;
  --red: #e5484d; --red-dark: #b02d33; --red-soft: #ffe3e2; --red-ink: #a5262c;
  --purple: #8b46d6; --purple-dark: #6429a6; --purple-soft: #f0e5ff; --purple-ink: #5a2399;
  --yellow: #ffc93c; --yellow-dark: #d9a20f; --yellow-soft: #fff4cc; --yellow-ink: #7a5a00;
  --shadow: 0 4px 0 var(--border);
  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17142a; --surface: #221e38; --surface-2: #2d2847; --text: #f4f1ff; --muted: #b5aecb; --border: #3a345a;
    --accent: #ff9d2e; --accent-strong: #ffb85c; --accent-ink: #1c1306; --good-soft: #173826;
    --blue: #4aa3ff; --blue-dark: #2a7fd6; --blue-soft: #16304f; --blue-ink: #9fcdff;
    --green: #37c977; --green-dark: #23a05b; --green-soft: #143a27; --green-ink: #8de8b5;
    --red: #ff6b70; --red-dark: #d6464c; --red-soft: #47202a; --red-ink: #ffb0b3;
    --purple: #b07bff; --purple-dark: #8a53e0; --purple-soft: #33224f; --purple-ink: #d7beff;
    --yellow: #ffd45c; --yellow-dark: #e0ad1f; --yellow-soft: #3d3313; --yellow-ink: #ffe08a;
    --shadow: 0 4px 0 #0c0a18;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17142a; --surface: #221e38; --surface-2: #2d2847; --text: #f4f1ff; --muted: #b5aecb; --border: #3a345a;
  --accent: #ff9d2e; --accent-strong: #ffb85c; --accent-ink: #1c1306; --good-soft: #173826;
  --blue: #4aa3ff; --blue-dark: #2a7fd6; --blue-soft: #16304f; --blue-ink: #9fcdff;
  --green: #37c977; --green-dark: #23a05b; --green-soft: #143a27; --green-ink: #8de8b5;
  --red: #ff6b70; --red-dark: #d6464c; --red-soft: #47202a; --red-ink: #ffb0b3;
  --purple: #b07bff; --purple-dark: #8a53e0; --purple-soft: #33224f; --purple-ink: #d7beff;
  --yellow: #ffd45c; --yellow-dark: #e0ad1f; --yellow-soft: #3d3313; --yellow-ink: #ffe08a;
  --shadow: 0 4px 0 #0c0a18;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 17px/1.5 var(--font-body); -webkit-tap-highlight-color: transparent; overflow-x: hidden; }
a { color: var(--accent-strong); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.1; }
h1 { font-size: clamp(2rem, 7vw, 2.8rem); font-weight: 800; margin: 0.3em 0 0.2em; }
h2 { font-size: 1.3rem; font-weight: 800; margin: 1.2em 0 0.4em; }
h2 small { font-family: var(--font-body); font-weight: 400; font-size: 0.8rem; color: var(--muted); margin-left: 6px; }
.muted { color: var(--muted); }
.small { font-size: 0.88rem; }
.center { justify-content: center; text-align: center; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
button { font: inherit; color: inherit; }
main { max-width: 820px; margin: 0 auto; padding: 8px 16px 64px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px;
  padding: 8px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 2px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font: 800 1.35rem var(--font-display); color: var(--text); text-decoration: none; }
.logo { width: 34px; height: 34px; border-radius: 10px; background: url("../icon.svg") center / cover; transform: rotate(-6deg); }
.nav { margin-left: auto; display: flex; gap: 2px; }
.nav a { color: var(--muted); text-decoration: none; font-weight: 800; padding: 6px 12px; border-radius: 999px; }
.nav a:hover, .nav a.active { background: var(--surface-2); color: var(--accent-strong); }
body.in-game .topbar { display: none; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
  padding: 10px 18px; border-radius: 999px; border: 2px solid var(--border); background: var(--surface);
  font-weight: 800; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .08s; touch-action: manipulation;
}
.btn:active, .btn.pressed { transform: translateY(4px); box-shadow: none; }
.btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 var(--accent-strong); }
.btn.big { font: 800 1.25rem var(--font-display); padding: 12px 26px; min-height: 58px; }
.btn.small { padding: 6px 12px; font-size: 0.9rem; }
.btn.danger { color: var(--bad); }
.btn.ghosty { background: transparent; box-shadow: none; border-style: dashed; color: var(--muted); }
.btn.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { scale: 1; } 50% { scale: 1.05; } }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 14px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; flex: none;
  border: 2px solid var(--border); background: var(--surface); cursor: pointer; text-decoration: none; font-size: 1.2rem; color: var(--text);
}
.icon-btn.toggle[aria-pressed="false"] { opacity: .45; filter: grayscale(1); }

/* home */
.hero { text-align: center; padding: 22px 0 6px; }
.title { font-size: clamp(3rem, 14vw, 4.6rem); margin: 0; }
.title span { display: inline-block; animation: bob 2.4s ease-in-out infinite; }
.title span:nth-child(2n) { animation-delay: .3s; }
.title span:nth-child(3n) { animation-delay: .6s; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
.lede { font-size: 1.1rem; margin: 6px auto 18px; line-height: 1.7; }
.play-btn { font-size: 1.7rem; padding: 14px 48px; min-height: 70px; }
.card { background: var(--surface); border: 2px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; margin-top: 12px; }
.level-card {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px 10px; border-radius: 18px;
  background: var(--surface-2); border: 2px solid transparent; color: var(--text); text-decoration: none; font: 800 1.05rem var(--font-display); text-align: center;
}
.level-card.next { border-color: var(--accent); }
.level-card .emoji { font-size: 2rem; line-height: 1.1; }
.stars { color: var(--yellow); letter-spacing: 1px; font-size: 1.05rem; }
.stars .off { color: var(--border); }
.sticker-book .stickers { display: flex; flex-wrap: wrap; gap: 6px; font-size: 2rem; }

/* play screen */
.play { padding-bottom: 210px; }
.play-top { display: flex; align-items: center; gap: 8px; padding: 8px 0; }
.dots { flex: 1; display: flex; justify-content: center; gap: 8px; }
.dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--border); transition: .3s; }
.dots i.now { background: var(--accent); transform: scale(1.3); }
.dots i.done { background: var(--good); }
.bubble {
  display: flex; align-items: center; gap: 10px; background: var(--surface); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 8px 8px 8px 12px; margin-bottom: 12px; box-shadow: var(--shadow); min-height: 72px;
}
.mascot { font-size: 2.3rem; flex: none; animation: bob 3s ease-in-out infinite; }
.say { flex: 1; margin: 0; font: 600 1.15rem/1.3 var(--font-display); }
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; will-change: transform;
  padding: 10px 16px max(12px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(10px);
  border-top: 2px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.dock:empty { display: none; }
.dock .hint { margin: 0; font-size: 0.85rem; color: var(--muted); }
.choices { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.choice-card {
  min-height: 72px; min-width: 72px; padding: 10px 14px; border-radius: 18px; cursor: pointer; touch-action: manipulation;
  background: var(--surface); border: 3px solid var(--border); box-shadow: var(--shadow); color: var(--text);
  display: flex; align-items: center; justify-content: center; text-align: center; font: 800 2rem var(--font-display);
}
.choice-card:active { transform: translateY(4px); box-shadow: none; }
.choice-card.right { background: var(--good-soft); border-color: var(--good); }
.choice-card.wrong { opacity: .4; border-style: dashed; }
.tap-here { cursor: pointer; animation: tapme 1.1s ease-in-out infinite; border-radius: 12px; }
@keyframes tapme { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 45%, transparent); } }

/* motion overlay */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.ghost { position: fixed; margin: 0 !important; transform-origin: 0 0; z-index: 60; pointer-events: none; }
.incoming { visibility: hidden; }
.fly-chip {
  display: grid; place-items: center; border-radius: 50%; font: 800 1.9rem/1 var(--font-display);
  background: var(--surface); box-shadow: 0 6px 18px rgb(0 0 0 / .25); border: 3px solid currentColor;
}
.confetti { position: fixed; top: 0; width: 10px; height: 14px; border-radius: 2px; z-index: 70; }

/* finish */
.finish { text-align: center; padding-top: 40px; }
.big-stars .stars { font-size: 3.4rem; }
.new-sticker { font-weight: 800; }
.new-sticker span { display: inline-block; font-size: 4.5rem; animation: bob 2s ease-in-out infinite; }

/* grown-ups */
.set { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.set input[type="checkbox"] { width: 26px; height: 26px; accent-color: var(--accent); flex: none; }
.set select, .set input[type="password"] { font: inherit; padding: 6px 10px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); color: var(--text); max-width: 46%; }
.prose p { margin: 10px 0; }

@media (max-width: 420px) { .btn.big { font-size: 1.1rem; padding: 10px 18px; } }
@media (prefers-reduced-motion: reduce) {
  .title span, .mascot, .btn.pulse, .tap-here, .new-sticker span { animation: none !important; }
}
