/* v2.css - 静心明物 (tools/lanterns/DESIGN.md). The hall by night, in 3D, fills the screen (stage.js's canvas; the first
   page's colours, faces and easing, ../lanterns.css); over it the names (a second canvas), the name and the
   night's numbers (top left), and at the foot the four things to do, or the qin's five strings, or a wish to pick and a
   lantern to light. Only transform and opacity move. */
:root {
  --ease: cubic-bezier(.22, 1, .36, 1);
  --night: #0d0c1f; --ink: #f6ecd6; --gold: #ffd98e; --cream: #fff1d2;
  --soft: rgba(246, 236, 214, .72); --faint: rgba(246, 236, 214, .5);
  --panel: rgba(13, 12, 31, .72); --line: rgba(255, 217, 142, .28); --edge: rgba(255, 255, 255, .08);
  --shade: 0 1px 12px rgba(13, 12, 31, .9), 0 0 2px rgba(13, 12, 31, .9);
  --font-ui: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  --font-title: "STKaiti", "KaiTi", "Kaiti SC", "楷体", "Noto Serif CJK SC", serif;
  --bar: calc(88px + env(safe-area-inset-bottom));
}
:root:lang(zh-Hant) { --font-ui: "PingFang TC", "Microsoft JhengHei", "Noto Sans CJK TC", system-ui, sans-serif; --font-title: "Kaiti TC", "BiauKaiTC", "BiauKai", "DFKai-SB", "STKaiti", serif; }
:root:lang(en) { --font-ui: system-ui, -apple-system, "Segoe UI", "PingFang SC", sans-serif; --font-title: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "STKaiti", serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: var(--night); color: var(--ink); font: 16px/24px var(--font-ui);
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; -webkit-user-select: none; user-select: none; }
button, a { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }

/* ---------------------------------------------------------------- the hall (stage.js), its edges in shadow, the names over it */
.scene { position: fixed; inset: 0; overflow: hidden; }
.scene::after { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse 80% 75% at 50% 45%, rgba(13, 12, 31, 0) 55%, rgba(13, 12, 31, .5) 100%), linear-gradient(rgba(13, 12, 31, .4), rgba(13, 12, 31, 0) 24%); }
.stage { position: absolute; inset: 0; z-index: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.words { position: absolute; inset: 0; z-index: 2; width: 100%; height: 100%; pointer-events: none; }

/* ---------------------------------------------------------------- the bar */
.top { position: fixed; top: 0; left: 0; right: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 8px; pointer-events: none;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left)); transition: opacity 800ms var(--ease); }
.top > * { pointer-events: auto; }
.home { padding: 8px 12px; border-radius: 9999px; font-size: 14px; line-height: 20px; font-weight: 600; color: var(--soft); text-decoration: none; text-shadow: var(--shade); transition: color 300ms var(--ease); }
.home:hover { color: var(--ink); }
.tools { display: flex; align-items: center; gap: 8px; }
.langs { display: flex; padding: 4px; border-radius: 9999px; border: 1px solid var(--edge); background: rgba(13, 12, 31, .5); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.langs button { padding: 4px 12px; border: 0; border-radius: 9999px; background: none; font-size: 14px; line-height: 20px; color: var(--soft); transition: color 300ms var(--ease); }
.langs button:hover { color: var(--ink); }
.langs button[aria-pressed="true"] { background: rgba(255, 217, 142, .16); color: var(--gold); }
.sound { display: grid; place-items: center; width: 40px; height: 40px; padding: 0; border-radius: 9999px; border: 1px solid var(--edge); background: rgba(13, 12, 31, .5); color: var(--soft);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); transition: transform 300ms var(--ease), color 300ms var(--ease); }
.sound:hover { color: var(--ink); }
.sound:active { transform: scale(.96); }
.sound .icon { width: 20px; height: 20px; }
.sound .off, .sound.muted .on { display: none; }
.sound.muted .off { display: block; }

