/* Story mode: title, character creator, world map, scenes. Uses the theme's variables so dark mode works. */
.story { max-width: 980px; margin: 0 auto; padding: 4px 0 24px; }
.story h1, .story h2 { text-shadow: none; }
.s-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.s-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.s-center { text-align: center; justify-content: center; }
.s-muted { color: var(--ink-soft); font-weight: 700; }

/* ── title ── */
.s-hero { overflow: hidden; padding: 0; text-align: center; }
.s-hero .art { height: 240px; border-bottom: 4px solid var(--ink); }
.s-hero .art svg { width: 100%; height: 100%; display: block; }
.s-hero .body { padding: 22px 20px 26px; display: grid; gap: 12px; justify-items: center; }
.s-hero h1 { font-size: clamp(30px, 6vw, 46px); line-height: 1.05; }
.s-hero p { max-width: 560px; margin: 0; font-weight: 700; color: var(--ink-soft); font-size: 18px; }

/* ── pickers ── */
.s-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.s-seg button { font: inherit; font-weight: 800; border: 3px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 14px; padding: 7px 12px; cursor: pointer; }
.s-seg button[aria-pressed='true'] { border-color: var(--ocean); background: var(--surface-2); }
.s-sw { display: flex; flex-wrap: wrap; gap: 8px; }
.s-sw button { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--ink); cursor: pointer; padding: 0; box-shadow: 0 3px 0 rgba(35,48,90,.2); }
.s-sw button[aria-pressed='true'] { outline: 4px solid var(--ocean); outline-offset: 2px; }
.s-label { font-family: var(--font-display); font-weight: 600; font-size: 17px; margin: 14px 0 6px; display: block; }
.s-input { font: inherit; font-weight: 800; font-size: 20px; padding: 10px 14px; border-radius: 14px; border: 3px solid var(--line); width: 100%; background: var(--surface); color: var(--ink); }

