:root {
  --bg: #fdf7ff;
  --bg2: #eef4ff;
  --ink: #2d2a4a;
  --muted: #7a7799;
  --card: #ffffff;
  --primary: #7c5cff;
  --primary-ink: #ffffff;
  --good: #22c55e;
  --bad: #f43f5e;
  --gold: #fbbf24;
  --radius: 22px;
  --shadow: 0 6px 0 rgba(45, 42, 74, 0.12), 0 10px 24px rgba(45, 42, 74, 0.08);
  font-family: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Varela Round', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: linear-gradient(160deg, var(--bg), var(--bg2));
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
}

#app { min-height: 100%; display: flex; flex-direction: column; }

h1, h2, h3 { margin: 0; line-height: 1.15; }

/* ------------------------------------------------------------------ buttons */
.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 26px;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.08s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(3px) scale(0.98); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-big { font-size: 1.5rem; padding: 18px 40px; }
.btn-ghost { background: transparent; box-shadow: none; color: var(--muted); }
.btn-small { font-size: 0.95rem; padding: 8px 16px; }
.icon-btn {
  appearance: none; border: 0; background: var(--card); box-shadow: var(--shadow);
  width: 52px; height: 52px; border-radius: 50%; font-size: 1.5rem; cursor: pointer;
  display: inline-grid; place-items: center; flex: none; touch-action: manipulation;
}
.icon-btn:active { transform: translateY(3px); }

/* ------------------------------------------------------------------ screens */
.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  animation: screen-in 0.25s ease;
}
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } }

.topbar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.topbar .grow { flex: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }

/* ------------------------------------------------------------------ profiles */
.logo { font-size: clamp(2rem, 6vw, 3.2rem); text-align: center; margin: 24px 0 6px; }
.tagline { text-align: center; color: var(--muted); margin-bottom: 28px; font-size: 1.1rem; }
.profile-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 18px; }
.profile-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  width: 150px; padding: 20px 12px; text-align: center; cursor: pointer; border: 0; font: inherit; color: inherit;
}
.profile-card .avatar { font-size: 3.6rem; display: block; }
.profile-card .name { font-weight: 800; font-size: 1.2rem; margin-top: 6px; display: block; }
.profile-card:active { transform: translateY(3px); }

.form { display: flex; flex-direction: column; align-items: center; gap: 18px; margin-top: 10px; }
.input {
  font: inherit; font-size: 1.4rem; padding: 14px 20px; border-radius: 16px; border: 3px solid #e3defa;
  text-align: center; width: min(340px, 90vw); outline: none; color: var(--ink); background: #fff;
  -webkit-user-select: text; user-select: text;
}
.input:focus { border-color: var(--primary); }
.avatar-pick { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; max-width: 520px; }
.avatar-pick button {
  font-size: 2.2rem; width: 64px; height: 64px; border-radius: 18px; border: 3px solid transparent;
  background: var(--card); box-shadow: var(--shadow); cursor: pointer;
}
.avatar-pick button.selected { border-color: var(--primary); transform: scale(1.08); }

/* ------------------------------------------------------------------ language */
.lang-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; max-width: 760px; width: 100%; margin: 10px auto 0; }
.lang-card {
  display: flex; align-items: center; gap: 16px; padding: 20px 22px; border-radius: var(--radius); border: 4px solid transparent;
  background: var(--card); box-shadow: var(--shadow); font: inherit; color: inherit; cursor: pointer; text-align: left;
}
.lang-card .flag { font-size: 3rem; line-height: 1; }
.lang-card .name { font-size: 1.4rem; font-weight: 800; }
.lang-card.selected { border-color: var(--primary); }
.lang-card:active { transform: translateY(3px); }