/* ---------------------------------------------------------------- the name and the night's numbers */
.ui { position: fixed; inset: 0; z-index: 2; pointer-events: none; }
.info { position: absolute; top: 64px; left: max(20px, env(safe-area-inset-left)); max-width: min(360px, calc(100% - 40px)); text-shadow: var(--shade); transition: opacity 800ms var(--ease); }
.info h1 { margin: 0; font: 700 30px/36px var(--font-title); letter-spacing: 6px; color: #fff4d6; text-shadow: 0 0 24px rgba(255, 190, 90, .45), var(--shade); }
.where { min-height: 20px; margin: 8px 0 0; font-size: 14px; line-height: 20px; color: var(--soft); }
.warm { min-height: 20px; margin: 4px 0 0; font-size: 14px; line-height: 20px; color: var(--cream); }
.mine { margin: 4px 0 0; font-size: 12px; line-height: 16px; color: var(--gold); }
.note { margin: 12px 0 0; font-size: 14px; line-height: 20px; color: var(--gold); text-wrap: pretty; animation: fade 500ms var(--ease) both; }
:lang(en) .info h1 { letter-spacing: 1px; font-size: 26px; line-height: 32px; }

.hint { position: absolute; left: 50%; bottom: calc(var(--bar) + 12px); width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 4px 12px; border-radius: 9999px; background: rgba(13, 12, 31, .45); text-wrap: balance;
  font-size: 14px; line-height: 20px; color: var(--soft); text-align: center; transform: translateX(-50%); opacity: 0; transition: opacity 500ms var(--ease); }
.hint.on { opacity: 1; }
.ui[data-mode="qin"] .hint, .ui[data-mode="qin"] .toast { bottom: calc(124px + env(safe-area-inset-bottom)); }
.ui[data-mode="hold"] .hint, .ui[data-mode="hold"] .toast { bottom: calc(116px + env(safe-area-inset-bottom)); }

/* ---------------------------------------------------------------- the four things to do */
.acts { position: absolute; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); display: flex; gap: 8px; padding: 8px; border-radius: 20px; border: 1px solid var(--edge); background: rgba(13, 12, 31, .55);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); transform: translateX(-50%); pointer-events: auto; transition: opacity 800ms var(--ease); }
.act { position: relative; display: grid; justify-items: center; gap: 2px; width: 72px; padding: 8px 4px 4px; border: 0; border-radius: 12px; background: none; color: var(--soft); font-size: 12px; line-height: 16px; letter-spacing: 2px;
  touch-action: manipulation; transition: transform 300ms var(--ease), color 300ms var(--ease), background-color 300ms var(--ease); }
.act svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.act:hover { color: var(--ink); background: rgba(255, 255, 255, .05); }
.act:active { transform: scale(.94); }
.act[data-act="spark"] { color: var(--gold); }
.act[data-act="spark"]::before { content: ""; position: absolute; left: 50%; top: 20px; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 9999px; pointer-events: none;
  background: radial-gradient(circle, rgba(255, 217, 142, .32), rgba(255, 217, 142, 0) 70%); transform: scale(calc(.7 + .5 * var(--breath, 0))); opacity: calc(.4 + .6 * var(--breath, 0)); }
.act .stand, .act.sitting .sit { display: none; }
.act.sitting .stand { display: block; }
:lang(en) .act { letter-spacing: 0; width: 76px; }

/* ---------------------------------------------------------------- the qin */
.qin-keys { position: absolute; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(440px, calc(100% - 24px)); transform: translateX(-50%); pointer-events: auto; animation: rise 500ms var(--ease) both; }
.keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.key { position: relative; height: 60px; padding: 0 0 6px; border: 1px solid var(--line); border-radius: 12px; background: rgba(13, 12, 31, .6); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  display: flex; align-items: flex-end; justify-content: center; font: 18px/24px var(--font-title); color: var(--cream); touch-action: none; transition: transform 200ms var(--ease), background-color 200ms var(--ease); }
.key::before { content: ""; position: absolute; left: 50%; top: 6px; bottom: 32px; width: 1px; background: linear-gradient(rgba(255, 217, 142, .2), rgba(255, 217, 142, .8), rgba(255, 217, 142, .2)); }
.key.on { transform: translateY(1px) scale(.97); background: rgba(255, 217, 142, .16); }
.key.on::before { animation: string 400ms var(--ease); }
.qin-row { display: flex; justify-content: space-between; }
.listen, .done { padding: 4px 12px; border-radius: 9999px; border: 1px solid var(--edge); background: rgba(13, 12, 31, .55); font-size: 14px; line-height: 20px; color: var(--soft); transition: color 300ms var(--ease); }
.listen:hover, .done:hover { color: var(--ink); }
.done { color: var(--gold); border-color: var(--line); }

