/* Mundo Brincando — Módulo Evoluído v0.1 */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --ink: #1d2740;
  --muted: #55627f;
  --brand: #263b66;
  --brand-ink: #ffffff;
  --accent: #e8a33d;
  --accent-ink: #2b1d00;
  --line: #d5ddec;
  --ok: #1f7a4d;
  --ok-bg: #e4f5ec;
  --warn: #8a4b00;
  --warn-bg: #fff1dc;
  --focus: #1a5fd0;
  --radius: 14px;
  --text-scale: 1;
}
:root[data-theme="natural"] {
  --bg: #f2f5ee; --surface: #fbfcf8; --ink: #24301f; --muted: #56654f;
  --brand: #365a3a; --line: #d3dcc9; --accent: #d9a441; --focus: #2a6b3c;
}
:root[data-theme="contraste"] {
  --bg: #000000; --surface: #0b0b0b; --ink: #ffffff; --muted: #e6e6e6;
  --brand: #ffe600; --brand-ink: #000000; --line: #ffffff;
  --accent: #00e5ff; --accent-ink: #000000; --focus: #00e5ff;
  --ok: #7dff9e; --ok-bg: #002b10; --warn: #ffd27d; --warn-bg: #2b1a00;
}
:root[data-text="large"] { --text-scale: 1.15; }
:root[data-text="xlarge"] { --text-scale: 1.3; }

