:root {
  --pink: #ff8fbd; --pink2: #ff5d9e; --pinkbg: #ffe3ef; --cream: #fff8f0;
  --mint: #7fe0c0; --sky: #8fd3ff; --gold: #ffc93c; --lilac: #c4a2ff;
  --ink: #5b4260; --ink2: #9a7fa3; --white: #fff;
  --shadow: 0 6px 0 rgba(180, 110, 160, .25), 0 10px 24px rgba(180, 110, 160, .25);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: 'Baloo 2', 'Nunito', system-ui, sans-serif; color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #fff0f7 0, transparent 40%), radial-gradient(circle at 90% 90%, #e5f6ff 0, transparent 45%),
    repeating-linear-gradient(45deg, #ffe9f2 0 22px, #fff2f8 22px 44px);
  user-select: none; -webkit-user-select: none; touch-action: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font-family: inherit; }
.hide { display: none !important; }
#cv { position: fixed; inset: 0; display: block; touch-action: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.top { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; gap: 8px; align-items: flex-start; justify-content: space-between; pointer-events: none; }
.top > * { pointer-events: auto; }
.prof { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 24px; padding: 5px 14px 5px 5px; box-shadow: var(--shadow); position: relative; max-width: 58vw; text-align: left; }
.prof .ava { width: 46px; height: 46px; border-radius: 50%; background: linear-gradient(135deg, #ffe0ee, #ffc1dc); display: grid; place-items: center; font-size: 30px; border: 3px solid #fff; box-shadow: 0 0 0 3px var(--pink); }
.prof .lv { position: absolute; left: 32px; bottom: 0; background: var(--pink2); color: #fff; font-weight: 800; font-size: 12px; min-width: 22px; height: 22px; border-radius: 11px; display: grid; place-items: center; border: 2px solid #fff; padding: 0 4px; }
.pinfo2 { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.pinfo2 b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pinfo2 small { font-size: 11px; color: var(--ink2); font-weight: 700; }
.xp { display: block; width: 120px; max-width: 100%; height: 8px; background: #ffe3ef; border-radius: 4px; overflow: hidden; margin: 2px 0; }
.xp i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ffb3d4, #ff6fa8); border-radius: 4px; transition: width .3s; }
.pills { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.pill { display: flex; align-items: center; gap: 4px; background: #fff; border-radius: 20px; padding: 3px 14px 3px 6px; box-shadow: var(--shadow); font-size: 17px; min-width: 96px; cursor: pointer; }
.pill span { font-size: 20px; }
.pill b { font-weight: 800; }
.pill.coin b { color: #e08a00; } .pill.gem b { color: #7a5cff; }
.mats-strip { position: absolute; top: calc(max(10px, env(safe-area-inset-top)) + 66px); left: 10px; display: flex; gap: 5px; flex-wrap: wrap; max-width: 70vw; }
.mat-chip { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,.92); border-radius: 12px; padding: 1px 8px 1px 4px; font-size: 12px; font-weight: 800; box-shadow: 0 3px 0 rgba(180,110,160,.2); }
.mat-chip i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.08); }
.mat-chip.low { background: #ffe0e4; color: #e0445e; animation: pulse 1s infinite; }
.side { position: absolute; right: 10px; top: calc(max(10px, env(safe-area-inset-top)) + 128px); display: flex; flex-direction: column; gap: 8px; }
.sbtn { width: 58px; height: 58px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; align-items: center; justify-content: center; position: relative; transition: transform .1s; }
.sbtn:active { transform: scale(.9) translateY(3px); }
.sbtn span { font-size: 26px; line-height: 1; }
.sbtn small { font-size: 9.5px; font-weight: 800; color: var(--ink2); line-height: 1.1; margin-top: 2px; }
.badge { position: absolute; top: -4px; right: -4px; min-width: 20px; height: 20px; border-radius: 10px; background: #ff4d6d; color: #fff; font-size: 12px; font-weight: 800; font-style: normal; display: none; place-items: center; padding: 0 5px; border: 2px solid #fff; animation: bob 1s infinite; }
.badge.show { display: grid; }
#tip { position: absolute; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 4px); transform: translateX(-50%) translateY(140%); background: #fff; border: 3px solid var(--pink); color: var(--ink); padding: 8px 16px; border-radius: 18px; font-weight: 800; font-size: 14px; box-shadow: var(--shadow); max-width: min(560px, calc(100vw - 130px)); text-align: center; transition: transform .35s cubic-bezier(.3,1.6,.5,1); pointer-events: none; }
#tip.show { transform: translateX(-50%) translateY(0); }
#hand-chip { position: absolute; left: 50%; top: calc(max(10px, env(safe-area-inset-top)) + 64px); transform: translateX(-50%) scale(0); background: #fff6d6; border: 3px solid var(--gold); padding: 4px 14px; border-radius: 16px; font-weight: 800; font-size: 13px; box-shadow: var(--shadow); white-space: nowrap; transition: transform .25s cubic-bezier(.3,1.6,.5,1); max-width: 64vw; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }
#hand-chip.show { transform: translateX(-50%) scale(1); }
#hand-chip i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin: 0 3px; vertical-align: -1px; }
#act-btn { position: absolute; right: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 8px); width: 86px; height: 86px; border-radius: 50%; background: linear-gradient(180deg, #fff, #ffe9f3); border: 4px solid #fff; box-shadow: 0 7px 0 #f2a6c8, 0 12px 26px rgba(255, 111, 168, .35); display: flex; flex-direction: column; align-items: center; justify-content: center; opacity: .75; transition: transform .1s, opacity .2s; }
#act-btn span { font-size: 34px; line-height: 1; }
#act-btn small { font-size: 11px; font-weight: 800; color: var(--pink2); white-space: nowrap; }
#act-btn.on { opacity: 1; background: linear-gradient(180deg, #ffb3d4, #ff6fa8); animation: bob 1.2s infinite; }
#act-btn.on small { color: #fff; }
#act-btn:active { transform: translateY(5px) scale(.95); box-shadow: 0 2px 0 #f2a6c8; }
.keys-hint { position: absolute; left: 12px; bottom: 10px; font-size: 11px; font-weight: 700; color: var(--ink2); background: rgba(255,255,255,.7); padding: 2px 10px; border-radius: 10px; pointer-events: none; }
@media (pointer: coarse) { .keys-hint { display: none; } }

/* ---------- toasts ---------- */
#toasts { position: fixed; top: calc(max(10px, env(safe-area-inset-top)) + 100px); left: 50%; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; width: min(92vw, 460px); }
.toast { background: #fff; padding: 8px 18px; border-radius: 18px; font-weight: 800; font-size: 14px; box-shadow: var(--shadow); animation: tin .35s cubic-bezier(.3,1.6,.5,1); text-align: center; border: 3px solid #e9dcf0; }
.toast.good { border-color: #8be0b5; background: #f0fff7; }
.toast.bad { border-color: #ffb0bd; background: #fff2f4; }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .4s; }

/* ---------- panel ---------- */
#panel { position: fixed; inset: 0; z-index: 30; display: none; place-items: center; background: rgba(110, 60, 110, .32); backdrop-filter: blur(3px); padding: 16px; }
#panel.show { display: grid; }
.pcard { width: min(560px, 100%); max-height: min(86vh, 760px); background: var(--cream); border-radius: 30px; border: 5px solid #fff; box-shadow: 0 10px 0 rgba(200, 120, 170, .35), 0 24px 60px rgba(120, 60, 110, .35); display: flex; flex-direction: column; overflow: hidden; }
.pcard.wide { width: min(860px, 100%); }
.pcard.pop { animation: popin .38s cubic-bezier(.3,1.5,.5,1); }
.phead { display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 8px 20px; background: linear-gradient(180deg, #ffb3d4, #ff8fbd); color: #fff; }
.phead h2 { margin: 0; font-size: 21px; text-shadow: 0 2px 0 rgba(200, 60, 120, .35); }
.x { width: 38px; height: 38px; border-radius: 50%; background: #fff; color: var(--pink2); font-weight: 900; font-size: 18px; box-shadow: 0 3px 0 rgba(200,60,120,.35); }
.ptabs { display: flex; gap: 6px; padding: 10px 12px 0; overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.ptab { background: #fff; border-radius: 14px; padding: 5px 13px; font-weight: 800; font-size: 13.5px; white-space: nowrap; box-shadow: 0 3px 0 rgba(180,110,160,.2); color: var(--ink2); }
.ptab.on { background: var(--pink); color: #fff; box-shadow: 0 3px 0 #e06a9c; }
.pbody { padding: 12px 14px 18px; overflow-y: auto; touch-action: pan-y; user-select: text; }
.pbody h3 { margin: 14px 0 6px; font-size: 16px; }
.pbody p { margin: 6px 0; }
.hint { color: var(--ink2); font-size: 13px; font-weight: 600; }
.center { text-align: center; }
.ok { color: #2fb57a; font-weight: 800; }
.warn { color: #e0445e; font-weight: 800; }
.lock { color: var(--ink2); font-weight: 800; font-size: 13px; white-space: nowrap; }
.loading { text-align: center; padding: 30px; color: var(--ink2); font-weight: 800; animation: pulse 1s infinite; }
.big { font-size: 36px; line-height: 1; width: 48px; text-align: center; flex-shrink: 0; }
.big2 { font-size: 64px; line-height: 1.1; animation: bob 2s infinite; }

.btn { background: #fff; border-radius: 16px; padding: 7px 16px; font-weight: 800; font-size: 14px; box-shadow: 0 4px 0 #e2cfe6; transition: transform .08s; white-space: nowrap; color: var(--ink); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #e2cfe6; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.buy { background: linear-gradient(180deg, #8ff0c4, #4fd39a); color: #fff; box-shadow: 0 4px 0 #2fa874; text-shadow: 0 1px 0 rgba(0,0,0,.15); }
.btn.gem { background: linear-gradient(180deg, #c9b3ff, #9a7bff); color: #fff; box-shadow: 0 4px 0 #6f52d9; }
.btn.danger { background: #fff0f2; color: #e0445e; box-shadow: 0 3px 0 #f5c2cb; margin-top: 12px; }
.btn.sm { padding: 4px 10px; font-size: 12.5px; }
.btn.xl { display: block; width: 100%; padding: 12px; font-size: 18px; margin: 10px 0 0; border-radius: 20px; }
.link { color: var(--pink2); font-weight: 800; text-decoration: underline; margin-top: 8px; font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.card { background: #fff; border-radius: 20px; padding: 12px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 3px; box-shadow: 0 4px 0 #f0dce9; }
.card b { font-size: 16px; } .card small { font-size: 12px; color: var(--ink2); font-weight: 600; min-height: 30px; }
.card .btn { margin-top: auto; width: 100%; }
.card.locked { filter: grayscale(.7); opacity: .7; }
.card.owned { background: #f0fff7; }
.tags { font-size: 12px; font-weight: 800; color: #7a5cff; }
.mats { display: flex; gap: 3px; margin: 2px 0 6px; }
.mats i, .dot { display: inline-block; width: 13px; height: 13px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.1); }
.dot { margin: 0 3px 0 6px; vertical-align: -1px; }
.pico { width: 64px; height: 56px; border-radius: 16px; background: linear-gradient(180deg, var(--c1), var(--c2)); display: grid; place-items: center; font-size: 30px; border: 3px solid #fff; box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.pico.lg { width: 90px; height: 80px; font-size: 44px; flex-shrink: 0; }
.pinfo { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 18px; padding: 9px 12px; box-shadow: 0 4px 0 #f0dce9; }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row .grow small { color: var(--ink2); font-weight: 600; font-size: 12.5px; }
.row.locked { opacity: .6; filter: grayscale(.6); }
.row.owned { background: #f6fff9; }
.row.rank { cursor: pointer; } .row.rank.me { background: #fff3c9; box-shadow: 0 4px 0 #f5d77d; }
.row.chest.ready { background: #f3ecff; animation: wiggle 1.4s infinite; }
.medal { font-size: 22px; font-weight: 800; width: 34px; text-align: center; color: var(--ink2); }
.val { font-size: 14px; white-space: nowrap; color: #e08a00; }
.spool { width: 40px; height: 40px; border-radius: 50%; background: radial-gradient(circle, #fff 0 5px, var(--c) 6px 100%); border: 4px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.08); flex-shrink: 0; }
.bar { height: 10px; background: #ffe3ef; border-radius: 6px; overflow: hidden; margin: 4px 0 2px; }
.bar.big { height: 14px; margin-bottom: 12px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb3d4, #ff6fa8); border-radius: 6px; }
.cgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.citem { background: #fff; border-radius: 18px; padding: 10px 6px; text-align: center; display: flex; flex-direction: column; align-items: center; position: relative; box-shadow: 0 4px 0 #f0dce9; }
.citem .ce { font-size: 42px; line-height: 1.1; }
.citem b { font-size: 13px; line-height: 1.2; } .citem small { font-size: 11px; color: var(--ink2); font-weight: 700; }
.citem.unk .ce { filter: brightness(0) opacity(.18); }
.citem.unk b { color: var(--ink2); }
.citem.shiny { background: linear-gradient(135deg, #fff9db, #ffe9f6, #e9f4ff); box-shadow: 0 4px 0 #f5d77d; }
.citem .sh { position: absolute; top: 4px; right: 6px; font-size: 11px; font-weight: 800; color: #e0a000; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.stats div { background: #fff; border-radius: 14px; padding: 7px 12px; display: flex; justify-content: space-between; gap: 8px; font-size: 14px; font-weight: 700; }
.stats.sm { grid-template-columns: 1fr 1fr; }
.dgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.dday { background: #fff; border-radius: 18px; padding: 8px 4px; text-align: center; box-shadow: 0 4px 0 #f0dce9; display: flex; flex-direction: column; align-items: center; }
.dday div { font-size: 30px; } .dday b { font-size: 12px; line-height: 1.2; } .dday small { font-weight: 800; color: var(--ink2); font-size: 11px; }
.dday.d7 { grid-column: span 2; background: linear-gradient(135deg, #fff3c9, #ffe3ef); }
.dday.done { opacity: 1; }
.dday.today { background: #ffe3ef; box-shadow: 0 0 0 3px var(--pink), 0 4px 0 #e06a9c; animation: wiggle 1.4s infinite; }
.bigcoin { font-size: 40px; font-weight: 800; color: #e08a00; margin: 6px 0; animation: bob 1s infinite; }
.lvbig { font-size: 80px; font-weight: 800; color: #fff; width: 140px; height: 140px; margin: 0 auto 8px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffd0e4, #ff6fa8); display: grid; place-items: center; text-shadow: 0 4px 0 rgba(200,60,120,.4); box-shadow: 0 8px 0 #e06a9c; animation: popin .6s cubic-bezier(.3,1.8,.5,1); }
.unl { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.unl span { background: #fff; border-radius: 12px; padding: 4px 10px; font-weight: 800; font-size: 13px; box-shadow: 0 3px 0 #f0dce9; }
.visit { text-align: center; }
.vrow { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.vrow.emo { font-size: 30px; }
.vp { width: 70px; padding: 4px; border-radius: 14px; background: linear-gradient(180deg, var(--c1), var(--c2)); font-size: 26px; display: flex; flex-direction: column; align-items: center; border: 3px solid #fff; }
.vp small { font-size: 10px; font-weight: 800; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
label { display: flex; flex-direction: column; font-weight: 800; font-size: 13px; margin-bottom: 8px; }
input:not([type=checkbox]) { border: 3px solid #f3d6e6; border-radius: 14px; padding: 8px 12px; font-size: 15px; font-weight: 700; color: var(--ink); background: #fff; outline: none; width: 100%; margin: 3px 0 6px; }
input:focus { border-color: var(--pink); }
label.toggle { flex-direction: row; align-items: center; gap: 8px; margin-top: 12px; font-size: 15px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--pink2); }
.avs { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 6px 0 10px; }
.av { width: 44px; height: 44px; border-radius: 14px; background: #fff; font-size: 26px; box-shadow: 0 3px 0 #f0dce9; transition: transform .1s; }
.av.on { background: #ffe3ef; box-shadow: 0 0 0 3px var(--pink), 0 3px 0 #e06a9c; transform: scale(1.1); }
.code { background: #fff; border: 3px dashed var(--lilac); border-radius: 14px; padding: 8px; font-family: ui-monospace, monospace; font-weight: 800; text-align: center; font-size: 15px; margin: 4px 0 6px; word-break: break-all; user-select: all; }

/* ---------- title screen ---------- */
#start { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; overflow-y: auto; touch-action: pan-y;
  background: radial-gradient(circle at 50% 120%, #ffd2e6 0, transparent 60%), linear-gradient(180deg, #bfe9ff 0%, #ffe3ef 70%); }
.sky span { position: fixed; font-size: 60px; opacity: .8; animation: drift 22s linear infinite; }
.sky span:nth-child(1) { top: 8%; left: -10%; } .sky span:nth-child(2) { top: 22%; left: -20%; animation-delay: -8s; font-size: 80px; }
.sky span:nth-child(3) { top: 60%; left: -15%; animation-delay: -15s; }
.sky span:nth-child(4) { top: 15%; right: 12%; animation: twinkle 2s infinite; font-size: 30px; left: auto; }
.sky span:nth-child(5) { bottom: 14%; left: 10%; animation: bob 2s infinite; font-size: 34px; }
.sky span:nth-child(6) { bottom: 22%; right: 8%; animation: twinkle 1.6s infinite; font-size: 34px; left: auto; }
.scard { position: relative; width: min(440px, 100%); background: rgba(255, 248, 240, .96); border-radius: 36px; border: 6px solid #fff; box-shadow: 0 12px 0 rgba(200, 120, 170, .35), 0 30px 80px rgba(120, 60, 110, .3); padding: 22px 22px 16px; text-align: center; animation: popin .6s cubic-bezier(.3,1.5,.5,1); }
.logo { display: flex; flex-direction: column; line-height: .95; margin-bottom: 4px; }
.logo .l1 { font-size: 30px; font-weight: 800; color: var(--pink2); }
.logo .l2 { font-size: 46px; font-weight: 800; color: #fff; -webkit-text-stroke: 0; text-shadow: 0 0 0 #ff6fa8, 3px 3px 0 #ff6fa8, -3px -3px 0 #ff6fa8, 3px -3px 0 #ff6fa8, -3px 3px 0 #ff6fa8, 0 7px 0 #e06a9c; letter-spacing: 1px; }
.hero-wrap { display: flex; justify-content: center; align-items: flex-end; gap: 16px; height: 120px; margin: 6px 0; }
.hero { font-size: 74px; animation: hop 1s infinite; }
.mini-printer { position: relative; width: 96px; height: 110px; }
.mp-top { position: absolute; top: 0; left: 4px; right: 4px; height: 82px; border: 8px solid #ff8fbd; border-bottom: 0; border-radius: 14px 14px 0 0; }
.mp-head { position: absolute; top: 26px; left: 30px; width: 24px; height: 16px; background: #ffd6e7; border: 3px solid #e06a9c; border-radius: 6px; animation: head 1.2s ease-in-out infinite alternate; }
.mp-obj { position: absolute; bottom: 30px; left: 0; right: 0; font-size: 34px; animation: grow 3s ease-in-out infinite; clip-path: inset(var(--c, 100%) 0 0 0); }
.mp-base { position: absolute; bottom: 0; left: 0; right: 0; height: 32px; background: linear-gradient(180deg, #ffd6e7, #ff8fbd); border-radius: 12px; border: 3px solid #fff; color: #5b4260; font-weight: 900; font-size: 15px; line-height: 24px; }
.sub { font-weight: 700; color: var(--ink2); font-size: 14px; margin: 4px 0 12px; }
.form { display: flex; flex-direction: column; }
.stats-line { display: block; color: var(--ink2); font-weight: 700; margin-top: 10px; min-height: 18px; }

/* ---------- animations ---------- */
@keyframes popin { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes tin { 0% { transform: translateY(-16px) scale(.8); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes hop { 0%, 100% { transform: translateY(0) scale(1, 1); } 40% { transform: translateY(-18px) scale(.95, 1.05); } 80% { transform: translateY(0) scale(1.08, .92); } }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-1.5deg); } 75% { transform: rotate(1.5deg); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes drift { from { transform: translateX(0); } to { transform: translateX(130vw); } }
@keyframes twinkle { 50% { transform: scale(.6) rotate(20deg); opacity: .4; } }
@keyframes head { from { left: 14px; } to { left: 52px; } }
@keyframes grow { 0% { --c: 100%; clip-path: inset(100% 0 0 0); } 80%, 100% { clip-path: inset(0 0 0 0); } }

@media (max-width: 520px) {
  .sbtn { width: 50px; height: 50px; border-radius: 16px; } .sbtn span { font-size: 22px; } .sbtn small { font-size: 8.5px; }
  .prof .ava { width: 40px; height: 40px; font-size: 26px; } .xp { width: 90px; }
  .pill { font-size: 15px; min-width: 84px; }
  #act-btn { width: 76px; height: 76px; } #act-btn span { font-size: 30px; }
  .grid { grid-template-columns: 1fr 1fr; } .card { padding: 9px; }
  .dgrid { grid-template-columns: repeat(4, 1fr); gap: 5px; }
  #panel { padding: 8px; }
  .pcard { max-height: 90vh; }
}

/* ---------- custom icons ---------- */
.ic { width: 1.2em; height: 1.2em; display: inline-block; vertical-align: -0.28em; flex-shrink: 0; overflow: visible; }
.big .ic, .big2 .ic, .ce .ic, .hero .ic, .av .ic, .ava .ic, .sbtn > span .ic, #act-btn > span .ic, .pill > span .ic, .dday div .ic, .vrow .ic, .vp .ic, .pico .ic, .lvbig .ic, .medal .ic { width: 1em; height: 1em; vertical-align: middle; }
.sbtn > span, #act-btn > span, .pill > span { display: grid; place-items: center; }
.hero .ic { width: 96px; height: 96px; }
.ava .ic { width: 34px; height: 34px; }
.av .ic { width: 32px; height: 32px; }
.x .ic { width: 22px; height: 22px; vertical-align: middle; }
.pico .ic { width: 70%; height: 70%; }
.big2 .ic { width: 80px; height: 80px; }
.vrow.emo .ic { width: 40px; height: 40px; }
.toast .ic { width: 1.35em; height: 1.35em; }
.pill.rate b { color: #f0a000; }
.meter { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; margin: 3px 0; }
.meter span { width: 120px; flex-shrink: 0; } .meter .bar { flex: 1; margin: 0; } .meter b { width: 38px; text-align: right; }
.pinfo .grow { flex: 1; min-width: 0; }
.sgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.sitem { background: #fff; border-radius: 16px; padding: 8px 6px; display: flex; flex-direction: column; align-items: center; box-shadow: 0 4px 0 #f0dce9; transition: transform .1s; }
.sitem:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #f0dce9; }
.sitem:disabled { opacity: .45; cursor: default; }
.sitem .ce { font-size: 34px; line-height: 1.1; } .sitem b { font-size: 12.5px; line-height: 1.2; } .sitem small { font-size: 11px; color: var(--ink2); font-weight: 700; }
.sitem .price { color: #e08a00; }
.rating-head { display: flex; align-items: center; gap: 14px; }
.rbig { font-size: 52px; font-weight: 800; color: #f0a000; line-height: 1; }
.rbars div { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; }
.rbars .bar { flex: 1; margin: 2px 0; } .rbars span { width: 34px; } .rbars small { width: 24px; text-align: right; }
.dim { opacity: .25; }
.review .stars { font-size: 13px; } .review small { font-style: italic; }
.kind { font-size: 10.5px; background: #f3ecff; color: #7a5cff; padding: 1px 7px; border-radius: 8px; margin-left: 4px; font-weight: 800; }
@media (max-width: 560px) {
  .side { top: auto; bottom: max(8px, env(safe-area-inset-bottom)); left: 6px; right: 6px; flex-direction: row; justify-content: space-between; gap: 4px; background: rgba(255,255,255,.75); backdrop-filter: blur(6px); padding: 5px; border-radius: 20px; box-shadow: var(--shadow); }
  .sbtn { width: auto; flex: 1; height: 48px; border-radius: 14px; box-shadow: none; background: transparent; }
  .sbtn span { font-size: 22px; } .sbtn small { font-size: 8.5px; }
  #act-btn { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 70px); right: 12px; }
  #tip { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 72px); max-width: calc(100vw - 120px); left: 10px; transform: translateY(160%); font-size: 12.5px; }
  #tip.show { transform: none; }
  .pills { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; max-width: 46vw; gap: 4px; }
  .pill { min-width: 0; padding: 2px 10px 2px 4px; font-size: 14px; }
  .prof { max-width: 52vw; padding-right: 10px; }
  #toasts { top: calc(max(10px, env(safe-area-inset-top)) + 96px); }
}

/* ---------- wide screens: HUD lives in the side columns, shop fully visible ---------- */
body.wide #tip { left: 16px; right: auto; bottom: auto; top: 150px; transform: translateX(-120%); width: calc(var(--side) - 40px); max-width: 360px; text-align: left; font-size: 15px; padding: 12px 16px; transition: transform .35s cubic-bezier(.3,1.6,.5,1); }
body.wide #tip.show { transform: none; }
body.wide #tip::before { content: 'Hướng dẫn'; display: block; font-size: 12px; color: var(--pink2); text-transform: uppercase; letter-spacing: .5px; }
body.wide #hand-chip { left: 16px; top: auto; bottom: 60px; transform: scale(0); transform-origin: left center; width: calc(var(--side) - 40px); max-width: 360px; white-space: normal; font-size: 14px; padding: 10px 14px; }
body.wide #hand-chip.show { transform: scale(1); }
body.wide #toasts { left: calc(var(--side) / 2); top: auto; bottom: 120px; transform: translateX(-50%); width: calc(var(--side) - 40px); max-width: 360px; flex-direction: column-reverse; }
body.wide .keys-hint { font-size: 12.5px; }
.mat-chip { font-size: 13px; padding: 2px 10px 2px 5px; }
/* ---------- customer dialog ---------- */
.talk { display: flex; gap: 12px; align-items: flex-start; }
.portrait { position: relative; width: 84px; height: 84px; flex-shrink: 0; background: radial-gradient(circle at 50% 40%, #fff, #ffe3ef); border-radius: 24px; display: grid; place-items: center; border: 3px solid #fff; box-shadow: 0 4px 0 #f0dce9; }
.portrait .ic { width: 70px; height: 70px; vertical-align: middle; }
.vipb { position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%); background: #ffcf5c; color: #7a4a00; font-size: 11px; font-weight: 800; padding: 0 8px; border-radius: 8px; border: 2px solid #fff; }
.speech { flex: 1; background: #fff; border-radius: 18px; padding: 8px 14px; position: relative; box-shadow: 0 4px 0 #f0dce9; border: 2px solid #5b426022; }
.speech::before { content: ''; position: absolute; left: -10px; top: 24px; border: 8px solid transparent; border-right-color: #fff; border-left: 0; }
.speech p { margin: 4px 0; }
.req { font-size: 15px; }
.tags2 { display: flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.tags2 span { font-size: 12px; font-weight: 800; padding: 2px 10px; border-radius: 10px; }
.t-rush { background: #fff2c2; color: #b07800; } .t-picky { background: #f3ecff; color: #7a5cff; } .t-pay { background: #e6fff2; color: #1f9d63; }
.chks { display: flex; flex-direction: column; gap: 4px; }
.chk { background: #fff; border-radius: 12px; padding: 6px 12px; font-weight: 700; font-size: 13.5px; border-left: 5px solid #4fd39a; }
.chk.bad { border-left-color: #ff5d6c; background: #fff4f5; } .chk.warnc { border-left-color: #ffb43c; background: #fffaf0; }
.reasons { display: flex; flex-direction: column; gap: 6px; }
.btn.reason { white-space: normal; text-align: left; font-weight: 700; padding: 9px 14px; }
.btn.reason small { display: block; color: var(--ink2); font-size: 11.5px; }
.btn.reason.danger small { color: #e0445e; }

/* =====================================================================
   HAND-DRAWN STICKER THEME — every UI piece gets ink outline + solid drop
   ===================================================================== */
:root { --ink: #5b4260; --ink2s: #b9adc0; }
.btn, .card, .row, .citem, .sitem, .dday, .stats div, .chk, .speech, .portrait, .pill, .sbtn, .prof, .mat-chip,
.toast, #tip, #hand-chip, .ptab, .av, .x, .code, .unl span, .vp, .spool, .pico {
  border: 2.5px solid var(--ink) !important;
}
.pill, .sbtn, .prof, #tip, #hand-chip, .toast { box-shadow: 0 4px 0 var(--ink) !important; }
.card, .row, .citem, .sitem, .dday, .speech, .portrait { box-shadow: 0 4px 0 var(--ink) !important; }
.stats div, .chk, .unl span { box-shadow: 0 3px 0 var(--ink) !important; }
.mat-chip, .ptab, .av { box-shadow: 0 3px 0 var(--ink) !important; }
.prof .ava { border: 2.5px solid var(--ink); box-shadow: none; }
.prof .lv { border: 2px solid var(--ink); }
.badge { border: 2px solid var(--ink); }

/* panel */
#panel { background: rgba(70, 40, 80, .45); }
.pcard { border: 3px solid var(--ink) !important; box-shadow: 0 8px 0 var(--ink), 0 24px 60px rgba(60, 30, 70, .35) !important; background: #fff8ef; }
.phead { background: #ff8fbd; border-bottom: 3px solid var(--ink); }
.phead h2 { color: #fff; text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 4px 0 var(--ink); letter-spacing: .3px; }
.x { background: #fff; box-shadow: 0 3px 0 var(--ink) !important; }
.ptabs { padding: 12px 12px 4px; }
.ptab { background: #fff; color: var(--ink); }
.ptab.on { background: #ffcf5c; color: var(--ink); box-shadow: 0 3px 0 var(--ink) !important; transform: translateY(-1px); }
.pbody { background-image: radial-gradient(rgba(91,66,96,.06) 1.2px, transparent 1.2px); background-size: 18px 18px; }

/* buttons */
.btn { background: #fff; color: var(--ink); font-weight: 800; box-shadow: 0 4px 0 var(--ink) !important; border-radius: 14px; padding: 7px 16px; transition: transform .07s, box-shadow .07s; }
.btn:hover:not(:disabled) { filter: brightness(1.04); transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink) !important; }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink) !important; }
.btn.buy { background: #4fd39a; color: #fff; text-shadow: 0 2px 0 rgba(40, 90, 60, .55); }
.btn.gem { background: #9a7bff; color: #fff; text-shadow: 0 2px 0 rgba(60, 30, 120, .5); }
.btn.poor { background: #fff; color: #e0445e; }
.btn.poor::after { content: ' · chưa đủ'; font-size: .8em; opacity: .8; }
.btn:disabled { background: #ece6ef !important; color: #9a8ba3 !important; border-color: var(--ink2s) !important; box-shadow: 0 3px 0 var(--ink2s) !important; text-shadow: none; opacity: 1; }
.btn.danger { background: #ffe1e6; color: #d23a55; }
.btn.xl { border-radius: 18px; padding: 12px; font-size: 18px; }
.btn.reason { background: #fff; }
.btn.reason.danger { background: #ffe9ec; }
.link { color: var(--pink2); }

/* cards & rows */
.card { background: #fff; border-radius: 22px; }
.card b { font-size: 17px; color: var(--ink); }
.card small { color: #8a7092; }
.card.locked { filter: none; opacity: 1; background: #f6f1f8; }
.card.locked .pico, .card.locked .big { filter: grayscale(.8); opacity: .7; }
.card.owned { background: #e9fff3; }
.row { background: #fff; border-radius: 18px; }
.row.locked { filter: none; opacity: 1; background: #f6f1f8; }
.row.locked .big { filter: grayscale(.8); opacity: .6; }
.row.owned { background: #eefff6; }
.citem.unk { background: #f6f1f8; }
.pico { box-shadow: 0 3px 0 var(--ink) !important; border-radius: 18px; }
.tags { color: #6c4fe0; }
.mats i, .dot { border: 2px solid var(--ink); box-shadow: none; }
.bar { border: 2px solid var(--ink); height: 12px; background: #fff; }
.bar i { border-radius: 4px; }
.hint { color: #8a7092; }
input:not([type=checkbox]) { border: 2.5px solid var(--ink); box-shadow: inset 0 3px 0 rgba(91,66,96,.08); }
input:focus { border-color: var(--pink2); }
.dday.today { background: #ffe3ef; box-shadow: 0 4px 0 var(--pink2) !important; border-color: var(--pink2) !important; }

/* HUD */
.sbtn { background: #fff; }
.sbtn:hover { transform: translateY(-2px); }
.sbtn small { color: var(--ink); }
.pill b { font-weight: 800; }
#act-btn { border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink) !important; background: #fff; opacity: .9; }
#act-btn.on { background: #ff8fbd; }
#act-btn.on small { color: #fff; text-shadow: 0 1px 0 var(--ink); }
#act-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink) !important; }
.toast.good { background: #eafff4; } .toast.bad { background: #fff0f2; }
#tip { border-color: var(--ink) !important; }
.keys-hint { border: 2px solid var(--ink2s); }

/* title screen */
.scard { border: 3px solid var(--ink); box-shadow: 0 10px 0 var(--ink), 0 30px 80px rgba(120,60,110,.3); }
.logo .l2 { text-shadow: 0 0 0 var(--ink), 3px 3px 0 var(--ink), -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 0 7px 0 var(--ink); }
.logo .l1 { color: var(--pink2); }
.av.on { background: #ffcf5c; box-shadow: 0 3px 0 var(--ink) !important; }
@media (max-width: 560px) { .side { border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); } .sbtn { border: 0 !important; box-shadow: none !important; } }
/* hand chip with drop button */
#hand-chip { pointer-events: auto !important; display: flex; align-items: center; gap: 10px; white-space: normal; }
#hand-chip .hc-t { flex: 1; min-width: 0; }
#hand-chip .drop { flex-shrink: 0; background: #fff; padding: 4px 10px; font-size: 12.5px; }
#hand-chip kbd { font-family: inherit; font-size: 10px; background: #f3ecff; border: 1.5px solid var(--ink); border-radius: 5px; padding: 0 4px; margin-left: 3px; }
@media (pointer: coarse) { #hand-chip kbd { display: none; } }
/* breathing room */
.pbody { padding: 16px 18px 22px; line-height: 1.45; }
.pbody h3 { margin: 20px 0 10px; }
.talk { gap: 18px; margin: 4px 0 18px; align-items: center; }
.speech { padding: 12px 18px; }
.speech p { margin: 6px 0; line-height: 1.5; }
.tags2 { margin: 10px 0 4px; gap: 8px; }
.pat { display: flex; align-items: center; gap: 12px; margin: 0 0 6px; font-weight: 800; font-size: 13px; }
.pat span { white-space: nowrap; }
.pat .bar { flex: 1; margin: 0; }
.chks { gap: 8px; }
.chk { padding: 8px 14px; }
.reasons { gap: 10px; }
.list { gap: 12px; }
.row { padding: 11px 14px; gap: 12px; }
.grid, .cgrid, .sgrid { gap: 14px; }
.btn.xl { margin: 16px 0 4px; }
.pinfo { gap: 18px; margin-bottom: 14px; }
.meter { margin: 6px 0; }
.btn.risky { background: #fff4d6; color: #b07800; }
/* the transparent HUD rows must never swallow taps meant for the shop below */
#hud > .top, #hud > .mats-strip { pointer-events: none !important; }
#hud > .top > *, #hud > .mats-strip > * { pointer-events: auto; }

/* ---------- compact modals ---------- */
.pcard { width: min(500px, 100%); max-height: min(82vh, 680px); border-radius: 24px; }
.pcard.wide { width: min(720px, 100%); }
.phead { padding: 8px 10px 8px 16px; }
.phead h2 { font-size: 18px; }
.x { width: 32px; height: 32px; font-size: 15px; }
.x .ic { width: 18px; height: 18px; }
.ptabs { padding: 10px 12px 2px; gap: 6px; }
.ptab { padding: 3px 11px; font-size: 12.5px; border-radius: 12px; }
.pbody { padding: 12px 14px 16px; line-height: 1.35; font-size: 14px; }
.pbody h3 { margin: 14px 0 7px; font-size: 14.5px; }
.pbody p { margin: 4px 0; }
.hint { font-size: 12px; }
.list { gap: 8px; }
.row { padding: 7px 10px; gap: 10px; border-radius: 14px; }
.row .grow b { font-size: 14px; }
.row .grow small { font-size: 11.5px; }
.big { font-size: 26px; width: 34px; }
.grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.card { padding: 10px 8px; gap: 2px; border-radius: 18px; }
.card b { font-size: 15px; }
.card small { font-size: 11px; min-height: 0; line-height: 1.3; }
.card .btn { margin-top: 6px; }
.pico { width: 48px; height: 42px; border-radius: 14px; }
.pico.lg { width: 66px; height: 58px; }
.cgrid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.citem .ce { font-size: 34px; }
.sgrid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; }
.sitem .ce { font-size: 28px; }
.btn { padding: 5px 12px; font-size: 13px; border-radius: 12px; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.xl { padding: 9px; font-size: 16px; margin: 12px 0 2px; border-radius: 15px; }
.talk { gap: 12px; margin: 0 0 12px; }
.portrait { width: 64px; height: 64px; border-radius: 18px; }
.portrait .ic { width: 52px; height: 52px; }
.speech { padding: 8px 12px; }
.speech p { margin: 3px 0; line-height: 1.4; }
.req { font-size: 14px; }
.tags2 { margin: 6px 0 2px; }
.chks { gap: 5px; }
.chk { padding: 5px 10px; font-size: 12.5px; border-left-width: 4px; }
.reasons { gap: 6px; }
.btn.reason { padding: 6px 12px; font-size: 13px; }
.pinfo { gap: 12px; margin-bottom: 8px; }
.meter { margin: 3px 0; font-size: 12px; }
.meter span { width: 110px; }
.stats { gap: 5px; } .stats div { padding: 5px 10px; font-size: 13px; }
.dgrid { gap: 6px; margin: 8px 0; } .dday div { font-size: 24px; }
.lvbig { width: 110px; height: 110px; font-size: 62px; }
.big2 { font-size: 48px; } .big2 .ic { width: 60px; height: 60px; }
.bigcoin { font-size: 32px; }
.bar { height: 10px; }

/* =========== DESKTOP 3-COLUMN LAYOUT (nothing overlaps the shop) =========== */
body.wide .top { left: 12px; right: 12px; }
body.wide .prof { width: calc(var(--side) - 12px); max-width: none; }
body.wide .pinfo2 { flex: 1; }
body.wide .xp { width: 100%; }
body.wide .pills { position: fixed; right: 12px; top: 12px; width: calc(var(--rside) - 12px); flex-direction: column; align-items: stretch; gap: 8px; }
body.wide .pill { width: 100%; min-width: 0; justify-content: flex-start; }
body.wide .mats-strip { top: 84px; left: 12px; max-width: calc(var(--side) - 12px); }
body.wide .side { position: fixed; right: 12px; top: 150px; width: calc(var(--rside) - 12px); display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
body.wide .sbtn { width: 100%; height: 58px; }
body.wide #tip { left: 12px; top: 150px; width: calc(var(--side) - 12px); max-width: none; font-size: 14px; }
body.wide #hand-chip { left: 12px; bottom: 56px; width: calc(var(--side) - 12px); max-width: none; }
body.wide #toasts { left: calc(var(--side) / 2 + 6px); bottom: 150px; width: calc(var(--side) - 12px); max-width: none; }
body.wide .keys-hint { left: 12px; bottom: 12px; width: calc(var(--side) - 12px); white-space: normal; line-height: 1.35; padding: 4px 10px; }
@media (pointer: fine) { body.wide #act-btn { display: none; } }
body.wide #act-btn { right: 12px; bottom: 12px; width: 76px; height: 76px; }
body:not(.wide) .keys-hint { display: none !important; }
/* any non-wide layout: menu becomes a bottom bar, coins row on top-right */
body:not(.wide) .side { top: auto !important; bottom: max(8px, env(safe-area-inset-bottom)); left: 6px; right: 6px; flex-direction: row; justify-content: space-between; gap: 4px; background: rgba(255,255,255,.92); padding: 5px; border-radius: 20px; border: 2.5px solid var(--ink); box-shadow: 0 4px 0 var(--ink); max-width: 640px; margin: 0 auto; }
body:not(.wide) .sbtn { width: auto; flex: 1; height: 48px; border-radius: 14px; box-shadow: none !important; border: 0 !important; background: transparent; }
body:not(.wide) .sbtn span { font-size: 22px; } body:not(.wide) .sbtn small { font-size: 9px; }
body:not(.wide) #act-btn { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 70px); right: 12px; width: 72px; height: 72px; }
body:not(.wide) #tip { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 70px); left: 10px; right: auto; transform: translateY(160%); max-width: calc(100vw - 110px); font-size: 12.5px; padding: 6px 12px; }
body:not(.wide) #tip.show { transform: none; }
body:not(.wide) .pills { flex-direction: row; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 50vw; }
body:not(.wide) .pill { min-width: 0; padding: 2px 10px 2px 4px; font-size: 14px; }
/* filament chips living inside the top-right pills row (narrow layouts) */
body:not(.wide) .pills { max-width: 64vw; align-items: center; }
.pills .mats-strip { position: static !important; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: none; pointer-events: auto; }
.pills .mat-chip { font-size: 12px; padding: 1px 8px 1px 4px; }
/* tabs: wrap instead of hidden horizontal scroll */
.ptabs { flex-wrap: wrap; overflow: visible; row-gap: 8px; touch-action: auto; }
.ptab { flex: 0 0 auto; }
.pbody { touch-action: pan-y; }
/* held-item card: one tidy line in a reserved slot above the bottom bar (narrow layouts) */
#hand-chip .hc-t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
body:not(.wide) #hand-chip { left: 10px; right: 96px; top: auto; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 70px); width: auto; max-width: none; transform: translateY(20px) scale(.9); opacity: 0; transition: transform .25s, opacity .2s; white-space: nowrap; padding: 6px 8px 6px 12px; font-size: 13px; pointer-events: none; }
body:not(.wide) #hand-chip.show { transform: none; opacity: 1; pointer-events: auto; }
body:not(.wide) #tip { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 122px); }
body.wide #hand-chip .hc-t { white-space: normal; }

/* =================== MODALS: fit the screen & fill the space =================== */
#panel { padding: 12px; }
.pcard { width: min(600px, 96vw); max-height: min(88vh, 760px); }
.pcard.wide { width: min(820px, 96vw); }
.pbody { display: flex; flex-direction: column; gap: 0; overflow-y: auto; }
.pbody > * { width: 100%; }
.pbody > .btn.sm, .pbody > .btn.danger { width: auto; align-self: flex-start; }
.ptabs { display: flex; flex-wrap: wrap; gap: 6px; }
.ptab { flex: 1 1 auto; text-align: center; justify-content: center; display: inline-flex; align-items: center; gap: 4px; }
/* grids stretch to fill each row, equal-height cards with the button at the bottom */
.grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: stretch; }
.card { height: 100%; justify-content: flex-start; }
.card .btn { margin-top: auto; width: 100%; }
.card small { flex: 0 0 auto; }
.cgrid { grid-template-columns: repeat(auto-fit, minmax(104px, 1fr)); }
.citem { height: 100%; justify-content: center; }
.sgrid { grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); }
.sitem { height: 100%; }
/* list rows: content grows, actions hug the right edge */
.row { width: 100%; }
.row > .btn, .row > .ok, .row > .lock { flex-shrink: 0; margin-left: auto; }
.row .grow { flex: 1 1 auto; }
.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.dgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.center .btn.xl, .visit .btn.xl { width: 100%; }
.chks .chk, .reasons .btn { width: 100%; }
.talk .speech { min-width: 0; }
label, input:not([type=checkbox]) { width: 100%; }
.pinfo { width: 100%; }
.pinfo .grow { min-width: 0; }
@media (max-width: 560px) {
  #panel { padding: 6px; align-items: end; }
  .pcard, .pcard.wide { width: 100%; max-height: 90vh; border-radius: 22px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cgrid, .sgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stats { grid-template-columns: 1fr 1fr; }
  .ptab { font-size: 12px; padding: 3px 8px; }
}
.pcard.wide .grid { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); } @media (max-width: 560px) { .pcard.wide .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* an empty / hidden tutorial tip must not leave a ghost pill behind */
#tip:not(.show) { opacity: 0; visibility: hidden; pointer-events: none; }
#tip:empty { display: none; }
.row.bug input { margin: 6px 0 0; font-size: 13px; padding: 6px 10px; }

/* claimed day: faded content + custom 'Đã nhận' stamp */
.dday { position: relative; overflow: hidden; }
.dday.done > small, .dday.done > div:not(.stamp), .dday.done > b { opacity: .38; filter: grayscale(.4); }
.dday .stamp { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; pointer-events: none; }
.dday .stamp .ic { width: 30px; height: 30px; filter: drop-shadow(0 2px 0 rgba(91,66,96,.35)); }
.dday .stamp span { background: #4fd39a; color: #fff; font-weight: 900; font-size: 10.5px; padding: 1px 8px; border-radius: 8px; border: 2px solid var(--ink); transform: rotate(-8deg); letter-spacing: .3px; }

/* ---------- round 2 UI fixes ---------- */
#h-mats { display: none !important; }
/* crisp outlined titles (no jagged multi-shadow) */
.phead h2 { text-shadow: none !important; -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; color: #fff; }
.logo .l2 { text-shadow: 0 6px 0 var(--ink) !important; -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; }
.ptab.on, .btn:hover:not(:disabled), .sbtn:hover { transform: none !important; }
/* action button: label always fits inside the circle */
#act-btn small { white-space: normal !important; font-size: 10px; line-height: 1.05; max-width: 62px; text-align: center; display: block; overflow: hidden; }
#act-btn span .ic { width: 28px; height: 28px; }
/* open / closed toggle */
.pill.shop-state { font: inherit; font-weight: 800; font-size: 13px; color: #1f9d63; cursor: pointer; padding: 3px 12px 3px 8px; }
.pill.shop-state .ic { width: 18px; height: 18px; }
.pill.shop-state.closed { color: #e0445e; background: #fff0f2; }
body.wide .pill.shop-state { width: 100%; justify-content: flex-start; }
/* zoom buttons */
.zoomctl { position: absolute; display: flex; flex-direction: column; gap: 6px; right: 14px; bottom: calc(max(8px, env(safe-area-inset-bottom)) + 156px); z-index: 2; }
.zoomctl button { width: 38px; height: 38px; border-radius: 12px; background: #fff; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); font-weight: 900; font-size: 20px; color: var(--ink); line-height: 1; }
.zoomctl button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
body.wide .zoomctl { right: calc(var(--rside) + 12px); bottom: 16px; }

/* action button removed: tap objects directly (keyboard: Space) */
#act-btn { display: none !important; }
body:not(.wide) .zoomctl { bottom: calc(max(8px, env(safe-area-inset-bottom)) + 76px); right: 12px; }
body:not(.wide) #hand-chip { right: 62px; }
body:not(.wide) #tip { max-width: calc(100vw - 80px); }

/* ---------- custom cursors: arrow = walk here, pointing hand = interact, fist = dragging the map ---------- */
#cv { cursor: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%2732%27%20height%3D%2732%27%20viewBox%3D%270%200%2032%2032%27%3E%3Cpath%20d%3D%27M4%203%20L4%2025%20L10%2019.5%20L14.5%2029%20L19%2027%20L14.6%2017.8%20L22.5%2017.5%20Z%27%20fill%3D%27%23ff8fbd%27%20stroke%3D%27%235b4260%27%20stroke-width%3D%272.4%27%20stroke-linejoin%3D%27round%27/%3E%3Cpath%20d%3D%27M7%208%20L7%2014%27%20stroke%3D%27%23fff%27%20stroke-width%3D%272%27%20stroke-linecap%3D%27round%27%20opacity%3D%27.8%27/%3E%3C/svg%3E") 4 3, default !important; }
#cv.cur-hit { cursor: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%2732%27%20height%3D%2732%27%20viewBox%3D%270%200%2032%2032%27%3E%3Cpath%20d%3D%27M11%203.5c1.6%200%202.8%201.2%202.8%202.8v8.2l1.4-.3c1.4-.3%202.6.5%202.9%201.6l1.6-.2c1.3-.1%202.5.7%202.7%201.9l1.3-.1c1.5-.1%202.8%201.1%202.8%202.6v3.5c0%204.4-3.6%208-8%208h-3.2c-2.6%200-5-1.3-6.4-3.4L4.4%2021c-.9-1.3-.5-3%20.8-3.8%201.1-.7%202.6-.5%203.5.5l.7.8V6.3c0-1.6%201.2-2.8%202.8-2.8z%27%20fill%3D%27%23fff1e2%27%20stroke%3D%27%235b4260%27%20stroke-width%3D%272.2%27%20stroke-linejoin%3D%27round%27/%3E%3Cpath%20d%3D%27M14%2015v5M18%2016v4M22%2017.5v3%27%20stroke%3D%27%235b4260%27%20stroke-width%3D%271.6%27%20stroke-linecap%3D%27round%27%20opacity%3D%27.55%27/%3E%3C/svg%3E") 11 3, pointer !important; }
#cv.cur-drag { cursor: url("data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%27http%3A//www.w3.org/2000/svg%27%20width%3D%2732%27%20height%3D%2732%27%20viewBox%3D%270%200%2032%2032%27%3E%3Cpath%20d%3D%27M8%2013c0-1.5%201.2-2.6%202.6-2.6S13%2011.5%2013%2013v-1.5c0-1.4%201.2-2.6%202.6-2.6s2.6%201.2%202.6%202.6V13c0-1.4%201.2-2.5%202.6-2.5S23.4%2011.6%2023.4%2013v1c0-1.3%201.1-2.4%202.4-2.4%201.3%200%202.4%201.1%202.4%202.4V20c0%205-4%209-9%209h-2.4c-3%200-5.8-1.6-7.3-4.2L6%2019.5c-.7-1.2-.3-2.8.9-3.5%201-.6%202.3-.4%203.1.4%27%20fill%3D%27%23ffcf5c%27%20stroke%3D%27%235b4260%27%20stroke-width%3D%272.2%27%20stroke-linejoin%3D%27round%27/%3E%3C/svg%3E") 16 16, grabbing !important; }
#h-shop { display: none !important; }

.staffcap { display: flex; flex-direction: column; gap: 2px; background: #fff6d6; border: 2.5px solid var(--ink); box-shadow: 0 3px 0 var(--ink); border-radius: 14px; padding: 8px 12px; margin-bottom: 8px; }
.staffcap b { font-size: 15px; } .staffcap span { font-size: 12px; color: #8a7092; font-weight: 700; }

/* ---------- sliding tab bar ---------- */
.ptabs-wrap { position: relative; display: flex; align-items: center; padding: 10px 6px 4px; gap: 4px; }
.ptabs { flex: 1; display: flex !important; flex-wrap: nowrap !important; overflow-x: auto !important; overflow-y: hidden; gap: 8px; padding: 2px 4px 6px !important; scroll-behavior: smooth; scrollbar-width: none; scroll-snap-type: x proximity; touch-action: pan-x !important; cursor: grab; -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%); mask-image: linear-gradient(90deg, transparent 0, #000 18px, #000 calc(100% - 18px), transparent 100%); }
.ptabs::-webkit-scrollbar { display: none; }
.ptabs.dragging { cursor: grabbing; scroll-behavior: auto; }
.ptabs .ptab { flex: 0 0 auto !important; scroll-snap-align: center; white-space: nowrap; }
.tabnav { flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; background: #fff; border: 2.5px solid var(--ink); box-shadow: 0 2px 0 var(--ink); font-weight: 900; font-size: 18px; line-height: 1; color: var(--ink); display: grid; place-items: center; padding: 0 0 2px; opacity: .25; pointer-events: none; transition: opacity .15s; }
.ptabs-wrap.can-prev .tabnav.prev, .ptabs-wrap.can-next .tabnav.next { opacity: 1; pointer-events: auto; }
.tabnav:active { transform: translateY(2px); box-shadow: none; }

/* ---------- thinner hand-drawn outlines ---------- */
.btn, .card, .row, .citem, .sitem, .dday, .stats div, .chk, .speech, .portrait, .pill, .sbtn, .prof, .mat-chip,
.toast, #tip, #hand-chip, .ptab, .av, .x, .code, .unl span, .vp, .spool, .pico, .tabnav, .zoomctl button, .staffcap,
input:not([type=checkbox]), .bar, .side, .badge, .prof .ava, .prof .lv { border-width: 1.8px !important; }
.pcard { border-width: 2.2px !important; box-shadow: 0 6px 0 var(--ink), 0 20px 50px rgba(60, 30, 70, .3) !important; }
.phead { border-bottom-width: 2.2px; }
.btn { box-shadow: 0 3px 0 var(--ink) !important; }
.btn:active:not(:disabled) { box-shadow: 0 1px 0 var(--ink) !important; }
.pill, .sbtn, .prof, #tip, #hand-chip, .toast, .card, .row, .citem, .sitem, .dday, .speech, .portrait, .staffcap { box-shadow: 0 3px 0 var(--ink) !important; }
.stats div, .chk, .unl span, .mat-chip, .ptab, .av, .tabnav, .zoomctl button, .x { box-shadow: 0 2px 0 var(--ink) !important; }
.phead h2 { -webkit-text-stroke-width: 4px; }
.scard { border-width: 2.2px; box-shadow: 0 8px 0 var(--ink), 0 30px 80px rgba(120,60,110,.3); }
.dday .stamp span { border-width: 1.5px; }
/* material rows: top line = spool + name, bottom line = actions */
.row.matrow { flex-direction: column; align-items: stretch; gap: 8px; }
.row.matrow .mhead { display: flex; align-items: center; gap: 10px; }
.row.matrow .mhead .grow { flex: 1; min-width: 0; }
.row.matrow .macts { display: flex; gap: 8px; }
.row.matrow .macts .btn { flex: 1; margin: 0; white-space: nowrap; }

/* profile card = settings entry (gear + cloud-sync badges) */
.prof { position: relative; padding-right: 30px !important; }
.prof .prof-gear { position: absolute; top: 6px; right: 8px; width: 20px; height: 20px; display: grid; place-items: center; }
.prof .prof-gear .ic { width: 18px; height: 18px; }
.prof .prof-cloud { position: absolute; bottom: 6px; right: 8px; width: 18px; height: 18px; display: grid; place-items: center; }
.prof .prof-cloud .ic { width: 16px; height: 16px; }
/* in-game confirm dialog */
#confirm { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; background: rgba(70, 40, 80, .45); padding: 16px; }
#confirm.show { display: grid; }
#confirm .cbox { width: min(360px, 100%); background: #fff8ef; border: 2.2px solid var(--ink); border-radius: 22px; box-shadow: 0 6px 0 var(--ink); padding: 18px 16px 14px; text-align: center; }
#confirm .cbox.pop { animation: popin .3s cubic-bezier(.3,1.5,.5,1); }
#confirm p { margin: 0 0 14px; font-weight: 800; font-size: 15px; line-height: 1.45; color: var(--ink); }
#confirm .cacts { display: flex; gap: 10px; }
#confirm .cacts .btn { flex: 1; padding: 9px; font-size: 15px; }
.btn.danger.solid { background: #ff5d6c !important; color: #fff !important; }
/* wide layout: keep the held-item card clear of the key-hint box */
body.wide .keys-hint { bottom: 14px; }
body.wide #hand-chip { bottom: 92px; }
body.wide #toasts { bottom: 200px; }
/* bug report box */
.bugbox { background: #fff; border: 1.8px solid var(--ink); box-shadow: 0 3px 0 var(--ink); border-radius: 16px; padding: 12px; margin: 0 0 18px; display: flex; flex-direction: column; gap: 10px; }
.bughead { display: flex; gap: 10px; align-items: center; }
.bughead .ic { width: 40px; height: 40px; flex-shrink: 0; }
.bughead b { display: block; font-size: 14.5px; } .bughead small { color: #8a7092; font-weight: 700; font-size: 12px; }
.bugbox textarea { width: 100%; border: 1.8px solid var(--ink); border-radius: 12px; padding: 8px 10px; font: inherit; font-weight: 700; font-size: 13.5px; color: var(--ink); resize: vertical; min-height: 54px; outline: none; background: #fff; user-select: text; }
.bugbox textarea:focus { border-color: var(--pink2); }
.bugbox .btn { width: 100%; padding: 8px; }
/* "not enough" buttons inside narrow cards: red price only, never overflow */
.card .btn.poor::after, .sitem .btn.poor::after, .macts .btn.poor::after, .row > .btn.sm.poor::after { content: none !important; }
.card .btn { white-space: normal !important; line-height: 1.2; font-size: 12.5px; padding: 6px 8px; overflow-wrap: anywhere; }
.btn.poor { color: #e0445e !important; }
.btn { max-width: 100%; }
/* held-item card in the narrow left column: text on top, full-width button below */
body.wide #hand-chip { flex-direction: column; align-items: stretch; gap: 8px; padding: 10px 12px; }
body.wide #hand-chip .hc-t { white-space: normal; line-height: 1.4; }
body.wide #hand-chip .drop { width: 100%; justify-content: center; text-align: center; }

/* review tips */
.rtips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; font-size: 12px; }
.rtips b { width: 100%; font-size: 12.5px; }
.rtips span { background: #fff6d6; border: 1.5px solid var(--ink); border-radius: 10px; padding: 3px 8px; font-weight: 700; }

/* printer rearrange grid */
.moveblk { margin: 12px 0 10px; display: flex; flex-direction: column; gap: 4px; }
.moveblk small { color: #8a7a92; }
.slotgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 4px; }
.slotgrid .sg { min-height: 44px; border-radius: 12px; border: 2px solid var(--ink); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; font: inherit; font-size: 11px; padding: 4px; cursor: pointer; box-shadow: 0 2px 0 var(--ink); line-height: 1.15; }
.slotgrid .sg b { font-size: 12px; }
.slotgrid .sg span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.slotgrid .sg:not(.empty):not(.lock) { background: color-mix(in srgb, var(--c1, #ffd0e2) 45%, #fff); }
.slotgrid .sg.empty { border-style: dashed; color: #c28aa6; background: #fff7fb; }
.slotgrid .sg.me { outline: 3px solid #ff6fa8; outline-offset: 1px; cursor: default; }
.slotgrid .sg.lock { opacity: .45; cursor: not-allowed; box-shadow: none; }
.slotgrid .sg:not(:disabled):active { transform: translateY(2px); box-shadow: none; }

/* ---- printer panel: compact header + equal action tiles ---- */
.phead2 { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.pstat { display: flex; align-items: center; gap: 10px; }
.pstat .pico { width: 40px; height: 40px; flex-shrink: 0; }
.pstat b { font-size: 14px; line-height: 1.3; }
.pchips { display: flex; flex-wrap: wrap; gap: 6px; }
.pchip { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: #fff; border: 1.5px solid var(--ink); }
.pchip.warn { background: #fff0d6; color: #c46a00; }
.pchip .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.pmeters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.pm { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 800; }
.pm .bar { height: 8px; }
.ptiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ptile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 88px; padding: 10px 6px; border-radius: 16px; border: 2px solid var(--ink); background: #fff; box-shadow: 0 3px 0 var(--ink); font: inherit; cursor: pointer; text-align: center; }
.ptile .ti { font-size: 24px; line-height: 1; height: 28px; display: grid; place-items: center; }
.ptile .ti svg, .ptile .ti img { width: 28px; height: 28px; }
.ptile b { font-size: 13.5px; }
.ptile small { font-size: 11px; color: #8a7a92; font-weight: 700; }
.ptile.hot { background: #e6fff1; border-color: #2f9e6e; box-shadow: 0 3px 0 #2f9e6e; }
.ptile.hot::after { content: 'nên làm'; font-size: 9.5px; font-weight: 900; color: #fff; background: #2f9e6e; border-radius: 999px; padding: 1px 7px; margin-top: 2px; }
.ptile.gem { background: #f1e9ff; }
.ptile:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; transform: translateY(3px); }
.ptile:not(:disabled):active { transform: translateY(3px); box-shadow: none; }
.phint { font-size: 11.5px; color: #8a7a92; text-align: center; margin: 8px 0 4px; }
.pmore { margin-top: 10px; border-top: 1.5px dashed rgba(91,66,96,.25); padding-top: 8px; }
.pmore summary { cursor: pointer; font-weight: 800; font-size: 12.5px; color: #7a5c80; list-style: none; padding: 4px 0; }
.pmore summary::before { content: '▸ '; }
.pmore[open] summary::before { content: '▾ '; }
.pmore summary::-webkit-details-marker { display: none; }
@media (min-width: 520px) { .ptiles { grid-template-columns: repeat(4, 1fr); } }

/* printer icon tile: icon truly centred */
.pico > span { display: grid; place-items: center; width: 100%; height: 100%; line-height: 0; }
.pico > span .ic { display: block; width: 64%; height: 64%; margin: 0; vertical-align: 0; }

/* printer panel rows: every action button the same size */
.prows .row > .btn { flex: 0 0 96px; width: 96px; min-height: 40px; justify-content: center; text-align: center; padding-left: 6px; padding-right: 6px; }

/* ---- printer panel header: visual specs ---- */
.pinfo-v { align-items: center; gap: 12px; margin-bottom: 10px; }
.pspool > .grow { flex: 1; }
.pst { display: inline-block; font-weight: 900; font-size: 13px; padding: 4px 12px; border-radius: 999px; border: 2px solid var(--ink); background: #e6fff1; color: #1f7a52; margin-bottom: 8px; }
.pst.busy { background: #e6f3ff; color: #2864a8; }
.pst.done { background: #fff6c8; color: #9a6a00; }
.pst.warn { background: #fff0d6; color: #c46a00; }
.pst.bad { background: #ffe1e6; color: #c42c47; }
.pspecs { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.spec small { display: block; font-size: 10.5px; font-weight: 800; color: #8a7a92; margin-bottom: 3px; }
.sizes { display: flex; gap: 3px; }
.sizes i { font-style: normal; font-size: 10.5px; font-weight: 900; width: 26px; height: 22px; display: grid; place-items: center; border-radius: 7px; background: #f1ebf4; color: #b9a9c2; border: 1.5px solid #e2d8e7; }
.sizes i.on { background: #ff8fbd; color: #fff; border-color: var(--ink); }
.cols { display: flex; align-items: center; gap: 3px; height: 22px; }
.cols i { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--ink); }
.cols b { font-size: 12px; margin-left: 5px; }
.pspool { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; border: 2px solid var(--ink); background: #fff; margin-bottom: 10px; }
.pspool .grow { min-width: 0; }
.pspool .grow b { font-size: 13px; }
.pspool .grow small { display: block; font-size: 11px; color: #8a7a92; }
.pspool .bar { height: 7px; margin-top: 4px; }
.pspool .g { font-size: 12.5px; white-space: nowrap; }
.pspool .g.low { color: #e0445e; }
.pspool.none { border-style: dashed; background: #fff7ec; }
.ring { width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; border: 2px solid var(--ink); background: conic-gradient(var(--c) calc(var(--p) * 1%), #efe7f2 0); display: grid; place-items: center; }
.ring span { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); }
.ring.empty { background: repeating-conic-gradient(#efe7f2 0 15deg, #fff 0 30deg); }
.pmeter2 { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.ptabs-wrap.fits .tabnav { display: none !important; }
.ptabs-wrap.fits .ptabs { justify-content: center; -webkit-mask-image: none !important; mask-image: none !important; }
body.touch .keys-hint, body.touch #hand-chip kbd { display: none !important; }

/* coins flying to the counter */
#coinfly { position: fixed; inset: 0; pointer-events: none; z-index: 60; }
.flycoin { position: absolute; left: -12px; top: -12px; width: 24px; height: 24px; filter: drop-shadow(0 2px 0 rgba(91,66,96,.35)); }
.flycoin svg { width: 100%; height: 100%; display: block; }
.pill.coin-bump { animation: coinbump .35s cubic-bezier(.3,1.8,.5,1); }
@keyframes coinbump { 0% { transform: scale(1); } 40% { transform: scale(1.18); } 100% { transform: scale(1); } }
/* status pill living in the panel title bar */
.phead h2 { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: nowrap; }
.phead h2 .tstat { margin: 0; font-size: 11.5px; padding: 3px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; max-width: 60%; font-family: inherit; text-shadow: none; -webkit-text-stroke: 0; letter-spacing: 0; }
