:root {
  --bg: #0b0d1a; --panel: rgba(20, 22, 44, .94); --line: rgba(160, 175, 255, .18); --ink: #eef0ff; --dim: #9aa3d6;
  --acc: #7c8cff; --gold: #ffcf5a; --pink: #ff7eb6; --good: #8be3a0; --bad: #ff6b6b;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: Mitr, "Noto Sans Thai", system-ui, sans-serif; overflow: hidden; overscroll-behavior: none; }
#cv { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { -webkit-user-drag: none; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: calc(8px + var(--safe-t)); left: 8px; right: 8px; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "who meters money" "mood mood mood"; gap: 6px 12px; align-items: center; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.who { grid-area: who; display: flex; align-items: center; gap: 8px; background: rgba(10,12,30,.6); padding: 4px 12px 4px 4px; border-radius: 30px; border: 1px solid var(--line); backdrop-filter: blur(6px); }
.lvring { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--acc), #b07cff); font-weight: 700; }
.lvring b { background: #141634; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 15px; }
#pname { font-size: 13px; max-width: 120px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.xp { width: 90px; height: 5px; background: #ffffff22; border-radius: 4px; overflow: hidden; margin-top: 3px; } .xp i { display: block; height: 100%; background: linear-gradient(90deg, #7c8cff, #b07cff); }
.money { grid-area: money; display: flex; gap: 6px; }
.pill { display: flex; align-items: center; gap: 4px; background: rgba(10,12,30,.6); border: 1px solid var(--line); padding: 3px 10px 3px 4px; border-radius: 30px; font-weight: 600; backdrop-filter: blur(6px); }
.pill img { width: 24px; height: 24px; }
#gemplus { margin-left: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: var(--good); color: #0b2a14; font-weight: 800; line-height: 1; padding: 0; }
#meters { grid-area: meters; display: flex; gap: 8px; justify-content: center; }
.meter { display: flex; align-items: center; gap: 3px; background: rgba(10,12,30,.55); padding: 3px 8px 3px 3px; border-radius: 20px; border: 1px solid var(--line); }
.meter img { width: 22px; height: 22px; }
.meter .bar { width: 70px; height: 9px; background: #ffffff1a; border-radius: 6px; overflow: hidden; }
.meter .bar i { display: block; height: 100%; border-radius: 6px; transition: width .35s; }
.meter.en i { background: linear-gradient(90deg, #ffb340, #ffe56b); } .meter.full i { background: linear-gradient(90deg, #ff8d4d, #ffc36b); }
.meter.water i { background: linear-gradient(90deg, #3f9bff, #7fd4ff); } .meter.sugar i { background: linear-gradient(90deg, #ff6bb1, #ffb3d9); }
.meter.low { animation: blink 1s infinite; border-color: var(--bad); } .meter.high { border-color: var(--pink); }
#meters.pulse .meter { animation: pop .35s; }
@keyframes pop { 50% { transform: scale(1.12); } } @keyframes blink { 50% { background: rgba(255,60,60,.35); } }
.moodline { grid-area: mood; text-align: center; font-size: 13px; color: var(--dim); text-shadow: 0 1px 3px #000; pointer-events: none; }
.mult b { color: var(--gold); }

#badges { position: fixed; right: 8px; top: calc(96px + var(--safe-t)); display: flex; flex-direction: column; gap: 6px; align-items: flex-end; z-index: 5; }
.badge { background: rgba(14,16,38,.82); border: 1px solid var(--line); border-radius: 20px; padding: 5px 12px; font-size: 13px; backdrop-filter: blur(6px); }
.badge.ready { background: linear-gradient(90deg, #ff9f43, #ffcf5a); color: #2b1600; font-weight: 700; animation: pop 1s infinite; }
.badge.gold { color: var(--gold); } .badge.warn { color: #ffb3b3; border-color: #ff6b6b66; }
.badge.gift { background: linear-gradient(90deg, #ff7eb6, #b07cff); font-weight: 600; } .badge.gift.wait { background: rgba(14,16,38,.82); font-weight: 400; color: var(--dim); }

#hint { position: fixed; left: 50%; bottom: calc(110px + var(--safe-b)); transform: translateX(-50%) translateY(10px); background: rgba(10,12,30,.82); border: 1px solid var(--line); padding: 10px 18px; border-radius: 30px; font-size: 16px; opacity: 0; transition: .25s; pointer-events: none; z-index: 6; max-width: 92vw; text-align: center; }
#hint.on { opacity: 1; transform: translateX(-50%); }
#eatbar { position: fixed; left: 10px; bottom: calc(14px + var(--safe-b)); display: none; align-items: center; gap: 8px; z-index: 6; }
#eatbar.on { display: flex; }
#eatbar button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(10,12,30,.8); font-size: 18px; }
#eatbar span { background: rgba(10,12,30,.7); padding: 6px 12px; border-radius: 20px; font-size: 14px; }

/* ---------- dock ---------- */
#dock { position: fixed; left: 0; right: 0; bottom: 0; padding: 6px 8px calc(6px + var(--safe-b)); display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; background: linear-gradient(0deg, rgba(8,9,22,.92), rgba(8,9,22,.55) 70%, transparent); z-index: 5; justify-content: safe center; transition: transform .3s; }
#dock::-webkit-scrollbar { display: none; }
#dock.hide { transform: translateY(110%); }
.dock-btn { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 2px; width: 70px; padding: 6px 2px; border: 0; background: transparent; border-radius: 14px; position: relative; }
.dock-btn:hover, .dock-btn:active { background: #ffffff14; }
.dock-btn .ic { font-size: 26px; line-height: 1.1; filter: drop-shadow(0 2px 3px #000a); }
.dock-btn .tx { font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.dock-btn.dot::after { content: ''; position: absolute; top: 6px; right: 14px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px #0b0d1a; }

/* ---------- work pads ---------- */
#pads { position: fixed; left: 0; right: 0; bottom: 0; padding: 8px 8px calc(10px + var(--safe-b)); display: none; gap: 8px; z-index: 6; }
#pads.on { display: flex; }
.pad { flex: 1; min-height: 64px; border-radius: 16px; border: 1px solid var(--line); background: rgba(20,22,50,.85); font-size: 17px; font-weight: 600; touch-action: manipulation; user-select: none; }
.pad:active { transform: scale(.96); background: rgba(124,140,255,.4); }
.pad.l0 { border-color: #ff6b9a; } .pad.l1 { border-color: #6bd3ff; } .pad.l2 { border-color: #ffd86b; }
.pad.big { flex: 3; font-size: 20px; } .pad.quit { flex: 0 0 96px; font-size: 13px; color: var(--dim); } .pad.note { display: grid; place-items: center; color: var(--dim); font-weight: 400; }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; display: none; place-items: center; background: rgba(4,5,14,.55); z-index: 10; padding: 10px; }
#modal.on { display: grid; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.card { width: min(560px, 100%); max-height: min(88vh, 88dvh); display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: 0 20px 60px #000a; animation: rise .25s; }
.card.wide { width: min(860px, 100%); }
@keyframes rise { from { transform: translateY(20px) scale(.98); } }
.card-h { display: flex; align-items: flex-end; justify-content: space-between; padding: 14px 14px 10px; background-size: cover; background-position: center; min-height: 56px; }
.card-h[style*="url"] { min-height: 110px; }
.card-h h2 { margin: 0; font-size: 20px; text-shadow: 0 2px 6px #000; }
.card-h .x { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: rgba(10,12,30,.7); flex: 0 0 auto; }
.card-b { padding: 4px 14px 16px; overflow-y: auto; }
.tip { color: var(--dim); font-size: 13px; margin: 8px 0; }
.empty { color: var(--dim); text-align: center; padding: 20px; }
.big { font-size: 26px; font-weight: 700; text-align: center; margin: 6px 0; color: var(--gold); }
.row { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.btn { flex: 1; min-height: 46px; padding: 8px 14px; border-radius: 14px; border: 0; background: linear-gradient(180deg, #8d9bff, #6a74f0); font-weight: 600; box-shadow: 0 3px 0 #3e45a8; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #3e45a8; }
.btn.ghost { background: #ffffff12; box-shadow: none; border: 1px solid var(--line); }
.btn.gold { background: linear-gradient(180deg, #ffd86b, #f5a623); color: #2b1600; box-shadow: 0 3px 0 #a86a00; }
.btn[disabled] { opacity: .5; }
.row-btn { width: 100%; padding: 10px; margin: 6px 0; border-radius: 12px; border: 1px solid var(--gold); background: #ffcf5a18; }
.tabs { display: flex; gap: 6px; margin: 8px 0; overflow-x: auto; }
.tab { flex: 1; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: transparent; white-space: nowrap; }
.tab.on { background: var(--acc); border-color: var(--acc); }
.grid { display: grid; gap: 8px; }
.grid.foods, .grid.book { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.food { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px; border-radius: 16px; border: 1px solid var(--line); background: #ffffff0a; text-align: center; }
button.food:active { transform: scale(.97); }
.food img { width: 84px; height: 84px; object-fit: contain; filter: drop-shadow(0 4px 6px #0008); }
.food b { font-size: 13px; font-weight: 500; line-height: 1.25; }
.food small { font-size: 11px; color: var(--dim); }
.food small.eff { display: flex; flex-wrap: wrap; justify-content: center; column-gap: 6px; line-height: 1.35; } .food small.eff > span { white-space: nowrap; }
.food em { font-style: normal; font-size: 12px; color: var(--dim); }
.food .cnt { position: absolute; top: 6px; right: 8px; font-style: normal; font-weight: 700; color: var(--gold); }
.food.locked img { filter: grayscale(1) brightness(.5); } .food.unknown img { filter: brightness(0) opacity(.5); }
.food.sel { border-color: var(--good); background: #8be3a014; }
.qty { display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.qty button { width: 30px; height: 30px; border-radius: 10px; border: 1px solid var(--line); background: #ffffff12; font-weight: 700; }
.qty span { font-size: 12px; min-width: 44px; }
.mini { margin-top: 4px; padding: 5px 12px; border-radius: 10px; border: 1px solid var(--line); background: #ffffff12; font-size: 13px; }
.mini.buy { background: var(--acc); border-color: var(--acc); } .mini[disabled] { opacity: .45; }
.cartbar { position: sticky; bottom: -16px; display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 10px 0 4px; background: linear-gradient(0deg, var(--panel) 75%, transparent); }
.cartbar div { display: flex; flex-direction: column; } .cartbar small { color: var(--dim); font-size: 12px; } .cartbar .btn { flex: 0 0 140px; }
.job { width: 100%; display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px; margin: 6px 0; border-radius: 16px; border: 1px solid var(--line); background: #ffffff0a; }
.job .ic { font-size: 30px; } .job div { flex: 1; display: flex; flex-direction: column; } .job small { color: var(--dim); font-size: 12px; }
.job em { font-style: normal; color: var(--gold); white-space: nowrap; } .job.locked { opacity: .55; }
.up { display: flex; align-items: center; gap: 10px; padding: 8px; border-bottom: 1px solid var(--line); }
.up img { width: 56px; height: 56px; object-fit: contain; } .up .ic { font-size: 34px; width: 56px; text-align: center; }
.up div { flex: 1; display: flex; flex-direction: column; } .up small { color: var(--dim); font-size: 12px; }
.grid.rooms { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.roomcard { display: flex; flex-direction: column; gap: 4px; padding: 8px; border-radius: 16px; border: 1px solid var(--line); background: #ffffff0a; }
.roomcard img { width: 100%; aspect-ratio: 3/2; object-fit: cover; border-radius: 10px; } .roomcard small { color: var(--dim); } .roomcard em { font-style: normal; color: var(--good); }
.roomcard.sel { border-color: var(--good); }
.handprev { display: block; margin: 0 auto; background: radial-gradient(#2a2f5a, #14162e); border-radius: 16px; width: 260px; height: 220px; }
.handtop { display: flex; flex-direction: column; align-items: stretch; gap: 8px; }
@media (max-height: 560px) { .handtop { flex-direction: row; align-items: center; gap: 12px; } .handtop .handprev { width: 150px; height: 127px; flex: none; margin: 0; } .handtop .hctl { flex: 1; min-width: 0; } .handtop .hctl .tip { margin: 6px 0 4px; } }
.tones { justify-content: center; } .tone { width: 36px; height: 36px; border-radius: 50%; border: 2px solid transparent; } .tone.on { border-color: #fff; }
.grid.items { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.item { padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: #ffffff0a; display: flex; flex-direction: column; gap: 2px; }
.item small { color: var(--gold); } .item.sel { border-color: var(--good); }
.mission { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; border: 1px solid var(--line); margin: 8px 0; }
.mission > div { flex: 1; } .mission small { color: var(--dim); font-size: 12px; } .mission em { font-style: normal; color: var(--good); }
.mission .bar { height: 7px; background: #ffffff1a; border-radius: 6px; margin: 6px 0 2px; overflow: hidden; } .mission .bar i { display: block; height: 100%; background: var(--good); }
.mission.claimed { opacity: .55; }
.passbox { display: flex; gap: 12px; align-items: center; padding: 12px; border-radius: 18px; background: linear-gradient(135deg, #2d2160, #18183a); border: 1px solid #ffcf5a55; margin: 8px 0; }
.passbox h3 { margin: 0 0 4px; color: var(--gold); } .passbox ul { margin: 4px 0; padding-left: 18px; font-size: 13px; } .passbox small { color: var(--dim); display: block; margin: 4px 0 8px; }
img.big { width: 90px; height: 90px; object-fit: contain; flex: 0 0 auto; }
.grid.packs { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
.pack { display: flex; flex-direction: column; align-items: center; padding: 10px; border-radius: 16px; border: 1px solid var(--line); background: #ffffff0a; }
.pack img { width: 48px; height: 48px; } .pack span { color: var(--gold); font-weight: 600; }
.orders .order { display: flex; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.order span:first-child { flex: 1; } .order em { font-style: normal; color: var(--dim); } .order.approved em { color: var(--good); } .order.rejected em { color: var(--bad); }
.qrbox { text-align: center; } .qr { width: 240px; height: 240px; border-radius: 12px; background: #fff; padding: 4px; }
.file { display: block; font-size: 13px; color: var(--dim); margin: 10px 0; } .file input { display: block; margin-top: 6px; color: var(--ink); }
.lbrow { display: grid; grid-template-columns: 40px 1fr auto auto; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); }
.lbrow em { font-style: normal; color: var(--gold); } .lbrow small { color: var(--dim); } .lbrow.me { background: #7c8cff22; border-radius: 10px; }
.field { display: flex; gap: 8px; align-items: center; margin: 10px 0; } .field input[type=text], .field input:not([type]) { flex: 1; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: #0d0f24; color: var(--ink); font: inherit; }
.slider { display: flex; gap: 10px; align-items: center; margin: 8px 0; } .slider input { flex: 1; }
.howto li { margin: 6px 0; }
.housead { text-align: center; padding: 10px; border-radius: 16px; background: linear-gradient(135deg, #2d2160, #18183a); }
.housead h3 { margin: 6px 0; color: var(--gold); }

/* ---------- overlays ---------- */
#toasts { position: fixed; top: calc(100px + var(--safe-t)); left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 20; pointer-events: none; width: min(92vw, 460px); }
.toast { background: rgba(14,16,40,.95); border: 1px solid var(--line); padding: 10px 16px; border-radius: 16px; font-size: 14px; text-align: center; animation: rise .25s; transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translateY(-10px); }
#loading { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; background: radial-gradient(#1c2050, #07080f); z-index: 50; }
#loading img { width: 110px; height: 110px; border-radius: 26px; margin: 0 auto; animation: pop 1.4s infinite; } #loading h1 { margin: 12px 0 0; font-size: 34px; } #loading p { color: var(--dim); }
.walk { position: fixed; inset: 0; display: grid; place-content: center; gap: 14px; background: #05060cee; z-index: 30; text-align: center; animation: fade .3s; }
.walk-t { font-size: 22px; } .walk-bar { width: 240px; height: 8px; border-radius: 6px; background: #ffffff22; overflow: hidden; }
.walk-bar i { display: block; height: 100%; width: 100%; background: var(--acc); animation: walkbar 3s linear; transform-origin: left; }
@keyframes walkbar { from { transform: scaleX(0); } }
.sleepov { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; background: #05060ccc; z-index: 30; transition: background .6s; font-size: 20px; }
.sleepov.dark { background: #000; } .sleepov .brush { width: 160px; margin: 0 auto; animation: brush .25s infinite alternate; }
@keyframes brush { to { transform: translateX(14px) rotate(-4deg); } }
#sleep { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; gap: 8px; background: radial-gradient(#0d1030, #000); z-index: 25; padding: 20px; }
#sleep .zzz { font-size: 40px; color: #b8c2ff; animation: pop 2s infinite; } #sleep p { color: var(--dim); } #sleep .btn { max-width: 260px; margin: 10px auto; }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  #hud { grid-template-columns: 1fr auto; grid-template-areas: "who money" "meters meters" "mood mood"; }
  #pname { max-width: 80px; } .xp { width: 60px; }
  .meter .bar { width: 44px; } .meter { padding-right: 6px; }
  #badges { top: calc(122px + var(--safe-t)); }
  .dock-btn { width: 62px; } .dock-btn .ic { font-size: 23px; }
  .grid.foods, .grid.book { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
  .food img { width: 70px; height: 70px; }
  #hint { font-size: 14px; bottom: calc(96px + var(--safe-b)); }
}
@media (max-width: 380px) { .meter .bar { width: 34px; } .pill { padding-right: 7px; } }

/* ===== v1.1 look: navy tiles + thin gold edge (matches the painted icons) ===== */
:root { --gold-edge: rgba(226, 178, 92, .55); --tile: linear-gradient(180deg, #1d2357 0%, #121638 100%); }
#hud { grid-template-columns: auto 1fr auto auto; grid-template-areas: "who meters clock money" "mood mood mood mood"; }
#clock { grid-area: clock; display: flex; align-items: center; gap: 8px; background: var(--tile); border: 1px solid var(--gold-edge); border-radius: 18px; padding: 3px 12px 3px 4px; box-shadow: 0 4px 14px #0007, inset 0 1px 0 #ffffff1a; }
#clock img { width: 38px; height: 38px; border-radius: 10px; }
#clock b { display: block; font-size: 19px; letter-spacing: .5px; font-variant-numeric: tabular-nums; color: #ffe3a3; line-height: 1.05; }
#clock small { display: block; font-size: 11px; color: var(--dim); }
#wxname { font-size: 12px; color: #cfd6ff; max-width: 120px; line-height: 1.2; }
.who, .pill, .meter { background: var(--tile); border-color: var(--gold-edge); box-shadow: 0 4px 12px #0006, inset 0 1px 0 #ffffff14; }
.lvring { background: conic-gradient(#ffd27a, #e29a3a, #ffd27a); }
.dock-btn img.ic { width: 46px; height: 46px; border-radius: 12px; filter: drop-shadow(0 3px 5px #000a); transition: transform .15s; }
.dock-btn:hover img.ic { transform: translateY(-3px) scale(1.05); }
.dock-btn:active img.ic { transform: scale(.94); }
.dock-btn .tx { color: #e8dcc0; text-shadow: 0 1px 2px #000; }
#dock { background: linear-gradient(0deg, rgba(10,12,34,.96), rgba(10,12,34,.7) 70%, transparent); border-top: 1px solid rgba(226,178,92,.18); }
.card { background: linear-gradient(180deg, #1a1f4d 0%, #10132e 100%); border: 1.5px solid var(--gold-edge); box-shadow: 0 24px 70px #000b, inset 0 1px 0 #ffffff1c; }
.card-h { border-bottom: 1px solid rgba(226,178,92,.25); }
.card-h h2 { display: flex; align-items: center; gap: 10px; color: #ffe9bf; }
.card-h .hico { width: 48px; height: 48px; border-radius: 12px; box-shadow: 0 4px 10px #0008; }
.card-h .x { border-color: var(--gold-edge); color: #ffe3a3; }
.btn { background: linear-gradient(180deg, #6f7dff, #4b55d6); box-shadow: 0 3px 0 #2c3291, inset 0 1px 0 #ffffff40; }
.btn.gold { background: linear-gradient(180deg, #ffe08a, #f0a537); box-shadow: 0 3px 0 #9a5d00, inset 0 1px 0 #ffffff80; }
.food, .job, .item, .pack, .roomcard, .mission { background: linear-gradient(180deg, #232a63aa, #161a40aa); border-color: rgba(226,178,92,.28); }
.food:hover, .job:hover, .item:hover, .pack:hover { border-color: rgba(255,210,122,.8); }
.tab { border-color: rgba(226,178,92,.3); } .tab.on { background: linear-gradient(180deg, #ffd27a, #e29a3a); color: #2a1600; border-color: #ffd27a; }
.mini.buy { background: linear-gradient(180deg, #ffd27a, #e29a3a); color: #2a1600; border-color: #ffd27a; font-weight: 600; }
.badge { background: var(--tile); border-color: var(--gold-edge); }
/* habit buttons (eyes / stretch / keyboard crumbs / phone) */
#habits { position: fixed; left: 8px; top: calc(100px + var(--safe-t)); display: flex; flex-direction: column; gap: 8px; z-index: 5; }
.habit { position: relative; width: 52px; height: 52px; padding: 0; border: 0; background: none; border-radius: 14px; }
.habit img { width: 52px; height: 52px; border-radius: 14px; box-shadow: 0 4px 10px #0008; }
.habit .ring { position: absolute; left: 4px; right: 4px; bottom: -5px; height: 5px; border-radius: 4px; background: linear-gradient(90deg, #ffb340 var(--p, 0%), #ffffff22 var(--p, 0%)); }
.habit.warn img { animation: blink 1.2s infinite; outline: 2px solid #ff6b6b; }
.habit .n { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); font-size: 11px; font-style: normal; display: grid; place-items: center; padding: 0 4px; }
.habit .n:empty { display: none; }
.habit.hide { display: none; }
.habit.ring-on img { animation: buzz .5s infinite; }
@keyframes buzz { 25% { transform: rotate(-8deg); } 75% { transform: rotate(8deg); } }
.pad.again { background: linear-gradient(180deg, #ffd27a, #e29a3a); color: #2a1600; }
/* phone modal */
.phone { margin: 6px auto 12px; width: min(300px, 100%); border-radius: 28px; padding: 14px; background: linear-gradient(180deg, #2a3168, #141838); border: 2px solid #3a3f6e; box-shadow: inset 0 0 0 6px #0b0d1f; }
.ph-top { text-align: center; font-size: 13px; color: var(--dim); margin-bottom: 10px; }
.bubble { background: #fff; color: #222; border-radius: 16px 16px 16px 4px; padding: 10px 12px; } .bubble b { color: #e0457b; font-size: 13px; } .bubble p { margin: 4px 0 0; }
.nightsum { color: #ffe3a3 !important; }
@media (max-width: 900px) {
  #hud { grid-template-columns: 1fr auto; grid-template-areas: "who money" "clock clock" "meters meters" "mood mood"; }
  #clock { justify-self: center; padding: 2px 10px 2px 3px; } #clock img { width: 30px; height: 30px; } #clock b { font-size: 16px; }
  #habits { top: calc(150px + var(--safe-t)); } .habit, .habit img { width: 44px; height: 44px; }
  #badges { top: calc(150px + var(--safe-t)); }
  .dock-btn img.ic { width: 40px; height: 40px; }
}

/* hand set picker */
.grid.handsets { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.handset { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 8px; border-radius: 18px; border: 1.5px solid rgba(226,178,92,.3); background: radial-gradient(circle at 50% 30%, #2c3478, #151a42); }
.handset img { height: 140px; width: auto; filter: drop-shadow(0 6px 8px #000a); transition: transform .2s; }
.handset:hover img { transform: translateY(-4px) rotate(-3deg); }
.handset b { color: #ffe9bf; } .handset small { color: var(--dim); font-size: 12px; }
.handset.sel { border-color: var(--good); box-shadow: 0 0 0 2px #8be3a055; }
.tone { color: #333; font-weight: 700; }

/* online night room bar */
#roombar { position: fixed; left: 8px; bottom: calc(86px + var(--safe-b)); display: flex; align-items: center; gap: 8px; z-index: 5; max-width: calc(100vw - 16px); background: var(--tile); border: 1px solid var(--gold-edge); border-radius: 18px; padding: 4px 6px; box-shadow: 0 6px 16px #0008; }
body:has(#dock.hide) #roombar, body:has(#dock.hide) #emopick { display: none; }
.rb-off { font-size: 12px; color: var(--dim); padding: 4px 8px; }
.rb-name { background: none; border: 0; text-align: left; padding: 0 6px; } .rb-name b { display: block; font-size: 13px; color: #ffe3a3; } .rb-name small { font-size: 11px; color: var(--dim); }
.rb-avs { display: flex; gap: 4px; }
.rb-av { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 2px solid #3a4180; background: radial-gradient(#2c3478, #151a42); padding: 0; overflow: visible; }
.rb-av img { width: 100%; height: 100%; object-fit: contain; border-radius: 50%; } .rb-av.me { border-color: var(--good); } .rb-av.work { border-color: #ffb340; }
.rb-av i { position: absolute; right: -4px; bottom: -4px; font-style: normal; font-size: 13px; }
.bubble-e { position: absolute; bottom: 44px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: #fff; color: #222; font-style: normal; font-size: 12px; padding: 3px 8px; border-radius: 10px; animation: rise .25s; }
.rb-coop { font-size: 12px; color: #ffcf5a; white-space: nowrap; }
.rb-emo { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--gold-edge); background: #ffffff10; font-size: 20px; }
#emopick { position: fixed; left: 8px; bottom: calc(136px + var(--safe-b)); display: none; flex-wrap: wrap; gap: 6px; max-width: min(420px, calc(100vw - 16px)); z-index: 7; background: var(--tile); border: 1px solid var(--gold-edge); border-radius: 16px; padding: 8px; }
#emopick.on { display: flex; } #emopick button { border: 1px solid var(--line); background: #ffffff10; border-radius: 12px; padding: 6px 10px; font-size: 13px; }
.member { display: flex; align-items: center; gap: 10px; padding: 8px; border-bottom: 1px solid var(--line); }
.member img { width: 42px; height: 42px; object-fit: contain; border-radius: 50%; background: radial-gradient(#2c3478, #151a42); } .member div { flex: 1; display: flex; flex-direction: column; } .member small { color: var(--dim); } .member.me b { color: var(--good); }
.feed { display: flex; flex-direction: column; gap: 2px; margin: 8px 0; padding: 8px; border-radius: 12px; background: #0008; } .feed small { color: #cfd6ff; }
.rooms-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.roomrow { display: flex; flex-direction: column; align-items: flex-start; padding: 10px; border-radius: 14px; border: 1px solid rgba(226,178,92,.3); background: #ffffff0a; } .roomrow small { color: var(--dim); } .roomrow.sel { border-color: var(--good); } .roomrow.new { border-style: dashed; }
@media (max-width: 720px) { .rb-name small { display: none; } .rb-av { width: 32px; height: 32px; } .rb-coop { display: none; } #roombar { bottom: calc(78px + var(--safe-b)); } }
@media (max-width: 900px) { #toasts { top: calc(165px + var(--safe-t)); } .who { justify-self: start; } }

/* in-game web browser on the monitor */
#webwin { position: fixed; z-index: 4; display: none; flex-direction: column; background: #fff; border-radius: 4px; overflow: hidden; box-shadow: 0 0 0 1px #000, 0 0 40px rgba(120,160,255,.25); }
#webwin.on { display: flex; }
.wb-bar { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; padding: 4px 6px; background: linear-gradient(180deg, #2a2f55, #1b1f3d); }
.wb-bar button { flex: 0 0 auto; min-width: 32px; height: 30px; border-radius: 8px; border: 1px solid #ffffff22; background: #ffffff12; color: #fff; font-size: 15px; padding: 0 6px; }
.wb-bar button:active { background: #ffffff30; }
.wb-url { flex: 1; min-width: 0; height: 28px; display: flex; align-items: center; gap: 6px; padding: 0 10px; border-radius: 14px; background: #0c0f24; color: #cfd6ff; font-size: 13px; white-space: nowrap; overflow: hidden; }
.wb-url .t { overflow: hidden; text-overflow: ellipsis; }
.wb-view { position: relative; flex: 1; min-height: 0; background: #fff; }
.wb-view iframe { width: 100%; height: 100%; border: 0; display: block; background: #fff; }
.wb-load { position: absolute; inset: 0; display: none; place-items: center; background: #f4f5fb; color: #555; font-size: 15px; }
#webwin.loading .wb-load { display: grid; }
body.webon #dock, body.webon #roombar, body.webon #emopick { display: none; }
body.webfull #hud, body.webfull #badges, body.webfull #habits, body.webfull #toasts { display: none; }

.wallprev { aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; border: 6px solid #111; background: linear-gradient(135deg, #1b2350, #3a1f4f); display: grid; place-items: center; color: #cfd6ff; margin: 8px 0; box-shadow: 0 6px 18px #0008; }
.wallprev img { width: 100%; height: 100%; object-fit: cover; display: block; }

#lampbox { position: fixed; z-index: 8; width: 260px; padding: 10px 12px; border-radius: 16px; background: var(--tile); border: 1px solid var(--gold-edge); box-shadow: 0 10px 30px #000a; animation: rise .2s; }
.lb-h { font-size: 14px; color: #ffe3a3; margin-bottom: 6px; } .lb-h b { float: right; color: #fff; }
.lb-row { display: flex; align-items: center; gap: 6px; } .lb-row input { flex: 1; accent-color: #ffcf5a; }
.lb-row button, .lb-x { border: 1px solid var(--line); background: #ffffff12; border-radius: 10px; padding: 4px 8px; font-size: 12px; }
.lb-x { margin-top: 8px; width: 100%; }

/* item mall */
.mallbanner { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: 16px; margin: 8px 0; background: linear-gradient(120deg, #3a2470, #1e2a6e 60%, #6b2f5e); border: 1px solid var(--gold-edge); }
.mallbanner b { font-size: 18px; color: #ffe9bf; } .mallbanner span { font-size: 13px; color: #cfd6ff; }
.grid.mall { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.mallcard { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 8px; border-radius: 18px; border: 1px solid rgba(226,178,92,.3); background: radial-gradient(circle at 50% 30%, #2c3478, #151a42); text-align: center; }
.mallcard:hover { border-color: rgba(255,210,122,.8); transform: translateY(-2px); }
.mallcard img { width: 110px; height: 110px; object-fit: contain; filter: drop-shadow(0 6px 8px #0009); }
.mallcard b { font-size: 14px; color: #ffe9bf; } .mallcard small { font-size: 11px; color: var(--dim); line-height: 1.3; }
.mallcard .soon { position: absolute; top: 8px; right: 8px; font-size: 11px; padding: 2px 8px; border-radius: 10px; background: #ff7eb6; color: #2a0a1a; font-weight: 600; }
.mallitem { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: center; }
.mallitem img { width: 200px; height: 200px; object-fit: contain; filter: drop-shadow(0 8px 12px #000a); }
.mallitem > div { flex: 1; min-width: 200px; } .mallitem h3 { margin: 4px 0; color: #ffe9bf; } .mallitem small { color: var(--dim); }

/* notifications never cover an open menu */
body:has(#modal.on) #toasts { z-index: 9; }

/* desktop: notifications sit on the right (over the window), never on the monitor */
@media (min-width: 901px) { #toasts { left: auto; right: 12px; transform: none; width: min(320px, 28vw); top: calc(150px + var(--safe-t)); } #badges { top: calc(96px + var(--safe-t)); } }

/* login / register */
.who { cursor: pointer; }
.authhero { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 6px 0; }
.authhero img { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 8px 20px #0009; }
.authhero p { margin: 0; color: #cfd6ff; } .authhero b { font-size: 22px; color: #ffe9bf; }
.authbtns { display: flex; flex-direction: column; gap: 8px; margin: 10px auto; max-width: 340px; }
.authform { display: flex; flex-direction: column; gap: 10px; max-width: 340px; margin: 6px auto; }
.authform label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); }
.authin { padding: 12px 14px; border-radius: 12px; border: 1px solid var(--gold-edge); background: #0c0f24; color: var(--ink); font: inherit; font-size: 16px; }
.authin.pin { letter-spacing: 8px; text-align: center; font-size: 22px; }
.row .authin.pin { flex: 1; min-width: 110px; font-size: 16px; letter-spacing: 4px; }
.authmsg { min-height: 18px; margin: 0; color: #ff9b9b; font-size: 13px; text-align: center; }
.linkbtn { background: none; border: 0; color: #9fb3ff; text-decoration: underline; font-size: 13px; }

.btn.ib, h3.ih { display: flex; align-items: center; justify-content: center; gap: 10px; } h3.ih { justify-content: flex-start; }
img.bi { width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto; box-shadow: 0 2px 6px #0007; }

/* room chat */
.rb-chat { position: relative; } .rb-n { position: absolute; top: -5px; right: -5px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: 11px; font-style: normal; display: grid; place-items: center; padding: 0 4px; }
.bubble-e.say { max-width: 180px; white-space: normal; text-align: left; }
#chatbox { position: fixed; left: 8px; bottom: calc(140px + var(--safe-b)); width: min(360px, calc(100vw - 16px)); height: min(380px, 52vh); display: none; flex-direction: column; z-index: 7; background: var(--tile); border: 1px solid var(--gold-edge); border-radius: 18px; box-shadow: 0 12px 30px #000b; overflow: hidden; }
#chatbox.on { display: flex; animation: rise .2s; }
.cb-h { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid rgba(226,178,92,.25); } .cb-h b { color: #ffe3a3; } .cb-room { flex: 1; color: var(--dim); }
.cb-x { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--line); background: #ffffff10; }
.cb-list { flex: 1; overflow-y: auto; padding: 8px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.cb-msg { display: flex; gap: 6px; align-items: flex-start; } .cb-msg img { width: 28px; height: 28px; object-fit: contain; border-radius: 50%; background: #2c3478; flex: 0 0 auto; }
.cb-msg div { background: #ffffff10; border-radius: 4px 14px 14px 14px; padding: 5px 10px; max-width: 80%; display: flex; flex-direction: column; }
.cb-msg b { font-size: 11px; color: #9fb3ff; } .cb-msg span { font-size: 14px; word-break: break-word; } .cb-msg small { font-size: 10px; color: var(--dim); align-self: flex-end; }
.cb-msg.me { flex-direction: row-reverse; } .cb-msg.me div { background: #6a74f055; border-radius: 14px 4px 14px 14px; } .cb-msg.me b { color: var(--good); }
.cb-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid rgba(226,178,92,.2); }
.cb-form input { flex: 1; min-width: 0; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: #0c0f24; color: var(--ink); font: inherit; font-size: 15px; }
.cb-form button { padding: 0 14px; border-radius: 12px; border: 0; background: linear-gradient(180deg, #ffd27a, #e29a3a); color: #2a1600; font-weight: 600; }
.cb-tip { color: var(--dim); font-size: 11px; text-align: center; padding: 0 0 6px; }
body:has(#dock.hide) #chatbox { display: none; }
@media (max-width: 720px) { #chatbox { bottom: calc(126px + var(--safe-b)); height: min(340px, 48vh); } }

/* room code / invite */
.invite { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; padding: 10px; border-radius: 16px; background: linear-gradient(120deg, #2d2160, #18183a); border: 1px solid var(--gold-edge); margin: 6px 0 10px; }
.inv-code { display: flex; flex-direction: column; align-items: center; padding: 4px 12px; } .inv-code small { color: var(--dim); font-size: 11px; }
.inv-code b { font-size: 30px; letter-spacing: 5px; color: #ffe3a3; font-family: ui-monospace, Consolas, monospace; }
.inv-btns { display: flex; gap: 6px; flex-wrap: wrap; } .inv-btns .btn { min-height: 40px; font-size: 14px; }
.inv-join { grid-column: 1 / -1; display: flex; gap: 6px; }
.codein { width: 120px; padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: #0c0f24; color: var(--ink); font: inherit; font-size: 18px; letter-spacing: 4px; text-align: center; text-transform: uppercase; }
.roomrow.priv { border-color: #ffcf5a88; }
@media (max-width: 520px) { .invite { grid-template-columns: 1fr; } }

/* admin announcement ticker */
#ticker { position: fixed; left: 50%; transform: translateX(-50%); top: calc(64px + var(--safe-t)); width: min(760px, calc(100vw - 16px)); height: 34px; display: none; align-items: center; z-index: 12; overflow: hidden; border-radius: 17px; border: 1px solid; box-shadow: 0 6px 18px #0009; pointer-events: none; }
#ticker.on { display: flex; animation: rise .3s; }
#ticker.c-gold { background: linear-gradient(90deg, #3a2a08ee, #5a3f0bee, #3a2a08ee); border-color: #ffcf5a; color: #ffe9b0; }
#ticker.c-red { background: linear-gradient(90deg, #4a0f14ee, #7a1820ee, #4a0f14ee); border-color: #ff6b6b; color: #ffe1e1; }
#ticker.c-blue { background: linear-gradient(90deg, #0f2350ee, #1a3a7aee, #0f2350ee); border-color: #7ec8ff; color: #e3f2ff; }
#ticker.c-green { background: linear-gradient(90deg, #0d3a22ee, #16583aee, #0d3a22ee); border-color: #8be3a0; color: #e5ffee; }
.tk-ic { flex: 0 0 auto; padding: 0 10px; font-size: 17px; height: 100%; display: grid; place-items: center; background: #0006; position: relative; z-index: 1; }
.tk-track { flex: 1; overflow: hidden; height: 100%; position: relative; }
.tk-text { position: absolute; left: 0; top: 50%; white-space: nowrap; font-weight: 600; font-size: 15px; transform: translate(100%, -50%); animation: tick 14s linear infinite; padding-left: 100%; }
@keyframes tick { from { transform: translate(0, -50%); } to { transform: translate(-100%, -50%); } }
@media (max-width: 900px) { #ticker { top: calc(118px + var(--safe-t)); height: 30px; } .tk-text { font-size: 14px; } }
@media (max-width: 900px) { #ticker { top: calc(150px + var(--safe-t)); } body:has(#ticker.on) #toasts { top: calc(195px + var(--safe-t)); } }
@media (max-width: 720px) { body:has(#ticker.on) #habits, body:has(#ticker.on) #badges { top: calc(188px + var(--safe-t)); } }

/* profile picture */
.lvring { position: relative; overflow: visible; }
#hudav { width: 30px; height: 30px; border-radius: 50%; object-fit: contain; background: #141634; }
#hudav.photo { object-fit: cover; }
.lvring b#lv { position: absolute; right: -6px; bottom: -6px; width: 18px; height: 18px; font-size: 11px; border: 1.5px solid #ffcf5a; }
.rb-av img.photo, .member img.photo, .cb-msg img.photo { object-fit: cover; }
.pf { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 6px 0 10px; }
.pf-picwrap { position: relative; }
.pf-pic { width: 128px; height: 128px; border-radius: 50%; object-fit: contain; background: radial-gradient(#2c3478, #151a42); border: 3px solid #ffcf5a; box-shadow: 0 8px 20px #0009; }
.pf-pic.photo { object-fit: cover; } .pf-pic.small { width: 84px; height: 84px; }
.pf-cam { position: absolute; right: 0; bottom: 4px; width: 38px; height: 38px; border-radius: 50%; border: 2px solid #ffcf5a; background: #1b1f3d; font-size: 18px; }
.pf-btns { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.pf-name { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--dim); max-width: 340px; margin: 0 auto; width: 100%; }

#passout { position: fixed; inset: 0; z-index: 26; display: grid; place-content: center; text-align: center; gap: 8px; padding: 20px; background: radial-gradient(#0d1030ee, #000f); }
#passout .zzz { font-size: 44px; color: #b8c2ff; animation: pop 2s infinite; } #passout p { color: var(--dim); margin: 0; }
#passout .po-t { font-size: 30px; color: #ffe3a3; font-variant-numeric: tabular-nums; } #passout .po-tip { color: #9be7a6; }
#passout .btn { max-width: 260px; margin: 12px auto 0; }

/* zoom in / out */
#zoombox { position: fixed; right: 8px; top: 50%; transform: translateY(-50%); z-index: 5; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; border-radius: 18px; background: var(--tile); border: 1px solid var(--gold-edge); box-shadow: 0 6px 16px #0008; }
#zoombox button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: #ffffff12; font-size: 20px; font-weight: 700; color: #ffe3a3; }
#zoombox button:active { background: #ffffff30; }
#zoombox b { font-size: 10px; color: var(--dim); font-weight: 500; writing-mode: horizontal-tb; }
body:has(#dock.hide) #zoombox, body.webon #zoombox { display: none; }
@media (max-width: 720px) { #zoombox { top: auto; bottom: calc(150px + var(--safe-b)); transform: none; } }

/* PC shop + builder */
.tabs.sub { flex-wrap: wrap; } .tabs.sub .tab { flex: 0 0 auto; font-size: 13px; padding: 6px 10px; }
.mallcard .soon.off { background: #8be3a0; color: #0b2a14; }
canvas.pcprev { width: 150px; height: 180px; }
.pcbuild { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.1fr); gap: 12px; }
.pcstage { background: radial-gradient(#2c3478, #0d0f24); border-radius: 18px; border: 1px solid var(--gold-edge); min-height: 420px; position: relative; }
canvas.pcbig { position: absolute; inset: 0; width: 100%; height: 100%; }
.pcside { display: flex; flex-direction: column; gap: 6px; max-height: 70vh; overflow-y: auto; }
.pcstat { padding: 8px 12px; border-radius: 14px; display: flex; flex-direction: column; } .pcstat.ok { background: #8be3a022; border: 1px solid #8be3a0; } .pcstat.bad { background: #ff6b6b22; border: 1px solid #ff6b6b; }
.pcstat small { color: var(--dim); } .pcerr { margin: 0; padding-left: 18px; color: #ffb3b3; font-size: 13px; }
.pcside h3 { margin: 8px 0 2px; font-size: 15px; color: #ffe3a3; }
.pcrow { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 10px; background: #ffffff08; font-size: 13px; } .pcrow img { width: 36px; height: 36px; object-fit: contain; } .pcrow span { flex: 1; } .pcrow.empty em { color: #ff9b9b; font-style: normal; }
.pcbox { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.pcpart { position: relative; display: flex; flex-direction: column; align-items: center; padding: 6px; border-radius: 12px; border: 1px solid rgba(226,178,92,.3); background: #ffffff0a; } .pcpart img { width: 56px; height: 56px; object-fit: contain; } .pcpart small { font-size: 10px; text-align: center; } .pcpart i { position: absolute; top: 4px; right: 6px; font-style: normal; color: var(--gold); font-size: 12px; }
@media (max-width: 720px) { .pcbuild { grid-template-columns: 1fr; } .pcstage { min-height: 300px; } }
.rgbrow { gap: 6px; } .rgbdot { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #ffffff33; } .rgbdot.on { border-color: #ffcf5a; box-shadow: 0 0 0 2px #ffcf5a66; }
.pcmenu { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
/* PC breakdowns: repair box, broken rows, 💎 prices, junk */
.buy2 { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.mini.gem { background: linear-gradient(180deg, #8fe3ff, #3fa3e8); border-color: #8fe3ff; color: #06223a; font-weight: 600; }
.btn.gem { background: linear-gradient(180deg, #8fe3ff, #3a9be0); color: #06223a; box-shadow: 0 3px 0 #1d5f96, inset 0 1px 0 #ffffff80; }
.pcbroken { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 16px; background: linear-gradient(180deg, #ff5c5c22, #ffb02a14); border: 1px solid #ff8a5c; animation: pbpulse 1.6s ease-in-out infinite; }
@keyframes pbpulse { 50% { box-shadow: 0 0 0 3px #ff8a5c33; } }
.pcbroken .pb-h { display: flex; gap: 10px; align-items: center; } .pcbroken .pb-ico { font-size: 30px; line-height: 1; }
.pcbroken .pb-h b { color: #ffd0b8; display: block; } .pcbroken .pb-h small { color: var(--dim); font-size: 12px; }
.pcbroken .pb-acts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; } .pcbroken .pb-acts .btn { min-height: 42px; font-size: 14px; padding: 6px 8px; }
.pcbroken .pb-acts .btn.ghost { grid-column: 1 / -1; }
.pcbroken .pb-paper { display: flex; flex-direction: column; gap: 6px; } .pcbroken .pb-paper small { color: #ffe3a3; }
/* คอมเครื่องฟรี: the big "use the free PC" option, the which-PC row, the builder badge */
.pcbroken .pb-free { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 58px; padding: 8px 12px; border-radius: 14px; background: linear-gradient(180deg, #3ddc84, #1fa862); color: #062b15; border: 0; box-shadow: 0 4px 14px #1fa86255; }
.pcbroken .pb-free b { font-size: 17px; } .pcbroken .pb-free small { font-size: 12px; color: #0a3d1f; }
.pcbroken .pb-freeon { margin: 0; padding: 8px 10px; border-radius: 12px; background: #3ddc8422; border: 1px solid #3ddc8466; color: #c9ffe0; font-size: 13px; }
.pcwhich { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-radius: 14px; background: #ffffff0d; border: 1px solid #ffffff1f; }
.pcwhich > div { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; } .pcwhich small { color: var(--dim); font-size: 12px; }
.pcwhich.free { background: #3ddc8418; border-color: #3ddc8466; } .pcwhich .btn { min-height: 40px; font-size: 14px; flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 560px) { .pcwhich .btn { flex: 1 1 100%; } }
.freebadge { display: inline-block; padding: 1px 8px; border-radius: 99px; background: #3ddc84; color: #062b15; font-size: 12px; font-weight: 700; vertical-align: middle; }
.pcbox .pcpart[disabled] { opacity: .45; cursor: not-allowed; }
.pb-bar { height: 8px; border-radius: 4px; background: #ffffff18; overflow: hidden; } .pb-bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffcf5a, #ff9a3c); }
.pcrow.broken { background: #ff4d4d26; outline: 1px solid #ff6b6b; } .pcrow.broken img { filter: sepia(1) saturate(4) hue-rotate(-40deg) brightness(.85); } .tagbad { color: #ff7b7b; }
.pcpart.junk { border-color: #ff6b6b88; } .pcpart.junk img { filter: grayscale(.7) brightness(.7); } .pcpart i.bad { color: #ff7b7b; }
@media (max-width: 420px) { .pcbroken .pb-acts { grid-template-columns: 1fr; } }
.paperbar { display: flex !important; flex-direction: column; justify-content: center; gap: 6px; padding: 0 14px; color: #ffe3a3 !important; font-weight: 600 !important; } .paperbar .pb-bar { width: 100%; height: 10px; }
body.papering .moodline, body.papering #meters, body.papering #clock, body.papering #mood, body.papering #mult, body.papering #habits, body.papering #badges, body.papering #roombar, body.papering #zoombox { display: none !important; }
.paperbar .pp-t { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* price tags inside buttons: coin / gem picture + number on a dark pill, readable on gold and blue */
.cost { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; padding: 1px 8px 1px 3px; border-radius: 999px; background: #1a0f2ee6; color: #fff3cf; font-weight: 700; line-height: 1.5; text-shadow: none; white-space: nowrap; }
.cost img { width: 18px; height: 18px; object-fit: contain; filter: drop-shadow(0 1px 1px #000a); }
.cost.gem { background: #08203ae6; color: #bff0ff; }
.btn .ic { font-size: 18px; line-height: 1; margin-right: 4px; filter: none; opacity: 1; }
.btn.gem, .mini.gem { background: linear-gradient(180deg, #3aa0ee, #1d5fb4) !important; border-color: #7cc8ff !important; color: #fff !important; text-shadow: 0 1px 2px #0008; }
.btn.gem { box-shadow: 0 3px 0 #123f78, inset 0 1px 0 #ffffff55 !important; }
.btn.off { background: #ffffff14 !important; color: #b9bdd6 !important; box-shadow: none !important; border: 1px dashed #ff8a8a88; cursor: not-allowed; }
.pcstat.info { background: #ffffff0d; border: 1px solid #ffffff22; }
.pcbroken .pb-acts .btn { display: inline-flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 2px; }
.mallcard .buy2 { margin-top: auto; padding-top: 6px; width: 100%; flex-wrap: nowrap; }
.mallcard .buy2 .mini { flex: 1 1 0; min-width: 0; display: inline-flex; align-items: center; justify-content: center; padding: 5px 4px; }
.mallcard .buy2 .cost { margin-left: 0; padding: 1px 6px 1px 2px; }
.mallcard .buy2 .cost img { width: 16px; height: 16px; }
/* weather name in the clock box: at most 2 tidy lines (no 4-line squeeze on mid-size screens) */
#wxname { min-width: 88px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; flex-shrink: 0; }
@media (min-width: 721px) and (max-width: 1180px) { #wxname { display: none; } }   /* the weather icon says it; the top row has no room for the name here */
/* toasts: under any open modal; moved off the PC case by UI.fitToasts() */
body.modalon #toasts { z-index: 9; }
#toasts.side-l { left: 76px; right: auto; transform: none; }
#toasts.narrow { left: 8px; right: auto; transform: none; max-width: calc(100vw - 16px); }
#toasts.low { bottom: auto; }
#toasts.narrow .toast { font-size: 13px; padding: 8px 12px; }
/* dark wrench icon on the repair buttons (the 🔧 emoji is grey and vanishes on the yellow button) */
.btn .ic.wrench { display: inline-block; width: 17px; height: 17px; margin-right: 5px; background: #2a1800; vertical-align: -3px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M22.7 19l-9.1-9.1c.9-2.3.4-5-1.5-6.9-2-2-5-2.4-7.4-1.3L9 6 6 9 1.6 4.7C.4 7.1.9 10.1 2.9 12.1c1.9 1.9 4.6 2.4 6.9 1.5l9.1 9.1c.4.4 1 .4 1.4 0l2.3-2.3c.5-.4.5-1.1.1-1.4z'/%3E%3C/svg%3E") center / contain no-repeat; }
.btn.gem .ic.wrench { background: #fff; }
.gembal { color: #cfe6ff !important; font-weight: 600; text-align: center; }
/* paper job bottom bar: bigger progress label, a smaller but clearer quit button */
#pads .paperbar .pp-t { font-size: 16px; color: #ffe9b8; }
#pads .pad.paperquit { flex: 0 0 78px; min-height: 52px; align-self: center; font-size: 16px; font-weight: 700; color: #fff; background: #b8323a; border-color: #ff8a8a; }
@media (max-width: 420px) { #pads .pad.paperquit { flex-basis: 88px; white-space: nowrap; padding-left: 4px; padding-right: 4px; } }   /* label + quit stay 16px on a phone too */
@media (min-width: 901px) { #pads .paperbar .pp-t { font-size: 18px; } }

/* left habit column: + quick work tools (auto / boost ×2 / refill); wraps into a 2nd column when the screen is short */
#habits { --ht: calc(100px + var(--safe-t)); --hs: 52px; top: var(--ht); display: grid; grid-auto-flow: column; grid-template-rows: repeat(auto-fill, var(--hs)); grid-auto-columns: var(--hs); gap: 10px 8px; max-height: calc(100dvh - var(--ht) - 172px - var(--safe-b)); }
.habit, .habit img { width: var(--hs); height: var(--hs); }
@media (max-width: 900px) { #habits { --ht: calc(150px + var(--safe-t)); --hs: 44px; } }
@media (max-width: 720px) { body:has(#ticker.on) #habits { --ht: calc(188px + var(--safe-t)); top: var(--ht); } }
@media (max-height: 560px) { #habits { --ht: calc(64px + var(--safe-t)); --hs: 40px; gap: 8px 6px; } }
.habit .tag { position: absolute; right: -5px; bottom: -5px; min-width: 20px; height: 17px; padding: 0 4px; border-radius: 9px; font: 800 10px/17px system-ui, sans-serif; font-style: normal; color: #fff; background: #20254d; border: 1px solid #ffffff40; box-shadow: 0 2px 4px #0009; white-space: nowrap; pointer-events: none; }
.habit .tag:empty { display: none; }
.habit[data-h=boost] .tag { background: linear-gradient(180deg, #ffcf5a, #e8891f); color: #3a1a00; border-color: #fff6; }
.habit[data-h=refill] .tag { background: #182a4a; color: #bfe9ff; }
.habit.on img { outline: 2px solid #46f0a4; box-shadow: 0 0 12px #2fe39a, 0 4px 10px #0008; animation: toolpulse 1.6s ease-in-out infinite; }
.habit[data-h=auto].on .tag { background: #1fb873; color: #04210f; border-color: #b9ffd9; }
.habit[data-h=boost].on img { outline-color: #ffc34a; box-shadow: 0 0 14px #ff9a2e, 0 4px 10px #0008; }
.habit.dim img { filter: saturate(.45) brightness(.7); }
@keyframes toolpulse { 50% { transform: scale(1.06); } }
@media (max-width: 520px) { #habits { left: 4px; --hs: 40px; gap: 9px 6px; } }
/* ⚙️ auto-work package picker */
.apacks { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; margin: 10px 0; }
.apack { position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 16px 8px 10px; border-radius: 16px; border: 1px solid var(--line); background: #ffffff0a; color: inherit; font: inherit; cursor: pointer; }
.apack b { font-size: 17px; } .apack .aday { color: var(--dim); font-size: 12px; } .apack .agem { color: var(--gold); font-weight: 700; font-size: 18px; } .apack small { color: var(--dim); font-size: 12px; }
.apack.best { border-color: var(--gold); background: linear-gradient(180deg, #ffcf5a22, #ffffff08); box-shadow: 0 0 16px #ffcf5a33; }
.apack.poor .agem { color: #ffb3b3; } .apack[disabled] { opacity: .45; cursor: default; }
.apack .abadge { position: absolute; top: -9px; left: 50%; transform: translateX(-50%); font-style: normal; font-size: 11px; font-weight: 700; white-space: nowrap; padding: 2px 9px; border-radius: 10px; background: linear-gradient(180deg, #ffd86b, #f5a623); color: #2b1600; }
.apack .abadge.save { background: #1fb873; color: #04210f; }
.apack .awarn, p.awarn { color: #ffb3b3; }
.astat { text-align: center; margin: 6px 0; } .astat span { color: var(--dim); font-size: 13px; }
/* hand accessories: quality badge + picture (✋ แต่งมือ) */
.grid.items.acc { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.item[style*="--tier"] { position: relative; border-color: color-mix(in srgb, var(--tier) 55%, transparent); background: linear-gradient(180deg, color-mix(in srgb, var(--tier) 22%, #1d2350), #161a40cc); }
.item[style*="--tier"].sel { border-color: var(--good); box-shadow: 0 0 0 2px var(--good) inset; }
.item .tier { align-self: flex-start; font-style: normal; font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 99px; color: #111; background: var(--tier); }
.item .accprev { width: 100%; height: 64px; object-fit: contain; filter: drop-shadow(0 3px 4px #0008); margin: 2px 0; }

/* ===== fit pass (phones portrait + landscape, tablets, desktops) ===== */
:root { --safe-l: env(safe-area-inset-left, 0px); --safe-r: env(safe-area-inset-right, 0px); }
#hud { left: calc(8px + var(--safe-l)); right: calc(8px + var(--safe-r)); }
#habits { left: calc(8px + var(--safe-l)); }
#roombar, #emopick, #chatbox { left: calc(8px + var(--safe-l)); }
#badges { right: calc(8px + var(--safe-r)); }
#zoombox { right: calc(8px + var(--safe-r)); }
#modal { padding: 10px calc(10px + var(--safe-r)) 10px calc(10px + var(--safe-l)); }
#dock, #pads { padding-left: calc(8px + var(--safe-l)); padding-right: calc(8px + var(--safe-r)); }
#eatbar { left: calc(10px + var(--safe-l)); }
@media (max-width: 520px) { #habits { left: calc(4px + var(--safe-l)); } }
/* mid desktop 901-1100: the one-row HUD would run past the right edge */
@media (min-width: 901px) and (max-width: 1100px) {
  .meter .bar { width: 46px; } #meters { gap: 5px; } #pname { max-width: 90px; } .xp { width: 70px; }
  #clock small { display: none; } #hud { gap: 6px 8px; }
}
/* during a job / eating: the side columns step aside so the monitor / snack has the whole screen */
body:has(#pads.on) #habits, body:has(#pads.on) #badges, body:has(#pads.on) #zoombox { display: none !important; }
/* short landscape (phones held sideways): HUD = one slim row, clock tucked top-right */
@media (max-height: 560px) and (orientation: landscape) {
  #hud { grid-template-columns: auto 1fr auto; grid-template-areas: "who meters money"; gap: 4px 8px; }
  .moodline, #wxname, #clock small { display: none; }
  #clock { position: fixed; top: calc(54px + var(--safe-t)); right: calc(8px + var(--safe-r)); padding: 2px 8px 2px 3px; }
  #clock img { width: 24px; height: 24px; } #clock b { font-size: 14px; }
  .meter img { width: 18px; height: 18px; } .meter .bar { width: 36px; } .meter { padding-right: 5px; } #meters { gap: 5px; }
  .lvring { width: 32px; height: 32px; } .lvring b { width: 25px; height: 25px; font-size: 13px; }
  #badges { top: calc(92px + var(--safe-t)); }
  #zoombox { top: auto; bottom: calc(92px + var(--safe-b)); transform: none; flex-direction: row; padding: 4px 6px; }
  #zoombox button { width: 38px; height: 38px; }
  #toasts { top: calc(56px + var(--safe-t)); }
  body:has(#pads.on) #meters, body:has(#pads.on) #clock, body:has(#pads.on) .moodline,
  body:has(#eatbar.on) #meters, body:has(#eatbar.on) #clock, body:has(#eatbar.on) .moodline { display: none !important; }
}
@media (max-height: 560px) and (orientation: landscape) and (max-width: 720px) {
  #hud { grid-template-columns: auto 1fr auto; grid-template-areas: "who meters money"; }
}
@media (max-width: 720px) and (orientation: portrait) { #zoombox { bottom: calc(140px + var(--safe-b)); flex-direction: row; padding: 3px 6px; } }   /* a low flat row: stays off the PC case and its hint */
#zoombox b { font-size: 12px; }
/* modals in short landscape: slim header, more rows visible, actions reachable */
@media (max-height: 500px) and (orientation: landscape) {
  #modal { padding: 4px calc(4px + var(--safe-r)) 4px calc(4px + var(--safe-l)); }
  .card { max-height: calc(100dvh - 8px); border-radius: 16px; }
  .card-h, .card-h[style*="url"] { min-height: 44px; padding: 6px 12px; background-size: cover; background-position: center 30%; }
  .card-h h2 { font-size: 16px; } .card-h .hico { width: 30px; height: 30px; }
  .grid.foods, .grid.book { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
  .food img { width: 56px; height: 56px; }
  .dock-btn { width: 58px; padding: 3px 2px; } .dock-btn img.ic { width: 32px; height: 32px; } .dock-btn .tx { font-size: 11px; }
  #dock { padding-top: 3px; padding-bottom: calc(3px + var(--safe-b)); }
  #roombar { bottom: calc(66px + var(--safe-b)); }
  #chatbox { bottom: calc(66px + var(--safe-b)); height: min(300px, calc(100dvh - 140px)); }
}
.card-b > .btn.gold:last-child { position: sticky; bottom: 0; z-index: 1; box-shadow: 0 -8px 16px #10132e, 0 3px 0 #9a5d00; }
/* settings / forms on narrow phones */
.field input { min-width: 0; } .field .mini { flex: none; margin-top: 0; }
.card-b input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--gold); vertical-align: middle; flex: none; }
.card-b label:has(> input[type=checkbox]) { display: flex; align-items: center; gap: 8px; min-height: 40px; }
/* touch targets */
/* gem "+": the button itself is a 44×44 touch target (negative margins keep the pill size); the green dot is drawn inside it */
#gemplus { position: relative; width: 44px; height: 44px; margin: -11px -11px -11px -7px; border-radius: 50%; background: radial-gradient(circle, var(--good) 0 10.5px, transparent 11.5px); flex: none; }
@media (pointer: coarse) {
  .qty button { width: 40px; height: 40px; } .cb-x { width: 40px; height: 40px; }
  .wb-bar button { min-width: 40px; height: 40px; } .linkbtn { padding: 10px 4px; min-height: 40px; }
  .rb-name { min-height: 40px; }
}
/* small text */
.habit .tag { font: 800 12px/18px Mitr, system-ui, sans-serif; height: 18px; min-width: 22px; }
/* dock: fade on the right edge when more buttons are off-screen (class set from ui.js) */
#dock.more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent); }
/* narrow phones: top tab rows (mall categories, shop, room, hands) wrap instead of running off the right edge */
@media (max-width: 560px) { .tabs { flex-wrap: wrap; overflow-x: visible; } .tabs .tab { flex: 1 1 auto; min-width: 0; } }

/* ===== short landscape phones (844×390, 740×360, 667×375): welcome + 24-hour store fit without cutting the bottom ===== */
.qty { min-width: 0; justify-content: center; } .qty button { flex: none; } .qty span { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
@media (max-height: 500px) and (orientation: landscape) {
  .authhero { flex-direction: row; justify-content: center; gap: 12px; padding: 2px 0; text-align: left; }
  .authhero img { width: 52px; height: 52px; border-radius: 14px; }
  .authbtns { margin: 6px auto; gap: 6px; max-width: 420px; }
  .authbtns .btn { min-height: 42px; padding-top: 6px; padding-bottom: 6px; }
  .authbtns .btn .bi { width: 26px; height: 26px; }
  .card-b > .tip:last-child { margin: 4px 0 0; }
  .howto { margin: 4px 0; padding-left: 20px; } .howto li { margin: 3px 0; }
  .grid.foods .food { padding-left: 4px; padding-right: 4px; }
  .grid.foods .qty { gap: 2px; } .grid.foods .qty button { width: 34px; height: 34px; }
  .cartbar { padding-top: 6px; padding-bottom: 6px; }
  /* ไอเท็มมอล: one-line banner + one scrolling row per tab strip, so the first product row is in view */
  .mallbanner { flex-direction: row; align-items: baseline; gap: 10px; padding: 5px 12px; margin: 4px 0; border-radius: 12px; }
  .mallbanner b { font-size: 15px; flex: none; } .mallbanner span { font-size: 12px; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tabs { margin: 4px 0; } .tabs .tab { padding: 5px 10px; }
  .tabs.sub { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; } .tabs.sub .tab { padding: 4px 9px; font-size: 12px; }
}

/* full-screen web browser (phones / small windows): the habit column and its 🐞 button must not cover the browser bar (hud.css sets display:block) */
body.webfull #habits, body.webfull #badges { display: none !important; }
/* store / delivery quantity buttons: the display font draws "+" as a tiny dot; a plain bold system font keeps + and − equally clear */
.qty button { font-family: system-ui, "Segoe UI", Arial, sans-serif; font-size: 20px; font-weight: 800; line-height: 1; padding: 0; display: inline-flex; align-items: center; justify-content: center; color: var(--ink, #fff); }
/* first-run profile on short landscape phones (844×390, 740×360): picture beside its buttons, so บันทึก + ข้ามไปก่อน fit the screen */
@media (max-height: 500px) and (orientation: landscape) {
  .pf { flex-direction: row; justify-content: center; gap: 14px; margin: 2px 0 6px; }
  .pf-pic { width: 76px; height: 76px; } .pf-cam { width: 32px; height: 32px; font-size: 15px; bottom: 0; right: -4px; }
  .pf-btns { align-items: flex-start; }
  .pf-name { gap: 2px; }
  .pf-name + .authmsg:empty { display: none; }
  .pf-name ~ .linkbtn { padding-top: 6px; padding-bottom: 6px; }
  .pf-name ~ .tip { font-size: 12px; margin: 2px 0 0; }
}
/* portrait phones: the monitor's apps as big tiles (main.js appSheet) */
.appsheet { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; margin: 6px 0 4px; }
.apptile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; min-height: 96px; padding: 8px 4px; border-radius: 16px; border: 1px solid var(--line); background: #ffffff0d; color: var(--ink, #fff); }
.apptile img { width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 3px 6px #0008); }
.apptile b { font: 600 14px/1.2 Mitr, system-ui, sans-serif; text-align: center; }
.apptile.locked img { filter: grayscale(1) brightness(.65); }
.apptile .lv { font: 600 12px/1 Mitr, system-ui, sans-serif; font-style: normal; color: #ffcf5a; }
.apptile .nb { position: absolute; top: 4px; right: 10px; min-width: 22px; height: 22px; padding: 0 5px; border-radius: 11px; background: #ff4d5e; color: #fff; font: 700 12px/22px Mitr, system-ui, sans-serif; font-style: normal; }
.apptile:active { transform: scale(.96); }