/* ------------------------------------------------------------------ home */
.hello { font-size: 1.6rem; font-weight: 800; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--card); box-shadow: var(--shadow);
  border-radius: 999px; padding: 8px 14px; font-weight: 800;
}
.mix-banner {
  display: flex; align-items: center; gap: 18px; padding: 20px 24px; border-radius: var(--radius);
  background: linear-gradient(120deg, #7c5cff, #c05cff); color: #fff; box-shadow: var(--shadow);
  margin-bottom: 22px; cursor: pointer; border: 0; font: inherit; text-align: left; width: 100%;
}
.mix-banner .big { font-size: 3rem; }
.mix-banner h2 { font-size: 1.5rem; }
.mix-banner p { margin: 4px 0 0; opacity: 0.9; }
.mix-banner:active { transform: translateY(3px); }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 18px; }
.game-card {
  --c: var(--primary);
  position: relative; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
  border-top: 8px solid var(--c); display: flex; flex-direction: column; gap: 6px; min-height: 170px;
}
.game-card:active { transform: translateY(3px); }
.game-card .emoji { font-size: 2.8rem; }
.game-card h3 { font-size: 1.25rem; }
.game-card .skill { color: var(--c); font-weight: 800; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.04em; }
.game-card .meta { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }
.level-badge { background: color-mix(in srgb, var(--c) 15%, white); color: var(--ink); border-radius: 999px; padding: 3px 10px; font-weight: 800; font-size: 0.9rem; white-space: nowrap; }
/* Ukrainian/Portuguese words can be long: let card texts hyphenate/break instead of widening the grid. */
.game-card h3, .game-card .skill, .game-card .muted { overflow-wrap: break-word; hyphens: auto; }
.stars { color: var(--gold); letter-spacing: 1px; font-size: 1.1rem; }
.stars .off { color: #e6e3f3; }
.done-today { position: absolute; top: 12px; right: 14px; font-size: 1.4rem; }

.home-footer { display: flex; justify-content: center; gap: 12px; margin-top: 26px; flex-wrap: wrap; }
.checkup-banner { background: linear-gradient(120deg, #0ea5e9, #22c55e); }

/* ------------------------------------------------------------------ kid progress: week, garden, badges */
.home-progress { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; margin-bottom: 22px; }
.home-progress .week { flex: 1 1 320px; }
.garden-btn { flex: 0 1 auto; border-radius: var(--radius); }
.week {
  display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding: 10px; border: 0; font: inherit; color: inherit;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); cursor: pointer; width: 100%;
}
.week-day { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border-radius: 12px; background: #f6f4fd; }
.week-day.played { background: #fff4d6; }
.week-day.today { outline: 3px solid var(--primary); }
.week-day .wd { font-size: 0.75rem; color: var(--muted); font-weight: 700; text-transform: capitalize; }
.week-day .ws { font-size: 0.85rem; font-weight: 800; white-space: nowrap; }
.section-title { margin: 24px 0 12px; font-size: 1.3rem; }
.garden { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 8px; }
.plot {
  --c: var(--primary);
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px; border: 0; font: inherit; color: inherit;
  border-radius: var(--radius); cursor: pointer; text-align: center;
  background: linear-gradient(180deg, #fff 55%, color-mix(in srgb, #a16207 22%, white) 55%); box-shadow: var(--shadow);
}
.plot .plant { font-size: 3.4rem; line-height: 1.1; animation: sway 3s ease-in-out infinite; transform-origin: bottom center; }
@keyframes sway { 50% { transform: rotate(-4deg); } }
.plot-title { font-weight: 800; font-size: 0.95rem; overflow-wrap: break-word; hyphens: auto; max-width: 100%; }
.plot-bar { width: 80%; height: 8px; border-radius: 999px; background: #ffffffaa; overflow: hidden; }
.plot-bar > span { display: block; height: 100%; background: var(--c); border-radius: 999px; }
.plot-sub { font-size: 0.8rem; }
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 14px 8px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow); }
.badge .big { font-size: 2.4rem; }
.badge-name { font-weight: 800; }
.badge-desc { font-size: 0.8rem; }
.badge.locked { opacity: 0.55; }
.new-badges { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast-badge { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.15rem; }
.toast-badge .big { font-size: 2rem; }
.toast {
  position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--card); border: 4px solid var(--gold); border-radius: 22px; padding: 12px 22px; box-shadow: var(--shadow);
  animation: toast-in 0.4s cubic-bezier(.3,1.6,.6,1); transition: opacity 0.5s, transform 0.5s;
}
.toast.out { opacity: 0; transform: translate(-50%, -20px); }
.toast-title { font-weight: 900; color: var(--primary); }
@keyframes toast-in { from { transform: translate(-50%, -40px) scale(0.8); opacity: 0; } }

/* ------------------------------------------------------------------ intro */
.intro { align-items: center; text-align: center; justify-content: center; gap: 18px; }
.intro .emoji { font-size: 5.5rem; }
.intro h1 { font-size: 2.3rem; }
.howto {
  list-style: none; padding: 0; margin: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 26px; text-align: left; font-size: 1.2rem; max-width: 560px; width: 100%;
}
.howto li { padding: 7px 0 7px 36px; position: relative; }
.howto li::before { content: '⭐'; position: absolute; left: 0; }
.why { max-width: 560px; font-size: 0.95rem; }

/* ------------------------------------------------------------------ play */
.play { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.hud { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.hud .title { font-weight: 800; font-size: 1.15rem; white-space: nowrap; }
.hud .bar { flex: 1; height: 16px; border-radius: 999px; background: #e9e5fb; overflow: hidden; min-width: 60px; }
.hud .bar > div { height: 100%; width: 0; background: var(--c, var(--primary)); border-radius: 999px; transition: width 0.3s ease; }
.status { text-align: center; font-size: 1.35rem; font-weight: 800; min-height: 1.8em; margin-bottom: 6px; }
.stage-wrap {
  flex: 1; position: relative; border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow);
  overflow: hidden; display: flex; min-height: 320px; transition: box-shadow 0.15s ease;
}
.stage-wrap.flash-good { box-shadow: 0 0 0 6px var(--good), var(--shadow); }
.stage-wrap.flash-bad { box-shadow: 0 0 0 6px var(--bad), var(--shadow); animation: shake 0.3s ease; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
/* min-width: 0 so wide content (long words) can never stretch the stage beyond the screen. */
.stage { flex: 1; min-width: 0; position: relative; display: flex; flex-direction: column; }

/* ------------------------------------------------------------------ results */
.results { align-items: center; justify-content: center; text-align: center; gap: 18px; position: relative; }
.results .big-stars { font-size: 4.5rem; letter-spacing: 6px; }
.results .big-stars span { display: inline-block; animation: star-pop 0.45s cubic-bezier(.3,1.6,.6,1) both; }
.results .big-stars .off { color: #e6e3f3; filter: grayscale(1); opacity: 0.4; }
@keyframes star-pop { from { transform: scale(0) rotate(-40deg); } }
.results h1 { font-size: 2.2rem; }
.results .row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.level-up { font-size: 1.3rem; font-weight: 800; color: var(--primary); }
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 10; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ------------------------------------------------------------------ brain break */
.break { align-items: center; justify-content: center; text-align: center; gap: 22px; }
.break-card {
  background: var(--card); border-radius: 28px; box-shadow: var(--shadow); padding: 34px 30px; max-width: 560px;
  border: 4px dashed #ffd36e;
}
.break-card .emoji { font-size: 5rem; }
.break-card p { font-size: 1.6rem; font-weight: 800; margin: 14px 0 0; }
.break-card .why { margin: 14px auto 0; font-weight: 400; font-size: 1rem; color: var(--muted); }

/* ------------------------------------------------------------------ parent corner */
.parent h1 { font-size: 1.8rem; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px; }
.panel h2 { font-size: 1.2rem; margin-bottom: 10px; }
.panel p, .panel li { line-height: 1.5; }
.stats { width: 100%; border-collapse: collapse; font-size: 0.98rem; }
.stats th, .stats td { padding: 8px 6px; text-align: left; border-bottom: 1px solid #efecf9; }
.stats th { color: var(--muted); font-weight: 700; font-size: 0.85rem; }
.spark { display: block; }
.toggle { display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.toggle input { width: 22px; height: 22px; }
.danger { color: var(--bad); }
.small { font-size: 0.85rem; }
.chg { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 0.8rem; font-weight: 800; white-space: nowrap; }
.chg-up { background: #dcfce7; color: #15803d; }
.chg-down { background: #ffe4e6; color: #be123c; }
.chg-same { background: #f1f0f7; color: var(--muted); }
.activity { display: block; width: 100%; max-width: 520px; height: auto; color: var(--ink); margin-top: 6px; }

/* ------------------------------------------------------------------ shared game helpers */
.g-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 16px; }
.g-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.g-big { font-size: clamp(2rem, 7vw, 4rem); font-weight: 900; }
.g-msg { font-size: 1.4rem; font-weight: 800; text-align: center; }
.g-btn {
  appearance: none; border: 0; font: inherit; font-weight: 800; font-size: 1.4rem; color: var(--ink);
  background: #f3f0ff; border-radius: 20px; padding: 18px 26px; min-width: 88px; min-height: 72px;
  box-shadow: 0 5px 0 rgba(45, 42, 74, 0.15); cursor: pointer; touch-action: manipulation;
}
.g-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(45, 42, 74, 0.15); }
.g-btn:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 560px) {
  .screen { padding-left: 12px; padding-right: 12px; }
  .hud .title { display: none; }
  .game-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .topbar { flex-wrap: wrap; row-gap: 10px; gap: 10px; }
  .icon-btn { width: 46px; height: 46px; font-size: 1.3rem; }
  .chip { padding: 6px 11px; }
  .game-card { min-height: 150px; padding: 14px; }
  .game-card .emoji { font-size: 2.2rem; }
}
