/* FaceTiles – one screen of big picture tiles, in Near the BRI's warm colours.
   The chosen word shows large at the top and is spoken by the phone's own voice. */
:root {
  --bg: #fff6e8; --card: #ffffff; --ink: #1b1b1b; --muted: #4a4a4a; --line: #ebd3b0;
  --brand: #f9bf5b; --brand-edge: #d4861c; --link: #7a3300; --ring: #1b1b1b;
  --need: #ffe1a8; --people: #ffd6cf; --feel: #f3e0c4; --fun: #dcefc9; --yes: #c9ecc9; --no: #ffcfc7;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a120c; --card: #271b12; --ink: #f7efe6; --muted: #d6c6b4; --line: #553b26;
    --brand: #f5b04a; --brand-edge: #f5b04a; --link: #ffc27a; --ring: #ffffff;
    --need: #4a3414; --people: #4a2620; --feel: #3d2c1a; --fun: #26371c; --yes: #1f3d22; --no: #4d2019;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a120c; --card: #271b12; --ink: #f7efe6; --muted: #d6c6b4; --line: #553b26;
  --brand: #f5b04a; --brand-edge: #f5b04a; --link: #ffc27a; --ring: #ffffff;
  --need: #4a3414; --people: #4a2620; --feel: #3d2c1a; --fun: #26371c; --yes: #1f3d22; --no: #4d2019;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.top {
  background: var(--brand); color: #1b1b1b; border-bottom: 2px solid var(--brand-edge);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: calc(10px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px));
}
.top h1 { margin: 0; font-size: 1.35rem; font-weight: 800; flex: 1 1 auto; }
.back { color: #1b1b1b; font-weight: 700; text-decoration: underline; padding: 6px 0; }
.lang select { font: inherit; font-size: 1rem; padding: 6px 8px; border: 2px solid #1b1b1b; border-radius: 10px; background: #fff; color: #1b1b1b; }
main { max-width: 60rem; margin: 0 auto; padding: 12px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.said {
  background: var(--card); border: 2px solid var(--line); border-radius: 18px; min-height: 96px;
  display: flex; align-items: center; gap: 16px; padding: 10px 18px; margin-bottom: 12px;
}
.said .pic { font-size: 56px; line-height: 1; }
.said-text { min-width: 0; }
.said .word { font-size: clamp(30px, 9vw, 56px); font-weight: 900; line-height: 1.1; overflow-wrap: anywhere; }
.said .hint { color: var(--muted); font-size: 1.25rem; font-weight: 700; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 12px; }
.controls button {
  font: inherit; font-weight: 700; font-size: 1rem; color: var(--ink); background: var(--card);
  border: 2px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 44px; cursor: pointer;
}
.novoice { margin: 0 0 12px; color: var(--muted); }
.voices { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 12px; padding: 10px; background: var(--card); border: 2px solid var(--line); border-radius: 18px; }
.voices button {
  font: inherit; font-weight: 700; font-size: 1rem; color: var(--ink); background: var(--bg);
  border: 2px solid var(--line); border-radius: 999px; padding: 8px 14px; min-height: 44px; cursor: pointer;
}
.controls #voice[aria-expanded="true"], .voices button[aria-pressed="true"] { background: var(--brand); color: #1b1b1b; border-color: var(--brand-edge); }
.voices button:focus-visible { outline: 4px solid var(--ring); outline-offset: 3px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1000px) { .grid { grid-template-columns: repeat(6, 1fr); } }
.tile {
  border: 2px solid rgba(0,0,0,.08); border-radius: 20px; aspect-ratio: 1 / 1; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 4px;
  cursor: pointer; color: var(--ink); font-family: inherit; transition: transform .12s ease;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
}
.tile .e { font-size: clamp(42px, 12vw, 72px); line-height: 1; }
.tile .t { font-size: clamp(16px, 4.4vw, 24px); font-weight: 800; text-align: center; line-height: 1.15; overflow-wrap: anywhere; }
.tile:active { transform: scale(.94); }
.tile:focus-visible, .controls button:focus-visible, .back:focus-visible, .lang select:focus-visible { outline: 4px solid var(--ring); outline-offset: 3px; }
.tile.on { outline: 6px solid var(--brand-edge); outline-offset: 2px; }
.need { background: var(--need); } .people { background: var(--people); } .feel { background: var(--feel); }
.fun { background: var(--fun); } .yes { background: var(--yes); } .no { background: var(--no); }
.about { color: var(--muted); margin: 18px 0 0; }
.about a { color: var(--link); font-weight: 700; text-underline-offset: 2px; }
/* Simple / More words switch */
.mode { display: flex; gap: 8px; margin: 0 0 10px; }
.mode button {
  flex: 1 1 0; font: inherit; font-weight: 800; font-size: 1.05rem; color: var(--ink); background: var(--card);
  border: 2px solid var(--line); border-radius: 14px; padding: 10px 8px; min-height: 48px; cursor: pointer;
}
.mode button[aria-pressed="true"] { background: var(--brand); color: #1b1b1b; border-color: var(--brand-edge); }

/* More words board */
.sentence-bar { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 10px; margin-bottom: 12px; }
.sentence { display: flex; flex-wrap: wrap; gap: 6px; min-height: 52px; align-items: center; }
.sentence .chip { display: inline-flex; align-items: center; gap: 4px; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 4px 8px; font-size: 1.3rem; font-weight: 800; }
.sentence .empty { color: var(--muted); font-weight: 700; }
.sentence-actions { display: flex; gap: 6px; margin-top: 8px; }
.sentence-actions button {
  font: inherit; font-weight: 800; font-size: .95rem; color: var(--ink); background: var(--bg);
  border: 2px solid var(--line); border-radius: 999px; padding: 8px 10px; min-height: 44px; cursor: pointer; min-width: 0;
}
.sentence-actions .say { background: var(--brand); color: #1b1b1b; border-color: var(--brand-edge); flex: 1 1 auto; font-size: 1.15rem; }
.bgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
@media (min-width: 640px) { .bgrid { grid-template-columns: repeat(6, 1fr); } }
.btile {
  border: 2px solid rgba(0,0,0,.08); border-radius: 14px; aspect-ratio: 1 / 1; min-width: 0; padding: 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer; color: var(--ink); font-family: inherit; background: var(--card);
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; transition: transform .12s ease;
}
.btile .e { font-size: clamp(26px, 8vw, 44px); line-height: 1; }
.btile .t { font-size: clamp(12px, 3.4vw, 18px); font-weight: 800; text-align: center; line-height: 1.1; overflow-wrap: anywhere; }
.btile:active { transform: scale(.94); }
.bgrid.core .btile { background: var(--need); }
.topics { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.topics button {
  font: inherit; font-weight: 800; font-size: 1rem; color: var(--ink); background: var(--card);
  border: 2px solid var(--line); border-radius: 999px; padding: 8px 12px; min-height: 44px; cursor: pointer;
}
.topics button[aria-pressed="true"] { background: var(--brand); color: #1b1b1b; border-color: var(--brand-edge); }
.mode button:focus-visible, .sentence-actions button:focus-visible, .btile:focus-visible, .topics button:focus-visible { outline: 4px solid var(--ring); outline-offset: 3px; }

/* My words: add-a-word form */
.btile.action { background: var(--bg); border-style: dashed; border-color: var(--brand-edge); }
.addword { background: var(--card); border: 2px solid var(--line); border-radius: 18px; padding: 12px; margin-top: 12px; }
.addword label, .picks-label { display: block; font-weight: 800; font-size: 1.1rem; margin-bottom: 4px; }
.addword input {
  font: inherit; font-size: 1.3rem; font-weight: 700; width: 100%; padding: 10px 12px; min-height: 48px;
  color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 12px; margin-bottom: 10px;
}
.keys { display: none; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 12px; }
body.eyes-on .keys { display: grid; }
.keys button {
  font: inherit; font-weight: 800; font-size: 1.4rem; line-height: 1; min-height: 48px; padding: 0; cursor: pointer;
  color: var(--ink); background: var(--bg); border: 2px solid var(--line); border-radius: 12px;
}
.keys button.wide { grid-column: span 3; background: var(--need); }
.keys button:focus-visible { outline: 4px solid var(--ring); outline-offset: 3px; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.picks button { font-size: 1.6rem; line-height: 1; min-height: 46px; background: var(--bg); border: 2px solid var(--line); border-radius: 12px; cursor: pointer; padding: 0; }
.picks button[aria-pressed="true"] { background: var(--brand); border-color: var(--brand-edge); }
.addword-actions { display: flex; gap: 8px; margin-top: 12px; }
.addword-actions button {
  font: inherit; font-weight: 800; font-size: 1.1rem; color: var(--ink); background: var(--bg);
  border: 2px solid var(--line); border-radius: 999px; padding: 8px 16px; min-height: 48px; cursor: pointer;
}
.addword-actions .say { background: var(--brand); color: #1b1b1b; border-color: var(--brand-edge); flex: 1 1 auto; }
.kept { color: var(--muted); margin: 10px 0 0; }
.addword input:focus-visible, .picks button:focus-visible, .addword-actions button:focus-visible { outline: 4px solid var(--ring); outline-offset: 3px; }

/* Body picture: opens full screen from "It hurts"; touch where it hurts. */
.hurt {
  position: fixed; inset: 0; z-index: 5; background: var(--bg); color: var(--ink);
  display: flex; flex-direction: column; align-items: center;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.hurt-top { width: 100%; max-width: 45rem; display: flex; align-items: center; gap: 12px; }
.hurt h2 { margin: 0; font-size: clamp(24px, 6vw, 40px); font-weight: 900; flex: 1 1 auto; min-width: 0; }
.hurt .close {
  font: inherit; font-weight: 800; font-size: 1.2rem; color: #1b1b1b; background: var(--brand);
  border: 2px solid var(--brand-edge); border-radius: 999px; padding: 10px 18px; min-height: 48px; cursor: pointer; flex: none;
}
.said2 { font-size: clamp(24px, 6vw, 38px); font-weight: 900; min-height: 1.3em; margin: 6px 0; text-align: center; }
.hurt svg { flex: 1 1 auto; min-height: 0; width: 100%; max-width: 520px; touch-action: manipulation; }
.part { cursor: pointer; stroke: var(--ink); stroke-width: 2.5; -webkit-tap-highlight-color: transparent; }
.part.hit { fill: transparent; stroke: transparent; }
.part.on, .part.hit.on { stroke: #e0302a; stroke-width: 7; }
.part:focus { outline: none; } .part:focus-visible { stroke: var(--ring); stroke-width: 6; }
.skin { fill: #f6cfa8; } .shirt { fill: #8fc1ff; } .trousers { fill: #6f8fd8; } .shoe { fill: #5a5f6b; }
.deco { pointer-events: none; fill: none; stroke: #3a2a20; stroke-width: 3; stroke-linecap: round; }
.girl-only { display: none; } .girl .girl-only { display: inline; }
.girl .shirt { fill: #f7a8c8; }
.who { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }
.who button {
  font: inherit; font-weight: 800; font-size: 1.15rem; color: var(--ink); background: var(--card);
  border: 2px solid var(--line); border-radius: 999px; padding: 8px 18px; min-height: 48px; cursor: pointer;
}
.who button[aria-pressed="true"] { background: var(--brand); color: #1b1b1b; border-color: var(--brand-edge); }
.who button:focus-visible { outline: 4px solid var(--ring); outline-offset: 3px; }
.hair { pointer-events: none; fill: #7a4a2a; stroke: #3a2a20; stroke-width: 2.5; stroke-linejoin: round; }
.deco-dot { pointer-events: none; fill: #3a2a20; }
.extra { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.extra button {
  font: inherit; font-weight: 800; font-size: 1.25rem; color: var(--ink); background: var(--feel);
  border: 2px solid var(--line); border-radius: 20px; padding: 12px 18px; min-height: 52px; cursor: pointer;
}
.extra button.on { outline: 6px solid #e0302a; outline-offset: 2px; }
.hurt .close:focus-visible, .extra button:focus-visible { outline: 4px solid var(--ring); outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .tile, .btile { transition: none; } .tile:active, .btile:active { transform: none; } }
/* While eye or head control is on, the picked word (or the sentence) stays at the top of the screen as the page moves. */
body.eyes-on .said, body.eyes-on .sentence-bar { position: sticky; top: 6px; z-index: 4; box-shadow: 0 4px 14px rgba(0, 0, 0, .35); }
