@font-face {
  font-family: 'Padauk';
  src: url('fonts/Padauk.woff') format('woff'), url('fonts/Padauk.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Padauk';
  src: url('fonts/Padauk-bold.woff') format('woff'), url('fonts/Padauk-bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}

:root {
  --night: #050a1f;
  --ink: #ffffff;
  --ink-dim: rgba(255, 255, 255, 0.74);
  /* Strategy First brand: red, black, white (sampled from the logo) */
  --sf-red: #e00000;
  --sf-red-bright: #ff2a1a;
  --sf-red-dark: #8a0000;
  --accent: #ff4a3d;              /* brand red lifted for legibility on the night sky */
  --panel: rgba(10, 8, 16, 0.74);
  --panel-line: rgba(255, 255, 255, 0.16);
  --parchment: #f7e9c4;
  --parchment-ink: #4a2a10;
  --sf-red: #e00000;
  /* Source Sans 3 is the closest open match to the logo's humanist sans */
  --brand-font: 'Source Sans 3', 'Myriad Pro', 'Padauk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: var(--brand-font);
  --sans: var(--brand-font);
  --my: 'Padauk', 'Myanmar Text', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--night);
  color: var(--ink);
  font-family: var(--sans);
}

button { font: inherit; color: inherit; }
.brand-en, .intro h1, .composer h2, .feed-head h2, .scroll-title, .reader-to {
  font-variant-caps: small-caps; letter-spacing: .02em;
}
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

#scene { position: fixed; inset: 0; display: block; touch-action: manipulation; }

/* ---------- top bar ---------- */

.topbar {
  position: fixed; top: 0; left: 0; right: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 16px;
  padding: max(14px, env(safe-area-inset-top)) 20px 0;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; text-shadow: 0 2px 12px rgba(0,0,0,.7); }
/* logo artwork is used as supplied: red crest badge + the logo's own white wordmark, never retyped */
/* the crest sits on its own white square; the lettering is white on the sky */
.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-badge { width: 52px; height: 52px; flex: none; display: block; filter: drop-shadow(0 4px 12px rgba(0,0,0,.45)); }
.brand-wordmark { height: 40px; width: auto; display: block; filter: drop-shadow(0 2px 8px rgba(0,0,0,.7)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; padding-left: 2px; }
/* warm candle-light yellow; Burmese needs taller lines so its marks don't touch the title */
.brand-my {
  font-family: var(--my); font-size: 14px; line-height: 1.7; margin-top: 3px;
  color: #ffd27a;
  text-shadow: 0 0 10px rgba(255,190,90,.55), 0 1px 6px rgba(0,0,0,.6);
}
.brand-en { font-family: var(--serif); font-size: 22px; font-weight: 700; }


.top-actions { grid-column: 3; display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: 99px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--panel-line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 13px; font-weight: 700;
}
.pill-btn:hover { border-color: var(--accent); }
.pill-btn[aria-pressed="true"] { background: var(--sf-red); border-color: var(--sf-red); }
.pill-svg { width: 18px; height: 18px; color: var(--accent); flex: none; }
.pill-btn[aria-pressed="true"] .pill-svg { color: #fff; }

/* ---------- bottom ---------- */

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 0 16px max(22px, env(safe-area-inset-bottom));
  pointer-events: none;
}
/* the button row: Write your message stays centred, the camera sits beside it */
.cta-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; width: 100%; max-width: 520px; }
.photo-btn {
  pointer-events: auto; cursor: pointer; justify-self: start;
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; padding: 0;
  color: #fff; background: rgba(20,18,50,.72); border: 1px solid rgba(255,255,255,.35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: transform .15s, background .2s;
}
.photo-btn svg { width: 24px; height: 24px; }
.photo-btn:hover { background: rgba(224,0,0,.55); }
.photo-btn:active { transform: scale(.94); }
.photo-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
/* photo mode: hide the page's buttons and hints, show only the shutter bar */
body.photo-mode .topbar, body.photo-mode .bottom-bar, body.photo-mode .toast,
body.photo-mode .tooltip, body.photo-mode .feed, body.photo-mode .flow-panel,
body.photo-mode .music-panel, body.photo-mode .texts-panel { display: none !important; }
.photo-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 16px max(22px, env(safe-area-inset-bottom));
  animation: fadeIn .3s ease;
}
.photo-tip { margin: 0; font-size: 13px; color: rgba(255,255,255,.85); text-shadow: 0 1px 8px #000; }
.photo-bar-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 28px; width: 100%; max-width: 360px; }
.photo-exit {
  pointer-events: auto; justify-self: end; width: 46px; height: 46px; border-radius: 50%; padding: 0; cursor: pointer;
  font-size: 24px; line-height: 1; color: #fff; background: rgba(20,18,50,.72); border: 1px solid rgba(255,255,255,.35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.shutter {
  pointer-events: auto; cursor: pointer; width: 74px; height: 74px; border-radius: 50%; padding: 5px;
  background: transparent; border: 4px solid #fff; box-shadow: 0 4px 24px rgba(0,0,0,.45);
}
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .12s, background .2s; }
.shutter:hover span { background: #ffe9e9; }
.shutter:active span { transform: scale(.88); }
.shutter:focus-visible, .photo-exit:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
/* make it yours: the editing panel above the shutter */
.photo-edit-btn {
  pointer-events: auto; justify-self: start; width: 46px; height: 46px; border-radius: 50%; padding: 0; cursor: pointer;
  display: grid; place-items: center; color: #fff; background: rgba(20,18,50,.72); border: 1px solid rgba(255,255,255,.35);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.photo-edit-btn svg { width: 22px; height: 22px; }
.photo-edit-btn[aria-expanded="true"] { background: var(--sf-red); border-color: var(--sf-red); }
.photo-edit-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.photo-edit {
  pointer-events: auto; width: min(440px, 100%); max-height: min(46dvh, 430px); display: flex; flex-direction: column;
  border-radius: 18px; background: rgba(10,8,16,.9); border: 1px solid var(--panel-line);
  box-shadow: 0 16px 50px rgba(0,0,0,.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: rise .25s ease; overflow: hidden;
}
.photo-edit[hidden] { display: none; }
/* dragged somewhere else on the screen by its grip */
.photo-edit.moved { position: fixed; z-index: 41; animation: none; }
.pe-grip { flex: 0 0 auto; display: grid; place-items: center; height: 18px; cursor: grab; touch-action: none; }
.pe-grip span { width: 44px; height: 5px; border-radius: 99px; background: rgba(255,255,255,.35); }
.pe-grip:hover span, .photo-edit.dragging .pe-grip span { background: rgba(255,255,255,.7); }
.photo-edit.dragging .pe-grip { cursor: grabbing; }
body.photo-editing .photo-tip { display: none; }
.photo-tabs { display: flex; gap: 4px; padding: 0 8px; border-bottom: 1px solid var(--panel-line); }
.photo-tabs [role="tab"] {
  flex: 1; padding: 9px 4px 10px; border: 0; background: none; color: var(--ink-dim); font: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.photo-tabs [aria-selected="true"] { color: #fff; border-bottom-color: var(--sf-red); }
.photo-tabs button:focus-visible { outline: 2px solid #fff; outline-offset: -2px; border-radius: 8px; }
.pe-close { flex: 0 0 40px; border: 0; background: none; color: #fff; font-size: 22px; cursor: pointer; }
.pe-body { padding: 12px 14px 14px; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; }
.pe-body[hidden] { display: none; }
.pe-label { font-size: 13px; font-weight: 700; color: rgba(255,255,255,.9); margin-top: 4px; }
.pe-label small { font-weight: 600; color: var(--ink-dim); }
.pe-row { display: flex; gap: 8px; align-items: center; }
.pe-row input, .pe-body textarea {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; font: inherit; font-size: 16px; color: #fff;
  background: rgba(255,255,255,.07); border: 1px solid var(--panel-line);
}
.pe-body textarea { resize: none; width: 100%; font-family: "Source Sans 3", Padauk, system-ui, sans-serif; }
.pe-row input:focus, .pe-body textarea:focus { outline: 2px solid var(--sf-red); outline-offset: 0; border-color: transparent; }
.pe-go { padding: 10px 16px; font-size: 14px; flex: 0 0 auto; }
.pe-hint { margin: 2px 0 0; font-size: 12px; color: var(--ink-dim); }
.pe-feature { display: flex; flex-direction: column; gap: 8px; }
/* a photo tool not yet unlocked: a "?" card saying how to earn it */
.pe-locked {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; cursor: pointer;
  font: inherit; font-size: 13px; text-align: left; color: rgba(255,255,255,.88);
  background: rgba(90,70,160,.18); border: 1px dashed rgba(255,213,107,.45);
}
.pe-locked b { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-family: var(--serif); font-size: 18px; color: #ffe08a; background: rgba(10,8,30,.8); text-shadow: 0 0 8px rgba(255,200,80,.9); }
.pe-locked:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.pe-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pe-chips button {
  padding: 7px 11px; border-radius: 99px; font: inherit; font-size: 13px; font-weight: 600; color: #fff; cursor: pointer;
  background: rgba(224,0,0,.18); border: 1px solid rgba(224,0,0,.6);
}
.pe-chips button[aria-pressed="false"] { background: rgba(255,255,255,.04); border-color: var(--panel-line); color: var(--ink-dim); text-decoration: line-through; }
.pe-body input[type="range"] { width: 100%; accent-color: var(--sf-red); }
.pe-chips button:focus-visible, .pe-body input[type="range"]:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.pe-reset { align-self: center; margin-top: 6px; padding: 9px 18px; font-size: 14px; }
/* ---------- festival quests ---------- */
/* the trophy button, left of Write your message (the camera sits on the right) */
.quest-btn {
  pointer-events: auto; cursor: pointer; justify-self: end; position: relative;
  width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; padding: 0;
  color: #ffd56b; background: rgba(20,18,50,.72); border: 1px solid rgba(255,213,107,.55);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 6px 20px rgba(0,0,0,.35); transition: transform .15s, background .2s;
}
.quest-btn svg { width: 24px; height: 24px; }
.quest-btn:hover { background: rgba(120,80,0,.55); }
.quest-btn:active { transform: scale(.94); }
.quest-btn:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.quest-count {
  position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  padding: 1px 6px; border-radius: 99px; font-size: 11px; font-weight: 800; white-space: nowrap;
  color: #2a1a00; background: linear-gradient(#ffe48a, #f2b42c); box-shadow: 0 2px 6px rgba(0,0,0,.4);
}
/* something newly earned and not yet looked at */
.quest-btn.fresh::after {
  content: ''; position: absolute; top: 2px; right: 2px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--sf-red-bright); box-shadow: 0 0 0 2px #140a20, 0 0 10px var(--sf-red-bright);
}
.quest-btn.fresh, .quest-btn.hello { animation: questGlow 1.6s ease-in-out infinite; }
@keyframes questGlow { 50% { box-shadow: 0 0 0 4px rgba(255,213,107,.25), 0 0 26px rgba(255,200,80,.65); } }
body.photo-mode .quest-btn { display: none; }

/* the college building picker (tap the building on the lake) */
.overlay.buildings { z-index: 46; }
.buildings-card {
  position: relative; width: min(460px, 100%); padding: 20px 18px 18px; border-radius: 22px;
  background: linear-gradient(180deg, rgba(30,20,52,.97), rgba(10,8,22,.97));
  border: 1px solid rgba(255,213,107,.35); box-shadow: 0 24px 70px rgba(0,0,0,.6); animation: rise .3s ease;
}
.buildings-card h2 { margin: 0; padding-right: 40px; font-family: var(--serif); font-size: 22px; color: #ffe08a; }
.buildings-sub { margin: 4px 0 14px; font-size: 14px; color: var(--ink-dim); }

/* the quests panel */
.overlay.quests { z-index: 46; align-items: flex-start; }
.quests-card {
  position: relative; width: min(760px, 100%); margin: auto 0; padding: 22px 20px 20px;
  border-radius: 22px; background: linear-gradient(180deg, rgba(30,20,52,.97), rgba(10,8,22,.97));
  border: 1px solid rgba(255,213,107,.35); box-shadow: 0 24px 70px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08);
  animation: rise .3s ease;
}
.quests-head { display: flex; gap: 14px; align-items: center; padding-right: 40px; }
.quests-trophy { font-size: 40px; filter: drop-shadow(0 0 14px rgba(255,200,80,.6)); }
.quests-head h2 { margin: 0; font-family: var(--serif); font-size: 26px; color: #ffe08a; letter-spacing: .02em; }
.quests-head p { margin: 4px 0 0; font-size: 14px; color: var(--ink-dim); }
.quests-progress { display: flex; align-items: center; gap: 12px; margin: 16px 0 6px; }
.quests-progress b { font-size: 16px; color: #ffe08a; white-space: nowrap; }
.quests-track { flex: 1; height: 10px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.quests-track span {
  display: block; height: 100%; width: 0; border-radius: inherit;
  background: linear-gradient(90deg, #c88b16, #ffe36a); box-shadow: 0 0 12px rgba(255,210,90,.7);
  transition: width .8s cubic-bezier(.3,.8,.3,1);
}
.quests-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 12px; }
.quests-group {
  grid-column: 1 / -1; margin: 12px 0 0; font-size: 12px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .14em; color: var(--accent);
}
.quest {
  position: relative; display: flex; flex-direction: column; border-radius: 16px; overflow: hidden;
  background: rgba(255,255,255,.04); border: 1px solid var(--panel-line);
}
.quest.earned { border-color: rgba(255,213,107,.6); background: linear-gradient(180deg, rgba(255,200,80,.1), rgba(255,255,255,.03)); }
.quest.next { border-color: var(--sf-red-bright); box-shadow: 0 0 0 1px var(--sf-red-bright), 0 0 22px rgba(255,42,26,.35); }
.quest.flash { animation: questFlash 1.4s ease; }
@keyframes questFlash { 30% { box-shadow: 0 0 0 3px #ffe36a, 0 0 30px rgba(255,220,100,.8); } }
.quest-art {
  position: relative; height: 96px; display: grid; place-items: center;
  background: radial-gradient(ellipse at 50% 60%, rgba(90,70,160,.45), rgba(10,8,30,.9) 70%);
}
.quest.earned .quest-art { background: radial-gradient(ellipse at 50% 60%, rgba(255,190,80,.35), rgba(30,16,50,.9) 70%); }
.quest-art > img, .quest-art > canvas { max-width: 82%; max-height: 82px; object-fit: contain; }
/* locked: a black silhouette with a faint edge, and a big glowing "?" */
.quest.locked .quest-art > img, .quest.locked .quest-art > canvas {
  filter: brightness(0) drop-shadow(0 0 1px rgba(170,180,255,.7)) drop-shadow(0 0 8px rgba(120,130,255,.35));
  opacity: .9;
}
.quest-q {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--serif); font-size: 44px; font-weight: 900; color: #ffe08a;
  text-shadow: 0 0 12px rgba(255,200,80,.9), 0 2px 0 #6b3d00;
  animation: questQ 2.4s ease-in-out infinite;
}
@keyframes questQ { 50% { transform: scale(1.12); } }
.quest-ribbon {
  position: absolute; top: 8px; left: 8px; padding: 3px 8px; border-radius: 99px;
  font-size: 10px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase;
  color: #fff; background: var(--sf-red);
}
.quest-body { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px 12px; flex: 1; }
.quest-body h4 { margin: 0; font-size: 16px; }
.quest.locked .quest-body h4 { color: var(--ink-dim); letter-spacing: .2em; }
.quest-task { margin: 0; font-size: 13px; color: rgba(255,255,255,.88); }
.quest.earned .quest-task { color: #ffe08a; font-weight: 700; }
.quest-bar { height: 6px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.quest-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--sf-red-dark), var(--sf-red-bright)); }
.quest-body small { font-size: 12px; color: var(--ink-dim); }
.quest-go {
  align-self: flex-start; margin-top: auto; padding: 7px 14px; border-radius: 99px; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 800; color: #fff; background: var(--sf-red); border: 0;
}
.quest.earned .quest-go { color: #2a1a00; background: linear-gradient(#ffe48a, #f2b42c); }
.quest-go:disabled { opacity: .55; cursor: default; }
.quest-go:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/* "Achievement unlocked!": slides down from the top */
.achieve {
  position: fixed; z-index: 58; top: max(16px, env(safe-area-inset-top)); left: 50%;
  display: flex; align-items: center; gap: 12px; width: min(440px, calc(100vw - 24px));
  padding: 10px 16px 10px 10px; border-radius: 18px; cursor: pointer; text-align: left; font: inherit; color: #fff;
  background: linear-gradient(135deg, rgba(60,36,8,.96), rgba(24,12,40,.96));
  border: 1.5px solid #f2b42c; box-shadow: 0 16px 50px rgba(0,0,0,.55), 0 0 30px rgba(255,190,60,.35);
  transform: translate(-50%, -140%);
}
.achieve.show { animation: achieveIn 4.2s cubic-bezier(.2,.9,.3,1.2) forwards; }
@keyframes achieveIn {
  0% { transform: translate(-50%, -140%); }
  10%, 88% { transform: translate(-50%, 0); }
  100% { transform: translate(-50%, -140%); }
}
.achieve-art {
  flex: 0 0 76px; height: 64px; display: grid; place-items: center; border-radius: 12px;
  background: radial-gradient(circle, rgba(255,200,80,.45), rgba(40,20,60,.6) 70%);
}
.achieve-art > img, .achieve-art > canvas { max-width: 70px; max-height: 58px; animation: achieveReveal 1.1s ease .25s both; }
/* the picture turns from silhouette to colour, like a reveal */
@keyframes achieveReveal { from { filter: brightness(0) drop-shadow(0 0 6px #ffe36a); transform: scale(.7); } to { filter: none; transform: scale(1); } }
.achieve-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.achieve-text small { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: #ffd56b; }
.achieve-text b { font-family: var(--serif); font-size: 20px; }
.achieve-text span { font-size: 13px; color: rgba(255,255,255,.85); }

/* locked buildings in Settings and photo mode */
.building-choice.locked { cursor: help; }
.building-choice.locked span:last-child { letter-spacing: .2em; color: var(--ink-dim); }
.building-thumb { position: relative; }
.building-choice.locked .building-thumb { background: radial-gradient(ellipse at 50% 70%, rgba(90,70,160,.55), rgba(10,8,30,.9) 75%); }
.building-choice.locked .building-thumb canvas { filter: brightness(0) drop-shadow(0 0 1px rgba(170,180,255,.8)) drop-shadow(0 0 6px rgba(120,130,255,.4)); }
.thumb-q {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--serif); font-size: 26px; font-weight: 900; color: #ffe08a; text-shadow: 0 0 10px rgba(255,200,80,.9);
}

/* ---------- guided tour ---------- */
/* everything is dimmed except the spotlit part (a huge shadow round a clear box) */
.tour { position: fixed; inset: 0; z-index: 62; }
.tour-hole {
  position: fixed; border-radius: 18px; pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(3,4,16,.74), 0 0 0 3px #ffd56b, 0 0 26px 6px rgba(255,200,80,.55);
  transition: left .35s ease, top .35s ease, width .35s ease, height .35s ease;
  animation: tourPulse 1.8s ease-in-out infinite;
}
.tour-hole.wide { border-radius: 24px; }
.tour-hole.none { left: 50%; top: 50%; width: 0; height: 0; box-shadow: 0 0 0 9999px rgba(3,4,16,.74); animation: none; }
@keyframes tourPulse { 50% { box-shadow: 0 0 0 9999px rgba(3,4,16,.74), 0 0 0 3px #ffd56b, 0 0 40px 12px rgba(255,200,80,.75); } }
.tour-card {
  position: fixed; width: min(340px, calc(100vw - 20px)); padding: 16px 16px 14px; border-radius: 18px;
  background: linear-gradient(180deg, rgba(36,24,60,.98), rgba(14,10,28,.98));
  border: 1px solid rgba(255,213,107,.5); box-shadow: 0 18px 50px rgba(0,0,0,.6);
  transition: left .35s ease, top .35s ease;
}
.tour-card.centre { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(380px, calc(100vw - 32px)); text-align: center; }
.tour-card.in { animation: tourIn .3s ease; }
.tour-card.centre.in { animation: tourInCentre .3s ease; }
@keyframes tourIn { from { opacity: 0; translate: 0 8px; } }
@keyframes tourInCentre { from { opacity: 0; transform: translate(-50%, -46%); } }
.tour-step { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
.tour-card h2 { margin: 4px 0 6px; font-family: var(--serif); font-size: 21px; color: #ffe08a; }
.tour-card p { margin: 0; font-size: 15px; line-height: 1.5; color: rgba(255,255,255,.9); }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.tour-card.centre .tour-actions { justify-content: center; flex-direction: column-reverse; }
.tour-nav { display: flex; gap: 8px; margin-left: auto; }
.tour-card.centre .tour-nav { margin: 0; }
.tour-skip { border: 0; background: none; color: var(--ink-dim); font: inherit; font-size: 14px; cursor: pointer; padding: 8px 4px; text-decoration: underline; text-underline-offset: 3px; }
.tour-back, .tour-next { border-radius: 99px; font: inherit; font-size: 14px; font-weight: 800; cursor: pointer; padding: 9px 16px; }
.tour-back { color: #fff; background: rgba(255,255,255,.08); border: 1px solid var(--panel-line); }
.tour-next { color: #fff; background: var(--sf-red); border: 0; box-shadow: 0 6px 18px rgba(224,0,0,.35); }
.tour-skip:focus-visible, .tour-back:focus-visible, .tour-next:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
/* the quests panel's "take the tour again" */
.quests-tour { margin-top: 8px; padding: 0; border: 0; background: none; color: #ffd56b; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Super cat's fortune cards ---------- */
.fortune-box {
  /* all in Myanmar: Padauk throughout, with room for the tall letters */
  font-family: Padauk, "Myanmar Text", var(--brand-font); line-height: 1.7;

  position: relative; width: min(560px, 100%); padding: 20px 18px 22px; border-radius: 24px; text-align: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(255,190,80,.16), transparent 60%), linear-gradient(180deg, rgba(36,20,52,.98), rgba(10,8,24,.98));
  border: 1px solid rgba(255,213,107,.45); box-shadow: 0 24px 70px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.08);
  animation: rise .3s ease;
}
.fortune-box .ph { white-space: nowrap; } /* a Myanmar phrase kept whole (fortune.js) */
.fortune-head { display: flex; gap: 12px; align-items: center; text-align: left; padding-right: 36px; }
.fortune-cat { width: 64px; height: auto; flex: none; filter: drop-shadow(0 4px 12px rgba(255,180,60,.35)); }
.fortune.shuffling .fortune-cat { animation: catShuffle .35s ease-in-out infinite alternate; }
@keyframes catShuffle { from { transform: rotate(-6deg); } to { transform: rotate(6deg) translateY(-3px); } }
.fortune-head h2 { margin: 0; font-size: 22px; line-height: 1.6; color: #ffe08a; }
.fortune-my { margin: 2px 0 0; font-family: Padauk, "Myanmar Text", sans-serif; font-size: 15px; color: #ffd56b; }
.fortune-sub { margin: 4px 0 0; font-size: 14px; color: var(--ink-dim); min-height: 1.3em; }

/* the cards: face down in a fan, dealt from the middle */
.fortune-table { position: relative; height: 210px; margin: 14px 0 6px; perspective: 900px; }
.fcard {
  --w: 104px; --h: 156px;
  position: absolute; left: 50%; top: 22px; width: var(--w); height: var(--h); margin-left: calc(var(--w) / -2);
  padding: 0; border: 0; background: none; cursor: pointer; border-radius: 12px;
  transform-origin: 50% 120%;
  transform: translateY(0) rotate(0deg);
  transition: transform .55s cubic-bezier(.2,.9,.3,1.15), opacity .4s, filter .3s;
}
.fortune.shuffling .fcard { animation: shuffle .28s ease-in-out infinite alternate; animation-delay: calc(var(--i) * 40ms); }
@keyframes shuffle { from { transform: translateX(calc(var(--i) * -6px)) rotate(calc(var(--i) * -3deg)); } to { transform: translateX(calc(var(--i) * 6px)) rotate(calc(var(--i) * 3deg)); } }
.fanned .fcard { transform: translateX(calc(var(--i) * 64px)) translateY(calc(var(--i) * var(--i) * 4px)) rotate(calc(var(--i) * 9deg)); transition-delay: calc((var(--i) + 2) * 50ms); }
.fanned .fcard:not(:disabled):hover, .fanned .fcard:not(:disabled):focus-visible {
  transform: translateX(calc(var(--i) * 64px)) translateY(calc(var(--i) * var(--i) * 4px - 16px)) rotate(calc(var(--i) * 9deg));
  filter: drop-shadow(0 0 14px rgba(255,210,90,.75)); transition-delay: 0s;
}
.fcard:focus-visible { outline: none; }
.fcard:disabled { cursor: default; }
.fcard.away { opacity: 0; transform: translateY(60px) scale(.8) !important; transition-delay: 0s; }
/* the chosen card rises to the middle, grows a little and turns over */
.fanned .fcard.picked, .fcard.picked { transform-origin: 50% 50%; transform: translateY(6px) scale(1.14) !important; z-index: 2; transition-delay: 0s; }
.fcard-inner {
  position: absolute; inset: 0; display: block; border-radius: inherit;
  transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3,.8,.3,1);
}
.fcard.flipped .fcard-inner { transform: rotateY(180deg); }
.fcard.still .fcard-inner { transition: none; }
.fcard-back, .fcard-front {
  position: absolute; inset: 0; border-radius: 12px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: 0 10px 24px rgba(0,0,0,.45);
}
/* the back: deep festival red, gold double frame, the crest and ကံ ("fortune") */
.fcard-back {
  background:
    radial-gradient(circle at 50% 50%, rgba(255,210,100,.18) 0 22%, transparent 23%),
    repeating-radial-gradient(circle at 50% 50%, transparent 0 10px, rgba(255,213,107,.12) 10px 11px),
    linear-gradient(160deg, #b0101b, #6e0a14);
  border: 2px solid #f2b42c; outline: 1px solid rgba(255,224,138,.6); outline-offset: -7px;
}
.fcard-back img { width: 42px; height: 42px; opacity: .95; }
.fcard-back b { font-family: Padauk, "Myanmar Text", sans-serif; font-size: 22px; color: #ffe08a; text-shadow: 0 0 8px rgba(255,200,80,.8); }
/* the face: parchment with a gold frame */
.fcard-front {
  transform: rotateY(180deg); padding: 8px 6px;
  background: radial-gradient(circle at 50% 35%, #fffaf0, #f3e2bf 70%);
  border: 2px solid #d9a12a; outline: 1px solid rgba(160,100,10,.5); outline-offset: -6px; color: #5a2a00;
}
.fcard-front.rare { background: radial-gradient(circle at 50% 35%, #fff6c8, #f5c64a 75%); border-color: #fff1a8; animation: rareGlow 1.6s ease-in-out infinite; }
@keyframes rareGlow { 50% { box-shadow: 0 0 26px 6px rgba(255,220,90,.85); } }
.fcard-front { justify-content: space-between; padding: 8px 6px 7px; }
.fcard-num { font-size: 12px; font-weight: 800; color: #7a3b00; letter-spacing: .05em; }
.fcard-art { font-size: 40px; line-height: 1.1; }
.fcard-art.illustrated { display: block; width: 100%; flex: 1; min-height: 0; mix-blend-mode: multiply; }
.fcard-art.illustrated svg { display: block; width: 100%; height: 100%; overflow: hidden; }
/* the name on a red ribbon, like a tarot card's title */
.fcard-name {
  align-self: stretch; padding: 3px 4px; border-radius: 4px; background: #b0101b; color: #ffe9b0;
  font-family: Padauk, "Myanmar Text", sans-serif; font-size: 11px; font-weight: 700; line-height: 1.45;
}

/* the reading */
.fortune-result { margin-top: 18px; animation: rise .4s ease; }
.fortune-result h3 { margin: 0; font-size: 22px; line-height: 1.6; color: #ffe08a; }
.fortune-result h3.rare { background: linear-gradient(90deg, #ffe08a, #fff6c8, #f2b42c); -webkit-background-clip: text; background-clip: text; color: transparent; }
.fortune-text { margin: 8px auto 0; max-width: 420px; font-size: 16px; line-height: 1.55; }
.fortune-bless { margin: 8px 0 0; font-family: Padauk, "Myanmar Text", sans-serif; font-size: 16px; color: #ffd56b; }
.fortune-lucky { display: flex; justify-content: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.fortune-lucky > span {
  display: flex; flex-direction: column; gap: 2px; padding: 8px 12px; border-radius: 12px; min-width: 110px;
  background: rgba(255,255,255,.05); border: 1px solid var(--panel-line);
}
.fortune-lucky small { font-size: 12px; font-weight: 700; color: #ff8a7a; }
.fortune-lucky b { display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 15px; white-space: nowrap; }
#fortune-number { font-size: 22px; color: #ffe08a; }
#fortune-color-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.fortune-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.fortune-actions .btn { padding: 10px 18px; font-size: 15px; font-family: Padauk, "Myanmar Text", var(--brand-font); }
.fortune-write { margin-top: 12px; border: 0; background: none; color: #ffd56b; font: inherit; font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.fortune-write:focus-visible { outline: 3px solid #fff; outline-offset: 3px; border-radius: 6px; }
@media (max-width: 420px) {
  /* a tighter fan that stays inside the box on narrow phones */
  .fortune-table { height: 170px; }
  .fcard { --w: 76px; --h: 116px; }
  .fanned .fcard { transform: translateX(calc(var(--i) * 40px)) translateY(calc(var(--i) * var(--i) * 4px)) rotate(calc(var(--i) * 8deg)); }
  .fanned .fcard:not(:disabled):hover, .fanned .fcard:not(:disabled):focus-visible { transform: translateX(calc(var(--i) * 40px)) translateY(calc(var(--i) * var(--i) * 4px - 14px)) rotate(calc(var(--i) * 8deg)); }
  .fcard-art { font-size: 28px; }
  .fcard-back img { width: 34px; height: 34px; }
  /* small cards: the name in full shows below the card */
  .fcard-name { font-size: 9.5px; padding: 2px 3px; line-height: 1.4; }
  .fortune-lucky { gap: 6px; flex-wrap: nowrap; }
  .fortune-lucky > span { min-width: 0; flex: 1; padding: 7px 6px; }
  .fortune-lucky small { font-size: 10.5px; }
  .fortune-lucky b { font-size: 12px; gap: 4px; }
  #fortune-color-dot { width: 10px; height: 10px; flex: none; }
  .fortune-head h2 { font-size: 19px; }
  .fortune-actions .btn { padding: 10px 14px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .fortune.shuffling .fcard, .fortune.shuffling .fortune-cat, .fcard-front.rare { animation: none; }
}

/* the shutter flash */
.photo-flash { position: fixed; inset: 0; z-index: 60; background: #fff; pointer-events: none; animation: photoFlash .45s ease-out forwards; }
@keyframes photoFlash { from { opacity: .85; } to { opacity: 0; } }
/* the photo preview */
.overlay.photo-sheet { z-index: 45; }
.photo-card {
  /* big enough on laptops and monitors to see the photo properly */
  position: relative; width: min(1100px, 100%); max-height: calc(100dvh - 48px); display: flex; flex-direction: column; gap: 14px;
  padding: 16px; border-radius: 20px; background: var(--panel); border: 1px solid var(--panel-line);
  box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: rise .3s ease;
}
.photo-card img { display: block; width: 100%; min-height: 0; flex: 1; object-fit: contain; border-radius: 12px; background: #000; }
.photo-card .close { top: -12px; right: -12px; z-index: 1; }
.photo-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.cta {
  pointer-events: auto; cursor: pointer;
  padding: 15px 30px; border: 0; border-radius: 99px;
  font-size: 18px; font-weight: 700; color: #fff;
  background: linear-gradient(180deg, var(--sf-red-bright), var(--sf-red) 55%, #a80000);
  box-shadow: 0 0 0 1px rgba(255,255,255,.35) inset, 0 10px 30px rgba(224,0,0,.45), 0 0 60px rgba(255,42,26,.25);
  position: relative;
}
/* The pulse is an extra glow that only fades in and out. Fading (opacity) is
   done by the graphics chip for free; animating the shadow itself would make
   the browser redraw the big blur on every frame. */
.cta::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: 0 10px 40px rgba(224,0,0,.45), 0 0 90px rgba(255,42,26,.22);
  opacity: 0; will-change: opacity;
  animation: ctaGlow 3s ease-in-out infinite;
}
.cta:hover { transform: translateY(-1px); }
.cta { display: inline-flex; align-items: center; gap: 10px; }
.cta-icon { width: 26px; height: 26px; flex: none; }
@keyframes ctaGlow { 50% { opacity: 1; } }
.hint {
  margin: 0; font-size: 13px; color: var(--ink-dim); text-align: center;
  text-shadow: 0 1px 8px #000; transition: opacity .35s;
  max-width: 100%; overflow-wrap: anywhere;
}
.hint.faded { opacity: 0; }
.credit {
  margin: 0; font-size: 12px; letter-spacing: .04em; color: rgba(255,255,255,.6);
  text-shadow: 0 1px 6px #000;
}

.tooltip {
  position: fixed; left: 0; top: 0; z-index: 5; pointer-events: none;
  padding: 6px 10px; border-radius: 8px; font-size: 12px; font-weight: 700;
  background: rgba(10,12,35,.88); border: 1px solid var(--panel-line);
  white-space: nowrap;
}

.toast {
  position: fixed; left: 50%; top: 120px; z-index: 30;
  transform: translate(-50%, -12px); opacity: 0;
  padding: 12px 20px; border-radius: 14px; text-align: center;
  background: rgba(20,18,50,.92); border: 1px solid var(--accent);
  box-shadow: 0 0 40px rgba(224,0,0,.35);
  transition: opacity .5s, transform .5s;
  max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast small { color: var(--ink-dim); }
.toast-close {
  position: absolute; top: -11px; right: -11px; width: 28px; height: 28px; padding: 0;
  display: grid; place-items: center; border-radius: 50%; cursor: pointer;
  background: rgba(20,18,50,.96); border: 1px solid var(--accent); color: #fff;
  font-size: 18px; line-height: 1; box-shadow: 0 2px 10px rgba(0,0,0,.4);
}
.toast-close:hover { background: var(--sf-red); }
.toast-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
/* a bigger hit area for fingers, without a bigger circle */
.toast-close::after { content: ""; position: absolute; inset: -8px; }

/* ---------- buttons ---------- */

.btn {
  cursor: pointer; border-radius: 99px; padding: 11px 22px;
  font-weight: 700; font-size: 16px; border: 1px solid transparent;
}
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary {
  color: #fff; border: 0;
  background: linear-gradient(180deg, var(--sf-red-bright), var(--sf-red) 55%, #a80000);
  box-shadow: 0 6px 20px rgba(224,0,0,.35);
}
.btn.ghost { background: transparent; border-color: currentColor; opacity: .85; }
.btn.danger { background: #111; color: #fff; margin-top: 14px; }
/* the "Remove this message?" check inside the message card */
.confirm-box {
  margin: 16px auto 0; padding: 14px 16px 16px; max-width: 360px; border-radius: 14px;
  background: rgba(176,0,0,.07); border: 1px solid rgba(176,0,0,.28); text-align: center;
  animation: rise .25s ease;
}
.confirm-title { margin: 0; font-weight: 700; font-size: 16px; color: #8a0000; }
.confirm-text { margin: 4px 0 12px; font-size: 13px; line-height: 1.45; opacity: .8; }
.confirm-actions { display: flex; gap: 10px; justify-content: center; }
.confirm-actions .btn { margin: 0; padding: 9px 20px; font-size: 15px; }
.confirm-actions .btn.danger { background: var(--sf-red); }
.confirm-actions .btn.danger:hover { filter: brightness(1.08); }
.btn.ghost-dark { background: transparent; color: inherit; border: 1px solid rgba(60,30,10,.35); }
.btn.ghost-dark:hover { background: rgba(60,30,10,.06); }
.btn:focus-visible, .pill-btn:focus-visible, .cta:focus-visible, .choice:focus-visible, .env-option:focus-visible, .envelope:focus-visible {
  outline: 3px solid #fff; outline-offset: 3px;
}

.close {
  position: absolute; top: 12px; right: 14px; z-index: 5;
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  border: 1px solid var(--panel-line); background: rgba(0,0,0,.35);
  font-size: 22px; line-height: 1;
}

/* Decorations behind a panel stay still; the active panel keeps animating. */
body.scene-covered .topbar,
body.scene-covered .topbar *,
body.scene-covered .topbar *::before,
body.scene-covered .topbar *::after,
body.scene-covered .bottom-bar,
body.scene-covered .bottom-bar *,
body.scene-covered .bottom-bar *::before,
body.scene-covered .bottom-bar *::after {
  animation-play-state: paused !important;
}

/* ---------- overlays ---------- */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(ellipse at center, rgba(8,10,35,.72), rgba(3,5,18,.9));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  overflow-y: auto;
  animation: fadeIn .4s ease;
}
@keyframes fadeIn { from { opacity: 0; } }

.intro { z-index: 40; transition: opacity .7s; align-items: flex-start; }
.intro.gone { opacity: 0; pointer-events: none; }
.intro-card { max-width: 560px; text-align: center; margin: auto; }
.intro-logo { display: flex; flex-direction: column; align-items: center; gap: 14px; margin: 0 auto 16px; }
.intro-crest { width: clamp(110px, 24vw, 150px); height: auto; display: block; filter: drop-shadow(0 16px 36px rgba(0,0,0,.55)); }
.intro-wordmark { width: clamp(200px, 46vw, 280px); height: auto; display: block; }
.intro-my { font-family: var(--my); color: var(--accent); font-size: 22px; margin: 6px 0 0; line-height: 1.6; }
.intro-credit {
  margin-top: 26px !important; padding-top: 14px; font-size: 13px !important;
  border-top: 1px solid rgba(224,0,0,.6);
}
.intro h1 { font-family: var(--serif); font-weight: 700; font-size: clamp(32px, 6vw, 50px); margin: 0 0 14px; line-height: 1.05; }
.intro p { color: var(--ink-dim); line-height: 1.6; font-size: 16px; }
/* Burmese needs taller lines so stacked vowels and medials don't collide */
.intro-body p { font-family: var(--my); line-height: 1.95; font-size: 16px; margin: 0; }
/* all three steps share one grid cell, so the card keeps the height of the
   longest and the buttons don't jump between steps */
.intro-body { display: grid; margin: 4px 0 0; }
.intro-step { grid-area: 1 / 1; opacity: 0; visibility: hidden; transform: translateX(16px); transition: opacity .45s, transform .45s, visibility 0s .45s; }
.intro-step.active { opacity: 1; visibility: visible; transform: none; transition: opacity .45s, transform .45s; }
.intro-step.before { transform: translateX(-16px); }
.intro-dots { display: flex; gap: 8px; justify-content: center; margin: 18px 0 4px; }
.intro-dots span { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.3); transition: background .3s, width .3s; }
.intro-dots span.on { width: 22px; border-radius: 99px; background: var(--sf-red); }
.intro-nav { display: flex; gap: 12px; justify-content: center; margin-top: 16px; }

/* ---------- composer ---------- */

.composer .step { display: none; flex-direction: column; align-items: center; text-align: center; width: 100%; margin: auto; }
.composer[data-step="choose"] .step-choose,
.composer[data-step="open"] .step-open,
.composer[data-step="write"] .step-write,
.composer[data-step="seal"] .step-seal,
.composer[data-step="light"] .step-light { display: flex; animation: fadeIn .45s ease; }
.composer.leaving { opacity: 0; transition: opacity 1s ease .3s; }
.composer h2 { font-family: var(--serif); font-weight: 700; font-size: clamp(28px, 4vw, 36px); margin: 0 0 4px; }
.composer .sub { color: var(--ink-dim); margin: 6px 0 22px; }
.stage { min-height: 290px; display: grid; place-items: center; margin-top: 30px; }

.env-grid {
  display: grid; grid-template-columns: repeat(3, auto); gap: 22px 26px; justify-content: center;
}
.env-option {
  background: none; border: 0; padding: 8px; cursor: pointer; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: transform .25s;
}
.env-option:hover { transform: translateY(-6px) rotate(-2deg); }
.env-option .envelope { --s: .5; }
.env-label { display: flex; flex-direction: column; line-height: 1.2; }
.env-label small { color: var(--ink-dim); }
@media (max-width: 560px) {
  .env-grid { grid-template-columns: repeat(2, auto); gap: 14px; }
  .env-option .envelope { --s: .44; }
}

/* ---------- envelope ---------- */

.envelope {
  --s: 1;
  position: relative;
  width: calc(300px * var(--s)); height: calc(200px * var(--s));
  perspective: 900px;
}
.envelope.big { --s: 1; cursor: pointer; animation: envFloat 4s ease-in-out infinite; }
@media (max-width: 400px) { .envelope.big { --s: .9; } }
@keyframes envFloat { 50% { transform: translateY(-8px) rotate(.6deg); } }

.envelope[data-color="ruby"] { --c1: #d8434b; --c2: #8e1a26; }
.envelope[data-color="saffron"] { --c1: #f0973a; --c2: #a8540f; }
.envelope[data-color="jade"] { --c1: #2bb37a; --c2: #0e5e3e; }
.envelope[data-color="sapphire"] { --c1: #3d78d8; --c2: #183b80; }
.envelope[data-color="lotus"] { --c1: #ea70ab; --c2: #9a2b63; }
.envelope[data-color="amethyst"] { --c1: #9a63d0; --c2: #4f2680; }

.env-back, .env-pocket, .env-flap { position: absolute; border-radius: calc(10px * var(--s)); }
.env-back {
  inset: 0;
  background: linear-gradient(160deg, var(--c2), color-mix(in srgb, var(--c2) 70%, #000));
  box-shadow: 0 18px 40px rgba(0,0,0,.5), inset 0 0 0 calc(3px * var(--s)) rgba(255,215,130,.5);
}
.env-letter {
  position: absolute; left: 7%; right: 7%; top: 6%; height: 86%; z-index: 1;
  border-radius: 4px;
  background:
    repeating-linear-gradient(transparent 0 calc(17px * var(--s)), rgba(120,70,20,.14) calc(17px * var(--s)) calc(18px * var(--s))),
    linear-gradient(#fbf1d6, #ecd49c);
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  transition: transform .6s ease;
}
.env-pocket {
  inset: 0; z-index: 2;
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
  background:
    radial-gradient(circle, rgba(255,220,140,.4) calc(1.6px * var(--s)), transparent calc(2.2px * var(--s))) 0 0 / calc(16px * var(--s)) calc(16px * var(--s)),
    linear-gradient(170deg, var(--c1), var(--c2));
}
.env-pocket::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 8%; height: 9%;
  background:
    repeating-linear-gradient(45deg, rgba(255,214,120,.85) 0 calc(4px * var(--s)), transparent calc(4px * var(--s)) calc(8px * var(--s))),
    linear-gradient(rgba(255,214,120,.25), rgba(255,214,120,.25));
  border-top: calc(1.5px * var(--s)) solid rgba(255,220,140,.9);
  border-bottom: calc(1.5px * var(--s)) solid rgba(255,220,140,.9);
}
.env-flap {
  left: 0; right: 0; top: 0; height: 62%; z-index: 3;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background:
    radial-gradient(circle, rgba(255,220,140,.4) calc(1.6px * var(--s)), transparent calc(2.2px * var(--s))) 0 0 / calc(16px * var(--s)) calc(16px * var(--s)),
    linear-gradient(180deg, color-mix(in srgb, var(--c1) 85%, #fff), var(--c1));
  transform-origin: top center;
  transition: transform .6s ease .5s, z-index 0s .8s;
}
.env-seal {
  position: absolute; left: 50%; top: 58%; z-index: 4;
  width: calc(56px * var(--s)); height: calc(56px * var(--s));
  margin: calc(-28px * var(--s)) 0 0 calc(-28px * var(--s));
  display: grid; place-items: center; border-radius: 50%;
  /* brand-red wax seal stamped with the crest in its logo colours */
  background:
    url('brand/seal-crest.png') center 52% / 74% auto no-repeat,
    radial-gradient(circle at 38% 32%, var(--sf-red-bright), var(--sf-red) 55%, var(--sf-red-dark));
  box-shadow: 0 3px 10px rgba(0,0,0,.45), inset 0 0 0 calc(2px * var(--s)) rgba(0,0,0,.35), inset 0 0 0 calc(4px * var(--s)) rgba(255,255,255,.18);
  transition: transform .45s cubic-bezier(.3,1.7,.5,1) 1.1s, opacity .3s 1.1s;
}
.envelope.open .env-seal { transform: scale(0) rotate(-40deg); opacity: 0; transition: transform .3s ease, opacity .3s; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; transition: transform .6s ease .25s, z-index 0s .55s; }
.envelope.open .env-letter { transform: translateY(-58%); transition: transform .7s ease .75s; }
.envelope.open { animation: none; }
.envelope.no-anim, .envelope.no-anim * { transition: none !important; }

/* ---------- scroll ---------- */

.scroll { width: min(580px, 100%); filter: drop-shadow(0 18px 30px rgba(0,0,0,.5)); }
.roller {
  position: relative; height: 24px; margin: 0 -14px; border-radius: 12px; z-index: 1;
  background: linear-gradient(#b3743a, #6a3712 55%, #3d1d08);
}
.roller::before, .roller::after {
  content: ''; position: absolute; top: -5px; width: 18px; height: 34px; border-radius: 7px;
  background: linear-gradient(90deg, #8a5a10, #ffd877 50%, #8a5a10);
}
.roller::before { left: -12px; }
.roller::after { right: -12px; }
.scroll-body {
  max-height: 0; overflow: hidden;
  transition: max-height 1s cubic-bezier(.45,.1,.3,1);
  background:
    linear-gradient(90deg, rgba(150,90,30,.18), transparent 6%, transparent 94%, rgba(150,90,30,.18)),
    linear-gradient(#f9eccb, #f0dba8);
  color: var(--parchment-ink);
}
.scroll.unrolled .scroll-body { max-height: 900px; }
.scroll-inner {
  margin: 0; padding: 22px 30px 26px;
  display: flex; flex-direction: column; gap: 14px; text-align: left;
  border-top: 6px double rgba(185,130,42,.55); border-bottom: 6px double rgba(185,130,42,.55);
}
.scroll-title { font-family: var(--serif); font-size: 28px; font-weight: 700; text-align: center; margin: 0; color: #b00000; }

.kinds { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.kinds label { cursor: pointer; }
.kinds input { position: absolute; opacity: 0; pointer-events: none; }
.kinds span {
  display: inline-block; padding: 8px 14px; border-radius: 99px; font-size: 14px; font-weight: 700;
  border: 1.5px solid rgba(122,63,12,.35); background: rgba(255,255,255,.35);
}
.kinds input:checked + span { background: var(--sf-red); color: #fff; border-color: var(--sf-red); }
.kinds input:focus-visible + span { outline: 3px solid #111; outline-offset: 2px; }

.field { display: flex; flex-direction: column; gap: 4px; position: relative; font-size: 13px; font-weight: 700; color: #7a3f0c; }
.field input, .field textarea {
  font: inherit; font-weight: 400; font-size: 16px; color: var(--parchment-ink);
  padding: 10px 12px; border-radius: 10px;
  border: 1.5px solid rgba(122,63,12,.3); background: rgba(255,255,255,.55);
}
.field textarea {
  resize: vertical; min-height: 120px; line-height: 1.5;
  font-family: var(--serif); font-size: 19px;
}
.field input:focus, .field textarea:focus { outline: none; border-color: var(--sf-red); box-shadow: 0 0 0 3px rgba(224,0,0,.18); }
.field input:disabled { opacity: .5; }
.count { position: absolute; right: 10px; bottom: 8px; font-size: 11px; opacity: .6; }
.sign { display: flex; gap: 14px; align-items: end; flex-wrap: wrap; }
.sign-name { flex: 1 1 220px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; font-weight: 700; padding-bottom: 12px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--sf-red); }
.scroll-inner .btn { align-self: center; margin-top: 4px; }

/* ---------- seal step ---------- */

.seal-controls { opacity: 0; transform: translateY(10px); transition: opacity .5s, transform .5s; pointer-events: none; }
.step-seal.ready .seal-controls { opacity: 1; transform: none; pointer-events: auto; }
.form-choice { display: flex; gap: 14px; justify-content: center; margin: 16px 0 20px; flex-wrap: wrap; }
.choice {
  width: 210px; padding: 16px 14px; border-radius: 16px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(255,255,255,.05); border: 1.5px solid var(--panel-line);
  transition: border-color .2s, background .2s, transform .2s;
}
.choice small { color: var(--ink-dim); line-height: 1.35; }
.choice:hover { transform: translateY(-3px); }
.choice[aria-checked="true"] { border-color: var(--sf-red); background: rgba(224,0,0,.16); box-shadow: 0 0 30px rgba(224,0,0,.3); }
.choice-art { width: 64px; height: 54px; position: relative; }
.choice-candle::before {
  content: ''; position: absolute; left: 4px; right: 4px; bottom: 4px; height: 14px; border-radius: 50%;
  background: radial-gradient(#4c9a52, #163d21);
}
.choice-candle::after {
  content: ''; position: absolute; left: 50%; bottom: 14px; width: 12px; height: 22px; margin-left: -6px;
  border-radius: 50% 50% 50% 50% / 70% 70% 30% 30%;
  background: radial-gradient(circle at 50% 75%, #fffbe6, #ffd36b 40%, #ff8a2a 80%, transparent);
  box-shadow: 0 0 20px 6px rgba(255,170,60,.5);
  animation: flick .15s infinite alternate;
}
.choice-lantern::before {
  content: ''; position: absolute; left: 50%; top: 6px; width: 36px; height: 42px; margin-left: -18px; border-radius: 50%;
  background: radial-gradient(circle at 50% 60%, #fff4d0, #ff8a7a 45%, #c8323a);
  box-shadow: 0 0 24px 6px rgba(255,140,100,.45);
}
.choice-lantern::after {
  content: ''; position: absolute; left: 50%; top: 0; width: 2px; height: 8px; margin-left: -1px; background: #c9a35a;
}
.seal-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.error { color: #ffb4a8; min-height: 1.4em; margin: 12px 0 0; }

/* ---------- lighting ---------- */

.light-stage { width: min(420px, 92vw); aspect-ratio: 300 / 240; margin-top: 10px; }
.light-art { width: 100%; height: 100%; overflow: visible; transition: transform 1.3s cubic-bezier(.5,0,.7,.4), opacity 1.3s; }
.light-art .glow { opacity: 0; transition: opacity 1s; }
.light-art .lf, .light-art .mf { transform-box: fill-box; transform-origin: 50% 100%; transform: scale(0); transition: transform .5s cubic-bezier(.3,1.6,.5,1); }
.light-art .flick { transform-box: fill-box; transform-origin: 50% 100%; animation: flick .14s ease-in-out infinite alternate; }
@keyframes flick { from { transform: scale(.94, .92) skewX(-2deg); } to { transform: scale(1.04, 1.08) skewX(2deg); } }
.light-art .paper-lit { opacity: 0; transition: opacity 1s; mix-blend-mode: screen; }

.match { transform: translate(420px, 170px); transition: transform .8s cubic-bezier(.3,.7,.3,1), opacity .5s; }
.light-stage.s-in .match { transform: translate(236px, 108px); }
.light-stage.s-strike .match { transform: translate(206px, 92px); transition-duration: .18s; }
.light-stage.s-touch .match { transform: translate(157px, 146px); transition-duration: .75s; }
.light-stage.is-lantern.s-touch .match { transform: translate(157px, 136px); }
.light-stage.s-out .match { transform: translate(420px, 60px); opacity: 0; }
.match .spark { stroke: #ffe08a; stroke-width: 2; stroke-linecap: round; opacity: 0; }
.light-stage.s-strike .spark { animation: spark .35s ease-out; }
@keyframes spark { 0% { opacity: 1; transform: scale(.4); } 100% { opacity: 0; transform: scale(1.6); } }
.light-stage.s-match-lit .mf { transform: scale(1); }
.light-stage.s-out .mf { transform: scale(0); }
.light-stage.s-lit .lf { transform: scale(1); }
/* waiting for the writer to tap the wick */
.light-stage.s-wait { cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }
.wick-hint { fill: rgba(255,214,120,.18); stroke: #ffd66b; stroke-width: 2; transform-box: fill-box; transform-origin: center; animation: wickHint 1.3s ease-in-out infinite; }
.light-stage.s-wait:focus-visible .wick-hint { stroke: #fff; }
@keyframes wickHint { 0%, 100% { transform: scale(.7); opacity: .95; } 50% { transform: scale(1.35); opacity: .35; } }
.light-stage.s-lit .glow, .light-stage.s-lit .paper-lit { opacity: 1; }
.light-stage.is-candle.s-release .light-art { transform: translateY(45%) scale(.3); opacity: 0; }
.light-stage.is-lantern.s-release .light-art { transform: translateY(-120%) scale(.4); opacity: 0; }

/* ---------- reader ---------- */

.reader-card {
  position: relative; width: min(520px, 100%);
  padding: 34px 32px 26px; border-radius: 20px; text-align: center;
  background: linear-gradient(#f9eccb, #efd8a3);
  color: var(--parchment-ink);
  border-top: 10px solid var(--c1, #d8434b);
  box-shadow: 0 0 0 1px rgba(255,255,255,.5), 0 20px 60px rgba(0,0,0,.6), 0 0 80px rgba(224,0,0,.25);
  animation: rise .45s cubic-bezier(.3,1.3,.5,1);
}
@keyframes rise { from { transform: translateY(30px) scale(.95); opacity: 0; } }
.reader-card[data-color="ruby"] { --c1: #d8434b; }
.reader-card[data-color="saffron"] { --c1: #f0973a; }
.reader-card[data-color="jade"] { --c1: #2bb37a; }
.reader-card[data-color="sapphire"] { --c1: #3d78d8; }
.reader-card[data-color="lotus"] { --c1: #ea70ab; }
.reader-card[data-color="amethyst"] { --c1: #9a63d0; }
.reader-card .close { color: var(--parchment-ink); background: rgba(255,255,255,.4); border-color: rgba(122,63,12,.25); }
/* the drawn joke icon sits in a line of text like an emoji would */
.kind-svg { width: 1.25em; height: 1.25em; vertical-align: -0.28em; display: inline-block; }
.reader-kind { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #b00000; }
.reader-to { font-family: var(--serif); font-size: 22px; font-weight: 700; margin: 10px 0 0; }
.reader-text {
  font-family: var(--serif); font-size: clamp(20px, 3.2vw, 24px); line-height: 1.45;
  margin: 16px 0; white-space: pre-wrap; overflow-wrap: anywhere;
}
.reader-from { font-family: var(--serif); font-style: italic; font-size: 20px; margin: 0; }
.reader-meta { font-size: 12px; opacity: .65; margin: 14px 0 0; }
.reactions { display: flex; justify-content: center; gap: 8px; margin: 18px 0 0; }
.react {
  display: inline-flex; align-items: center; gap: 7px; min-width: 66px; justify-content: center;
  padding: 5px 13px 5px 6px; border-radius: 99px; cursor: pointer; font: inherit; color: inherit;
  background: rgba(255,255,255,.55); border: 1px solid rgba(90,50,10,.16);
  box-shadow: 0 1px 2px rgba(90,50,10,.12);
  transition: background .2s, border-color .2s, box-shadow .2s;
}
.react-icon {
  width: 26px; height: 26px; flex: none; display: block;
  filter: drop-shadow(0 1px 1.5px rgba(90,40,0,.3));
  transition: transform .18s cubic-bezier(.3,1.6,.5,1);
}
/* thank you uses the device's own 🙏 emoji, sized to match the drawn badges */
.react-emoji {
  display: grid; place-items: center; font-size: 22px; line-height: 1; filter: none;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  /* keep the emoji on its own layer so growing it doesn't make the browser
     redraw the glyph mid-animation (that made it jump and blur on hover) */
  will-change: transform; backface-visibility: hidden; transform: translateZ(0);
  transition: transform .2s ease-out;
}
.react b { font-size: 14px; font-weight: 700; min-width: 1ch; }
.react:hover { background: rgba(255,255,255,.8); }
.react:hover .react-icon { transform: scale(1.15) translateY(-1px); }
/* the 🙏 emoji grows a little less and without the lift, which made it wobble */
.react:hover .react-emoji { transform: translateZ(0) scale(1.12); }
/* the reaction you gave: tinted in its own colour */
.react[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--rx) inset, 0 1px 2px rgba(90,50,10,.12); border-color: transparent; color: var(--rx); }
.react[data-reaction="pray"] { --rx: #d9730d; }
.react[data-reaction="heart"] { --rx: #e0245e; }
.react[data-reaction="laugh"] { --rx: #b77f00; }
/* a quick bounce when you react */
.react.pop .react-icon { animation: reactPop .45s cubic-bezier(.3,1.6,.5,1); }
@keyframes reactPop { 0% { transform: scale(1); } 35% { transform: scale(1.45) translateY(-4px) rotate(-8deg); } 70% { transform: scale(.92); } 100% { transform: scale(1); } }
.react:focus-visible { outline: 2px solid var(--sf-red); outline-offset: 2px; }

/* ---------- feed ---------- */

.feed {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 15;
  width: min(380px, 100vw);
  display: flex; flex-direction: column;
  background: rgba(8,11,32,.92); border-left: 1px solid var(--panel-line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: slideIn .35s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } }
.feed-head { position: relative; padding: 22px 20px 6px; }
.feed-head h2 { font-family: var(--serif); font-weight: 700; margin: 0; font-size: 28px; }
.feed-head .close { top: 18px; }
.feed-note { margin: 2px 20px 4px; font-size: 13px; color: var(--ink-dim); line-height: 1.4; }
.feed-search {
  display: flex; align-items: center; gap: 8px; margin: 8px 20px 0; padding: 0 12px;
  border-radius: 99px; background: rgba(255,255,255,.07); border: 1px solid var(--panel-line);
  color: var(--ink-dim); transition: border-color .2s, background .2s;
}
.feed-search:focus-within { border-color: var(--accent); background: rgba(255,255,255,.1); }
.feed-search svg { width: 17px; height: 17px; flex: none; }
.feed-search input {
  flex: 1; min-width: 0; padding: 10px 0; border: 0; outline: none; background: transparent;
  color: var(--ink); font: inherit; font-size: 15px;
}
.feed-search input::placeholder { color: var(--ink-dim); }
.feed-filters { display: flex; gap: 6px; padding: 8px 20px 12px; flex-wrap: wrap; }
.feed-filters button {
  cursor: pointer; padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 700;
  background: transparent; border: 1px solid var(--panel-line);
}
.feed-filters button.active { background: var(--sf-red); border-color: var(--sf-red); }
.feed-list { list-style: none; margin: 0; padding: 0 14px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.feed-item {
  width: 100%; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 14px; border-radius: 12px;
  background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.08);
  border-left: 4px solid var(--c1, var(--accent));
}
.feed-item:hover { background: rgba(255,255,255,.08); }
.feed-item[data-color="ruby"] { --c1: #d8434b; }
.feed-item[data-color="saffron"] { --c1: #f0973a; }
.feed-item[data-color="jade"] { --c1: #2bb37a; }
.feed-item[data-color="sapphire"] { --c1: #3d78d8; }
.feed-item[data-color="lotus"] { --c1: #ea70ab; }
.feed-item[data-color="amethyst"] { --c1: #9a63d0; }
.feed-item-head { font-size: 12px; font-weight: 800; color: var(--accent); }
.feed-item-text {
  font-family: var(--serif); font-size: 17px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.feed-item-meta { font-size: 12px; color: var(--ink-dim); }
.feed-empty { padding: 0 20px; color: var(--ink-dim); }
.feed-more { padding: 10px 0 4px; text-align: center; font-size: 13px; color: var(--ink-dim); }

/* ---------- water flow ---------- */

.flow-panel {
  position: fixed; z-index: 16;
  top: calc(max(14px, env(safe-area-inset-top)) + 46px); right: 20px;
  width: min(300px, calc(100vw - 24px));
  padding: 16px 18px 14px; border-radius: 16px;
  background: rgba(10,8,16,.94); border: 1px solid var(--panel-line);
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: rise .3s ease;
}
.flow-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.flow-head h2 { margin: 0; font-size: 20px; font-weight: 700; font-variant-caps: small-caps; }
.flow-head output { font-weight: 700; color: var(--accent); }
.flow-panel input { width: 100%; accent-color: var(--sf-red); }
.flow-panel input:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.building-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.building-choice {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 6px 8px;
  border-radius: 12px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; color: inherit;
  background: rgba(255,255,255,.05); border: 1px solid var(--panel-line);
  transition: border-color .2s, background .2s;
}
.building-choice:hover { background: rgba(255,255,255,.09); }
.building-choice[aria-checked="true"] { border-color: var(--sf-red); background: rgba(224,0,0,.12); }
.building-choice:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.building-thumb { display: block; width: 100%; aspect-ratio: 120 / 54; border-radius: 8px; overflow: hidden; }
.building-thumb canvas { display: block; width: 100%; height: 100%; }
.flow-section + .flow-section { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--panel-line); }
.texts-panel { width: min(380px, calc(100vw - 24px)); }
.texts-list { margin-top: 12px; }
.texts-list-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; font-weight: 700; color: var(--ink-dim); }
.texts-add {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; flex: none;
  display: grid; place-items: center; font-size: 20px; line-height: 1; font-weight: 700;
  background: var(--sf-red); border: 0; color: #fff;
}
.texts-add:disabled { opacity: .35; cursor: default; }
.texts-add:focus-visible, .texts-remove:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.texts-items { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.texts-item { display: flex; align-items: center; gap: 6px; }
.texts-item input {
  flex: 1; min-width: 0; font: inherit; font-size: 15px; color: var(--ink); font-family: var(--brand-font);
  padding: 8px 10px; border-radius: 10px;
  background: rgba(255,255,255,.06); border: 1px solid var(--panel-line);
}
.texts-item input:focus { outline: none; border-color: var(--sf-red); }
.texts-remove {
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; flex: none;
  display: grid; place-items: center; font-size: 18px; line-height: 1;
  background: transparent; border: 1px solid var(--panel-line); color: var(--ink-dim);
}
.texts-remove:hover { color: #fff; border-color: var(--sf-red); }
.texts-empty { font-size: 13px; color: var(--ink-dim); padding: 4px 2px; }
.texts-field { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 13px; font-weight: 700; color: var(--ink-dim); }
.texts-field textarea {
  font: inherit; font-weight: 400; font-size: 15px; color: var(--ink); line-height: 1.6;
  font-family: var(--brand-font);
  padding: 8px 10px; border-radius: 10px; resize: vertical;
  background: rgba(255,255,255,.06); border: 1px solid var(--panel-line);
}
.texts-field textarea:focus { outline: none; border-color: var(--sf-red); }
.texts-hint { margin: 10px 0 0; font-size: 12px; color: var(--ink-dim); line-height: 1.45; }
.texts-actions { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 12px; }
.texts-status { font-size: 13px; color: var(--ink-dim); }
.flow-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink-dim); margin-top: 4px; }

/* ---------- music ---------- */

.music-panel {
  position: fixed; z-index: 16;
  top: calc(max(14px, env(safe-area-inset-top)) + 46px); right: 20px;
  width: min(360px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 90px));
  display: flex; flex-direction: column;
  background: rgba(10,8,16,.94); border: 1px solid var(--panel-line); border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  animation: rise .3s ease;
}
.music-head { position: relative; padding: 16px 18px 4px; }
.music-head h2 { margin: 0; font-size: 22px; font-weight: 700; font-variant-caps: small-caps; }
.music-head .close { top: 10px; right: 10px; width: 34px; height: 34px; }
.now {
  margin: 8px 14px 12px; padding: 14px; border-radius: 14px;
  background: linear-gradient(160deg, rgba(224,0,0,.32), rgba(138,0,0,.18));
  border: 1px solid rgba(255,42,26,.35);
}
.now-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.now-text small { color: var(--ink-dim); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.now-text b { font-size: 17px; line-height: 1.3; overflow-wrap: anywhere; }
.now-controls { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 12px 0 8px; }
.m-btn {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  display: grid; place-items: center;
  background: rgba(255,255,255,.08); border: 1px solid var(--panel-line);
}
.m-btn svg { width: 20px; height: 20px; }
.m-btn:disabled { opacity: .35; cursor: default; }
.m-play { width: 54px; height: 54px; background: var(--sf-red); border-color: var(--sf-red); box-shadow: 0 6px 20px rgba(224,0,0,.45); }
.m-play svg { width: 26px; height: 26px; }
.m-play .i-pause, .m-play.playing .i-play { display: none; }
.m-play.playing .i-pause { display: block; }
.m-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.m-volume { display: flex; align-items: center; gap: 10px; color: var(--ink-dim); }
.m-volume svg { width: 20px; height: 20px; flex: none; }
.m-volume input { flex: 1; accent-color: var(--sf-red); }
.m-switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 2px 18px 14px; font-size: 14px; font-weight: 700; cursor: pointer; }
.m-switch input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  width: 42px; height: 24px; border-radius: 99px; position: relative;
  background: rgba(255,255,255,.18); transition: background .2s;
}
.m-switch input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform .2s;
}
.m-switch input:checked { background: var(--sf-red); }
.m-switch input:checked::after { transform: translateX(18px); }
.m-switch input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.m-label { margin: 0 18px 6px; font-size: 12px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: .1em; }
.m-playlists { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 10px; }
.m-playlists button {
  cursor: pointer; padding: 6px 12px; border-radius: 99px; font-size: 13px; font-weight: 700;
  background: transparent; border: 1px solid var(--panel-line);
}
.m-playlists button[aria-pressed="true"] { background: var(--sf-red); border-color: var(--sf-red); }
.m-tracks { list-style: none; margin: 0; padding: 0 10px 12px; overflow-y: auto; flex: 1; }
.m-track {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; cursor: pointer;
  padding: 9px 10px; border-radius: 10px; background: none; border: 0;
}
.m-track:hover { background: rgba(255,255,255,.07); }
.m-track[aria-current="true"] { background: rgba(224,0,0,.2); }
.m-track .num { width: 22px; flex: none; text-align: center; color: var(--ink-dim); font-size: 13px; }
.m-track .title { flex: 1; min-width: 0; }
.bars { display: inline-flex; gap: 2px; align-items: flex-end; height: 14px; }
.bars i { width: 3px; background: var(--accent); animation: bar .9s ease-in-out infinite; }
.bars i:nth-child(2) { animation-delay: -.3s; }
.bars i:nth-child(3) { animation-delay: -.6s; }
@keyframes bar { 0%, 100% { height: 4px; } 50% { height: 14px; } }
.m-error { margin: 0 18px 12px; color: #ffb4a8; font-size: 13px; }
.m-error:empty { display: none; }

/* ---------- small screens ---------- */

@media (max-width: 760px) {
  .topbar { grid-template-columns: 1fr auto; padding: max(10px, env(safe-area-inset-top)) 12px 0; gap: 8px; }
  .brand { gap: 5px; }
  .brand-lockup { gap: 8px; }
  .brand-badge { width: 38px; height: 38px; }
  .brand-wordmark { height: 28px; }
  .brand-en { font-size: 16px; }
  .brand-my { font-size: 12px; margin-top: 2px; }
  .credit { font-size: 10px; }
  .top-actions { grid-column: 2; grid-row: 1; }
  .pill-label { display: none; }
  /* icon-only on phones: every button the same round size, icons a bit bigger */
  .pill-btn { width: 42px; height: 42px; padding: 0; justify-content: center; }
  .pill-svg { width: 22px; height: 22px; }
  .toast { top: 150px; }
  .intro-logo { gap: 10px; margin-bottom: 10px; }
  .intro-crest { width: 92px; }
  .intro-wordmark { width: 190px; }
  .intro h1 { font-size: 30px; margin-bottom: 10px; }
  .intro-body p { font-size: 15px; line-height: 1.85; }
  .flow-panel { right: 12px; top: calc(max(10px, env(safe-area-inset-top)) + 46px); }
  .music-panel { right: 12px; top: calc(max(10px, env(safe-area-inset-top)) + 46px); }
  .cta { font-size: 16px; padding: 14px 24px; }
  .reader-card { padding: 30px 20px 22px; }
  .scroll-inner { padding: 18px 18px 22px; }
}
/* thin phones: a touch smaller buttons so all four stay on one row, icons kept big */
@media (max-width: 400px) {
  .top-actions { gap: 5px; }
  .pill-btn { width: 38px; height: 38px; }
  .pill-svg { width: 21px; height: 21px; }
}
@media (max-width: 340px) {
  .top-actions { gap: 4px; }
  .pill-btn { width: 34px; height: 34px; }
  .pill-svg { width: 20px; height: 20px; }
  .brand-badge { width: 34px; height: 34px; }
  .brand-wordmark { height: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01s !important; animation-iteration-count: 1 !important; }
}