/* ---------------------------------------------------------------- a wish to pick, a lantern to light (as the first page) */
.pane { position: absolute; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); width: min(520px, calc(100% - 24px)); transform: translateX(-50%); text-align: center; pointer-events: auto; animation: rise 500ms var(--ease) both; }
.pick { padding: 16px; border-radius: 16px; border: 1px solid var(--edge); background: var(--panel); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
.ask { margin: 0 0 12px; font-size: 16px; line-height: 24px; font-weight: 600; letter-spacing: 2px; color: var(--gold); }
.wishes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 0; list-style: none; }
.wishes button { width: 100%; min-height: 48px; padding: 12px 8px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); font: 16px/24px var(--font-title); color: var(--cream);
  transition: transform 300ms var(--ease), border-color 300ms var(--ease); }
.wishes button:hover { border-color: rgba(255, 217, 142, .7); transform: translateY(-1px); }
.wishes button:active { transform: scale(.98); }
.back { margin-top: 12px; padding: 8px 12px; border: 0; background: none; font-size: 14px; line-height: 20px; color: var(--soft); transition: color 300ms var(--ease); }
.back:hover { color: var(--ink); }
.hold { display: flex; align-items: center; gap: 12px; width: min(420px, calc(100% - 24px)); padding: 12px; border-radius: 20px; border: 1px solid var(--edge); background: var(--panel);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); text-align: left; }
.hold-words { min-width: 0; }
.wish-now { margin: 0; font: 700 18px/28px var(--font-title); letter-spacing: 2px; color: var(--gold); }
.holder { flex: none; position: relative; width: 72px; height: 72px; padding: 0; border: 0; border-radius: 9999px; background: rgba(13, 12, 31, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  touch-action: none; -webkit-touch-callout: none; transition: transform 500ms var(--ease); }
.holder:active { transform: scale(.96); }
.ring { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .track { stroke: rgba(255, 255, 255, .14); }
.ring .fill { stroke: var(--gold); stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100; }
.flame { position: absolute; left: 50%; top: 50%; width: 20px; height: 28px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; transform: translate(-50%, -50%); opacity: .45;
  background: radial-gradient(circle at 50% 70%, #fffbe6, #ffd27a 45%, rgba(255, 160, 80, 0) 75%); transition: opacity 300ms var(--ease), transform 500ms var(--ease); }
.holder.lit .flame { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
.hold-say { margin: 0; font-size: 14px; line-height: 20px; color: var(--soft); }
.hold-back { flex: none; margin-top: 0; padding: 8px; }
.toast { position: absolute; left: 50%; bottom: calc(var(--bar) + 48px); width: max-content; max-width: calc(100% - 32px); margin: 0; padding: 8px 12px; border-radius: 9999px; background: var(--panel);
  font-size: 14px; line-height: 20px; text-align: center; transform: translateX(-50%); animation: toast 500ms var(--ease) both; }
.noscript { position: fixed; left: 50%; bottom: 48px; z-index: 6; margin: 0; padding: 8px 16px; border-radius: 9999px; background: var(--panel); transform: translateX(-50%); font-size: 14px; line-height: 20px; }

/* sitting a while: everything but the cloud steps back, till a touch */
body.calm .info, body.calm .acts, body.calm .top, body.calm .hint { opacity: .12; }

@keyframes rise { from { opacity: 0; transform: translate(-50%, 16px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 8px); } }
@keyframes string { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(1.5px); } 50% { transform: translateX(-1px); } 75% { transform: translateX(.5px); } }

@media (min-width: 900px) {
  .info { top: 88px; left: 48px; }
  .info h1 { font-size: 40px; line-height: 1; letter-spacing: 10px; }
}
@media (max-width: 640px) {
  .info h1 { font-size: 24px; line-height: 32px; letter-spacing: 4px; }
  .where, .warm { font-size: 13px; line-height: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .pane, .qin-keys, .note { animation-name: fade; }
  .toast { animation: none; }
  .key.on::before { animation: none; }
  .wishes button:hover { transform: none; }
}
