/* Sky Lanterns: write a wish on a lantern, light it, let it go. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  --ui: #f4e9d8;
  --muted: #a9a3b8;
  --line: rgba(220, 215, 255, 0.14);
  --warm: #ffb45c;
  position: fixed; inset: 0; overflow: hidden;
  background: #0a0d1f; color: var(--ui);
  font-family: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  overscroll-behavior: none; user-select: none; -webkit-user-select: none; touch-action: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; }

#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; z-index: 0; }

.bar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) calc(env(safe-area-inset-right) + 12px) 4px calc(env(safe-area-inset-left) + 10px);
  pointer-events: none;
}
.bar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 7px; font-weight: 800; letter-spacing: 0.05em; font-size: 16px; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6); }
.brand img { display: block; border-radius: 7px; }
.home { display: grid; place-items: center; width: 28px; height: 32px; color: var(--muted); }
.home svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(20, 22, 50, 0.45); display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.icon-btn:hover { background: rgba(60, 60, 110, 0.5); }
.icon-btn svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn svg circle { fill: currentColor; stroke: none; }
.icon-btn.txt { font-size: 12.5px; font-weight: 800; }
.chip {
  height: 32px; padding: 0 13px; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 13.5px;
  border: 1px solid rgba(255, 180, 92, 0.5); background: rgba(255, 150, 60, 0.16); color: #ffd6a8;
}
.rec { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; color: #ffb0a8; padding: 0 6px; }
.rec i { width: 8px; height: 8px; border-radius: 50%; background: #ff4b3e; box-shadow: 0 0 8px #ff4b3e; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

/* Drawing tools under the bar. */
.tools {
  position: fixed; z-index: 3; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top) + 52px);
  display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 999px;
  background: rgba(16, 18, 44, 0.55); border: 1px solid var(--line);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.4s, transform 0.4s;
  max-width: calc(100vw - 16px);
}
.tools.off { opacity: 0; pointer-events: none; transform: translateX(-50%) translateY(-10px); }
.group { display: flex; gap: 5px; }
.sep { width: 1px; height: 20px; background: var(--line); }
.sw {
  width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.sw[aria-checked="true"] { border-color: #fff; box-shadow: 0 0 0 2px rgba(255, 190, 110, 0.6); }
.sw.paper { border-radius: 7px; }
.tool {
  width: 30px; height: 30px; border-radius: 50%; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--ui);
}
.tool:hover { background: rgba(255, 255, 255, 0.08); }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool .dot { display: block; width: var(--d, 8px); height: var(--d, 8px); border-radius: 50%; background: currentColor; }

.hint {
  position: fixed; z-index: 3; left: 12px; right: 12px; margin: 0;
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  min-height: 2.6em; display: flex; align-items: center; justify-content: center; text-align: center;
  font-size: 14px; line-height: 1.3; color: #f3e2c6; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
  pointer-events: none; transition: color 0.3s, opacity 0.4s;
}
.hint.warn { color: #ffbf73; }
.hint.off { opacity: 0; }

/* Result card. */
.result {
  position: fixed; inset: 0; z-index: 5; display: flex; align-items: flex-end; justify-content: center;
  padding: 0 16px calc(env(safe-area-inset-bottom) + 22px); pointer-events: none;
}
.card {
  pointer-events: auto; width: min(100%, 380px); text-align: center; padding: 22px 20px 18px; border-radius: 22px;
  background: rgba(14, 16, 40, 0.72); border: 1px solid rgba(255, 210, 150, 0.2);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  animation: rise 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.1) both;
}
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.r-line { margin: 0 0 4px; font-size: 20px; font-weight: 800; letter-spacing: 0.04em; color: #ffe2b8; }
.r-sub { margin: 0 0 16px; font-size: 13px; color: var(--muted); }
.r-note { margin: 8px 0 10px; min-height: 1.2em; font-size: 12px; color: var(--muted); }
.btn {
  display: flex; width: 100%; align-items: center; justify-content: center; gap: 8px; border: 0; cursor: pointer;
  height: 50px; border-radius: 999px; font-size: 16.5px; font-weight: 800; letter-spacing: 0.04em;
}
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn.primary { background: linear-gradient(180deg, #ffbe6a, #f2872e); color: #3a1a05; box-shadow: 0 8px 24px rgba(255, 140, 40, 0.35); }
.btn.primary:disabled { opacity: 0.55; cursor: progress; }
.btn.ghost { height: 46px; font-size: 15.5px; background: rgba(255, 255, 255, 0.07); border: 1px solid rgba(255, 220, 180, 0.3); color: var(--ui); }
.btn.ghost:hover { background: rgba(255, 255, 255, 0.13); }

.sheet-back {
  position: fixed; inset: 0; z-index: 10; background: rgba(4, 5, 14, 0.6);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center; animation: fade 0.2s ease both;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: relative; width: min(100%, 520px); max-height: 86vh; overflow-y: auto; touch-action: pan-y; user-select: text; -webkit-user-select: text;
  padding: 22px 22px calc(24px + env(safe-area-inset-bottom));
  border-radius: 20px 20px 0 0; background: #15172e; border: 1px solid var(--line); border-bottom: 0; line-height: 1.6; font-size: 14.5px;
}
@media (min-width: 640px) { .sheet-back { align-items: center; } .sheet { border-radius: 20px; border-bottom: 1px solid var(--line); } }
.sheet h2 { margin: 0 0 6px; font-size: 20px; }
.sheet h3 { margin: 16px 0 4px; font-size: 15px; color: #ffd6a0; }
.sheet p, .sheet ol { margin: 0; color: #d9d4e6; }
.sheet ol { padding-left: 20px; }
.sheet .close { position: absolute; right: 14px; top: 14px; }
.sheet a { color: #ffc685; }
.credits { font-size: 13px; }
.stat { margin-top: 14px !important; color: var(--muted) !important; font-size: 13px; }
.farland { display: inline-block; margin-top: 14px; font-weight: 700; text-decoration: none; }

.toast {
  position: fixed; z-index: 12; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 100px);
  padding: 9px 16px; border-radius: 999px; background: rgba(20, 22, 50, 0.9); border: 1px solid var(--line); font-size: 14px;
  animation: fade 0.2s ease both; white-space: nowrap;
}
.share-slot { margin: 0 0 12px; color: var(--ui); }
