/* Layout: o singură coloană centrată — masa de lucru (propoziția) sus, cutiile cu piese jos. */
:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #eceef3;
  --ink: #171a23;
  --ink-2: #5b6172;
  --line: #dde0e8;
  --dot: #cfd3dd;
  --accent: #1f3fd1;
  --accent-ink: #ffffff;
  --good: #16865a;
  --good-bg: #e3f5ec;
  --bad: #d4383a;
  --bad-bg: #fdeceb;
  --warn: #b26a00;
  --warn-bg: #fff4dc;
  --paper-ink: #171a23;
  --shadow: 0 1px 2px rgba(23, 26, 35, .06), 0 8px 24px rgba(23, 26, 35, .06);
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --text: "Lexend", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --r-lg: 22px;
  --r-md: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 var(--text);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 1040px;
  margin: 0 auto;
  padding-block: 14px 48px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
.app > * { min-width: 0; }

/* ---------- Bara de sus ---------- */
.top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; }
.brand svg { width: 40px; height: 34px; flex: none; }
.brand h1 {
  margin: 0;
  font: 800 clamp(20px, 4.6vw, 26px)/1 var(--display);
  letter-spacing: -.02em;
}
.brand small { display: block; font: 500 11px/1.2 var(--text); color: var(--ink-2); letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; }
.top-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.seg.levels button { display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1; padding: 5px 12px; }
.seg.levels small { font-size: 10px; font-weight: 500; opacity: .8; }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  height: 38px;
  min-width: 38px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
}
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn.stars svg { color: #e6a700; }
.icon-btn[aria-pressed="false"] { color: var(--ink-2); }

.modes { display: flex; }
.modes .seg { width: 100%; }
.modes .seg button { flex: 1; padding: 9px 10px; font-size: 14px; }

/* ---------- Masa de lucru ---------- */
.mission-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
/* Masa rămâne lipită sus cât timp copilul derulează prin cuvinte. */
.board {
  position: sticky;
  top: calc(env(safe-area-inset-top, 0px) + 8px);
  z-index: 20;
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow), 0 10px 30px rgba(23, 26, 35, .12);
  padding: 16px;
  display: grid;
  gap: 12px;
}
/* Lipită sus: mai mică, ca să rămână loc pentru cuvinte. */
.board.stuck { padding: 8px 10px; gap: 6px; }
.board.stuck .tray { min-height: 0; padding: 6px 20px 6px 6px; row-gap: 8px; }
.board.stuck .tray-empty { font-size: 13px; }
.board.stuck .tray-empty svg { display: none; }
.board.stuck .preview { display: none; }
.board.stuck .btn { height: 34px; padding: 0 9px; border-radius: 10px; }
.board.stuck .btn .lbl { display: none; }
.board.stuck .btn.primary { padding: 0 14px; font-size: 15px; }
.board.stuck .btn.primary .lbl { display: inline; }
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 25;
  background: var(--bg);
}
.mission { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.mission-text { flex: 1 1 260px; min-width: 0; }
.mission-text .eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.mission-text p { margin: 2px 0 0; font-weight: 600; font-size: 17px; line-height: 1.35; text-wrap: balance; }
.mission-text .example { margin-top: 4px; font-size: 14px; color: var(--ink-2); font-weight: 400; }
.chip-btn {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tray {
  position: relative;
  min-height: 132px;
  border-radius: var(--r-md);
  background-color: var(--surface);
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.3px);
  background-size: 18px 18px;
  border: 1.5px dashed var(--line);
  padding: 18px 26px 18px 14px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  row-gap: 16px;
  transition: border-color .2s, background-color .2s;
}
.tray.drop { border-color: var(--accent); }
.tray.ok { border-style: solid; border-color: var(--good); }
.tray-empty {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--ink-2);
  text-align: center;
  font-size: 14px;
  pointer-events: none;
}
.tray-empty svg { width: 120px; height: 46px; color: var(--dot); }

