/* ============================================================
   PicPK — design system (v2)
   Minimal, warm off-white, hand-drawn mascot, soft cards,
   spring motion. Mobile-first, safe-area aware, PWA standalone.
   ============================================================ */

:root {
  --bg: #f3f4f0;
  --bg-grad: radial-gradient(135% 110% at 50% -8%, #fcfcfa 0%, #f3f4f0 48%, #edefe9 100%);
  --surface: #ffffff;
  --surface-2: #f5f6f2;
  --ink: #191a18;
  --ink-soft: #51544c;
  --muted: #969b8f;
  --line: rgba(20, 22, 18, 0.06);
  --line-2: rgba(20, 22, 18, 0.11);

  --green: #74b483;
  --green-deep: #4c8a5f;
  --green-wash: #e9f2ea;
  --coral: #ef7e57;
  --coral-wash: #fdece4;
  --gold: #e3ad42;
  --gold-wash: #f8f0d9;

  --r-xl: 30px; --r-lg: 24px; --r-md: 16px; --r-sm: 12px; --pill: 999px;

  --sh-card: 0 8px 30px rgba(28, 32, 24, 0.06), 0 1px 4px rgba(28, 32, 24, 0.04);
  --sh-soft: 0 3px 14px rgba(28, 32, 24, 0.05);
  --sh-pop: 0 16px 46px rgba(28, 32, 24, 0.18);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-soft: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; overscroll-behavior: none; }
body {
  font-family: var(--font); background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  user-select: none; -webkit-user-select: none; touch-action: manipulation; line-height: 1.5;
}
input, textarea { user-select: text; -webkit-user-select: text; font-family: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; padding: 0; text-align: left; }
img { -webkit-user-drag: none; user-drag: none; }
.icn { display: inline-grid; place-items: center; flex: none; }
.icn svg { display: block; }

/* ---------------- app frame ---------------- */
#app {
  position: relative; width: 100%; max-width: 480px; margin: 0 auto;
  min-height: 100%; background: var(--bg-grad); overflow: hidden;
}
@media (min-width: 481px) {
  body { background: #e5e7e2; }
  #app { min-height: 100dvh; box-shadow: 0 30px 90px rgba(0, 0, 0, 0.16); }
}

.screen { position: absolute; inset: 0; display: flex; flex-direction: column; min-height: 100%; background: var(--bg-grad); will-change: transform, opacity; overflow: hidden; }
.screen-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--safe-t) + 8px) 20px calc(var(--safe-b) + 28px); }
.screen-scroll.has-header { padding-top: 4px; }
.dock { padding: 12px 20px calc(var(--safe-b) + 16px); background: linear-gradient(to top, var(--bg) 60%, transparent); }

