:root {
  --violet: #5b22d6;
  --violet-d: #3f14a8;
  --magenta: #e2409c;
  --ink: #2a1f45;
  --ink-2: #6b5f86;
  --line: rgba(91, 34, 214, 0.14);
  --glass: rgba(255, 255, 255, 0.42);
  --sans: -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; color: var(--ink); font-family: var(--sans); }
body { overflow: hidden; overscroll-behavior: none; background: #fbf1e4 url(/bg-m.svg) center / cover no-repeat fixed; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
.hidden { display: none !important; }

/* ---------- 标题（参考主视觉：深紫粗体 + 浅紫投影；副标渐变斜体） ---------- */
.subtitle {
  display: inline-block; font-weight: 800; font-style: italic; letter-spacing: 0.02em; font-size: 12.5px; line-height: 1.4;
  background: linear-gradient(90deg, #ff6fa8, #b04cf0 55%, #7b5cff); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.title {
  margin: 4px 0 0; font-size: clamp(24px, 7.8vw, 40px); line-height: 1.2; font-weight: 900; letter-spacing: 0.04em; color: var(--violet); white-space: nowrap;
  font-style: italic; -webkit-text-stroke: 0.8px var(--violet);
  text-shadow: 0 2px 0 #fff, 0 4px 0 #cdb8ff, 0 10px 22px rgba(91, 34, 214, 0.35);
}

/* ---------- 首页 ---------- */
.home { display: flex; flex-direction: column; height: 100%; }
.top { padding: 22px 20px 8px; text-align: center; }
.stat { font-size: 13px; color: var(--ink-2); min-height: 18px; margin-top: 8px; }
.stat b { color: var(--violet); font-variant-numeric: tabular-nums; }
.stat .live { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #3cb371; margin-right: 5px; vertical-align: 2px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }
.stage { position: relative; flex: 1; min-height: 0; margin: 6px 12px 0; border-radius: 20px; overflow: hidden;
  background: var(--glass); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7), 0 10px 30px rgba(91, 34, 214, 0.12);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.stage canvas { width: 100%; height: 100%; display: block; }
.stage .hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-size: 11px; color: var(--ink-2); pointer-events: none; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8); }
.dock { padding: 14px 20px calc(14px + var(--safe-b)); text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.mine-link { font-size: 13px; color: var(--violet); padding: 4px 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 52px; padding: 0 30px; border-radius: 26px; font-size: 17px; font-weight: 700; letter-spacing: 0.1em; transition: transform 0.12s, opacity 0.2s; }
.btn:active { transform: scale(0.97); }
.btn.primary { color: #fff; min-width: 230px; background: linear-gradient(90deg, #7b2ff7, #e2409c); box-shadow: 0 8px 22px rgba(123, 47, 247, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.btn.ghost { background: rgba(255, 255, 255, 0.6); box-shadow: inset 0 0 0 1.5px var(--violet); color: var(--violet); }
.btn.small { height: 42px; font-size: 15px; padding: 0 18px; min-width: 0; }
.btn[disabled] { opacity: 0.4; pointer-events: none; }

/* ---------- 全屏层 ---------- */
.layer { position: fixed; inset: 0; display: flex; flex-direction: column; z-index: 10; animation: up 0.28s ease-out; background: #fbf1e4 url(/bg-m.svg) center / cover no-repeat; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.bar { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.bar .x { width: 36px; height: 36px; font-size: 22px; color: var(--ink-2); }
.bar .ttl { font-size: 14px; color: var(--ink-2); text-align: center; flex: 1; }
.bar .ttl b { color: var(--violet); }
.scroll-y { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.foot { padding: 12px 20px calc(14px + var(--safe-b)); display: flex; gap: 12px; justify-content: center; }

.wavy { -webkit-mask: url(/wavy.svg) center / 100% 100% no-repeat; mask: url(/wavy.svg) center / 100% 100% no-repeat; }
.lift { filter: drop-shadow(0 10px 18px rgba(75, 22, 201, 0.28)); }

/* 选色 */
.stitch-wrap { display: flex; justify-content: center; padding: 6px 0 4px; }
.stitch-wrap img { display: block; width: min(42vw, 20vh, 200px); aspect-ratio: 1; }
.slots { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 12px 16px 4px; }
.slot { flex: 1; max-width: 160px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 14px; background: var(--glass); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8); text-align: left; }
.slot.on { box-shadow: inset 0 0 0 2px var(--violet), 0 6px 16px rgba(91, 34, 214, 0.18); background: rgba(255, 255, 255, 0.75); }
.slot .y { font-weight: 800; font-style: italic; color: var(--violet); font-size: 15px; }
.slot .n { font-size: 12px; color: var(--ink-2); }
.slot .ball { width: 26px; height: 26px; flex: none; }
.slots .arrow { color: var(--ink-2); font-size: 16px; }
.pick-hint { text-align: center; font-size: 15px; font-weight: 700; color: var(--ink); margin: 12px 0 2px; }
.pick-hint small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-2); margin-top: 3px; }
/* 调色盘：色相绕一圈，越往外越浓；滑杆调深浅 */
.wheel-wrap { position: relative; width: min(74vw, 40vh, 310px); aspect-ratio: 1; margin: 10px auto 6px; touch-action: none; }
.wheel-wrap canvas { width: 100%; height: 100%; display: block; }
.bar .move { font-size: 13px; color: var(--violet); padding: 6px 4px; white-space: nowrap; }
/* 选位置 */
.stage.placing { box-shadow: inset 0 0 0 2px var(--violet), 0 10px 30px rgba(91, 34, 214, 0.25); }
.ball { width: 40px; height: 40px; border-radius: 50%; transition: transform 0.15s;
  background: radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 45%),
    repeating-linear-gradient(-55deg, rgba(255, 255, 255, 0.16) 0 2px, rgba(255, 255, 255, 0) 2px 5px),
    repeating-linear-gradient(35deg, rgba(58, 46, 72, 0.06) 0 1px, rgba(0, 0, 0, 0) 1px 4px), var(--c);
  box-shadow: inset -3px -4px 8px rgba(58, 46, 72, 0.18), 0 0 0 1.5px rgba(255, 255, 255, 0.35), 0 2px 8px rgba(58, 46, 72, 0.14); filter: blur(0.15px); }

/* 寄语表单 */
.form { padding: 6px 22px 10px; }
.form .preview { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.form .preview img { width: 86px; height: 86px; }
.form .preview p { margin: 0; font-size: 13px; color: var(--ink-2); line-height: 1.7; }
.form .preview p b { color: var(--violet); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.field label small { float: right; }
.field input, .field textarea { width: 100%; border: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.72); box-shadow: inset 0 0 0 1px var(--line); padding: 12px 14px; font: inherit; font-size: 16px; color: var(--ink); outline: none; }
.field textarea { height: 92px; resize: none; line-height: 1.6; }
.field input:focus, .field textarea:focus { box-shadow: inset 0 0 0 1.5px var(--violet); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips button { font-size: 12px; padding: 5px 10px; border-radius: 14px; background: rgba(255, 255, 255, 0.6); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--ink-2); line-height: 1.5; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--violet); flex: none; }

/* 完成：一屏放下，不滚动 */
.done { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; padding: 0 18px; text-align: center; }
.done h2 { flex: none; font-size: 19px; font-weight: 900; font-style: italic; color: var(--violet); margin: 0 0 8px; letter-spacing: 0.06em; }
.done h2 .pill { font-style: normal; font-weight: 600; letter-spacing: 0; vertical-align: 3px; margin-left: 4px; }
.card-box { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; }
.card-box img.card { display: block; max-width: 100%; max-height: 100%; width: auto; height: auto; border-radius: 12px;
  box-shadow: 0 14px 34px rgba(75, 22, 201, 0.25); -webkit-touch-callout: default; user-select: auto; }
.done .save { flex: none; font-size: 12px; color: var(--magenta); margin: 8px 0 0; }
.pill { display: inline-block; font-size: 12px; padding: 3px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.75); color: var(--violet); font-variant-numeric: tabular-nums; }
.pill.ok { background: rgba(60, 179, 113, 0.16); color: #23794a; }
#doneLayer .foot .btn { flex: 1; max-width: 190px; }
.tabs { display: flex; justify-content: center; gap: 6px; }
.tabs button { font-size: 13px; padding: 4px 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.55); color: var(--ink-2); }
.tabs button.on { background: var(--violet); color: #fff; }

/* 祝福语词云 */
.cloud { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cloud-word { position: absolute; white-space: nowrap; font-weight: 700; padding: 0.25em 0.7em; border-radius: 1.2em;
  background: rgba(255, 255, 255, 0.72); box-shadow: 0 0.2em 0.8em rgba(75, 22, 201, 0.15), inset 0 0 0 1px var(--glow, #fff);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); animation: drift linear forwards; }
@keyframes drift {
  0% { opacity: 0; transform: translateY(0.8em) scale(0.92); }
  12% { opacity: 1; transform: translateY(0) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-2.2em) scale(1); }
}

/* 格子详情 */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(30, 20, 48, 0.4); display: flex; align-items: flex-end; animation: fade 0.2s; }
@keyframes fade { from { opacity: 0; } }
.modal .panel { width: 100%; background: rgba(255, 251, 244, 0.97); border-radius: 20px 20px 0 0; padding: 18px 20px calc(20px + var(--safe-b)); animation: up 0.25s ease-out; }
.detail { display: flex; gap: 16px; }
.detail img { width: 128px; height: 128px; flex: none; }
.detail .meta { flex: 1; min-width: 0; }
.detail .pos { font-size: 12px; color: var(--ink-2); }
.detail .colors { display: flex; gap: 10px; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.detail .colors span { display: inline-flex; align-items: center; gap: 4px; }
.detail .colors .ball { width: 14px; height: 14px; box-shadow: none; }
.detail .mood { font-size: 16px; font-weight: 600; line-height: 1.55; margin: 8px 0; word-break: break-all; color: var(--ink); }
.detail .who { font-size: 13px; color: var(--ink-2); }
.like { margin-top: 10px; height: 34px; padding: 0 14px; border-radius: 17px; box-shadow: inset 0 0 0 1px var(--line); font-size: 14px; background: #fff; }
.like.on { color: var(--magenta); box-shadow: inset 0 0 0 1px var(--magenta); }

.toast { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); background: rgba(42, 31, 69, 0.88); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 50; max-width: 80vw; text-align: center; animation: fade 0.2s; }