.preview {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 34px;
}
.preview .label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); }
.preview .text { font: 500 clamp(19px, 3.6vw, 24px)/1.3 var(--text); min-width: 0; overflow-wrap: anywhere; }
.preview .text.empty { color: var(--ink-2); font-weight: 400; font-size: 16px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions .spacer { flex: 1; }
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  height: 44px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  cursor: pointer;
}
.btn svg { width: 19px; height: 19px; flex: none; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  padding: 0 22px;
  font-size: 16px;
}
.btn .lbl-short { display: none; }

/* ---------- Răspunsul verificării ---------- */
.feedback { border-radius: var(--r-lg); padding: 16px 18px; display: grid; gap: 10px; }
.feedback[hidden] { display: none; }
.feedback.bad { background: var(--bad-bg); }
.feedback.good { background: var(--good-bg); }
.feedback.info { background: var(--surface-2); }
.feedback h2 { margin: 0; font: 800 22px/1.1 var(--display); letter-spacing: -.01em; }
.feedback.bad h2 { color: var(--bad); }
.feedback.good h2 { color: var(--good); }
.feedback ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 10px; }
.feedback li { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.feedback li .n {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--bad); color: var(--surface);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.feedback li b { font-weight: 700; }
.feedback .why { color: var(--ink); }
.feedback .t { font-weight: 700; display: block; }
.feedback .hint { font-size: 13px; color: var(--ink-2); margin: 0; }
.roles { display: flex; flex-wrap: wrap; gap: 6px; }
.role {
  background: var(--surface);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 14px;
  display: inline-flex;
  gap: 6px;
  align-items: baseline;
}
.role i { font-style: normal; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-2); }
.warn-box { background: var(--warn-bg); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); border-radius: 14px; padding: 12px 14px; display: grid; gap: 6px; }
.warn-box > b { color: var(--warn); font-size: 15px; }
.warn-box ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.feedback .warn-box li { display: list-item; font-size: 15px; }
.feedback .warn-box li .t { display: block; }
.tips { margin: 0; padding-left: 18px; font-size: 14px; }
.fb-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Cutiile cu piese ---------- */
.kit {
  background: var(--surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow);
  padding: 14px 16px 18px;
  display: grid;
  gap: 12px;
  min-width: 0;
}
.kit-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kit-head h2 { margin: 0; font: 800 18px/1 var(--display); margin-right: auto; }
.search {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: var(--surface-2);
  font: 500 14px var(--text);
  color: var(--ink);
  width: min(220px, 100%);
}
/* Coloana cu categorii (doar pe telefon). */
.rail { display: none; }
.kit-main { min-width: 0; display: grid; gap: 12px; align-content: start; }
.rail-btn {
  border: 0;
  border-radius: 12px;
  background: var(--cat);
  color: var(--paper-ink);
  display: grid;
  justify-items: center;
  gap: 2px;
  padding: 9px 2px 8px;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
}
.rail-btn svg { width: 16px; height: 16px; }
.rail-btn b { font-size: 10px; font-weight: 600; line-height: 1.1; letter-spacing: -.01em; }
.rail-btn[aria-pressed="true"] { outline: 2.5px solid var(--ink); outline-offset: 1px; }
.rail-btn.suf { background: var(--surface-2); }
.rail-btn .suf-mark { font-weight: 800; font-size: 13px; line-height: 16px; color: var(--bad); }
.hint-en { text-transform: none; letter-spacing: 0; font-weight: 500; }

/* Categoriile și terminațiile rămân lipite chiar sub masa de lucru. */
.kit-dock {
  position: sticky;
  top: calc(var(--dock-top, 0px) + 6px);
  z-index: 15;
  display: grid;
  gap: 10px;
  margin-inline: -16px;
  padding: 8px 16px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.endings { display: flex; align-items: center; gap: 4px 0; flex-wrap: wrap; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-2); }