/* ── creator ── */
.s-creator { display: grid; grid-template-columns: minmax(220px, 300px) 1fr; gap: 20px; align-items: start; }
.s-preview { background: linear-gradient(180deg, #bfe6ff, #eaf8ff); border-radius: 20px; border: 4px solid var(--ink); padding: 10px; display: grid; justify-items: center; position: sticky; top: 8px; }
.s-preview .me { height: 280px; } .s-preview .me svg { height: 100%; width: auto; }
.s-preview .pet { height: 70px; margin-top: -14px; margin-left: 120px; } .s-preview .pet svg { height: 100%; width: auto; }
.s-companions { display: flex; flex-wrap: wrap; gap: 8px; }
.s-companions button { width: 74px; border: 3px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; padding: 4px 2px; font: inherit; font-weight: 800; font-size: 12px; color: var(--ink); }
.s-companions button svg { width: 54px; height: 54px; display: block; margin: 0 auto; }
.s-companions button[aria-pressed='true'] { border-color: var(--ocean); background: var(--surface-2); }
@media (max-width: 700px) { .s-creator { grid-template-columns: 1fr; } .s-preview { position: static; } .s-preview .me { height: 200px; } .s-preview .pet { height: 56px; margin-left: 90px; } }

/* ── map ── */
.s-map-head { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; margin-bottom: 14px; }
.s-me-card { display: flex; gap: 12px; align-items: center; }
.s-me-card .face { width: 92px; height: 92px; border-radius: 22px; border: 3px solid var(--ink); background: linear-gradient(180deg, #bfe6ff, #eaf8ff); overflow: hidden; display: grid; place-items: start center; }
.s-me-card .face svg { width: 104px; height: auto; margin-top: 2px; }
.s-flames { display: flex; gap: 6px; align-items: center; }
.s-flames svg { width: 24px; height: 30px; display: block; }
.s-sea { background: linear-gradient(180deg, #5ec8ff 0%, #2f9bff 100%); border: 4px solid var(--ink); border-radius: 26px; padding: 18px 10px 26px; position: relative; overflow: hidden; }
.s-sea::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(115deg, rgba(255,255,255,.07) 0 14px, transparent 14px 40px); pointer-events: none; }
.s-isles { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; justify-items: center; }
.s-isles .isle:nth-child(2), .s-isles .isle:nth-child(5) { margin-top: 26px; }
.isle { background: none; border: 0; font: inherit; color: #fff; cursor: pointer; display: grid; justify-items: center; gap: 0; padding: 2px; max-width: 250px; }
.isle svg { width: min(100%, 220px); height: auto; filter: drop-shadow(0 6px 0 rgba(35,48,90,.18)); transition: transform .2s; }
.isle:not([disabled]):hover svg, .isle:focus-visible svg { transform: translateY(-5px) scale(1.03); }
.isle[disabled] { cursor: default; opacity: .96; }
.isle .nm { background: var(--surface); color: var(--ink); border-radius: 16px; padding: 4px 14px 6px; box-shadow: 0 3px 0 var(--line); display: grid; gap: 1px; text-align: center; margin-top: -8px; position: relative; }
.isle .nm b { font-family: var(--font-display); font-weight: 600; font-size: 17px; line-height: 1.1; }
.isle .nm span { font-size: 12px; font-weight: 800; color: var(--ink-soft); }
.isle.open .nm { background: #ffe27a; color: #23305a; } .isle.open .nm span { color: #6b4e00; }
.s-note { font-weight: 800; color: #fff; text-align: center; margin: 12px 0 0; text-shadow: 0 2px 0 rgba(35,48,90,.3); position: relative; }
@media (max-width: 640px) { .s-isles { grid-template-columns: repeat(2, 1fr); } .s-isles .isle:nth-child(2), .s-isles .isle:nth-child(5) { margin-top: 0; } .s-isles .isle:nth-child(even) { margin-top: 24px; } .s-map-head { grid-template-columns: 1fr; } }
.s-stats { display: grid; gap: 8px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-top: 14px; }
.s-stat { background: var(--surface-2); border-radius: 16px; padding: 8px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-weight: 800; }
.s-pips { display: inline-flex; gap: 3px; } .s-pips i { width: 12px; height: 12px; border-radius: 50%; background: var(--line); display: block; border: 2px solid var(--line-2); } .s-pips i.on { background: var(--c, var(--ocean)); border-color: var(--ink); }
.s-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.s-badge { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border-radius: 16px; padding: 6px 12px 6px 8px; font-weight: 800; font-size: 14px; } .s-badge .e { font-size: 26px; line-height: 1; }
.s-badge.locked { opacity: .45; filter: grayscale(1); }

/* ── scenes ── */
.story-bar { display: flex; gap: 8px; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; }
.stg { position: relative; aspect-ratio: 16 / 9; min-height: 220px; max-height: 56vh; width: 100%; border-radius: 24px; overflow: hidden; border: 4px solid var(--ink); background: #bfe6ff; box-shadow: var(--shadow); }
.stg-bg, .stg .stg-bg svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stg-bg.fade { animation: sFade .6s ease; }
@keyframes sFade { from { opacity: 0; } to { opacity: 1; } }
.stg-me, .stg-pet, .stg-who { position: absolute; bottom: -2%; }
.stg svg { height: 100%; width: auto; display: block; }
.stg-me { left: 3%; height: 74%; } .stg-pet { left: 21%; height: 26%; bottom: 1%; }
.stg-with { position: absolute; left: 36%; right: 30%; bottom: 3%; height: 40%; display: flex; gap: 2%; justify-content: center; align-items: flex-end; }
.stg-with svg { height: 100%; width: auto; max-width: 48%; }
.stg-who { right: 4%; height: 84%; transform-origin: bottom center; animation: sIn .35s ease both; } .stg-who.big { height: 94%; } .stg-who.animal { height: 62%; bottom: 2%; }
.stg-who.mem { opacity: .9; filter: drop-shadow(0 0 14px #ffe27a) saturate(.9); }
@keyframes sIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.dlg { background: var(--card); border: 4px solid var(--ink); border-radius: 22px; box-shadow: var(--shadow); padding: 14px 16px 16px; margin-top: 10px; position: relative; display: grid; gap: 10px; }
.dlg-name { position: absolute; top: -17px; left: 16px; background: var(--c, var(--grape)); color: #fff; font-family: var(--font-display); font-weight: 600; font-size: 17px; padding: 3px 14px; border-radius: 12px; border: 3px solid var(--ink); text-shadow: 0 2px 0 rgba(0,0,0,.2); }
.dlg-text { margin: 6px 0 0; font-size: clamp(18px, 2.6vw, 22px); font-weight: 700; line-height: 1.45; white-space: pre-line; animation: sIn .3s ease both; }
.dlg-text.nar { font-style: italic; color: var(--ink-soft); } .dlg-text.mem { font-style: italic; }
.dlg-act { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; }
.dlg-opts { display: grid; gap: 10px; }
.dlg-opts button { font: inherit; font-weight: 800; font-size: clamp(17px, 2.4vw, 20px); text-align: left; padding: 12px 16px; border-radius: 16px; border: 3px solid var(--ink); background: var(--surface-2); color: var(--ink); cursor: pointer; box-shadow: 0 4px 0 rgba(35,48,90,.18); }
.dlg-opts button:hover, .dlg-opts button:focus-visible { background: #ffe27a; color: #23305a; transform: translateY(-1px); }
.s-pz-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; flex-wrap: wrap; margin-bottom: 8px; }
.s-pz-head h2 { font-size: 24px; }
.story.puzzling .stg, .story.puzzling .dlg { display: none; }

/* ── pop-ups ── */
.s-pop { position: fixed; inset: 0; background: rgba(20,28,60,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.s-pop .box { background: var(--card); border: 4px solid var(--ink); border-radius: 26px; padding: 24px 22px; max-width: 420px; width: 100%; text-align: center; display: grid; gap: 10px; justify-items: center; animation: sIn .35s ease both; }
.s-pop .em { font-size: 74px; line-height: 1; }
.s-pop h2 { font-size: 28px; } .s-pop p { margin: 0; font-weight: 700; color: var(--ink-soft); }
.s-pop .lan svg { width: 190px; height: auto; }
.s-puzzle .puzzle-title .pill { display: none; }

/* ── phones: the picture stays put while the words scroll ──
   The scene sticks to the top of the screen, so you never lose sight of your character when you scroll the words or the answers.
   The Next button follows you at the bottom. On a phone held sideways the scene sits beside the words instead. */
@media (max-width: 760px) {
  .story:not(.puzzling) .stg { position: sticky; top: 0; z-index: 6; aspect-ratio: auto; height: clamp(190px, 36dvh, 320px); max-height: none; min-height: 0; border-radius: 0 0 22px 22px; border-top-width: 0; margin: 0 -2px; }
  .story:not(.puzzling) .story-bar { position: relative; z-index: 7; margin-bottom: 6px; }
  .story:not(.puzzling) .dlg { margin-top: 14px; padding-bottom: 12px; }
  .dlg-act { position: sticky; bottom: 8px; z-index: 5; justify-content: stretch; }
  .dlg-act .btn { width: 100%; min-height: 52px; font-size: 20px; box-shadow: 0 6px 18px rgba(35,48,90,.28), 0 4px 0 rgba(0,0,0,.18); }
  .dlg-opts button { min-height: 52px; }
  .dlg-text { font-size: clamp(18px, 4.6vw, 21px); }
  .stg-me { height: 80%; } .stg-who { height: 90%; } .stg-who.big { height: 98%; } .stg-who.animal { height: 66%; }
  .s-pz-head h2 { font-size: 20px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .story:not(.puzzling) { display: grid; grid-template-columns: minmax(0, 52%) minmax(0, 1fr); gap: 0 12px; align-items: start; }
  .story:not(.puzzling) .story-bar { grid-column: 1 / -1; margin-bottom: 4px; }
  .story:not(.puzzling) .stg { position: sticky; top: 0; grid-row: 2; height: calc(100dvh - 70px); max-height: 420px; aspect-ratio: auto; border-radius: 20px; border-width: 4px; margin: 0; }
  .story:not(.puzzling) .dlg { grid-row: 2; margin-top: 18px; max-height: calc(100dvh - 90px); overflow: auto; }
  .dlg-act { position: sticky; bottom: 0; }
}

/* ── a little life: breathing, a hop for the pet, a droop when sad, a bounce when laughing ──
   These are gentle, so they also run on phones set to "reduce motion" (that setting switches off every other animation on the site, which made the story look frozen). */
@keyframes sBreathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(1.025); } }
@keyframes sHop { 0%, 70%, 100% { transform: translateY(0); } 80% { transform: translateY(-9%); } 90% { transform: translateY(0); } }
@keyframes sDroop { from { transform: translateY(0) scaleY(1); } to { transform: translateY(2%) scaleY(.97); } }
@keyframes sBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5%); } }
@keyframes sTalk { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-1.2deg); } 75% { transform: rotate(1.2deg); } }
.stg-me svg, .stg-who svg { transform-origin: bottom center; animation: sBreathe 3.4s ease-in-out infinite; }
.stg-who svg { animation-delay: -1.1s; }
.stg-pet svg { transform-origin: bottom center; animation: sHop 4.2s ease-in-out infinite; }
.stg-me.mood-sad svg { animation: sDroop 1.4s ease-in-out infinite alternate; }
.stg-me.mood-laugh svg, .stg-me.mood-wow svg { animation: sBounce .7s ease-in-out infinite; }
.stg-pet.mood-sad svg { animation: none; transform: translateY(3%) scaleY(.95); }
.stg-with svg { transform-origin: bottom center; animation: sHop 3.6s ease-in-out infinite; }
.stg-who:not(.mem) svg { animation-name: sBreathe, sTalk; animation-duration: 3.4s, 2.4s; }
@media (prefers-reduced-motion: reduce) {
  .stg-bg.fade { animation: sFade .6s ease both !important; }
  .stg-who { animation: sIn .35s ease both !important; }
  .dlg-text { animation: sIn .3s ease both !important; }
  .s-pop .box { animation: sIn .35s ease both !important; }
  .stg-me svg, .stg-who svg { animation: sBreathe 3.4s ease-in-out infinite !important; }
  .stg-who:not(.mem) svg { animation: sBreathe 3.4s ease-in-out infinite, sTalk 2.4s ease-in-out infinite !important; }
  .stg-pet svg, .stg-with svg { animation: sHop 4.2s ease-in-out infinite !important; }
  .stg-me.mood-sad svg { animation: sDroop 1.4s ease-in-out infinite alternate !important; }
  .stg-me.mood-laugh svg, .stg-me.mood-wow svg { animation: sBounce .7s ease-in-out infinite !important; }
  .stg-pet.mood-sad svg { animation: none !important; }
}
@media (orientation: landscape) and (max-height: 540px) {
  body:has(.story:not(.puzzling)) .topbar { display: none; }   /* a sideways phone has no room to spare: the ☰ Menu button is still there */
  .story:not(.puzzling) .stg { height: calc(100dvh - 80px); }
  .story:not(.puzzling) .dlg { max-height: calc(100dvh - 90px); }
}

/* ── phones: the character you are designing stays in view while you scroll through the choices ── */
@media (max-width: 700px) {
  .s-creator { gap: 10px; }
  .s-preview { position: sticky; top: 0; z-index: 8; display: flex; justify-content: center; align-items: flex-end; gap: 6px; padding: 6px 12px 8px; border-radius: 0 0 22px 22px; border-top-width: 0; box-shadow: 0 8px 18px rgba(35,48,90,.22); }
  .s-preview .me { height: clamp(140px, 25dvh, 200px); }
  .s-preview .pet { height: clamp(46px, 8dvh, 64px); margin: 0 0 4px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  body:has(.s-creator) .topbar { display: none; }
  .s-creator { grid-template-columns: minmax(150px, 34%) 1fr; gap: 14px; }
  .s-preview { position: sticky; top: 6px; display: grid; justify-items: center; border-radius: 20px; border-width: 4px; padding: 8px; box-shadow: var(--shadow); }
  .s-preview .me { height: calc(100dvh - 110px); max-height: 300px; }
  .s-preview .pet { height: 48px; margin: -14px 0 0 70px; }
}
