/* Little Town: a calm seaside town builder in the Favabeans look (see ../APP_DESIGN.md).
   Light by default, dark when the system asks. Accent: harbour coral, with sea blue and
   butter as supporting colours. No dark green or dark teal anywhere. The scene itself follows
   the town's own time of day, so the page theme never changes the sea. */
:root {
  --canvas: #F7F6F2;
  --surface: #FFFFFF;
  --surface-2: #F1F0EC;
  --surface-3: #E7E6E1;
  --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;

  /* harbour coral (white text on it is 4.95:1) */
  --accent: #B4533C;
  --accent-2: #CB6A51;
  --accent-ink: #FFFFFF;
  --accent-soft: #FCEBE4;
  --accent-text: #9A4330;
  --focus: #B4533C;
  --sea: #A9DAEC;
  --sea-soft: #E4F3F9;
  --butter-soft: #FFF5DA;

  /* the floating controls over the sea */
  --hud: rgb(255 255 255 / .9);
  --hud-ink: #1D1D1F;
  --hud-ink-2: #4E4E57;
  --hud-line: rgb(29 29 31 / .1);
  --hud-shadow: 0 1px 2px rgb(20 40 60 / .08), 0 8px 22px -10px rgb(20 40 60 / .3);
  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: #F2A287; --accent-2: #F6B7A2; --accent-ink: #2B120A; --accent-soft: #2D1F1A; --accent-text: #F5B7A2; --focus: #F5B7A2;
    --sea-soft: #16222A; --butter-soft: #26221A;
    --hud: rgb(28 28 32 / .9); --hud-ink: #F2F2F4; --hud-ink-2: #C2C2CA; --hud-line: rgb(255 255 255 / .1);
    --hud-shadow: 0 1px 0 rgb(255 255 255 / .05) inset, 0 10px 24px -10px rgb(0 0 0 / .6);
    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: #F2A287; --accent-2: #F6B7A2; --accent-ink: #2B120A; --accent-soft: #2D1F1A; --accent-text: #F5B7A2; --focus: #F5B7A2;
  --sea-soft: #16222A; --butter-soft: #26221A;
  --hud: rgb(28 28 32 / .9); --hud-ink: #F2F2F4; --hud-ink-2: #C2C2CA; --hud-line: rgb(255 255 255 / .1);
  --hud-shadow: 0 1px 0 rgb(255 255 255 / .05) inset, 0 10px 24px -10px rgb(0 0 0 / .6);
  color-scheme: dark;
}
:root[data-contrast="high"] { --ink-2: var(--ink); --hud-ink-2: var(--hud-ink); --line: rgb(29 29 31 / .3); --line-2: rgb(29 29 31 / .5); --hud: var(--surface); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
:root[data-text="large"] { font-size: 120%; }
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, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.02em; }
h2 { margin: 0; font-size: 1.25rem; line-height: 1.25; }
h3 { margin: 18px 0 4px; font-size: 1.0625rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header ---------- */
.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: 1400px; 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; 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-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;
}
.home-link:hover { box-shadow: inset 0 0 0 1px var(--line-2); }

/* ---------- Layout ---------- */
.app {
  max-width: 1400px; margin: 0 auto; padding: 20px var(--gutter) 32px;
  display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; align-items: start;
}
.play { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; min-width: 0; position: sticky; top: 76px; }
.side { display: grid; gap: 16px; min-width: 0; }

