:root {
  --bg1: #0c1f2b;
  --bg2: #10344a;
  --ink: #f6f3ea;
  --muted: rgba(246, 243, 234, .66);
  --card: rgba(255, 255, 255, .07);
  --line: rgba(255, 255, 255, .12);
  --accent: #ffcc4d;
  --accent2: #ff8a3d;
  --green: #47d18c;
  --red: #ff6b6b;
  --panel: #fbf7ee;
  --panel-ink: #1f2a33;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: radial-gradient(120% 70% at 50% 0%, #1c5a6e 0%, var(--bg2) 35%, var(--bg1) 75%) fixed;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
h1, h2, h3 { margin: 0; line-height: 1.15; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

#sky { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#sky i { position: absolute; top: -10px; width: 6px; height: 6px; border-radius: 50%; background: #fff; animation: fall linear infinite; }
@keyframes fall { to { top: 105%; margin-left: 30px; } }

#app { position: relative; z-index: 1; max-width: 520px; margin: 0 auto; min-height: 100vh; }
.loader, .center { min-height: 70vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid rgba(255,255,255,.2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.big-emoji { font-size: 56px; }

/* buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 15px 18px; border-radius: 16px; font-weight: 700; font-size: 16px; transition: transform .12s, opacity .2s; text-decoration: none; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.btn.xl { padding: 18px; font-size: 18px; border-radius: 18px; }
.btn.primary { background: linear-gradient(180deg, #ffd65c, #ffb52e); color: #3a2400; box-shadow: 0 6px 0 #c98714, 0 10px 24px rgba(255, 180, 40, .35); }
.btn.primary:active { box-shadow: 0 2px 0 #c98714; transform: translateY(4px); }
.btn.gold { background: linear-gradient(90deg, #f5d27a, #e7a948, #f5d27a); color: #3a2400; margin-top: 14px; }
.btn.soft { background: rgba(31, 42, 51, .07); color: var(--panel-ink); margin-bottom: 12px; }
.link { display: block; margin: 18px auto 6px; color: rgba(31,42,51,.55); font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.lang { position: absolute; left: 14px; top: 12px; padding: 7px 11px; border-radius: 99px; background: rgba(0,0,0,.25); border: 1px solid var(--line); font-size: 13px; font-weight: 700; z-index: 3; }

/* landing */
.landing { padding: 54px 22px calc(28px + var(--safe-b)); text-align: center; display: flex; flex-direction: column; gap: 14px; }
.landing h1 { font-size: 30px; font-weight: 600; }
.landing h1 b { color: var(--accent); font-weight: 800; }
.landing .sub { color: var(--muted); font-size: 16px; line-height: 1.45; margin: 0 0 8px; }
.hero-tree { height: 300px; margin: -6px auto 0; width: 100%; }
.hero-tree .tree-svg { height: 100%; }
.card { border-radius: var(--radius); padding: 16px; }
.glass { background: var(--card); border: 1px solid var(--line); backdrop-filter: blur(10px); }

/* tree */
.tree-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.tree-svg .tw { animation: twinkle 2s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .25; } }
.tree-svg .star { transform-origin: 160px 40px; animation: pulse 3s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.tree-svg .orn { cursor: pointer; animation: drop .5s cubic-bezier(.3, 1.4, .5, 1) both; transform-box: fill-box; }
@keyframes drop { from { opacity: 0; transform: translateY(-14px); } }
.tree-svg .orn.mine circle:first-of-type { stroke: #fff; stroke-width: 2.2; }
.tree-svg .lbl { font-size: 9px; font-weight: 700; fill: #fff; text-anchor: middle; paint-order: stroke; stroke: rgba(10, 30, 20, .75); stroke-width: 3px; stroke-linejoin: round; pointer-events: none; }

/* home */
.home { display: flex; flex-direction: column; min-height: 100vh; }
.top { position: relative; height: 56px; display: flex; align-items: center; justify-content: center; }
.title-chip { background: linear-gradient(180deg, #ff6767, #d63a3a); padding: 9px 16px; border-radius: 12px; font-weight: 800; font-size: 15px; max-width: 60%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; box-shadow: 0 4px 0 #9c2222; }
.count { position: absolute; right: 14px; top: 14px; padding: 6px 10px; border-radius: 99px; background: rgba(0,0,0,.25); font-size: 13px; font-weight: 700; }
.tree-wrap { height: min(56vh, 460px); padding: 4px 8px 0; }
.panel { flex: 1; background: var(--panel); color: var(--panel-ink); border-radius: 26px 26px 0 0; margin-top: -10px; padding: 18px 18px calc(24px + var(--safe-b)); box-shadow: 0 -10px 30px rgba(0,0,0,.25); }
.panel h3 { font-size: 17px; margin: 22px 2px 10px; }
.banner { background: #eaf7ef; border: 1px solid #c5ebd3; color: #1d5a37; border-radius: 14px; padding: 12px 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.4; }
.banner b { font-size: 15px; }
.invite { text-align: center; margin: 4px 0 14px; }
.invite b { font-size: 18px; display: block; margin-bottom: 6px; }
.invite p { margin: 0; color: rgba(31,42,51,.65); line-height: 1.45; }
.actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.act { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 16px; background: #fff; border: 1px solid #ece4d3; font-size: 13px; font-weight: 700; color: var(--panel-ink); }
.act span { font-size: 24px; }
.act:active { transform: scale(.96); }
.badge { position: absolute; top: 6px; right: 10px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--red); color: #fff; font-style: normal; font-size: 12px; line-height: 20px; padding: 0 5px; }
.empty { text-align: center; margin: 22px 0 4px; padding: 18px; border: 2px dashed #e4dac5; border-radius: 16px; }
.empty p { margin: 6px 0 0; color: rgba(31,42,51,.6); font-size: 14px; line-height: 1.4; }
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.board li { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #fff; border: 1px solid #ece4d3; border-radius: 14px; }
.board li.me { border-color: #ffc94a; background: #fff8e3; }
.board .medal { width: 26px; text-align: center; font-size: 18px; }
.board .num { font-size: 14px; font-weight: 700; color: rgba(31,42,51,.45); }
.board .nm { flex: 1; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .sc { font-weight: 800; color: #1e8a52; }

/* quiz */
.quiz { padding: 22px 20px calc(24px + var(--safe-b)); min-height: 100vh; display: flex; flex-direction: column; }
.progress { height: 8px; border-radius: 8px; background: rgba(255,255,255,.12); overflow: hidden; }
.progress div { height: 100%; background: linear-gradient(90deg, var(--green), var(--accent)); border-radius: 8px; transition: width .3s; }
.qmeta { display: flex; justify-content: space-between; gap: 10px; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.qtext { font-size: 25px; font-weight: 800; margin: 36px 0 26px; line-height: 1.25; }
.options { display: flex; flex-direction: column; gap: 12px; }
.opt { display: flex; align-items: center; gap: 14px; text-align: left; padding: 16px; border-radius: 16px; background: rgba(255,255,255,.08); border: 1.5px solid var(--line); font-size: 17px; font-weight: 600; animation: rise .3s both; transition: transform .1s, background .15s, border-color .15s; }
.opt:active { transform: scale(.98); }
.opt.picked { background: rgba(255, 204, 77, .2); border-color: var(--accent); }
.opt .dot { flex: none; width: 30px; height: 30px; border-radius: 10px; background: rgba(255,255,255,.12); display: grid; place-items: center; font-size: 14px; font-weight: 800; }
.opt.picked .dot { background: var(--accent); color: #3a2400; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* result */
.result { position: relative; padding: 40px 20px calc(28px + var(--safe-b)); text-align: center; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.result h2 { font-size: 26px; }
.score-ring { --p: 0; width: 150px; height: 150px; margin: 0 auto 6px; border-radius: 50%; display: grid; place-items: center; align-content: center; background: radial-gradient(closest-side, var(--bg1) 78%, transparent 79%), conic-gradient(var(--accent) calc(var(--p) * 1%), rgba(255,255,255,.12) 0); animation: pop .6s cubic-bezier(.3, 1.5, .5, 1) both; }
.score-ring b { font-size: 52px; line-height: 1; }
.score-ring span { color: var(--muted); font-weight: 700; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
.result .card { text-align: left; display: flex; flex-direction: column; gap: 10px; }
.lbl2 { font-weight: 700; }
textarea { width: 100%; resize: none; border-radius: 14px; border: 1.5px solid var(--line); background: rgba(0,0,0,.2); color: inherit; font: inherit; padding: 12px; user-select: text; }
.sheet textarea { background: #fff; border-color: #e6dcc8; color: var(--panel-ink); margin: 12px 0; }
.result .btn.soft { background: rgba(255,255,255,.12); color: var(--ink); margin: 0; }
.review { text-align: left; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; }
.review summary { font-weight: 700; cursor: pointer; }
.rv { padding: 10px 0; border-top: 1px solid var(--line); }
.rv p { margin: 0 0 4px; font-weight: 600; }
.rv small { color: var(--muted); }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 8px; height: 14px; border-radius: 2px; animation: conf ease-in forwards; }
@keyframes conf { to { transform: translateY(110vh) rotate(720deg); opacity: .8; } }

/* sheet */
#sheet-root { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#sheet-root.open { pointer-events: auto; }
.backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .2s; }
#sheet-root.open .backdrop { opacity: 1; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-width: 520px; margin: 0 auto; max-height: 88vh; overflow-y: auto; background: var(--panel); color: var(--panel-ink); border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + var(--safe-b)); transform: translateY(100%); transition: transform .22s cubic-bezier(.2, .8, .3, 1); }
#sheet-root.open .sheet { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: #e0d6c2; margin: 0 auto 14px; }
.sheet h3 { font-size: 20px; text-align: center; }
.sheet > p.muted, .sheet .muted { color: rgba(31,42,51,.6); text-align: center; margin: 6px 0 14px; }
.sheet .center { min-height: 0; padding: 10px 0; }
.skins { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.skins.row { grid-template-columns: repeat(4, 1fr); margin: 10px 0 6px; }
.skin { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 4px 8px; border-radius: 16px; background: #fff; border: 2px solid #ece4d3; font-size: 13px; font-weight: 700; color: var(--panel-ink); }
.skin svg { width: 52px; height: 60px; }
.skin.sm svg { width: 40px; height: 46px; }
.skin.sm { font-size: 11px; padding: 8px 2px 6px; }
.skin.on { border-color: #6c63ff; background: #f1f0ff; }
.skin .lock { position: absolute; top: 6px; right: 8px; font-style: normal; font-size: 13px; }
.price { text-align: center; font-size: 32px; font-weight: 800; margin: 8px 0 2px; }
.price small { display: block; font-size: 13px; font-weight: 600; color: rgba(31,42,51,.55); margin-top: 2px; }
.steps { padding-left: 22px; margin: 16px 0; display: flex; flex-direction: column; gap: 14px; }
.steps li b { display: block; margin-bottom: 8px; font-size: 15px; }
.cardno { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: 14px; background: #fff; border: 1.5px dashed #d8c9a8; font-size: 19px; font-weight: 800; letter-spacing: 1.5px; color: var(--panel-ink); }
.drop { display: flex; justify-content: center; align-items: center; min-height: 64px; border-radius: 14px; background: #fff; border: 1.5px dashed #d8c9a8; font-weight: 700; cursor: pointer; padding: 10px; }
.drop span { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.drop img { max-height: 140px; max-width: 100%; border-radius: 10px; }
.drop small { color: rgba(31,42,51,.55); }
.wishes { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.wish { background: #fff; border: 1px solid #ece4d3; border-radius: 14px; padding: 12px 14px; }
.wish b small { color: #1e8a52; margin-left: 4px; }
.wish p { margin: 6px 0 0; line-height: 1.45; user-select: text; }

#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); transform: translate(-50%, 30px); background: rgba(20, 28, 34, .94); color: #fff; padding: 11px 16px; border-radius: 14px; font-size: 14px; font-weight: 600; opacity: 0; transition: .25s; z-index: 30; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
