/* אי המילים — warm parchment + sea palette, big touch targets, bidi-safe. */
:root {
  --bg: #fff6e5; --bg2: #f6e7c8; --card: #fffdf7; --ink: #2b1b12; --muted: #8a6f5c; --line: #e5d3b3;
  --teal: #1b6f8a; --teal2: #2a9d8f; --accent: #e07a2f; --gold: #f4b942; --red: #d63b3b; --green: #3a9d5d;
  --chip: #ffffff; --chipline: #c9a97a; --shadow: 0 2px 0 rgba(43, 27, 18, .15);
  --radius: 14px; --fs: 1.05rem;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15202b; --bg2: #1c2b38; --card: #1f3040; --ink: #f6ead2; --muted: #b8a58d; --line: #34495e;
    --chip: #28405a; --chipline: #4f6f8f; --shadow: 0 2px 0 rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15202b; --bg2: #1c2b38; --card: #1f3040; --ink: #f6ead2; --muted: #b8a58d; --line: #34495e;
  --chip: #28405a; --chipline: #4f6f8f; --shadow: 0 2px 0 rgba(0, 0, 0, .35); color-scheme: dark;
}
:root[data-big="1"] { --fs: 1.25rem; }
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-size: var(--fs); line-height: 1.45;
  font-family: "Rubik", "Varela Round", "Heebo", "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background-image: radial-gradient(circle at 20% 10%, rgba(244, 185, 66, .18), transparent 40%),
    radial-gradient(circle at 80% 90%, rgba(42, 157, 143, .14), transparent 45%);
  min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom, 0px);
}
button { font: inherit; color: inherit; }
a { color: var(--teal); }
[hidden] { display: none !important; }
svg { display: block; }

/* header */
#top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .6rem;
  padding: calc(.45rem + env(safe-area-inset-top, 0px)) .8rem .45rem; color: #fff;
  background: linear-gradient(180deg, var(--teal), #155a71); box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
}
#brand { display: flex; align-items: center; gap: .45rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.15rem; }
#brandicon svg { width: 30px; height: 30px; }
#coins { margin-inline-start: auto; display: flex; align-items: center; gap: .3rem; font-weight: 700; font-variant-numeric: tabular-nums; }
#coins .coin, .coin { display: inline-block; width: 1.1em; height: 1.1em; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #ffe08a, var(--gold) 60%, #b7791f); box-shadow: inset 0 0 0 2px rgba(120, 70, 0, .35); }
#coins.bump .coin { animation: pop .5s; }
.iconbtn { background: rgba(255, 255, 255, .15); border: 0; border-radius: 10px; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; }
.iconbtn:hover { background: rgba(255, 255, 255, .28); }