/* ---------- The stage (the town on the sea) ---------- */
.stage {
  position: relative; overflow: hidden; isolation: isolate;
  height: clamp(460px, calc(100vh - 170px), 860px);
  border-radius: 28px; background: linear-gradient(#C4E7F3, #93CDE4);
  box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; border-radius: inherit; }
#scene:focus-visible { outline: 3px solid var(--focus); outline-offset: -5px; }
#scene.panning { cursor: grabbing; }

.hud { position: absolute; z-index: 2; pointer-events: none; }
.hud > * { pointer-events: auto; }
.hud-top { top: 14px; inset-inline: 14px 74px; display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 100%; }
.town-title {
  margin: 0; max-width: 100%; padding: 8px 16px; border-radius: 999px;
  background: var(--hud); color: var(--hud-ink); box-shadow: var(--hud-shadow);
  font-size: 1.0625rem; letter-spacing: -0.015em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.example {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 4px 0 14px; min-height: 40px; border-radius: 999px;
  background: var(--hud); color: var(--hud-ink-2); box-shadow: var(--hud-shadow); font-size: .8125rem; font-weight: 500;
}
.link-btn { min-height: 40px; padding: 0 12px; border: 0; border-radius: 999px; background: none; color: var(--accent-text); font-weight: 600; font-size: .8125rem; cursor: pointer; }
.link-btn:hover { background: var(--accent-soft); }
.wish-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: min(100%, 420px); min-height: 44px; padding: 6px 16px 6px 8px;
  border: 0; border-radius: 999px; background: var(--hud); color: var(--hud-ink); box-shadow: var(--hud-shadow);
  font: 500 .875rem/1.3 var(--font); text-align: start; cursor: pointer;
}
.wish-chip .wc-ico { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); }
.wish-chip .wc-ico .ico { width: 18px; height: 18px; }
.wish-chip .wc-text { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.wish-chip.glow { box-shadow: var(--hud-shadow), 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
:root:not([data-motion="reduce"]) .wish-chip.glow { animation: lt-glow 1.6s var(--ease); }
@keyframes lt-glow { 0% { transform: scale(1); } 30% { transform: scale(1.03); } 100% { transform: scale(1); } }

.hud-side { top: 14px; inset-inline-end: 14px; display: flex; flex-direction: column; gap: 8px; }
.round {
  width: 44px; height: 44px; border: 0; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  background: var(--hud); color: var(--hud-ink); box-shadow: var(--hud-shadow);
  transition: transform .2s var(--ease), opacity .2s;
}
.round:hover:not(:disabled) { background: color-mix(in srgb, var(--hud-ink) 6%, var(--hud)); }
.round:active:not(:disabled) { transform: scale(.94); }
.round:disabled { opacity: .45; cursor: default; }
.round .ico { width: 22px; height: 22px; }
#undoBtn { margin-bottom: 6px; }
#soundBtn { margin-top: 6px; }

.hud-bottom {
  bottom: 14px; inset-inline: 14px; display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap;
}
.tools, .palette { background: var(--hud); box-shadow: var(--hud-shadow); }
.seg { display: inline-flex; padding: 4px; gap: 2px; border-radius: 16px; }
.seg button {
  min-height: 40px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: var(--hud-ink-2);
  font: 500 .9375rem/1 var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg button .ico { width: 19px; height: 19px; }
.seg button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--accent); }
.seg button:focus-visible { outline-offset: 1px; }
.palette {
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 18px;
  max-width: 100%; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
}
.palette::-webkit-scrollbar { display: none; }
.swatch {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; cursor: pointer; position: relative;
  background: radial-gradient(circle at 34% 30%, rgb(255 255 255 / .7) 0 18%, transparent 46%), var(--c);
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1), inset 0 -5px 0 0 color-mix(in srgb, var(--r) 70%, transparent);
  transition: transform .2s var(--ease);
}
.swatch[aria-checked="true"] { box-shadow: inset 0 0 0 1px rgb(0 0 0 / .1), inset 0 -5px 0 0 color-mix(in srgb, var(--r) 70%, transparent), 0 0 0 3px var(--hud), 0 0 0 5.5px var(--accent); transform: scale(1.04); }
.swatch:focus-visible { outline-offset: 5px; }
.deco-btn {
  flex: none; width: 44px; height: 44px; border: 0; border-radius: 14px; padding: 0; cursor: pointer; position: relative;
  background: var(--sea-soft); display: grid; place-items: center;
}
.deco-btn img { width: 40px; height: 40px; display: block; }
.deco-btn[aria-checked="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.deco-btn[aria-disabled="true"] { cursor: default; }
.deco-btn[aria-disabled="true"] img { filter: grayscale(1) opacity(.35); }
.deco-btn .lock { position: absolute; inset: auto 2px 2px auto; width: 18px; height: 18px; border-radius: 50%; background: var(--hud); color: var(--hud-ink-2); display: grid; place-items: center; }
.deco-btn .lock .ico { width: 13px; height: 13px; }
.palette-note { margin: 0; padding: 4px 8px; color: var(--hud-ink-2); font-size: .875rem; max-width: 34ch; }

.hint {
  position: absolute; z-index: 2; left: 50%; bottom: 84px; transform: translateX(-50%); margin: 0;
  padding: 9px 16px; border-radius: 999px; background: rgb(29 40 56 / .78); color: #FFFFFF;
  font-size: .9375rem; font-weight: 500; white-space: nowrap; pointer-events: none;
}
:root:not([data-motion="reduce"]) .hint:not([hidden]) { animation: lt-rise .5s var(--ease); }
@keyframes lt-rise { from { opacity: 0; transform: translate(-50%, 6px); } }

.offer {
  position: absolute; z-index: 3; top: 70px; left: 50%; transform: translateX(-50%); width: min(380px, calc(100% - 28px));
  display: grid; gap: 10px; padding: 14px 16px; border-radius: 20px;
  background: var(--hud); color: var(--hud-ink); box-shadow: var(--hud-shadow), 0 18px 40px -20px rgb(20 40 60 / .45);
}
.offer p { margin: 0; font-weight: 500; }
.offer-acts { display: flex; flex-wrap: wrap; gap: 8px; }
:root:not([data-motion="reduce"]) .offer:not([hidden]) { animation: lt-drop .4s var(--ease); }
@keyframes lt-drop { from { opacity: 0; transform: translate(-50%, -6px); } }
.visit { top: auto; bottom: 120px; }

/* the bar under the stage: time of day */
.stage-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.time { flex: 1 1 320px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; min-width: 0; }
.time-ico { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--butter-soft); color: #9A6B10; flex: none; }
.time-ico .ico { width: 20px; height: 20px; }
.time-ico.night { background: var(--sea-soft); color: #3F5D8A; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) .time-ico { color: #F2D27A; } :root:where(:not([data-theme="light"])) .time-ico.night { color: #AFC8F0; } }
:root:where([data-theme="dark"]) .time-ico { color: #F2D27A; }
:root:where([data-theme="dark"]) .time-ico.night { color: #AFC8F0; }
#timeRange { flex: 1 1 120px; min-width: 90px; height: 44px; accent-color: var(--accent); cursor: pointer; background: transparent; }
#timeOut { min-width: 9ch; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: .9375rem; }
.chip {
  min-height: 44px; padding: 0 16px; border: 0; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2); color: var(--ink); font: 500 .9375rem/1 var(--font); white-space: nowrap;
}
.chip .ico { width: 19px; height: 19px; }
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; box-shadow: inset 0 0 0 1.5px var(--accent); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border-radius: var(--r-card); padding: 20px; box-shadow: var(--shadow-1), inset 0 0 0 1px var(--line); display: grid; gap: 10px; align-content: start; }
.card:focus { outline: none; }
.help { margin: 0; color: var(--ink-2); font-size: .9375rem; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.btn {
  min-height: 44px; padding: 0 18px; border: 0; border-radius: 999px; background: var(--btn, var(--surface-2)); color: var(--ink);
  font: 500 .9375rem/1.2 var(--font); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  transition: background-color .2s, transform .2s var(--ease);
}
.btn:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 6%, var(--btn, var(--surface-2))); }
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; }
.btn .ico { width: 19px; height: 19px; }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent) 70%); color: var(--accent-ink); font-weight: 600; box-shadow: 0 8px 18px -12px var(--accent), inset 0 1px 0 rgb(255 255 255 / .18); }
@media (prefers-color-scheme: light) { :where(:root:not([data-theme="dark"])) .btn.primary { background: linear-gradient(180deg, #BC5A42, var(--accent) 70%); } }
:where(:root[data-theme="light"]) .btn.primary { background: linear-gradient(180deg, #BC5A42, var(--accent) 70%); }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 12%, var(--accent)); }
.btn.small { min-height: 40px; padding: 0 14px; font-size: .875rem; }
.btn.danger { color: var(--danger); background: color-mix(in srgb, var(--danger) 9%, transparent); }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.field { display: grid; gap: 4px; font-size: .875rem; color: var(--ink-2); font-weight: 500; }
.field input { min-height: 44px; padding: 0 14px; border: 0; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); font-size: 1rem; width: 100%; min-width: 0; }
.field input:focus-visible { outline-offset: 1px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none; }

/* wishes */
.daily { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 2px 12px; align-items: center; padding: 12px 14px; border-radius: var(--r-md); background: linear-gradient(120deg, var(--butter-soft), var(--accent-soft)); }
.daily .d-ico { grid-row: span 2; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface); color: var(--accent-text); }
.daily .d-ico .ico { width: 22px; height: 22px; }
.daily .d-title { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-text); }
.daily .d-text { font-weight: 500; }
.daily .d-meta { grid-column: 2; font-size: .8125rem; color: var(--ink-2); }
.daily.done .d-text { color: var(--ink-2); }
.wish-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.wish { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 2px 12px; align-items: center; padding: 8px; border-radius: 16px; }
.wish .w-pic { grid-row: span 2; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: var(--sea-soft); color: var(--ink-2); position: relative; }
.wish .w-pic img { width: 42px; height: 42px; }
.wish .w-pic .ico { width: 22px; height: 22px; }
.wish .w-text { font-weight: 500; font-size: .9375rem; line-height: 1.35; }
.wish .w-meta { font-size: .8125rem; color: var(--ink-2); }
.wish.current { background: var(--accent-soft); }
.wish.current .w-meta { color: var(--accent-text); }
.wish.done .w-text { color: var(--ink-2); }
.wish.done .w-pic::after { content: ''; position: absolute; inset: auto -4px -4px auto; width: 18px; height: 18px; border-radius: 50%; background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 12.5 4 4L18 8'/%3E%3C/svg%3E") center / 12px no-repeat; box-shadow: 0 0 0 2px var(--surface); }
.collect { margin: 4px 0 0; font-size: .875rem; color: var(--ink-2); }

/* towns */
.town-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.town { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 4px 12px; align-items: center; padding: 8px; border-radius: 18px; background: var(--surface-2); }
.town.current { background: var(--accent-soft); }
.town canvas, .town .thumb { grid-row: span 2; width: 84px; height: 56px; border-radius: 12px; display: block; background: #A9DAEC; }
.town .t-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.town .t-meta { font-size: .8125rem; color: var(--ink-2); }
.town .t-acts { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
.town .t-acts .btn { --btn: var(--surface); min-height: 40px; padding: 0 14px; font-size: .875rem; }
.town.current .t-meta { color: var(--accent-text); }

/* share */
.link-box { display: grid; gap: 8px; }
.postcard { margin: 6px 0 0; display: grid; gap: 10px; }
.postcard img { width: 100%; height: auto; border-radius: 14px; box-shadow: var(--shadow-1); display: block; }

/* details panels */
.panel { padding-block: 6px; }
.panel summary { cursor: pointer; font-weight: 600; font-size: 1.0625rem; min-height: 48px; display: flex; align-items: center; list-style: none; }
.panel summary::-webkit-details-marker { display: none; }
.panel summary::after { content: ''; margin-inline-start: auto; width: 9px; height: 9px; border-inline-end: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg) translate(-3px, -3px); transition: transform .25s var(--ease); }
.panel[open] summary::after { transform: rotate(225deg); }
.panel[open] { padding-bottom: 16px; }

.ico { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.ico .f { fill: color-mix(in srgb, currentColor 22%, transparent); }
.ico .k { fill: currentColor; stroke: none; }
:root[dir="rtl"] .ico.flip { transform: scaleX(-1); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; z-index: 30; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px); min-height: 52px; padding: 6px 6px 6px 20px;
  border-radius: 999px; background: var(--ink); color: var(--canvas); font-weight: 500; box-shadow: var(--shadow-2);
}
:root[dir="rtl"] .toast { padding: 6px 20px 6px 6px; }
.toast:not(:has(.toast-btn:not([hidden]))) { padding-inline-end: 20px; }
.toast-btn { flex: none; min-height: 40px; padding: 0 16px; border: 0; border-radius: 999px; background: var(--canvas); color: var(--ink); font: 600 .9375rem/1 var(--font); cursor: pointer; }
.toast-btn:focus-visible { outline-color: var(--accent); }
:root:not([data-motion="reduce"]) .toast:not([hidden]) { animation: lt-toast .3s var(--ease); }
@keyframes lt-toast { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ---------- About, FAQ, footer ---------- */
.foot { max-width: 1400px; margin: 0 auto; padding: 18px var(--gutter) 28px; color: var(--ink-2); font-size: .875rem; }
.foot p { margin: 0 0 6px; }
.fb-about { max-width: 1400px; 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; max-width: 860px; }
.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-offset: 2px; border-radius: 16px; }
.fb-faq details p { margin: 0; padding: 0 16px 14px; max-width: 70ch; line-height: 1.6; }

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; }

/* ---------- Arabic ---------- */
: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"] .daily .d-title { text-transform: none; }
.fb-suggest { --btn: var(--surface); grid-column: 1 / -1; 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); }

/* ---------- Less motion ---------- */
:root[data-motion="reduce"] *, :root[data-motion="reduce"] *::before, :root[data-motion="reduce"] *::after { animation: none !important; transition: none !important; }

/* ---------- Tablets and phones ---------- */
@media (max-width: 1080px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .play { position: static; }
  .side { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }
  .stage { height: clamp(440px, calc(100svh - 150px), 820px); }
}
@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: '→'; }
  .app { padding: 10px 10px 24px; gap: 14px; }
  .stage { height: calc(100svh - 56px - 96px); min-height: 420px; max-height: 760px; border-radius: 24px; }
  .hud-top { top: 10px; inset-inline: 10px 64px; gap: 6px; }
  .hud-side { top: 10px; inset-inline-end: 10px; gap: 6px; }
  #undoBtn { margin-bottom: 2px; }
  #soundBtn { margin-top: 2px; }
  .town-title { font-size: .9375rem; padding: 7px 14px; }
  .wish-chip { font-size: .8125rem; min-height: 40px; }
  .hud-bottom { bottom: 10px; inset-inline: 10px; gap: 8px; flex-direction: column; align-items: stretch; }
  .tools { align-self: center; }
  .seg button { padding: 0 12px; }
  .palette { justify-content: flex-start; }
  .hint { bottom: 128px; font-size: .875rem; }
  .visit { bottom: 128px; }
  .stage-bar { padding-inline: 4px; }
  .time { flex-basis: 100%; }
  .card { padding: 16px; border-radius: 24px; }
  .side { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 360px) {
  .seg button { padding: 0 9px; font-size: .875rem; }
  .seg button .ico { display: none; }
  #fitBtn { display: none; }
  #timeOut { min-width: 0; }
}