.endings .lbl { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-right: 10px; }
.endings .sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 14px 0 4px; }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
  margin: 0 -4px;
  padding-inline: 4px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none;
  border: 0;
  border-radius: 12px;
  padding: 8px 12px 8px 10px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: left;
}
.tab svg { width: 18px; height: 18px; flex: none; }
.tab span { display: grid; line-height: 1.15; }
.tab b { font-size: 14px; font-weight: 600; }
.tab small { font-size: 11px; color: var(--ink-2); }
.tab[aria-selected="true"] { background: var(--cat); color: var(--paper-ink); }
.tab[aria-selected="true"] small { color: var(--paper-ink); opacity: .7; }

.groups { display: flex; gap: 6px; flex-wrap: wrap; }
.group {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--ink-2);
}
.group[aria-pressed="true"] { background: var(--ink); color: var(--surface); border-color: var(--ink); }

.bank { display: flex; flex-wrap: wrap; gap: 12px 22px; align-content: flex-start; min-height: 60px; }
.bank-empty { color: var(--ink-2); font-size: 14px; }
.bank-head { width: 100%; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-2); margin-top: 4px; }

/* ---------- Piesa de puzzle ---------- */
.piece {
  position: relative;
  border: 0;
  background: transparent;
  padding: 0;
  height: var(--h);
  width: var(--w);
  flex: none;
  cursor: pointer;
  color: var(--paper-ink);
  font: 600 var(--fs) / 1 var(--text);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .15s ease;
}
.piece svg.shape { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.piece .shape path.body { stroke-width: 1.4; }
.piece .shape { filter: drop-shadow(0 3px 0 var(--edge)); }
.piece .word {
  position: absolute;
  top: 0;
  bottom: 3px;
  left: var(--pl);
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  pointer-events: none;
}
.piece:hover { transform: translateY(-2px); }
.piece:active { transform: translateY(1px); }
.tray .piece { touch-action: none; }
.piece.suffix .word { font-weight: 700; }
.piece.selected { transform: translateY(-5px); z-index: 3; }
.piece.selected .shape path.body { stroke: var(--ink); stroke-width: 2.5; }
.piece.bad .shape path.body { stroke: var(--bad); stroke-width: 3; stroke-dasharray: 6 4; }
.piece.bad { animation: wiggle .5s ease 2; }
.piece.warn .shape path.body { stroke: var(--warn); stroke-width: 3; stroke-dasharray: 6 4; }
.piece.ghost { opacity: .35; }
.piece.flying { position: fixed; z-index: 50; pointer-events: none; transform: rotate(-3deg) scale(1.06); transition: none; }
.piece.pop { animation: pop .35s ease backwards; }
.tray.ok .piece { animation: snap .45s cubic-bezier(.3, 1.6, .5, 1) backwards; animation-delay: calc(var(--i) * 45ms); }

@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-4deg); } 75% { transform: rotate(4deg); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
@keyframes snap { 40% { transform: translateY(-10px); } }

/* Meniul piesei selectate */
.piece-menu {
  position: absolute;
  z-index: 10;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--ink);
  border-radius: 12px;
  box-shadow: var(--shadow);
  transform: translate(-50%, calc(-100% - 10px));
}
.piece-menu button {
  border: 0;
  background: transparent;
  color: var(--surface);
  height: 36px;
  min-width: 36px;
  border-radius: 9px;
  padding: 0 8px;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.piece-menu button:hover { background: rgba(255, 255, 255, .14); }
.piece-menu button:disabled { opacity: .35; }
.piece-menu svg { width: 18px; height: 18px; }

/* ---------- Caietul ---------- */
dialog {
  border: 0;
  border-radius: var(--r-lg);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: min(80vh, 640px);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(10, 12, 18, .45); }
.dlg { display: grid; grid-template-rows: auto 1fr; max-height: inherit; }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0 auto 0 0; font: 800 22px/1 var(--display); }
.dlg-body { overflow: auto; padding: 8px 18px 18px; }
.note { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.note p { margin: 0; flex: 1; min-width: 0; font-size: 16px; overflow-wrap: anywhere; }
.note small { display: block; color: var(--ink-2); font-size: 12px; }
.empty-note { color: var(--ink-2); padding: 18px 0; }

/* ---------- Vocea ---------- */
.voice-body { display: grid; gap: 14px; padding-top: 14px; }
.voice-toggle, .voice {
  display: flex; align-items: center; gap: 12px; width: 100%;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  color: var(--ink); font: inherit; font-size: 16px; font-weight: 600; line-height: 1.2; padding: 12px 14px; text-align: left; cursor: pointer;
}
.voice-toggle span, .voice span { flex: 1; min-width: 0; }
.voice-toggle i { width: 42px; height: 24px; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; }
.voice-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.voice-toggle[aria-pressed="true"] i { background: var(--accent); }
.voice-toggle[aria-pressed="true"] i::after { transform: translateX(18px); }
.voice-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-weight: 600; }
.voice-list { display: grid; gap: 8px; }
.voice small, .voice-toggle small { display: block; color: var(--ink-2); font-size: 12px; font-weight: 500; margin-top: 2px; }
.voice-body svg { flex: none; width: 22px; height: 22px; }
.voice svg { color: var(--ink-2); }
.voice-toggle i { flex: none; }
.voice[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.voice[aria-pressed="true"] svg { color: var(--accent); }
.voice-tip { margin: 0; color: var(--ink-2); font-size: 13px; line-height: 1.45; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--surface);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  z-index: 60;
  box-shadow: var(--shadow);
}