*, *::before, *::after { box-sizing: border-box; }
html { font-size: calc(100% * var(--text-scale)); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", Verdana, system-ui, sans-serif;
  line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.7rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .75rem; max-width: 70ch; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link {
  position: absolute; left: -999px; top: 0; background: var(--brand); color: var(--brand-ink);
  padding: .6rem 1rem; z-index: 100;
}
.skip-link:focus { left: 0; }

/* Topo */
.topbar {
  display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; justify-content: space-between;
  background: var(--brand); color: var(--brand-ink); padding: .75rem 1.25rem;
}
.brand { display: flex; align-items: center; gap: .75rem; }
.brand strong { display: block; line-height: 1.1; }
.brand span { font-size: .85rem; opacity: .85; }
.brand-mark {
  width: 2.5rem; height: 2.5rem; border-radius: 10px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 800;
}
.top-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.nav-button {
  background: transparent; color: inherit; border: 2px solid transparent; border-radius: 999px;
  padding: .45rem .95rem; font: inherit; cursor: pointer;
}
.nav-button:hover { border-color: currentColor; }
.nav-button.active { background: var(--brand-ink); color: var(--brand); font-weight: 700; }
:root[data-theme="contraste"] .topbar { border-bottom: 2px solid #fff; }

/* Página */
.page { width: 100%; max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.25rem 3rem; flex: 1; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.eyebrow { font-size: .8rem; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 0 0 .25rem; }
.lead { font-size: 1.1rem; color: var(--muted); }
.lead.narrow { max-width: 60ch; }
.muted { color: var(--muted); }
.small-note { font-size: .85rem; color: var(--muted); }

.welcome { display: grid; gap: 1.5rem; grid-template-columns: 1.4fr 1fr; align-items: center; margin-bottom: 1.5rem; }
.welcome[hidden] { display: none; }
.welcome-controls label { display: block; font-weight: 700; margin-bottom: .3rem; }
.progress-card { margin-top: 1rem; padding: 1rem; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.progress-card span { display: block; font-size: .9rem; color: var(--muted); }
.progress-card strong { font-size: 1.5rem; }
.progress-track { height: .8rem; background: var(--line); border-radius: 999px; overflow: hidden; margin: .4rem 0; }
#progressBar { height: 100%; width: 0; background: var(--accent); transition: width .4s ease; }
:root[data-theme="contraste"] .progress-track { background: #333; }

/* Visões */
.view { display: none; }
.view.active { display: block; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }

/* Botões e campos */
button { font: inherit; }
.primary-button, .secondary-button, .text-button, .filter-chip {
  cursor: pointer; border-radius: 10px; padding: .65rem 1.1rem; min-height: 2.75rem;
}
.primary-button { background: var(--brand); color: var(--brand-ink); border: 2px solid var(--brand); font-weight: 700; }
.secondary-button { background: transparent; color: var(--brand); border: 2px solid var(--brand); font-weight: 600; }
:root[data-theme="contraste"] .secondary-button { color: #fff; border-color: #fff; }
.text-button { background: none; border: none; color: var(--brand); text-decoration: underline; padding-inline: .25rem; }
:root[data-theme="contraste"] .text-button { color: var(--brand); }
.primary-button:hover, .secondary-button:hover { filter: brightness(1.12); }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; }
select {
  width: 100%; font: inherit; padding: .6rem .7rem; border-radius: 10px;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink); min-height: 2.75rem;
}

/* Atividades */
.filters { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.filter-chip { background: var(--surface); border: 2px solid var(--line); color: var(--ink); padding: .4rem .95rem; }
.filter-chip.selected { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }
.activity-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.activity-card {
  display: flex; flex-direction: column; gap: .5rem; text-align: left; cursor: pointer;
  background: var(--surface); color: var(--ink); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem; min-height: 11rem;
}
.activity-card:hover { border-color: var(--brand); }
.activity-card .icon {
  width: 3rem; height: 3rem; display: grid; place-items: center; font-size: 1.6rem;
  background: var(--bg); border-radius: 12px;
}
.activity-card h3 { margin: 0; }
.activity-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.activity-card .tag { margin-top: auto; font-size: .8rem; color: var(--muted); font-weight: 600; }

.support-strip {
  display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 1.5rem;
  background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius); padding: 1rem 1.25rem;
}
.support-strip > div:nth-child(2) { flex: 1; min-width: 200px; }
.support-strip p { margin: 0; color: var(--muted); }
.support-icon { font-size: 1.8rem; color: var(--brand); }

/* Rotina */
.routine-layout { display: grid; gap: 1.25rem; grid-template-columns: 1fr 1fr; }
.routine-list { padding-left: 1.2rem; margin: 1rem 0; }
.routine-list li { margin-bottom: .6rem; }
.routine-list label { display: flex; gap: .6rem; align-items: center; cursor: pointer; }
.routine-list input, .switch-row input { width: 1.4rem; height: 1.4rem; accent-color: var(--brand); flex: none; }
.calm-panel { text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.calm-symbol { font-size: 3rem; color: var(--brand); }
.status-message { margin-top: 1rem; min-height: 1.5rem; font-weight: 600; }

/* Acessibilidade */
.settings-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.setting-card label:not(.switch-row) { display: block; font-weight: 700; margin: 1rem 0 .3rem; }
.switch-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.communication-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem; margin-top: .75rem; }
.communication-grid button {
  display: flex; flex-direction: column; align-items: center; gap: .3rem; padding: .8rem .5rem;
  background: var(--bg); color: var(--ink); border: 2px solid var(--line); border-radius: 12px; cursor: pointer; font-weight: 600;
}
.communication-grid button span { font-size: 1.5rem; }
.communication-grid button:hover { border-color: var(--brand); }
.communication-message {
  margin-top: 1rem; padding: .9rem 1rem; border-radius: 12px; background: var(--bg);
  border-left: 6px solid var(--accent); font-size: 1.15rem; font-weight: 700; min-height: 3.2rem;
}
.settings-footer { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; margin-top: 1.25rem; }
.settings-footer span { color: var(--muted); font-size: .9rem; }

/* Jogo */
.game-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-bottom: .75rem; }
.game-meta { display: flex; justify-content: space-between; color: var(--muted); font-weight: 600; margin-bottom: .75rem; }
.game-instruction { color: var(--muted); }
.hide-instructions .game-instruction { display: none; }
.question-area { margin: 1rem 0; }
.question-prompt { font-size: 1.35rem; font-weight: 700; margin-bottom: 1rem; }
.question-visual { font-size: 2.4rem; letter-spacing: .15em; margin-bottom: 1rem; word-break: break-word; }
.options { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.option-button {
  padding: 1rem; font-size: 1.15rem; font-weight: 600; cursor: pointer; border-radius: 12px;
  background: var(--surface); color: var(--ink); border: 2px solid var(--line); min-height: 3.5rem;
}
.option-button:hover:not(:disabled) { border-color: var(--brand); }
.option-button.correct { background: var(--ok-bg); border-color: var(--ok); color: var(--ok); opacity: 1; }
.option-button.tried { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); opacity: 1; }
.feedback { min-height: 1.6rem; font-weight: 700; }
.feedback.good { color: var(--ok); }
.feedback.try { color: var(--warn); }
.hint-box { padding: .7rem 1rem; border-radius: 10px; background: var(--warn-bg); color: var(--warn); margin-top: .5rem; }
.game-actions { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; margin-top: 1rem; }
.end-screen { text-align: center; padding: 1rem 0; }
.end-screen .big { font-size: 3rem; }

footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem;
  padding: 1rem 1.25rem; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line);
}

/* Responsivo */
@media (max-width: 760px) {
  .welcome, .routine-layout { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
  .top-actions { justify-content: center; }
  .game-actions button { flex: 1 1 100%; }
}

/* Movimento reduzido (preferência do sistema ou do módulo) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after {
  transition: none !important; animation: none !important; scroll-behavior: auto !important;
}

/* Quadro de comunicação personalizável */
.comm-img { width: 3rem; height: 3rem; object-fit: cover; border-radius: 10px; }
.comm-tools { margin-top: 1rem; }
.comm-tools .secondary-button { margin: .5rem .5rem 0 0; }
.comm-edit { margin-top: 1rem; }
.comm-row { border: 2px solid var(--line); border-radius: 12px; padding: .8rem; margin-bottom: .8rem; }
.comm-row label { display: block; font-weight: 600; margin: .5rem 0 .2rem; }
.comm-row input { width: 100%; font: inherit; padding: .5rem; border: 2px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.comm-row button { margin: .5rem .5rem 0 0; }
.comm-actions { margin-top: .5rem; }
.install-card details { margin-top: .4rem; }
.install-card summary { cursor: pointer; font-weight: 600; }
.install-card button[hidden], #commEdit[hidden] { display: none; }