main { max-width: 760px; margin: 0 auto; padding: .8rem .8rem 1.5rem; }
h1, h2, h3 { margin: .2rem 0 .5rem; line-height: 1.2; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: .3rem 0; }
.muted { color: var(--muted); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; box-shadow: var(--shadow); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; cursor: pointer; border-radius: 12px;
  padding: .55rem 1.1rem; border: 2px solid var(--accent); background: var(--accent); color: #fff; font-weight: 700;
  box-shadow: 0 3px 0 #a8521a; transition: transform .08s, box-shadow .08s; min-height: 46px;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #a8521a; }
.btn:disabled { opacity: .5; cursor: default; box-shadow: none; transform: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--chipline); box-shadow: var(--shadow); }
.btn.teal { background: var(--teal2); border-color: var(--teal2); box-shadow: 0 3px 0 #166f65; }
.btn.big { font-size: 1.2rem; padding: .8rem 1.4rem; }
.btn.small { min-height: 36px; padding: .3rem .7rem; font-size: .95rem; }

/* home map */
.map { position: relative; border-radius: var(--radius); overflow: hidden; border: 2px solid #b48a4c; box-shadow: var(--shadow); background: #2a9d8f; }
.map svg { width: 100%; height: auto; }
.map .spot {
  position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: .15rem;
  background: rgba(255, 253, 247, .94); color: var(--ink); border: 2px solid #b48a4c; border-radius: 14px; padding: .35rem .6rem;
  cursor: pointer; box-shadow: 0 3px 0 rgba(43, 27, 18, .3); font-weight: 700; font-size: .95rem; min-width: 7.5rem; text-align: center;
}
.map .spot:hover { background: #fff; }
.map .spot small { font-weight: 500; color: var(--muted); font-size: .8rem; }
.map .spot .stars { color: var(--gold); font-size: .85rem; letter-spacing: .05em; }
.map .spot svg { width: 42px; height: 42px; }
@media (max-width: 520px) { .map .spot { min-width: 6.2rem; font-size: .85rem; padding: .25rem .4rem; } .map .spot svg { width: 32px; height: 32px; } .map .spot small { display: none; } }

.host { display: flex; gap: .6rem; align-items: flex-end; margin: .6rem 0; }
.host .avatar { flex: 0 0 64px; width: 64px; height: 64px; }
.host .avatar svg { width: 100%; height: 100%; }
.host .avatar.talk svg { animation: nod .5s ease-in-out 2; }
.bubble {
  position: relative; flex: 1; background: var(--card); border: 2px solid var(--chipline); border-radius: 16px; padding: .55rem .8rem;
  min-height: 3rem; display: flex; align-items: center; gap: .5rem; box-shadow: var(--shadow); font-size: 1.05rem;
}
.bubble::before { content: ""; position: absolute; inset-inline-start: -12px; bottom: 14px; border: 8px solid transparent; border-inline-end-color: var(--chipline); }
.bubble .text { flex: 1; }
.bubble .say { flex: 0 0 auto; }
.say { background: transparent; border: 0; cursor: pointer; font-size: 1.2rem; padding: .2rem .35rem; border-radius: 8px; line-height: 1; }
.say:hover { background: var(--bg2); }

/* game shell */
.game .stage { border-radius: var(--radius); overflow: hidden; border: 3px solid #5a3b1f; box-shadow: var(--shadow); background: #000; }
.game .stage svg, .game .stage img { width: 100%; height: auto; display: block; }
.game .stage img { aspect-ratio: 16 / 10; object-fit: cover; }
.task { margin-top: .6rem; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin: .5rem 0 .2rem; color: var(--muted); font-size: .9rem; }
.dots { display: flex; gap: .3rem; flex-wrap: wrap; }
.dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); display: inline-block; }
.dots i.done { background: var(--green); } .dots i.cur { background: var(--accent); box-shadow: 0 0 0 3px rgba(224, 122, 47, .3); }
.dots i.half { background: var(--gold); }

/* choices */
.choices { display: grid; gap: .5rem; margin-top: .5rem; }
.choicerow { display: flex; gap: .3rem; align-items: stretch; }
.choicerow .choice { flex: 1; }
.choicerow .say { flex: 0 0 auto; align-self: center; }
.choice {
  text-align: start; background: var(--chip); border: 2px solid var(--chipline); border-radius: 12px; padding: .65rem .9rem; cursor: pointer;
  font-size: 1.1rem; box-shadow: var(--shadow); display: flex; gap: .6rem; align-items: center; min-height: 52px;
}
.choice:hover { border-color: var(--accent); }
.choice .n { flex: 0 0 1.7rem; height: 1.7rem; border-radius: 50%; background: var(--bg2); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .95rem; }
.choice.good { border-color: var(--green); background: rgba(58, 157, 93, .12); }
.choice.bad { border-color: var(--red); opacity: .55; text-decoration: line-through; }
.choice.bad, .choice.good, .choice:disabled { cursor: default; }

/* sentence builder */
.builder { margin-top: .4rem; }
.slots {
  display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; min-height: 3.4rem; padding: .5rem; border-radius: 12px;
  background: var(--bg2); border: 2px dashed var(--chipline); margin-bottom: .6rem;
}
.slots .prefix { font-weight: 700; color: var(--teal); padding: .3rem .2rem; }
.slots .dot { font-weight: 700; padding: .3rem 0; }
.slot { min-width: 3.2rem; min-height: 2.6rem; border-radius: 10px; border: 2px dashed var(--chipline); background: transparent; }
.chip {
  display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; user-select: none; -webkit-user-select: none;
  background: var(--chip); border: 2px solid var(--chipline); border-radius: 10px; padding: .4rem .7rem; font-size: 1.12rem;
  box-shadow: var(--shadow); min-height: 2.6rem; line-height: 1.25; touch-action: manipulation;
}
.chip:hover { border-color: var(--accent); }
.chip.placed { border-color: var(--teal2); background: var(--card); }
.chip.locked { border-color: var(--green); background: rgba(58, 157, 93, .14); cursor: default; }
.chip.locked::after { content: "✓"; color: var(--green); font-size: .8em; }
.chip.bad { animation: shake .45s; border-color: var(--red); }
.chip.hint { animation: pulse 1s infinite; border-color: var(--accent); }
.chip.off { opacity: .35; text-decoration: line-through; cursor: default; }
.chip.ghost { opacity: .35; }
.bank { display: flex; flex-wrap: wrap; gap: .45rem; min-height: 3rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-top: .7rem; }
.actions .spacer { flex: 1; }
.sentence { font-size: 1.2rem; font-weight: 700; margin: .4rem 0; }
.fuller { background: rgba(42, 157, 143, .12); border-inline-start: 4px solid var(--teal2); padding: .5rem .8rem; border-radius: 8px; margin-top: .5rem; font-size: 1.1rem; }

/* word bank (missing word) */
.gap { font-size: 1.35rem; font-weight: 700; text-align: center; margin: .5rem 0; }
.gap .blank { display: inline-block; min-width: 4.5rem; border-bottom: 3px solid var(--accent); vertical-align: bottom; margin: 0 .2rem; color: var(--accent); }
.gap .blank.filled { border-bottom-color: var(--green); color: var(--green); }
.wordbank { display: grid; grid-template-columns: repeat(3, 1fr); gap: .45rem; }
@media (max-width: 380px) { .wordbank { grid-template-columns: repeat(2, 1fr); } }
.wordbank .chip { justify-content: center; text-align: center; transition: opacity .3s; }
.wordbank .chip.off { pointer-events: none; }
.wordbank .chip.right { border-color: var(--green); background: rgba(58, 157, 93, .18); }
.hintbox { background: rgba(244, 185, 66, .18); border: 1px dashed var(--gold); border-radius: 10px; padding: .45rem .8rem; margin: .5rem 0; }
.hintbox b { color: #9a6a00; }

/* story panels */
.panels { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
@media (max-width: 480px) { .panels:not(.telling) { grid-template-columns: 1fr; } }
.panels.telling { position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 5; background: var(--bg); padding: .3rem 0; }
.panels.telling .panel { cursor: default; }
.panels.telling .panel:not(.cur) { opacity: .55; }
.panel { position: relative; border: 3px solid #5a3b1f; border-radius: 10px; overflow: hidden; cursor: pointer; background: #000; box-shadow: var(--shadow); }
.panel svg { width: 100%; height: auto; }
.panel .num { position: absolute; top: 6px; inset-inline-start: 6px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; border: 2px solid #fff; font-size: 1rem; }
.panel.sel { outline: 4px solid var(--accent); }
.panel.good { outline: 4px solid var(--green); }
.panel.bad { outline: 4px solid var(--red); animation: shake .45s; }
.panel.cur { box-shadow: 0 0 0 4px var(--gold); }
.storyline { display: grid; gap: .3rem; margin: .5rem 0; }
.storyline div { padding: .3rem .6rem; border-radius: 8px; background: var(--bg2); }
.storyline div b { color: var(--teal); }

/* builder (iso) */
.iso-wrap { position: relative; }
.ask { display: grid; gap: .5rem; margin-top: .5rem; }
.block-drop { animation: drop .5s cubic-bezier(.2, .8, .3, 1.2); }
.block-ghost { animation: ghost 1.4s ease-in-out infinite; }

/* result */
.result { text-align: center; padding: 1rem; }
.result .coinsrow { display: flex; justify-content: center; gap: .4rem; margin: .5rem 0; }
.result .coinsrow .coin { width: 2.2rem; height: 2.2rem; animation: pop .5s both; }
.result .coinsrow .coin:nth-child(2) { animation-delay: .15s; } .result .coinsrow .coin:nth-child(3) { animation-delay: .3s; }
.result .coinsrow .coin.empty { background: var(--bg2); box-shadow: inset 0 0 0 2px var(--line); }
.unlock { margin-top: .8rem; padding: .6rem; border-radius: 12px; background: rgba(244, 185, 66, .2); border: 1px dashed var(--gold); }
.unlock svg { width: 64px; height: 64px; margin: 0 auto .3rem; }

/* collection + dashboard */
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: .5rem; }
.item { text-align: center; padding: .5rem .3rem; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font-size: .85rem; }
.item svg { width: 48px; height: 48px; margin: 0 auto .2rem; }
.item.locked { opacity: .4; filter: grayscale(1); }
table.dash { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.dash th, table.dash td { text-align: start; padding: .4rem .5rem; border-bottom: 1px solid var(--line); }
table.dash th { color: var(--muted); font-weight: 600; }
.tablewrap { overflow-x: auto; }
.badge { display: inline-block; padding: .05rem .5rem; border-radius: 999px; background: var(--bg2); font-size: .85rem; }
.badge.red { background: rgba(214, 59, 59, .15); color: var(--red); }
.badge.green { background: rgba(58, 157, 93, .15); color: var(--green); }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.toggle:last-child { border-bottom: 0; }
.toggle input[type="checkbox"] { width: 1.4rem; height: 1.4rem; accent-color: var(--teal2); }
.toggle input[type="text"] { font: inherit; padding: .35rem .5rem; border-radius: 8px; border: 1px solid var(--chipline); background: var(--card); color: var(--ink); max-width: 10rem; }
.fieldnote { color: var(--muted); font-size: .85rem; }
.menu { position: fixed; top: 0; inset-inline-end: 0; bottom: 0; width: min(320px, 85vw); background: var(--card); z-index: 20; box-shadow: -4px 0 20px rgba(0, 0, 0, .3); padding: calc(.8rem + env(safe-area-inset-top, 0px)) .9rem .9rem; overflow: auto; }
.menu a, .menu button.link { display: block; width: 100%; text-align: start; padding: .7rem .4rem; border: 0; background: transparent; border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 1.05rem; cursor: pointer; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 15; }

#toast { position: fixed; bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: .55rem 1rem; border-radius: 999px; z-index: 30; max-width: 90vw; text-align: center; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); }

@keyframes shake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes pop { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(1); } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(224, 122, 47, .5); } 50% { box-shadow: 0 0 0 8px rgba(224, 122, 47, 0); } }
@keyframes nod { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-6deg) translateY(-2px); } }
@keyframes drop { 0% { transform: translateY(-60px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@keyframes ghost { 0%, 100% { opacity: .35; } 50% { opacity: .8; } }
@keyframes floaty { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
.floaty { animation: floaty 2.4s ease-in-out infinite; }
.pulse { animation: pulse 1s infinite; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