@media (max-width: 560px) {
  .board, .kit, .mission-card { padding: 12px; }
  .board { gap: 8px; top: env(safe-area-inset-top, 0px); border-radius: 0 0 var(--r-lg) var(--r-lg); margin-inline: -4px; }
  .tray { padding: 12px 22px 12px 10px; min-height: 84px; row-gap: 12px; }
  .tray-empty svg { display: none; }
  .kit-dock { display: none; }
  .kit-body { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; align-items: start; }
  .rail {
    display: grid;
    gap: 6px;
    position: sticky;
    top: calc(var(--dock-top, 0px) + 8px);
    max-height: calc(100vh - var(--dock-top, 0px) - 16px);
    max-height: calc(100dvh - var(--dock-top, 0px) - 16px);
    overflow-y: auto;
    scrollbar-width: none;
    padding: 2px;
  }
  .rail::-webkit-scrollbar { display: none; }
  .bank { gap: 10px 18px; }
  .endings { padding: 4px 8px; }
  .tab { border-radius: 10px; }
  .tab b { font-size: 13px; }
  .endings .lbl { display: none; }
  .tab { padding: 6px 10px 6px 8px; }
  .tab small { display: none; }
  .preview { min-height: 0; }
  .preview .label { display: none; }
  .preview .text { font-size: 17px; }
  .btn { height: 40px; }
  .mission-text p { font-size: 15px; }
  .btn { padding: 0 10px; }
  .btn.primary { padding: 0 16px; }
  .actions { gap: 6px; }
  .top-tools { width: 100%; }
  .top-tools .seg.levels { margin-right: auto; }
  .lvl-word { display: none; }
  .seg.levels button { min-width: 38px; padding: 7px 12px; }
  .brand small { display: none; }
  .btn .lbl { display: none; }
  .btn.primary .lbl { display: inline; }
  .seg.levels small { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Despre joc (text pentru părinți și pentru Google) ---------- */
.about {
  max-width: 1040px;
  margin: 0 auto;
  padding-block: 8px 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  color: var(--ink-2);
  font-size: 14px;
  line-height: 1.6;
}
.about h2 { margin: 18px 0 6px; font: 700 16px/1.2 var(--display); color: var(--ink); }
.about p { margin: 0 0 8px; max-width: 70ch; }
.about b { color: var(--ink); font-weight: 600; }