/* ---------------- top bar ---------------- */
.topbar { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 12px) 14px 8px; min-height: 54px; }
.topbar h1 { font-size: 17px; font-weight: 750; margin: 0; letter-spacing: -0.2px; flex: 1; text-align: center; }
.topbar .spacer { flex: 1; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--pill); display: grid; place-items: center; background: var(--surface); box-shadow: var(--sh-soft); color: var(--ink); transition: transform 0.16s var(--ease-spring); flex: none; }
.icon-btn:active { transform: scale(0.88); }
.icon-btn.ghost { background: rgba(255,255,255,0.6); box-shadow: none; }
.code-chip { margin: 0 auto; background: var(--ink); color: #fff; padding: 9px 18px; border-radius: var(--pill); font-size: 13px; font-weight: 600; letter-spacing: 0.3px; transition: transform 0.16s var(--ease-spring); }
.code-chip b { letter-spacing: 3px; margin-left: 4px; font-weight: 800; }
.code-chip:active { transform: scale(0.94); }

/* ---------------- typography ---------------- */
.h-hero { font-size: 32px; font-weight: 820; letter-spacing: -1px; line-height: 1.1; }
.h-title { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.h-sec { font-size: 12px; font-weight: 750; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.sub { color: var(--muted); font-size: 15px; }
.muted { color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gold-t { color: #b08a25; } .green-t { color: var(--green-deep); } .coral-t { color: var(--coral); }
.row-h { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-l { margin-top: 26px; }
.stack > * + * { margin-top: var(--gap, 14px); }
.home-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; margin: calc(var(--safe-t) + 10px) 2px 20px; }

/* ---------------- cards ---------------- */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-card); padding: 18px; }
.tap { transition: transform 0.16s var(--ease-spring); }
.tap:active { transform: scale(0.972); }
.empty { background: var(--surface-2); border: 1px dashed var(--line-2); border-radius: var(--r-lg); padding: 26px 18px; text-align: center; color: var(--muted); font-size: 14px; }

/* ---------------- buttons ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 54px; padding: 0 24px; width: 100%; border-radius: var(--pill); background: var(--ink); color: #fff; font-size: 16.5px; font-weight: 750; letter-spacing: -0.2px; box-shadow: 0 8px 20px rgba(25,26,24,0.2); transition: transform 0.15s var(--ease-spring), opacity 0.2s; }
.btn:active { transform: scale(0.96); }
.btn[disabled] { opacity: 0.38; box-shadow: none; pointer-events: none; }
.btn.green { background: var(--green-deep); box-shadow: 0 8px 20px rgba(76,138,95,0.28); }
.btn.coral { background: var(--coral); box-shadow: 0 8px 20px rgba(239,126,87,0.28); }
.btn.gold { background: linear-gradient(135deg, #e7b441, #d29a1e); box-shadow: 0 8px 20px rgba(217,165,33,0.32); }
.btn.secondary { background: var(--surface); color: var(--ink); box-shadow: var(--sh-soft); }
.btn.ghost { background: transparent; color: var(--ink-soft); box-shadow: none; }
.btn.gbtn { background: #fff; color: var(--ink); box-shadow: var(--sh-card); border: 1px solid var(--line); font-weight: 700; }
.gmark { display: inline-grid; place-items: center; }
.or-line { display: flex; align-items: center; gap: 12px; margin: 18px 4px; color: var(--muted); font-size: 13px; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--line-2); }

/* ---------------- chips ---------------- */
.chip { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--pill); background: var(--surface); color: var(--ink-soft); font-size: 13.5px; font-weight: 650; box-shadow: var(--sh-soft); }
.chip.green { background: var(--green-wash); color: var(--green-deep); box-shadow: none; }
.chip.coral { background: var(--coral-wash); color: var(--coral); box-shadow: none; }
.chip.gold { background: var(--gold-wash); color: #a9801f; box-shadow: none; }
.chip.dark { background: var(--ink); color: #fff; box-shadow: none; }
.seg { display: inline-flex; align-items: center; gap: 2px; padding: 3px; border-radius: var(--pill); background: var(--surface-2); }
.seg button { height: 30px; padding: 0 12px; border-radius: var(--pill); color: var(--muted); font-size: 12px; font-weight: 800; text-align: center; }
.seg button.sel { background: var(--surface); color: var(--ink); box-shadow: var(--sh-soft); }
.seg.compact button { height: 28px; padding: 0 10px; }
.seg.icon-seg button { display: inline-flex; align-items: center; justify-content: center; padding: 0 9px; }
.seg.icon-seg button .icn { color: inherit; }
.mini-btn { height: 32px; padding: 0 13px; border-radius: var(--pill); background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 800; }

/* ---------------- inputs ---------------- */
.field { display: block; width: 100%; }
.field input, .field textarea { width: 100%; height: 56px; padding: 0 18px; border-radius: var(--r-md); background: var(--surface); border: 1.5px solid var(--line-2); font-size: 17px; color: var(--ink); outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.field textarea { height: auto; padding: 14px 18px; resize: none; line-height: 1.5; }
.field input:focus, .field textarea:focus { border-color: var(--green); box-shadow: 0 0 0 4px var(--green-wash); }
.field input::placeholder, .field textarea::placeholder { color: #b7bbb1; }
.field-label { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin: 0 0 8px 4px; }
.code-input { letter-spacing: 16px; text-align: center; font-weight: 800; font-size: 30px; text-transform: uppercase; padding-left: 16px; height: 64px; }

/* ---------------- avatar ---------------- */
.avatar { width: 44px; height: 44px; border-radius: var(--pill); display: grid; place-items: center; font-weight: 800; font-size: 16px; color: #fff; flex: none; }
.avatar.sm { width: 34px; height: 34px; font-size: 13px; }
.avatar.lg { width: 86px; height: 86px; font-size: 32px; box-shadow: var(--sh-soft); }
.avatar.img { background-size: cover; background-position: center; background-repeat: no-repeat; }
.avatar-stack { display: flex; }
/* avatar upload */
.ava-edit { position: relative; display: inline-block; }
.ava-cam { position: absolute; right: -2px; bottom: -2px; width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; border: 3px solid var(--bg); }
.handle-pill { display: inline-block; margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); background: var(--surface-2); padding: 3px 12px; border-radius: var(--pill); letter-spacing: 0.5px; }

/* ---------------- mascot ---------------- */
.mascot { display: block; margin-inline: auto; }
.mascot img { width: 100%; height: 100%; object-fit: contain; }
.mascot-bubble { position: relative; background: var(--surface); border-radius: var(--r-lg); padding: 14px 18px; box-shadow: var(--sh-soft); font-weight: 550; color: var(--ink-soft); font-size: 14.5px; line-height: 1.55; }

/* ---------------- home ---------------- */
.hero-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-card); padding: 20px; margin-bottom: 12px; }
.hero-card.dark { background: linear-gradient(135deg, #1e1f1c, #34332e); color: #fff; }
.hero-t { font-size: 21px; font-weight: 800; letter-spacing: -0.4px; }
.hero-d { font-size: 13.5px; margin-top: 4px; opacity: 0.92; }
.hero-card.dark .hero-d { opacity: 0.66; }
.hero-ic { font-size: 30px; font-weight: 300; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,0.14); }
.hero-card:not(.dark) .hero-ic { background: var(--surface-2); color: var(--ink); }
.step { display: flex; gap: 12px; padding: 9px 0; align-items: flex-start; }
.step-n { width: 26px; height: 26px; border-radius: 50%; background: var(--green-wash); color: var(--green-deep); font-weight: 800; font-size: 13px; display: grid; place-items: center; flex: none; margin-top: 1px; }
.step-t { font-weight: 700; font-size: 15px; }
.step-d { color: var(--muted); font-size: 13px; }

/* ---------------- tab bar ---------------- */
.tabbar { display: flex; padding: 8px 8px calc(var(--safe-b) + 8px); background: rgba(255,255,255,0.86); backdrop-filter: saturate(180%) blur(20px); border-top: 1px solid var(--line); }
.tab { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 0; color: var(--muted); transition: color 0.2s, transform 0.16s var(--ease-spring); }
.tab .icn { transition: transform 0.22s var(--ease-spring); }
.tab-lbl { font-size: 11px; font-weight: 700; }
.tab-dot { position: absolute; top: 1px; width: 5px; height: 5px; border-radius: 50%; background: var(--green-deep); opacity: 0; transform: scale(0); transition: opacity 0.2s, transform 0.25s var(--ease-spring); }
.tab.active { color: var(--ink); }
.tab.active .icn { transform: translateY(-1px) scale(1.06); }
.tab.active .tab-dot { opacity: 1; transform: scale(1); }
.tab:active { transform: scale(0.9); }
.tab-ic-wrap { position: relative; display: inline-flex; }
.tab-badge { position: absolute; top: -2px; right: -4px; width: 9px; height: 9px; border-radius: 50%; background: var(--coral); border: 2px solid #fff; }

/* friends / social */
.players-cluster { display: flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; color: inherit; cursor: pointer; }
.players-cluster:active { transform: scale(0.97); }
.friend-row { display: flex; align-items: center; gap: 12px; padding: 12px 4px; }
.card.friend-row { padding: 12px 14px; margin-top: 10px; }
.fr-name { font-weight: 750; font-size: 15px; display: flex; align-items: center; gap: 4px; }

/* ---------------- create: pick cards ---------------- */
.pick-card { display: flex; align-items: center; gap: 14px; width: 100%; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-card); padding: 16px; border: 2px solid transparent; transition: transform 0.16s var(--ease-spring), border-color 0.2s; }
.pick-card:active { transform: scale(0.98); }
.pick-card.sel { border-color: var(--green); }
.pick-emoji { font-size: 28px; width: 30px; text-align: center; flex: none; }
.judge-ava { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; flex: none; }
.judge-ava.img { background-size: cover; background-position: center; background-repeat: no-repeat; box-shadow: inset 0 0 0 1px var(--line); }
.judge-ava.sm-ava { width: 44px; height: 44px; border-radius: 13px; font-size: 22px; }
.pick-name { font-weight: 800; font-size: 17px; letter-spacing: -0.2px; display: flex; align-items: baseline; gap: 8px; }
.pick-blurb { color: var(--ink-soft); font-size: 13px; margin-top: 3px; }
.pick-model { font-size: 11px; font-weight: 700; color: var(--muted); }
.judge-tags { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.jtag { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: var(--pill); }
.jtag.muted-tag { background: var(--surface-2); color: var(--muted); }
/* custom-judge: delete badge, "add" card, large avatar preview */
.judge-del { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 18px; line-height: 1; display: grid; place-items: center; flex: none; align-self: flex-start; }
.judge-del:active { transform: scale(0.9); }
.pick-card.add-card { border: 2px dashed var(--line-2); background: transparent; box-shadow: none; }
.judge-ava.add { background: var(--green-wash); color: var(--green-deep); font-size: 30px; font-weight: 700; }
.judge-ava-lg { width: 84px; height: 84px; border-radius: 22px; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); }
.judge-ava-lg.img { background-size: cover; background-position: center; background-repeat: no-repeat; }
/* custom-judge avatar placeholder: animal mascot + pulsing dots (idle / generating) */
.judge-edit { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; flex: none; align-self: flex-start; }
.judge-edit:active { transform: scale(0.9); }
.judge-ava.gen { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.gen-glyph { display: grid; place-items: center; color: var(--muted); opacity: 0.7; }
.gen-glyph.idle { color: var(--line-2); opacity: 0.95; }
.judge-ava-lg.gen .gen-glyph, .judge-ava.gen .gen-glyph { color: var(--green-deep); opacity: 1; animation: genBreathe 1.4s ease-in-out infinite; }
.gen-dots { display: flex; gap: 4px; }
.gen-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--green-deep); opacity: 0.3; animation: genDot 1.05s ease-in-out infinite; }
.gen-dots span:nth-child(2) { animation-delay: 0.18s; }
.gen-dots span:nth-child(3) { animation-delay: 0.36s; }
.gen-dots.sm span { width: 4px; height: 4px; }
@keyframes genDot { 0%, 80%, 100% { opacity: 0.28; transform: translateY(0); } 40% { opacity: 0.95; transform: translateY(-2px); } }
@keyframes genBreathe { 0%, 100% { transform: scale(0.94); } 50% { transform: scale(1.08); } }
.field textarea.ta { min-height: 120px; font-size: 15px; }
/* history rows */
.hist-row { display: flex; align-items: center; gap: 12px; width: 100%; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-card); padding: 12px 14px; }
.hist-main { flex: 1; min-width: 0; display: block; text-align: left; }
.hist-more { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); flex: none; }
.dino-badge { width: 56px; height: 56px; border-radius: 50%; background: var(--surface); box-shadow: var(--sh-soft); display: grid; place-items: center; flex: none; overflow: hidden; }
.dino-badge .mascot { animation: bob 3.4s var(--ease-soft) infinite; }
.radio { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; transition: background 0.2s, border-color 0.2s; }
.pick-card.sel .radio { background: var(--green-deep); border-color: var(--green-deep); box-shadow: inset 0 0 0 4px #fff; }
.checkbox { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line-2); flex: none; position: relative; transition: background 0.2s, border-color 0.2s; }
.pick-card.sel .checkbox, .checkbox.on { background: var(--green-deep); border-color: var(--green-deep); }
.pick-card.sel .checkbox::after, .checkbox.on::after { content: ""; position: absolute; left: 8px; top: 3px; width: 5px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }
.hist-row.sel { outline: 2px solid var(--green-deep); outline-offset: -2px; border-radius: 14px; }
.judge-banner-avas { display: flex; align-items: center; flex: none; }

/* ---------------- room board ---------------- */
.judge-banner { display: flex; align-items: center; gap: 12px; background: var(--green-wash); border-radius: var(--r-lg); padding: 12px 14px; }
.jb-name { font-weight: 750; font-size: 15px; color: var(--ink); }
.jb-sub { font-size: 12px; color: var(--ink-soft); margin-top: 1px; }
.room-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.theme-list.list { display: block; }
.theme-list.list > * + * { margin-top: var(--gap, 10px); }
.theme-list.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-list.grid .theme-card { min-height: 132px; padding: 12px; }
.theme-list.grid .theme-card > .between:first-child { display: block; }
.theme-list.grid .theme-card .status { display: inline-flex; margin-top: 10px; }
.theme-list.grid .theme-card .dots { flex-wrap: wrap; max-width: 100%; }
.theme-card { position: relative; display: block; width: 100%; background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-card); padding: 16px; }
.theme-n { width: 28px; height: 28px; border-radius: 9px; background: var(--surface-2); color: var(--ink-soft); font-weight: 800; font-size: 14px; display: grid; place-items: center; flex: none; }
.theme-title { font-weight: 750; font-size: 16.5px; }
.theme-sub { margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 650; }
.theme-color { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); flex: none; }
.theme-type-ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: var(--green-wash); color: var(--green-deep); flex: none; }
.status { font-size: 12px; font-weight: 750; padding: 5px 11px; border-radius: var(--pill); flex: none; }
.status.st-open { background: var(--green-wash); color: var(--green-deep); }
.status.st-judge { background: var(--coral-wash); color: var(--coral); }
.status.st-done { background: var(--ink); color: #fff; }
.dots { display: flex; gap: 5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--line-2); }
.win-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 700; color: #b08a25; }
.win-pill .icn { color: #b08a25; }
.mini { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.mini.ok { color: var(--green-deep); } .mini.todo { color: var(--coral); }
.theme-thumb { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1); flex: none; background: var(--surface-2); }
.del { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--muted); font-size: 17px; display: grid; place-items: center; flex: none; }
.del:active { transform: scale(0.85); }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.lb-rank { width: 26px; text-align: center; font-size: 17px; font-weight: 800; color: var(--ink-soft); }
.lb-row .name { font-weight: 700; font-size: 15px; }
.lb-score { text-align: right; } .lb-score b { display: block; font-weight: 800; font-size: 15px; } .lb-score span { font-size: 12px; }
.finish-cta { margin-top: 18px; padding: 18px; border-radius: var(--r-lg); background: linear-gradient(135deg, #fff, var(--coral-wash)); box-shadow: var(--sh-card); }
.finish-title { font-weight: 800; font-size: 17px; }
.finish-sub { margin: 2px 0 14px; color: var(--ink-soft); font-size: 13px; }

/* ---------------- theme presets ---------------- */
.preset-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.preset-card { min-height: 76px; padding: 13px 14px; border-radius: var(--r-md); background: var(--surface-2); border: 2px solid transparent; transition: transform 0.16s var(--ease-spring), border-color 0.2s, background 0.2s; }
.preset-card:active { transform: scale(0.98); }
.preset-card.sel { background: #fff; border-color: var(--green); }
.preset-name { font-size: 15px; font-weight: 800; }
.preset-desc { margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.35; }
.preset-preview { margin-top: 6px; }
.preset-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 12px; }
.preset-items { display: grid; gap: 8px; }
.preset-items.grid { grid-template-columns: repeat(3, 1fr); }
.preset-item { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--ink-soft); font-size: 13.5px; font-weight: 650; }
.preset-items.grid .preset-item { min-height: 76px; justify-content: center; text-align: center; flex-direction: column; padding: 9px; }
.preset-time { min-width: 46px; color: var(--green-deep); font-weight: 800; font-variant-numeric: tabular-nums; }
.time-range { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.time-range .field-label { margin-left: 2px; }
.time-range input { font-size: 13px; padding: 0 10px; }
.color-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.color-cell { aspect-ratio: 1; border-radius: var(--r-md); display: grid; place-items: center; padding: 8px; text-align: center; font-size: 13px; font-weight: 800; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1); }

/* ---------------- upload ---------------- */
.prog-p { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 650; color: var(--muted); opacity: 0.5; }
.prog-p.done { opacity: 1; color: var(--green-deep); }
.dropzone { position: relative; border-radius: var(--r-lg); border: 2px dashed var(--line-2); background: var(--surface-2); aspect-ratio: 3/4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); text-align: center; padding: 20px; transition: transform 0.16s var(--ease-spring); }
.dropzone:active { transform: scale(0.98); }
.dropzone.filled { border-style: solid; border-color: transparent; padding: 0; overflow: hidden; }
.dropzone.filled img { width: 100%; height: 100%; object-fit: cover; }
.photo-tile { position: relative; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-2); box-shadow: var(--sh-card); aspect-ratio: 3/4; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .tag { position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,0.5); color: #fff; backdrop-filter: blur(6px); padding: 5px 11px; border-radius: var(--pill); font-size: 12.5px; font-weight: 700; }
.photo-tile.winner { box-shadow: 0 0 0 3px var(--gold), var(--sh-card); }
.photo-tile.zoomable, .dropzone.filled.zoomable { cursor: zoom-in; }
.photo-tile.zoomable { transition: transform 0.16s var(--ease-spring); }
.photo-tile.zoomable:active { transform: scale(0.985); }
.photo-tile.zoomable:focus-visible, .dropzone.zoomable:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
.photo-zoom-badge, .photo-replace { position: absolute; top: 10px; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: rgba(0,0,0,0.46); backdrop-filter: blur(8px); box-shadow: 0 4px 14px rgba(0,0,0,0.16); z-index: 2; }
.photo-zoom-badge { right: 10px; pointer-events: none; }
.photo-replace { left: 10px; pointer-events: auto; }
.photo-replace:active { transform: scale(0.9); }
.result-card .photo-zoom-badge { top: 5px; right: 5px; width: 22px; height: 22px; }
.result-card .photo-zoom-badge .icn, .result-card .photo-zoom-badge svg { width: 12px !important; height: 12px !important; }
.orb { width: 130px; height: 130px; border-radius: 50%; margin: 0 auto; background: radial-gradient(circle at 35% 30%, #fff, var(--green-wash) 62%, var(--green) 100%); display: grid; place-items: center; animation: orbPulse 1.9s var(--ease-soft) infinite; }
.orb .mascot { animation: bob 2.2s var(--ease-soft) infinite; }
@keyframes orbPulse { 0%,100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(116,180,131,0.4); } 50% { transform: scale(1.04); box-shadow: 0 0 0 22px rgba(116,180,131,0); } }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }

/* ---------------- results ---------------- */
.winner-card { background: linear-gradient(165deg, #fff, var(--gold-wash)); border-radius: var(--r-xl); box-shadow: var(--sh-card); padding: 22px 18px 20px; text-align: center; position: relative; margin-top: 16px; }
.winner-card .crown { font-size: 34px; filter: drop-shadow(0 3px 5px rgba(0,0,0,.15)); }
.hl-pill { display: inline-block; margin-top: 10px; background: rgba(255,255,255,0.7); color: #a9801f; font-weight: 700; font-size: 13px; padding: 6px 14px; border-radius: var(--pill); }
.result-card { padding: 16px; }
.res-rank { width: 26px; text-align: center; font-size: 19px; font-weight: 800; color: var(--ink-soft); flex: none; }
.result-card .name { font-weight: 750; font-size: 15.5px; }
.res-total { text-align: right; flex: none; } .res-total b { font-size: 24px; font-weight: 800; } .res-total span { font-size: 11px; color: var(--muted); margin-left: 2px; }
.review { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 13.5px; line-height: 1.6; }
.photo-social { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.social-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.social-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 32px; padding: 0 12px; border-radius: var(--pill); background: var(--surface-2); color: var(--ink-soft); font-size: 12.5px; font-weight: 800; }
.social-btn b { color: inherit; font-variant-numeric: tabular-nums; }
.social-btn.sel, .social-btn.heart.sel { background: var(--coral-wash); color: var(--coral); }
.social-btn[disabled] { opacity: 0.5; pointer-events: none; }
.social-note { color: var(--muted); font-size: 12.5px; font-weight: 650; }
.comment-list { margin-top: 10px; display: grid; gap: 6px; }
.comment-line { display: flex; gap: 8px; align-items: flex-start; min-width: 0; color: var(--ink-soft); font-size: 13px; line-height: 1.45; background: var(--surface-2); border-radius: var(--r-sm); padding: 8px 10px; }
.comment-line b { color: var(--ink); margin-right: 6px; }
.comment-heart { display: inline-flex; align-items: center; gap: 3px; height: 24px; padding: 0 7px; border-radius: var(--pill); background: #fff; color: var(--muted); font-size: 11px; font-weight: 800; flex: none; }
.comment-heart.sel { color: var(--coral); background: var(--coral-wash); }
.comment-more { margin-top: 6px; color: var(--muted); font-size: 12px; }
.score-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.score-row .lbl { width: 40px; font-size: 13px; font-weight: 650; color: var(--ink-soft); flex: none; }
.score-track { flex: 1; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.score-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--green), var(--green-deep)); width: 0; }
.score-val { width: 26px; text-align: right; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums; }

/* ---------------- wallet ---------------- */
.balance { background: linear-gradient(135deg, #1e1f1c, #34332e); color: #fff; border-radius: var(--r-xl); padding: 24px; text-align: center; margin-top: 6px; }
.bal-lbl { opacity: 0.62; font-weight: 650; font-size: 14px; }
.bal-num { font-size: 54px; font-weight: 820; letter-spacing: -2px; margin: 4px 0 2px; }
.bal-sub { opacity: 0.55; font-size: 12.5px; }
.pack { position: relative; display: flex; align-items: center; gap: 14px; width: 100%; padding: 16px; border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-card); }
.pack-gem { font-size: 30px; flex: none; }
.pack-amt { font-weight: 800; font-size: 19px; }
.pack-price { margin-left: auto; font-weight: 800; font-size: 18px; min-width: 48px; text-align: right; }
.pack-tag { position: absolute; top: -9px; right: 16px; background: var(--coral); color: #fff; font-size: 11px; font-weight: 750; padding: 3px 10px; border-radius: var(--pill); }

/* ---------------- gallery ---------------- */
.gal-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.gal-cell { aspect-ratio: 1; border-radius: var(--r-sm); }
.room-gallery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.gallery-photo { position: relative; aspect-ratio: 3/4; overflow: hidden; border-radius: var(--r-md); background: var(--surface-2); box-shadow: var(--sh-soft); }
.gallery-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-info { position: absolute; left: 8px; right: 8px; bottom: 8px; display: block; border-radius: var(--r-sm); padding: 7px 8px; background: rgba(0,0,0,0.48); color: #fff; backdrop-filter: blur(8px); text-align: left; }
.gallery-info b { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gallery-info small { display: block; opacity: 0.76; font-size: 11px; }

/* ---------------- profile ---------------- */
.setting-row { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 16px 18px; }
.setting-row .icn { color: var(--ink-soft); }
.switch { flex: 0 0 auto; width: 46px; height: 28px; border-radius: 999px; background: #d8d4cf; position: relative; transition: background .2s; cursor: pointer; }
.switch.on { background: var(--coral, #ef7e57); }
.switch-dot { position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: left .2s; }
.switch.on .switch-dot { left: 21px; }

/* ---------------- toast / sheet / loaders ---------------- */
#overlay-root { position: fixed; inset: 0; pointer-events: none; z-index: 1000; max-width: 480px; margin: 0 auto; }
.toast { position: absolute; left: 50%; top: calc(var(--safe-t) + 14px); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--pill); font-weight: 600; font-size: 14px; box-shadow: var(--sh-pop); max-width: 90%; text-align: center; }
.toast.err { background: #c8473a; } .toast.ok { background: var(--green-deep); }
.sheet-scrim { position: absolute; inset: 0; background: rgba(20,22,18,0.36); pointer-events: auto; opacity: 0; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: calc(100dvh - var(--safe-t) - 18px); overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--surface); border-radius: 28px 28px 0 0; padding: 10px 20px calc(var(--safe-b) + 22px); box-shadow: var(--sh-pop); pointer-events: auto; will-change: transform; }
.sheet .grabber { width: 40px; height: 5px; border-radius: 999px; background: var(--line-2); margin: 6px auto 16px; }
.photo-preview-scrim { position: absolute; inset: 0; background: rgba(12,13,11,0.78); backdrop-filter: blur(10px); pointer-events: auto; opacity: 0; }
.photo-preview { position: absolute; inset: 0; display: grid; place-items: center; padding: calc(var(--safe-t) + 66px) 16px calc(var(--safe-b) + 32px); pointer-events: auto; opacity: 0; will-change: transform, opacity; }
.photo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 18px; background: #000; box-shadow: 0 18px 54px rgba(0,0,0,0.38); }
.photo-preview-close { position: absolute; top: calc(var(--safe-t) + 14px); right: 14px; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,0.92); color: var(--ink); box-shadow: var(--sh-pop); font-size: 28px; line-height: 1; z-index: 1; }
.photo-preview-close:active { transform: scale(0.9); }
.photo-preview-actions { position: absolute; left: 0; right: 0; bottom: calc(var(--safe-b) + 22px); display: flex; gap: 12px; justify-content: center; pointer-events: auto; z-index: 1; }
.photo-preview-actions button { display: inline-flex; align-items: center; gap: 6px; font-size: 14.5px; font-weight: 600; color: #fff; background: rgba(255,255,255,0.18); backdrop-filter: blur(10px); border-radius: 999px; padding: 11px 18px; box-shadow: var(--sh-soft); }
.photo-preview-actions button.danger { color: #ffe0d4; background: rgba(239,126,87,0.32); }
.photo-preview-actions button:active { transform: scale(0.94); }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,0.35); border-top-color: #fff; animation: spin 0.7s linear infinite; }
.spinner.dark { border-color: var(--line-2); border-top-color: var(--ink); }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(100deg, var(--surface-2) 30%, #eef0ea 50%, var(--surface-2) 70%); background-size: 200% 100%; animation: sk 1.3s infinite; border-radius: var(--r-md); }
@keyframes sk { to { background-position: -200% 0; } }
.confetti { position: absolute; width: 9px; height: 14px; border-radius: 2px; will-change: transform, opacity; top: -20px; }

/* ---- result collage share sheet ---- */
.collage-chips { display: flex; gap: 8px; margin-bottom: 14px; }
.collage-chip { flex: 1; height: 40px; border-radius: var(--pill); background: var(--surface-2); color: var(--ink-soft); font-weight: 750; font-size: 14px; border: 2px solid transparent; transition: transform 0.14s var(--ease-spring), background 0.2s, color 0.2s, border-color 0.2s; }
.collage-chip:active { transform: scale(0.95); }
.collage-chip.on { background: var(--gold-wash); color: #a9801f; border-color: var(--gold); }
.collage-preview { position: relative; width: 62%; max-width: 280px; margin: 0 auto 4px; aspect-ratio: 1080 / 1920; border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); box-shadow: var(--sh-card); }
.collage-canvas { width: 100%; height: 100%; display: block; }
.collage-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(251,250,245,0.7); backdrop-filter: blur(3px); }

@media (prefers-reduced-motion: reduce) { * { animation-duration: 0.001s !important; transition-duration: 0.05s !important; } }
