/* The Boy Speak -- a gentle, low-sensory vocabulary practice game.
   Design goals (see app.js header for the research behind them): a calm warm
   palette, no flashing or saturated colour, large tap targets, one clear thing
   on screen at a time, and a predictable layout that never moves around. */

:root {
  --bg:        #f6f1e7;   /* warm cream, low glare */
  --panel:     #fffdf8;
  --ink:       #3c3a42;   /* soft near-black, not pure #000 */
  --muted:     #8a8676;
  --line:      #e7ddca;
  --sage:      #7fa98f;   /* primary calm accent */
  --sage-dim:  #689079;
  --sky:       #8aa9c9;   /* secondary accent */
  --coral:     #e0997a;   /* record / "your turn", warm but not alarming red */
  --coral-dim: #cf805f;
  --shadow:    0 6px 18px rgba(60, 58, 66, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "Segoe UI Rounded", "Hiragino Maru Gothic ProN",
               "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  justify-content: center;
}

.app {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---- Screen switching ------------------------------------------------- */
.screen { display: none; flex: 1; flex-direction: column; padding: 20px; }
.screen.is-active { display: flex; }
[hidden] { display: none !important; }

/* ====================== HOME / CATEGORY PICKER ====================== */
.home { align-items: center; }
.home-head { text-align: center; margin: 18px 0 22px; }
.home-head h1 { font-size: clamp(26px, 7vw, 36px); font-weight: 800; letter-spacing: 0.2px; }
.tagline { color: var(--muted); margin-top: 6px; font-size: clamp(14px, 4vw, 17px); }

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 460px;
}
.cat-card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.cat-card:hover { border-color: var(--sage); }
.cat-card:active { transform: scale(0.97); }
.cat-card .emoji { font-size: clamp(40px, 12vw, 56px); line-height: 1; }
.cat-card .name { font-size: clamp(15px, 4.4vw, 18px); font-weight: 700; }

.text-btn {
  margin-top: 22px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-btn:hover { color: var(--sage-dim); }

/* ====================== PRACTICE SCREEN ====================== */
.play { gap: 4px; }
.play-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.icon-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 44px;
}
.icon-btn:hover { border-color: var(--sage); }
.cat-name { font-size: 16px; font-weight: 800; color: var(--sage-dim); }

/* The picture card: one big, clear image, lots of calm whitespace. */
.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0 14px;
}
.picture {
  width: min(64vw, 260px);
  height: min(64vw, 260px);
  border-radius: 28px;
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(36vw, 150px);
  line-height: 1;
  user-select: none;
}
/* Colour-swatch items fill the card with the colour itself + a readable label. */
.picture.swatch { font-size: 0; }
.picture.swatch .swatch-fill {
  width: 78%; height: 78%;
  border-radius: 20px;
  border: 3px solid rgba(60,58,66,0.12);
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
}
.prompt-text { font-size: clamp(20px, 6vw, 28px); font-weight: 800; }
.word-text {
  font-size: clamp(34px, 11vw, 56px);
  font-weight: 800;
  color: var(--sage-dim);
  text-transform: lowercase;
}
.sentence-text {
  font-size: clamp(17px, 5vw, 22px);
  color: var(--ink);
  max-width: 22ch;
  line-height: 1.5;
}
.sentence-text b { color: var(--coral-dim); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.next-row { display: flex; gap: 12px; margin-top: 6px; }

/* Buttons: big, rounded, calm. */
.round-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(15px, 4.4vw, 18px);
  border-radius: 18px;
  padding: 14px 22px;
  min-height: 54px;
  cursor: pointer;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.round-btn:active { transform: scale(0.97); }
.round-btn.small { font-size: 14px; min-height: 44px; padding: 10px 16px; }

.round-btn.soft {
  background: var(--panel);
  border-color: var(--line);
  color: var(--ink);
}
.round-btn.soft:hover { border-color: var(--sky); }

.round-btn.go { background: var(--sage); color: #fff; }
.round-btn.go:hover { background: var(--sage-dim); }

.round-btn.record {
  background: var(--coral);
  color: #fff;
  font-size: clamp(17px, 5vw, 20px);
  padding: 16px 28px;
  min-height: 60px;
}
.round-btn.record:hover { background: var(--coral-dim); }
.round-btn.record.is-recording { background: var(--coral-dim); }
.rec-dot {
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; opacity: 0; flex: none;
}
.round-btn.record.is-recording .rec-dot { opacity: 1; animation: pulse 1.1s ease-in-out infinite; }

.mic-note { color: var(--muted); font-size: 13px; max-width: 26ch; }

/* ---- Break suggestion (calm, caregiver-facing) ----------------------- */
.break {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(246, 241, 231, 0.96);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 12px;
  padding: 28px;
}
.break-emoji { font-size: 64px; }
.break-title { font-size: 24px; font-weight: 800; }
.break-sub { color: var(--muted); max-width: 28ch; line-height: 1.5; }

/* ====================== SETTINGS SHEET ====================== */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(60, 58, 66, 0.35);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.sheet-card {
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 50px rgba(60,58,66,0.25);
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: 90vh;
  overflow-y: auto;
}
.sheet-card h2 { font-size: 22px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
}
.row select, .row input[type="range"] { font-family: inherit; font-size: 15px; }
.row select {
  padding: 8px 10px; border-radius: 10px; border: 2px solid var(--line);
  background: #fff; color: var(--ink); max-width: 60%;
}
.row.toggle input { width: 22px; height: 22px; accent-color: var(--sage); }
.words-today { color: var(--muted); font-size: 14px; }
.words-today strong { color: var(--ink); }
.about { font-size: 14px; color: var(--muted); line-height: 1.55; }
.about summary { cursor: pointer; color: var(--sage-dim); font-weight: 700; }
.about p { margin-top: 8px; }

/* ====================== FOOTER ====================== */
.foot {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  padding: 8px;
}

@keyframes pulse {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.6); opacity: 0.5; }
}
@keyframes pop {
  0%   { transform: scale(0.6); opacity: 0; }
  60%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}
.picture.pop { animation: pop 0.34s ease-out; }

/* Respect reduced-motion: both the OS setting and the in-app "gentle motion"
   toggle (which adds .reduce-motion to <body>). */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
body.reduce-motion * { animation: none !important; transition: none !important; }

/* Return to games list */
.text-btn.home { display: inline-block; text-decoration: none; font-size: 13px; margin-top: 14px; }
