/* Hue Flow: a calm colour-gradient puzzle in the Favabeans look (see ../APP_DESIGN.md).
   Light by default, dark when the system asks. Accent: warm apricot. The board's colours are the
   picture; the interface stays quiet around them. No dark green or teal in the interface. */
:root {
  --canvas: #F7F7F5;
  --surface: #FFFFFF;
  --surface-2: #F1F1EE;
  --surface-3: #E7E7E3;
  --ink: #1D1D1F;
  --ink-2: #57575F;
  --line: rgb(29 29 31 / .09);
  --line-2: rgb(29 29 31 / .17);
  --danger: #b3261e;
  --shadow-1: 0 1px 2px rgb(0 0 0 / .04), 0 8px 24px -14px rgb(0 0 0 / .12);
  --shadow-2: 0 2px 4px rgb(0 0 0 / .04), 0 24px 48px -22px rgb(0 0 0 / .22);
  --ease: cubic-bezier(.22, 1, .36, 1);
  --r-card: 26px;
  --r-md: 18px;
  --r-sm: 12px;
  --gutter: clamp(16px, 4vw, 40px);
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  /* This app's accent: warm apricot (white text on --accent is 5.4:1) */
  --accent: #B24A26;
  --accent-ink: #FFFFFF;
  --accent-soft: #FCEBE3;
  --accent-text: #9A3B1E;
  --focus: #B24A26;
  --btn-grad: linear-gradient(180deg, #BD5530, #A9431F);

  /* the board */
  --glow-o: .42;
  --glow-solved: .85;
  --tile-edge: rgb(29 29 31 / .06);
  --ring-sel: #1D1D1F;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --canvas: #0C0C0E;
    --surface: #161619;
    --surface-2: #202024;
    --surface-3: #2A2A2F;
    --ink: #F2F2F4;
    --ink-2: #ABABB5;
    --line: rgb(255 255 255 / .09);
    --line-2: rgb(255 255 255 / .17);
    --danger: #ffb4ab;
    --shadow-1: 0 1px 0 rgb(255 255 255 / .04) inset, 0 8px 24px -12px rgb(0 0 0 / .6);
    --shadow-2: 0 1px 0 rgb(255 255 255 / .05) inset, 0 28px 56px -22px rgb(0 0 0 / .8);
    --accent: #FFB59A;
    --accent-ink: #2A140C;
    --accent-soft: #2B1D19;
    --accent-text: #FFC6B0;
    --focus: #FFB59A;
    --btn-grad: linear-gradient(180deg, #FFC2AA, #FFAA8B);
    --glow-o: .22;
    --glow-solved: .5;
    --tile-edge: rgb(0 0 0 / .25);
    --ring-sel: #F2F2F4;
    color-scheme: dark;
  }
}
:root:where([data-theme="dark"]) {
  --canvas: #0C0C0E;
  --surface: #161619;
  --surface-2: #202024;
  --surface-3: #2A2A2F;
  --ink: #F2F2F4;
  --ink-2: #ABABB5;
  --line: rgb(255 255 255 / .09);
  --line-2: rgb(255 255 255 / .17);
  --danger: #ffb4ab;
  --shadow-1: 0 1px 0 rgb(255 255 255 / .04) inset, 0 8px 24px -12px rgb(0 0 0 / .6);
  --shadow-2: 0 1px 0 rgb(255 255 255 / .05) inset, 0 28px 56px -22px rgb(0 0 0 / .8);
  --accent: #FFB59A;
  --accent-ink: #2A140C;
  --accent-soft: #2B1D19;
  --accent-text: #FFC6B0;
  --focus: #FFB59A;
  --btn-grad: linear-gradient(180deg, #FFC2AA, #FFAA8B);
  --glow-o: .22;
  --glow-solved: .5;
  --tile-edge: rgb(0 0 0 / .25);
  --ring-sel: #F2F2F4;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body {
  margin: 0; background: var(--canvas); color: var(--ink);
  font: 400 1.0625rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: clip;
}
a { color: inherit; text-underline-offset: 3px; }
button { font: inherit; color: inherit; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ti { display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none; }
.ti svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.ti svg .f { fill: color-mix(in srgb, currentColor 18%, transparent); stroke: none; }
.ti svg .k { fill: currentColor; stroke: none; }

/* ---------- Header: a thin frosted bar ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--canvas) 78%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
}
.top-in { max-width: 1180px; margin: 0 auto; padding-inline: var(--gutter); min-height: 60px; display: flex; flex-wrap: wrap; align-items: center; gap: 0 14px; }
.brand { display: flex; align-items: center; gap: 10px; margin-inline-end: auto; min-width: 0; }
.brand img { width: 28px; height: 28px; border-radius: 7px; box-shadow: 0 1px 2px rgb(0 0 0 / .1); flex: none; }
.brand h1 { margin: 0; display: flex; align-items: center; font: 600 1.0625rem/1.2 var(--font); letter-spacing: -0.015em; white-space: nowrap; }
body .top .fbk-beta {
  margin-inline-start: 8px; padding: .32em .62em; border: 0; border-radius: 999px; box-shadow: none;
  font: 600 max(.66rem, 11px)/1.1 var(--font); letter-spacing: .05em;
  color: var(--accent-text); background: var(--accent-soft);
}
.fb-lang { display: flex; align-items: center; gap: 0; font-size: .875rem; color: var(--line-2); }
.fb-lang button { min-height: 44px; padding: 0 8px; border: 0; border-radius: 10px; background: none; color: var(--ink-2); font: 500 .875rem/1 var(--font); cursor: pointer; }
.fb-lang button:hover { color: var(--ink); }
.fb-lang button[lang="ar"] { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-size: .95rem; }
.fb-lang button[aria-pressed="true"] { color: var(--ink); font-weight: 600; }
.fb-lang button:focus-visible { outline: 3px solid var(--focus); outline-offset: -2px; }
.home-link {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 999px;
  color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
  font: 500 .875rem/1 var(--font); text-decoration: none; white-space: nowrap;
  transition: box-shadow .2s;
}
.home-link:hover { box-shadow: inset 0 0 0 1px var(--line-2); }

main { max-width: 1180px; margin: 0 auto; padding: 20px var(--gutter) 32px; display: grid; gap: 20px; }
h2 { margin: 0; font-size: 1.375rem; }
h3 { margin: 0; font-size: 1.0625rem; }
.help { margin: 4px 0 0; color: var(--ink-2); font-size: .9375rem; }
.eyebrow { margin: 0; font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); }
:root[lang="ar"] .eyebrow { text-transform: none; letter-spacing: 0; font-size: .875rem; }
.card { background: var(--surface); border-radius: var(--r-card); padding: clamp(18px, 2.6vw, 28px); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; cursor: pointer;
  background: var(--btn, var(--surface-2)); color: var(--ink); font: 500 .9375rem/1.1 var(--font);
  transition: background-color .2s, transform .2s var(--ease), box-shadow .2s;
  text-decoration: none; white-space: nowrap;
}
.btn:hover { background: color-mix(in srgb, var(--btn, var(--surface-2)) 94%, var(--ink)); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--btn-grad); color: var(--accent-ink); box-shadow: 0 8px 18px -12px var(--accent); }
.btn.primary:hover { filter: brightness(1.04); }
.btn.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .875rem; }
.btn.wide { width: 100%; }
.btn .ti { width: 20px; height: 20px; }
.btn:disabled { opacity: .45; cursor: default; }
.file-btn { position: relative; }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink); cursor: pointer; flex: none; }
.icon-btn:hover { background: color-mix(in srgb, var(--surface-2) 92%, var(--ink)); }
.sound-btn { position: relative; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); }
.sound-btn[data-on="false"] { color: var(--ink-2); }

/* Segmented control (iOS style) */
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 13px; background: var(--surface-2); max-width: 100%; }
.seg button { min-height: 38px; padding: 0 16px; border: 0; border-radius: 10px; background: transparent; color: var(--ink-2); font: 500 .9375rem/1 var(--font); cursor: pointer; transition: background-color .2s, color .2s; white-space: nowrap; }
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 3px 10px -3px rgb(0 0 0 / .1); }
@media (prefers-color-scheme: dark) { :where(:root:not([data-theme="light"])) .seg button[aria-checked="true"], :where(:root:not([data-theme="light"])) .tabs [aria-selected="true"] { background: var(--surface-3); box-shadow: 0 1px 2px rgb(0 0 0 / .4); } }
:where(:root[data-theme="dark"]) .seg button[aria-checked="true"], :where(:root[data-theme="dark"]) .tabs [aria-selected="true"] { background: var(--surface-3); box-shadow: 0 1px 2px rgb(0 0 0 / .4); }

/* ---------- Mode tabs ---------- */
.tabs { display: flex; padding: 4px; gap: 2px; border-radius: 16px; background: var(--surface-2); justify-self: start; max-width: 100%; }
.tabs button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border: 0; border-radius: 12px; background: transparent; cursor: pointer;
  color: var(--ink-2); font: 500 .9375rem/1 var(--font); white-space: nowrap; transition: background-color .2s, color .2s;
}
.tabs button:hover { color: var(--ink); }
.tabs [aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .08), 0 3px 10px -3px rgb(0 0 0 / .1); }
.tabs [aria-selected="true"] .ti { color: var(--accent); }
.tabs .ti { width: 20px; height: 20px; }

