:root {
  --bg: #fdf6ee;
  --card: #ffffff;
  --ink: #2b2d42;
  --muted: #8d90a3;
  --line: #ece4d9;
  --pri: #ff6b5b;
  --pri2: #ffb347;
  --blue: #4d96ff;
  --hl: #c9cfd8;
  --hl-px: #a8ccff;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; overscroll-behavior: none; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
.hidden, [hidden] { display: none !important; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding-top: var(--safe-t); }

/* headers */
.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 6px; gap: 10px; }
.brand { font-weight: 800; font-size: 22px; letter-spacing: -0.3px; }
.brand.small { font-size: 16px; color: var(--muted); font-weight: 700; }
.logo { font-size: 26px; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; font-size: 22px; display: grid; place-items: center; background: var(--card); box-shadow: 0 1px 0 var(--line), 0 2px 8px rgba(60, 40, 20, .06); flex: none; }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { background: var(--ink); color: #fff; }
h1 { font-size: 30px; text-align: center; margin: 22px 0 18px; font-weight: 800; }

/* profiles */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 18px; padding: 8px 22px 40px; overflow-y: auto; }
.pcard { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pcard .av { width: 112px; height: 112px; border-radius: 50%; display: grid; place-items: center; font-size: 62px; background: var(--card); box-shadow: 0 4px 0 var(--line), 0 6px 18px rgba(60, 40, 20, .08); transition: transform .12s; }
.pcard:active .av { transform: scale(.93); }
.pcard .nm { font-weight: 800; font-size: 19px; }
.pcard .lv { font-size: 13px; color: var(--muted); margin-top: -6px; }
.pcard.add .av { background: transparent; border: 3px dashed #d9cdbd; box-shadow: none; color: #c4b49f; font-size: 48px; }

/* gallery */
.who { display: flex; align-items: center; gap: 8px; background: var(--card); padding: 5px 14px 5px 5px; border-radius: 999px; box-shadow: 0 1px 0 var(--line), 0 2px 8px rgba(60, 40, 20, .06); }
.who .av { width: 36px; height: 36px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 22px; }
.who .nm { font-weight: 800; font-size: 17px; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 8px 14px 10px; scrollbar-width: none; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { flex: none; padding: 9px 15px; border-radius: 999px; background: var(--card); font-weight: 700; font-size: 15px; box-shadow: 0 1px 0 var(--line); white-space: nowrap; }
.tab.on { background: var(--ink); color: #fff; }
.gallery { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px calc(24px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.card { position: relative; aspect-ratio: 1; background: var(--card); border-radius: 22px; box-shadow: 0 3px 0 var(--line), 0 4px 14px rgba(60, 40, 20, .06); overflow: hidden; display: grid; place-items: center; }
.card:active { transform: scale(.97); }
.card img.th { width: 86%; height: 86%; object-fit: contain; }
.card .ph { font-size: 64px; opacity: .18; filter: grayscale(1); }
.card .prog { position: absolute; left: 12px; right: 12px; bottom: 9px; height: 6px; border-radius: 3px; background: #f1ebe3; overflow: hidden; }
.card .prog i { display: block; height: 100%; background: linear-gradient(90deg, var(--pri2), var(--pri)); border-radius: 3px; }
.card .done { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 50%; background: #3ccf7a; color: #fff; display: grid; place-items: center; font-weight: 900; font-size: 17px; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }
.card .del { position: absolute; top: 6px; left: 6px; width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .9); font-size: 15px; display: grid; place-items: center; color: #999; }
.card.add { border: 3px dashed #e0d4c4; background: transparent; box-shadow: none; flex-direction: column; color: #b09a80; font-weight: 800; text-align: center; padding: 10px; gap: 4px; }
.card.add b { font-size: 46px; line-height: 1; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 17px; padding: 50px 20px; line-height: 1.5; }
.empty b { display: block; font-size: 54px; margin-bottom: 8px; }

/* colouring */
.ctop { display: flex; align-items: center; gap: 8px; padding: 8px 10px; z-index: 2; }
.cprog { flex: 1; display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; color: var(--muted); }
.cprog .bar { flex: 1; height: 10px; background: #efe7dc; border-radius: 5px; overflow: hidden; }
.cprog .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--pri2), var(--pri)); border-radius: 5px; transition: width .3s; }
.stage { flex: 1; position: relative; overflow: hidden; touch-action: none; background: #f6f1ea; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage .r { stroke: #a3abb5; stroke-width: 1; vector-effect: non-scaling-stroke; transition: fill .25s ease; }
.stage .r.f { stroke-width: 1.2; }
.stage .px.r { stroke: #dfe3e8; stroke-width: .6; }
.stage .base { fill: #a3abb5; }
.stage text { font-family: ui-rounded, "SF Pro Rounded", system-ui, sans-serif; font-weight: 600; fill: #6f7783; text-anchor: middle; pointer-events: none; }
.stage text.f { display: none; }
.stage .pulse { animation: pulse .5s ease-in-out 4 alternate; }
@keyframes pulse { from { fill: var(--hl); } to { fill: #ffe066; } }
.stage .shake { animation: shake .35s; }
@keyframes shake { 25% { fill: #ffd6d6; } 75% { fill: #ffd6d6; } }
.ripple { pointer-events: none; }
.palette { flex: none; display: flex; gap: 10px; overflow-x: auto; padding: 16px 18px calc(14px + var(--safe-b)); background: var(--card); box-shadow: 0 -2px 12px rgba(60, 40, 20, .07); scrollbar-width: none; scroll-behavior: smooth; }
.palette::-webkit-scrollbar { display: none; }
.sw { position: relative; flex: none; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 19px; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .08); transition: transform .15s; }
.sw.sel { transform: scale(1.14); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .1), 0 0 0 3px #fff, 0 0 0 6px var(--ink); }
.sw.ok { opacity: .35; }
.sw.ok::after { content: "✓"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; }
.sw .ring { position: absolute; inset: -4px; pointer-events: none; }

/* modal sheet */
.modal { position: fixed; inset: 0; background: rgba(30, 25, 40, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 20px 20px calc(24px + var(--safe-b)); animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(40px); } }
.sheet h2 { margin: 0 0 16px; font-size: 24px; font-weight: 800; text-align: center; }
.sheet label.l { display: block; font-weight: 800; font-size: 14px; color: var(--muted); margin: 16px 0 8px; text-transform: uppercase; letter-spacing: .5px; }
.sheet input[type=text] { width: 100%; font: inherit; font-size: 20px; font-weight: 700; padding: 14px 16px; border-radius: 16px; border: 2px solid var(--line); background: #fff; outline: none; -webkit-user-select: text; user-select: text; }
.sheet input[type=text]:focus { border-color: var(--blue); }
.avs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avs button { aspect-ratio: 1; font-size: 30px; border-radius: 14px; background: #fff; }
.avs button.on { box-shadow: 0 0 0 3px var(--ink); }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; padding: 12px 6px; border-radius: 16px; background: #fff; font-weight: 800; font-size: 16px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.seg button small { font-weight: 600; font-size: 12px; color: var(--muted); }
.seg button.on { background: var(--ink); color: #fff; }
.seg button.on small { color: #ccc; }
.btns { display: flex; gap: 10px; margin-top: 22px; }
.btn { flex: 1; padding: 16px; border-radius: 18px; font-weight: 800; font-size: 18px; background: #fff; box-shadow: 0 2px 0 var(--line); }
.btn.pri { background: var(--pri); color: #fff; box-shadow: 0 3px 0 #e04e3f; }
.btn.danger { color: #e04e3f; }
.btn:active { transform: translateY(2px); }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; background: #fff; padding: 10px 14px; border-radius: 16px; font-weight: 700; font-size: 17px; }
.row .e { font-size: 28px; }
.row .grow { flex: 1; }
.row .small { color: var(--muted); font-size: 13px; font-weight: 600; }
.menu { display: flex; flex-direction: column; gap: 10px; }
.menu .btn { text-align: left; display: flex; gap: 12px; align-items: center; }
.note { font-size: 13px; color: var(--muted); line-height: 1.45; margin-top: 18px; text-align: center; }

/* celebration */
.celebrate { position: fixed; inset: 0; z-index: 30; background: rgba(253, 246, 238, .97); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: calc(20px + var(--safe-t)) 20px calc(20px + var(--safe-b)); animation: fade .3s; }
.celebrate h2 { font-size: 34px; margin: 0 0 14px; font-weight: 900; text-align: center; }
.celebrate .art { width: min(82vw, 52vh); height: min(82vw, 52vh); background: #fff; border-radius: 26px; box-shadow: 0 8px 30px rgba(60, 40, 20, .15); display: grid; place-items: center; overflow: hidden; }
.celebrate .art svg, .celebrate .art img { width: 88%; height: 88%; }
.celebrate .btns { width: 100%; max-width: 420px; flex-wrap: wrap; }
.confetti { position: fixed; top: -40px; font-size: 28px; pointer-events: none; z-index: 31; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.toast { position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-weight: 700; z-index: 40; max-width: 90vw; text-align: center; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 5px solid #eadfce; border-top-color: var(--pri); animation: spin 0.8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
#btn-hint { position: relative; }
#btn-hint .hint-n { position: absolute; top: -5px; right: -5px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--pri); color: #fff; font-size: 12px; font-weight: 900; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); }
#btn-hint.empty { opacity: .7; filter: grayscale(1); }
#btn-hint.empty .hint-n { background: #9aa0aa; }
.empty-hint { grid-column: 1 / -1; text-align: center; color: var(--muted); font-size: 17px; margin: 4px 0 0; }
.profile-grid:has(.empty-hint) { display: flex; flex-direction: column; align-items: center; }

/* daily picture banner */
.daily { display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; background: linear-gradient(135deg, #fff7d6, #ffe3d3); border-radius: 22px; padding: 10px 14px 10px 10px; margin: 2px 0 12px; box-shadow: 0 3px 0 #f1dcc4; }
.daily:active { transform: scale(.98); }
.daily .dth { flex: none; width: 84px; height: 84px; border-radius: 16px; background: #fff; display: grid; place-items: center; overflow: hidden; }
.daily .dth img { width: 90%; height: 90%; object-fit: contain; }
.daily .dth .ph { font-size: 40px; opacity: .25; filter: grayscale(1); }
.daily .dtx { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.daily .dtx b { font-size: 17px; font-weight: 800; }
.daily .dtx small { font-size: 13px; color: #8a6d4f; font-weight: 700; }
.daily .wk { display: flex; gap: 4px; }
.daily .wk i { font-style: normal; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; font-weight: 800; background: rgba(255,255,255,.75); color: #b59b80; }
.daily .wk i.ok { background: #3ccf7a; color: #fff; }
.daily .wk i.now { box-shadow: 0 0 0 2px var(--pri); color: var(--pri); }
.daily .wk i.ok.now { color: #fff; }
.daily .wk i.fut { opacity: .5; }
.daily.won { background: linear-gradient(135deg, #dcf7e6, #e6f3ff); box-shadow: 0 3px 0 #c9e6d3; }
/* album */
.sec { font-size: 18px; font-weight: 800; margin: 10px 2px 10px; display: flex; align-items: baseline; gap: 8px; }
.sec small { font-size: 14px; color: var(--muted); font-weight: 700; }
.stickers { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; background: #fff; border-radius: 20px; padding: 12px; box-shadow: 0 3px 0 var(--line); }
.stickers i { font-style: normal; aspect-ratio: 1; display: grid; place-items: center; font-size: 26px; border-radius: 50%; background: #fdf6ee; }
.stickers i.lock { font-size: 15px; color: #d6cbbd; font-weight: 900; background: #f6f0e8; }
.medals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.medal { background: #fff; border-radius: 16px; padding: 10px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 12px; font-weight: 700; color: var(--ink); box-shadow: 0 2px 0 var(--line); }
.medal b { font-size: 30px; }
.medal.lock { opacity: .4; filter: grayscale(1); }
/* celebration rewards */
.celebrate .won { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; background: #fff; padding: 8px 18px 8px 10px; border-radius: 999px; box-shadow: 0 3px 12px rgba(60,40,20,.12); margin-bottom: 12px; animation: pop .6s cubic-bezier(.2,1.6,.4,1) both .4s; }
.celebrate .won .stk { font-size: 40px; line-height: 1; }
.celebrate .won.streak { background: #fff1e0; animation-delay: .7s; padding: 10px 18px; }
@keyframes pop { from { transform: scale(0); opacity: 0; } }
/* free mode palette */
.sw.free { width: 46px; height: 46px; }