/* ---------- Play: the board and its side ---------- */
.play { display: grid; gap: 16px 32px; grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "stage" "side" "chapters"; align-items: start; }
.play-head { grid-area: head; display: grid; gap: 4px; }
.play-head h2 { font-size: clamp(1.375rem, 2.4vw, 1.75rem); letter-spacing: -0.025em; }
.play-sub { margin: 0; color: var(--ink-2); font-size: .9375rem; }
.moves { justify-self: start; margin: 6px 0 0; padding: 4px 12px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); font-size: .875rem; font-variant-numeric: tabular-nums; }
.side { grid-area: side; display: grid; gap: 14px; align-content: start; }
.chapters { grid-area: chapters; margin-top: 18px; }

.stage { grid-area: stage; position: relative; display: grid; place-items: center; padding: clamp(6px, 2vw, 18px) 0; isolation: isolate; }
.glow {
  position: absolute; inset: 8% 4%; z-index: -1; border-radius: 40%;
  background-size: 100% 100%; filter: blur(46px) saturate(1.15);
  opacity: var(--glow-o); transition: opacity 1.6s var(--ease);
  pointer-events: none;
}
.board {
  display: block; width: 100%; height: auto; max-height: min(64svh, 680px);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  overflow: visible;
}
.board:focus { outline: none; }
.tile {
  stroke: var(--tile-edge); stroke-width: .016; cursor: grab; outline: none;
  transform-box: fill-box; transform-origin: center;
  transition: d .95s var(--ease), opacity .18s;
}
.tile.fixed { cursor: default; }
.tile.hole { opacity: .2; }
.tile.hidden { opacity: 0; transition: none; }
.tile.sel { stroke: #FFFFFF; stroke-width: .09; }
.tile.enter { animation: tile-in .7s var(--ease) both; animation-delay: var(--dl, 0s); }
@keyframes tile-in { from { opacity: 0; transform: scale(.55); } }
.clone .tile { stroke: rgb(255 255 255 / .55); stroke-width: .05; }
.marks { pointer-events: none; transition: opacity .5s; }
.dot { fill: rgb(29 29 31 / .58); }
.lbl { fill: rgb(29 29 31 / .78); font-family: var(--font); font-weight: 600; text-anchor: middle; dominant-baseline: central; letter-spacing: -0.02em; }
.ring { fill: none; pointer-events: none; opacity: 0; transition: opacity .15s; }
.ring.on { opacity: 1; }
.ring.sel { stroke: var(--ring-sel); stroke-width: .06; }
.ring.focus { stroke: var(--focus); stroke-width: .09; }
.ring.target { stroke: var(--ring-sel); stroke-width: .05; stroke-dasharray: .14 .1; }
.field { opacity: 0; pointer-events: none; transition: opacity 1.3s var(--ease) .45s; }
.peek .field { opacity: 1; transition-delay: 0s; transition-duration: .35s; }
.peek .marks, .intro .marks { opacity: 0; }
.fly { pointer-events: none; }

/* Solved: the gaps close, the colours melt into one smooth field and glow, the board breathes once. */
.is-solved .field { opacity: 1; }
.is-solved .marks { opacity: 0; }
.is-solved .glow { opacity: var(--glow-solved); }
.is-solved .tile { cursor: default; stroke-width: 0; }
.is-solved .board { animation: breathe 3.4s var(--ease) .35s both; }
@keyframes breathe { 0% { transform: scale(1); } 38% { transform: scale(1.022); } 100% { transform: scale(1); } }
.instant *, .instant { transition: none !important; animation: none !important; }
.reveal {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 2px;
  text-align: center; pointer-events: none; padding: 16px;
  opacity: 0; translate: 0 10px; transition: opacity 1s var(--ease), translate 1.2s var(--ease);
  color: #1D1D1F;
}
.reveal.on { opacity: 1; translate: 0 0; }
.reveal-eyebrow { font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; opacity: .72; }
:root[lang="ar"] .reveal-eyebrow { letter-spacing: 0; text-transform: none; font-size: .9375rem; }
.reveal-name {
  font-weight: 300; font-size: clamp(2.1rem, 7vw, 4.2rem); line-height: 1.02; letter-spacing: -0.04em;
  text-shadow: 0 1px 22px rgb(255 255 255 / .55); max-width: 12ch; text-wrap: balance;
}

/* Tools under (phone) or beside (desktop) the board */
.tools { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.tool {
  display: grid; justify-items: center; align-content: center; gap: 4px; min-height: 60px; padding: 6px 2px;
  border: 0; border-radius: 16px; background: var(--surface); color: var(--ink); cursor: pointer;
  box-shadow: inset 0 0 0 1px var(--line); font: 500 .75rem/1.15 var(--font); text-align: center;
  transition: background-color .2s, transform .2s var(--ease), color .2s;
}
.tool:hover { background: color-mix(in srgb, var(--surface) 94%, var(--ink)); }
.tool:active { transform: scale(.97); }
.tool:disabled { opacity: .42; cursor: default; }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 600; }
.tool .ti { width: 22px; height: 22px; }
:root[lang="ar"] .tool { font-size: .8125rem; }
.zen-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }


.done-panel {
  display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 14px 16px; align-items: center;
  padding: 18px; border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
  animation: rise .6s var(--ease) both .5s;
}
@keyframes rise { from { opacity: 0; translate: 0 8px; } }
.done-swatch { width: 64px; height: 64px; border-radius: 18px; background-size: cover; box-shadow: inset 0 0 0 1px var(--line); }
.done-text h3 { font-size: 1.375rem; letter-spacing: -0.025em; }
.done-text .help { margin-top: 2px; }
.chip { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: .8125rem; font-weight: 600; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chapter-end { grid-column: 1 / -1; display: grid; gap: 8px; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); }
.chapter-strip { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 4px; }
.chapter-strip span { aspect-ratio: 1 / 1.4; border-radius: 6px; background: var(--surface-3); background-size: cover; }
.done-acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; }
.done-acts .primary { flex: 1 1 100%; }
.done-acts .btn:not(.primary) { flex: 1 1 0; }

/* ---------- Chapters ---------- */
.sec-head { display: grid; gap: 4px; margin-bottom: 14px; }
.chapter-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); align-items: start; }
.chapter { display: grid; gap: 14px; padding: 16px; border-radius: var(--r-card); background: var(--surface); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.chapter.locked { background: var(--surface-2); box-shadow: none; }
.chapter.locked .ch-thumb { opacity: .4; filter: saturate(.4); }
.ch-head { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 14px; align-items: center; }
.ch-thumb { width: 72px; height: 72px; display: grid; place-items: center; }
.thumb { width: 100%; height: 100%; }
.ch-text h3 { font-size: 1.0625rem; }
.ch-text .help { font-size: .875rem; margin: 2px 0 0; }
.ch-prog { margin: 6px 0 0; font-size: .8125rem; font-weight: 600; color: var(--ink-2); }
.lv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.lv {
  position: relative; min-height: 44px; aspect-ratio: 1; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--surface-2) center / cover no-repeat; color: var(--ink-2); font: 500 .875rem/1 var(--font); font-variant-numeric: tabular-nums;
  transition: transform .2s var(--ease), box-shadow .2s;
}
.lv:hover:not(:disabled) { transform: translateY(-1px); box-shadow: inset 0 0 0 1.5px var(--line-2); }
.lv.solved { color: #1D1D1F; font-weight: 600; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .06); }
.lv.clean::after { content: ''; position: absolute; top: 5px; inset-inline-end: 5px; width: 6px; height: 6px; border-radius: 50%; background: rgb(29 29 31 / .55); }
.lv.current { box-shadow: 0 0 0 2px var(--canvas), 0 0 0 4px var(--accent); }
.lv:disabled { cursor: default; opacity: .55; }
.chapter.locked .lv { background: var(--surface-3); }

/* ---------- Gallery ---------- */
.gallery .sec-head { margin-bottom: 18px; }
.pal-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px 14px; grid-template-columns: repeat(auto-fill, minmax(min(46%, 150px), 1fr)); }
.pal { display: grid; gap: 8px; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: start; color: var(--ink); }
.pal-sw {
  display: block; aspect-ratio: 3 / 4; border-radius: 20px; background: var(--surface-2) center / cover no-repeat;
  box-shadow: var(--shadow-1), inset 0 0 0 1px rgb(0 0 0 / .05); transition: transform .3s var(--ease), box-shadow .3s;
}
.pal:hover .pal-sw { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.pal-name { font-weight: 500; font-size: .9375rem; padding-inline: 4px; }
.pal.unknown { cursor: default; }
.pal.unknown .pal-sw { box-shadow: inset 0 0 0 1px var(--line); background-image: radial-gradient(circle at 50% 45%, var(--surface-3) 0 14%, transparent 15%); }
.pal.unknown .pal-name { color: var(--ink-2); font-weight: 400; }
.pal:focus-visible { outline: none; }
.pal:focus-visible .pal-sw { outline: 3px solid var(--focus); outline-offset: 3px; }

/* ---------- Settings, backup ---------- */
.panel summary { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; font-weight: 600; font-size: 1.0625rem; list-style: none; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: ''; margin-inline-start: auto; width: 9px; height: 9px; border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg) translate(-2px, -2px); transition: transform .25s var(--ease); }
.panel[open] summary::after { transform: rotate(-135deg) translate(-2px, -2px); }
.panel[open] summary { margin-bottom: 10px; }
.pi { width: 36px; height: 36px; padding: 7px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); }
.switches { display: grid; gap: 2px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none; }
.panel .help { margin-bottom: 12px; }
[data-fava-prefs] { margin: 8px 0 6px; padding-top: 12px; border-top: 1px solid var(--line); }
.msg { margin: 10px 0 0; min-height: 1.4em; color: var(--ink-2); font-size: .9375rem; }

/* ---------- Palette sheet ---------- */
.sheet {
  width: min(480px, calc(100% - 32px)); max-height: calc(100svh - 32px); padding: 0; border: 0; border-radius: var(--r-card);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2);
}
.sheet::backdrop { background: rgb(12 12 14 / .42); }
.sheet[open] { animation: sheet-in .35s var(--ease); }
@keyframes sheet-in { from { opacity: 0; translate: 0 16px; } }
.sheet-in { display: grid; gap: 16px; padding: 20px; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet-head h2 { font-size: 1.625rem; letter-spacing: -0.03em; font-weight: 500; }
.wall-wrap { display: grid; place-items: center; padding: 12px; border-radius: var(--r-md); background: var(--surface-2); }
.wall-preview { display: block; height: min(46svh, 360px); width: auto; max-width: 100%; border-radius: 18px; box-shadow: var(--shadow-2); }
.wall-preview.wide { height: auto; width: 100%; max-height: 46svh; object-fit: contain; border-radius: 12px; }
.wall-opts { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; inset-inline: 0; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 40; margin: 0 auto; width: max-content; max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 999px; background: var(--ink); color: var(--canvas); font-weight: 500; font-size: .9375rem;
  box-shadow: var(--shadow-2); overflow-wrap: anywhere; animation: toast-in .3s var(--ease);
}
@keyframes toast-in { from { opacity: 0; translate: 0 8px; } }

/* ---------- About, footer ---------- */
.fb-about { max-width: 1180px; margin: 12px auto 0; padding: 26px var(--gutter) 6px; color: var(--ink-2); font-size: .9375rem; }
.fb-about h2 { margin: 0 0 8px; font-size: 1.0625rem; color: var(--ink); }
.fb-about > p { margin: 0 0 14px; max-width: 70ch; line-height: 1.6; }
.fb-faq { display: grid; gap: 8px; }
.fb-faq h3 { margin: 8px 0 4px; font-size: .9375rem; color: var(--ink); }
.fb-faq details { border-radius: 16px; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.fb-faq summary { cursor: pointer; padding: 12px 16px; font-weight: 500; color: var(--ink); list-style-position: inside; }
.fb-faq summary:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 16px; }
.fb-faq details p { margin: 0; padding: 0 16px 14px; max-width: 70ch; line-height: 1.6; }
.foot { max-width: 1180px; margin: 0 auto; padding: 18px var(--gutter) 32px; color: var(--ink-2); font-size: .875rem; }
.foot p { margin: 0 0 8px; }

/* Feedback box from /assets/feedback.js, fitted to this page */
body .fbk {
  width: min(760px, calc(100% - 2 * var(--gutter)));
  margin: 24px auto 72px; padding: 24px 26px;
  background: var(--surface); border: 0; border-radius: var(--r-card);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
}
body .fbk-q { font-weight: 600; letter-spacing: -0.01em; }
body .fbk-q svg { stroke: var(--accent); }
body .fbk-hint { color: var(--accent-text); }
body .fbk-send { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
body .fbk textarea, body .fbk input[type=email] { background: var(--surface); border-color: var(--line-2); border-radius: var(--r-sm); }
body .fbk .fbk-beta { color: var(--accent-text); background: var(--accent-soft); border: 0; box-shadow: none; font-family: var(--font); font-weight: 600; letter-spacing: .05em; }
body .fbk-star:focus-visible, body .fbk button:focus-visible, body .fbk textarea:focus-visible, body .fbk input:focus-visible { outline-color: var(--focus); }
body .fbk .fbk-star { background: none; padding: 8px; border-radius: 8px; }
body .fbk .fbk-link { background: none; min-height: 44px; padding: 4px 0; border-radius: 0; }
body .fbk .fbk-send { min-height: 44px; padding: 0 22px; border-radius: 999px; border: 0; }

/* ---------- Language (English / العربية) ---------- */
:root[lang="ar"] { --font: "Geist", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif; }
:root[lang="ar"] body { line-height: 1.7; }
:root[lang="ar"] body *:not(svg):not(svg *) { letter-spacing: normal !important; }
:root[lang="ar"] h1, :root[lang="ar"] h2, :root[lang="ar"] h3, :root[lang="ar"] .reveal-name { line-height: 1.4; }
:root[lang="ar"] .reveal-name { font-weight: 400; }
.fb-suggest { --btn: var(--surface); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin: 0; padding: 12px 16px; border-radius: 20px; background: var(--surface); box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); }
.fb-suggest p { margin: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; }
.fb-suggest [lang="ar"] { font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; font-weight: 600; }
.fb-suggest [lang="en"] { font-family: 'Geist', system-ui, sans-serif; color: var(--ink-2); }
.fb-suggest-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-suggest button { min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; cursor: pointer; font: 500 .9375rem var(--font); }
.fb-suggest .fb-ar { background: var(--accent); color: var(--accent-ink); font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif; }
.fb-suggest .fb-en { background: var(--surface-2); color: var(--ink); }

/* ---------- Shared “easier to see” settings (Favabeans prefs.js) ---------- */
:root[data-text="large"] { font-size: 120%; }
:root[data-contrast="high"] { --ink-2: var(--ink); --line: rgb(29 29 31 / .45); --line-2: rgb(29 29 31 / .6); --tile-edge: rgb(29 29 31 / .35); }
@media (prefers-color-scheme: dark) { :root[data-contrast="high"]:where(:not([data-theme="light"])) { --line: rgb(255 255 255 / .45); --line-2: rgb(255 255 255 / .6); --tile-edge: rgb(0 0 0 / .6); } }
:root[data-contrast="high"]:where([data-theme="dark"]) { --line: rgb(255 255 255 / .45); --line-2: rgb(255 255 255 / .6); --tile-edge: rgb(0 0 0 / .6); }
:root[data-contrast="high"] .btn, :root[data-contrast="high"] .tool, :root[data-contrast="high"] .lv { box-shadow: inset 0 0 0 1.5px var(--line-2); }
:root[data-contrast="high"] .dot { fill: #1D1D1F; }
:root[data-contrast="high"] .lbl { fill: #1D1D1F; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
/* Until the app's first render (app.js removes .fb-wait), keep everything below the header hidden. */
html.fb-wait body > :not(.top) { visibility: hidden; }

/* ---------- Sizes ---------- */
@media (min-width: 980px) {
  .play { grid-template-columns: minmax(0, 1fr) 330px; grid-template-areas: "stage head" "stage side" "chapters chapters"; grid-template-rows: auto 1fr auto; }
  .play-head { padding-top: 28px; }
  .board { max-height: min(72svh, 700px); }
  .tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tool { grid-auto-flow: column; justify-content: start; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px; font-size: .875rem; text-align: start; }
  .tool:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .top-in { min-height: 56px; gap: 0 8px; }
  .brand { gap: 8px; }
  .brand h1 { font-size: 1rem; }
  .fb-lang button { padding: 0 6px; font-size: .8125rem; }
  .fb-lang button[lang="ar"] { font-size: .875rem; }
  .home-link { font-size: 0; width: 40px; min-width: 40px; padding: 0; justify-content: center; }
  .home-link::before { content: '←'; font-size: 1.05rem; line-height: 1; }
  :root[dir="rtl"] .home-link::before { content: '→'; }
  /* Looks the same size as the home button beside it, but keeps a 44px target by overlapping the gaps */
  .sound-btn { margin-inline: -2px; background: none; box-shadow: none; isolation: isolate; }
  .sound-btn::before { content: ''; position: absolute; inset: 2px; z-index: -1; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
  main { padding-top: 12px; gap: 16px; }
  .tabs { justify-self: stretch; }
  .tabs button { flex: 1 1 0; min-width: 0; padding: 0 6px; gap: 6px; font-size: .875rem; }
  .play { gap: 12px; }
  .card { padding: 16px; border-radius: 24px; }
  .done-panel { padding: 16px; border-radius: 24px; }
  .sheet { width: 100%; max-width: none; margin: auto 0 0; border-radius: 26px 26px 0 0; max-height: calc(100svh - 24px); }
  .sheet-in { padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); }
  .sheet-in::before { content: ''; justify-self: center; width: 36px; height: 4px; border-radius: 2px; background: var(--line-2); margin-bottom: -4px; }
}
@media (max-width: 430px) { .top-in { gap: 0 4px; } }   /* keeps the header on one line with the sound button */
@media (max-width: 400px) {
  .top-in { gap: 0 4px; }
  .brand { gap: 6px; }
  .brand img { width: 24px; height: 24px; }
  .brand h1 { font-size: .9375rem; }
  body .top .fbk-beta { margin-inline-start: 6px; padding: .3em .5em; }
  .fb-lang button { padding: 0 4px; }
  .home-link { width: 36px; min-width: 36px; min-height: 36px; }
  .sound-btn { margin-inline: -4px; }
  .sound-btn::before { inset: 4px; }
}
@media (max-width: 380px) {
  .tabs .ti { display: none; }
  .tool { font-size: .6875rem; min-height: 56px; }
  .brand img { display: none; }   /* room for the sound button in the header */
  .wall-opts .seg button { padding: 0 12px; }
}
@media (max-width: 340px) {
  .brand img { display: none; }
  .fb-lang button { font-size: .75rem; padding: 0 2px; }
  .top-in { gap: 0 2px; }
}
