/* 包租物語 — 扁平、公會頁風格的介面 */
:root {
  --ink: #1d1d1f; --muted: #7a7a7f; --line: #e6e6e6; --card: #ffffff; --soft: #f4f4f2;
  --g: #3f9a6a; --r: #d9534a; --y: #f2c14e;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2c3a33; color: var(--ink);
  font-family: "PingFang TC", "Noto Sans TC", system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
button:disabled { opacity: 0.4; cursor: default; }
canvas#c { position: fixed; inset: 0; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; }

.muted { color: var(--muted); }
.sm { font-size: 12px; }
.up { color: var(--g); font-weight: 700; }
.down { color: var(--r); font-weight: 700; }
.grow { flex: 1; min-width: 0; }
.right { text-align: right; }

/* 標籤 */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.tag { position: absolute; left: 0; top: 0; white-space: nowrap; background: #fff; border: 1px solid #e3e3e3; border-radius: 999px;
  padding: 3px 10px; font-size: 12px; box-shadow: 0 2px 0 rgba(0,0,0,0.18); pointer-events: auto; cursor: pointer; }
.tag b { margin-right: 4px; }
.tag i { font-style: normal; background: #222; color: #fff; border-radius: 999px; padding: 0 6px; margin-right: 6px; font-size: 11px; }
.tag.mine { background: #fff4cc; border-color: #f0d67a; }
.tag.bubble { font-weight: 700; font-size: 14px; padding: 7px 13px; border-radius: 16px; animation: bob 1.2s ease-in-out infinite; }
.tag.bubble.good { background: #eaf7ee; border-color: #bfe3cb; }
.tag.bubble::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fff; }
.tag.bubble.good::after { border-top-color: #eaf7ee; }
.tag .ping { position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -4px); background: #222; color: #fff; border-radius: 999px;
  padding: 3px 9px; font-size: 11px; animation: rise 3.5s ease-out forwards; }
@keyframes bob { 50% { margin-top: -3px; } }
@keyframes rise { 0% { opacity: 0; margin-bottom: -6px; } 10%, 80% { opacity: 1; margin-bottom: 0; } 100% { opacity: 0; } }
.dlabel { position: absolute; left: 0; top: 0; background: rgba(255,255,255,0.92); border-radius: 12px; padding: 4px 10px; font-size: 12px;
  box-shadow: 0 2px 0 rgba(0,0,0,0.15); white-space: nowrap; pointer-events: none; }
.dlabel b { margin-right: 6px; }

/* HUD */
#hud { position: fixed; left: 12px; top: 12px; transition: opacity .2s; }
#hud.dim { opacity: 0; pointer-events: none; }
.hudcard { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 10px 14px; box-shadow: 0 3px 0 rgba(0,0,0,0.18); min-width: 210px; }
.hudcard > b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; background: var(--soft); border-radius: 999px; padding: 3px; margin-top: 8px; gap: 2px; }
.seg button { border-radius: 999px; padding: 3px 11px; font-size: 12px; font-weight: 700; color: var(--muted); }
.seg button.on { background: #222; color: #fff; }
#pausechip { margin-left: 6px; vertical-align: middle; }
#topbtns { position: fixed; right: 12px; top: 12px; display: flex; gap: 8px; }
#topbtns button { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 9px 16px; font-weight: 700; font-size: 14px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.18); position: relative; }
#evcount { position: absolute; top: -6px; right: -4px; background: var(--r); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; line-height: 18px; text-align: center; }
#ticker { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); background: #fff; border-radius: 999px; padding: 7px 16px 7px 8px;
  font-size: 13px; box-shadow: 0 3px 0 rgba(0,0,0,0.18); max-width: calc(100vw - 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
#ticker .pill { margin-right: 8px; }
#ticker.flash { animation: flash .6s; }
@keyframes flash { 30% { transform: translateX(-50%) scale(1.06); } }

/* 共用元件 */
.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 700; background: #222; color: #fff; margin: 2px 4px 2px 0; white-space: nowrap; }
.pill.g { background: #e3f3e9; color: #2f7d52; } .pill.r { background: #fbe4e2; color: #b8423a; } .pill.y { background: #fff1c7; color: #8a6a12; }
.pill.gray { background: #eeeeec; color: #77777c; } .pill.w { background: rgba(255,255,255,0.8); color: var(--ink); font-weight: 500; }
.pill.q { background: #fff; color: var(--ink); border: 1px dashed #bbb; font-weight: 500; cursor: pointer; }
.btn { background: #222; color: #fff; border-radius: 999px; padding: 10px 18px; font-weight: 700; font-size: 14px; }
.btn2 { background: #efefed; border-radius: 999px; padding: 10px 16px; font-weight: 700; font-size: 13px; }
.row { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.row .btn2 { flex: 1 1 auto; }
.bar { height: 8px; background: #eeeeec; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; }
.chips { display: flex; flex-wrap: wrap; margin-top: 4px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 12px 14px; margin: 8px 0; }
.card.alert { display: flex; gap: 10px; align-items: center; background: #fff6f4; border-color: #f3cfc9; }
.list { border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: #fff; margin: 8px 0; }
.item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid #f0f0ee; font-size: 14px; }
.card .item { padding: 6px 0; border: 0; }
.item:first-child { border-top: 0; }
.item.wrap { flex-wrap: wrap; }
.item > span:first-child { color: var(--muted); font-size: 13px; min-width: 64px; }
.item.click { cursor: pointer; } .item.click:hover { background: #fafaf8; }
.item.app { display: block; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.stat { background: var(--soft); border-radius: 14px; padding: 8px 10px; }
.stat span { display: block; font-size: 11px; color: var(--muted); }
.stat b { font-variant-numeric: tabular-nums; font-size: 15px; }
.note { background: var(--soft); border-radius: 14px; padding: 12px; font-size: 13px; color: var(--muted); margin: 8px 0; }
.dots i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #e2e2df; margin: 0 1px; vertical-align: middle; }
.dots i.on { background: #222; }
.loc { display: flex; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.av { width: 40px; height: 40px; border-radius: 50%; image-rendering: pixelated; flex: none; border: 1px solid var(--line); }
.person { display: flex; gap: 10px; align-items: center; }
.ico { width: 36px; height: 36px; image-rendering: pixelated; flex: none; }
.ico.big { width: 48px; height: 48px; }
.pthumb { width: 46px; height: 46px; flex: none; border-radius: 12px; background: #9cc77c no-repeat 50% 92%; background-size: 70px auto; image-rendering: pixelated; border: 1px solid var(--line); }
.big { font-size: 22px; }
.spark { display: block; }
h2 { margin: 2px 0 4px; font-size: 20px; }
h3 { margin: 16px 0 4px; font-size: 15px; }
.eyebrow { font-size: 12px; color: #555; }

/* 側邊面板 */
.sheet { position: fixed; right: 12px; top: 64px; bottom: 60px; width: 390px; max-width: calc(100vw - 24px); background: #fafaf8; border-radius: 24px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.18), 0 10px 30px rgba(0,0,0,0.15); transform: translateX(calc(100% + 30px)); transition: transform .25s ease; z-index: 5; display: flex; flex-direction: column; }
.sheet.open { transform: none; }
.sheet .x { position: absolute; right: 12px; top: 12px; width: 32px; height: 32px; border-radius: 50%; background: #efefed; font-size: 14px; z-index: 2; }
.sbody { overflow-y: auto; padding: 16px; flex: 1; }
.hero { border-radius: 24px; padding: 14px; display: flex; gap: 12px; align-items: center; margin-bottom: 8px; padding-right: 40px; }
.hero .pthumb { width: 64px; height: 64px; background-size: 96px auto; }
.pricebox { display: flex; justify-content: space-between; align-items: flex-end; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 12px 14px; margin: 8px 0; }
.pricebox > div > * { display: block; }
.demand { margin-top: 6px; }
.drow { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.drow .muted { color: #e0a23a; width: 34px; font-size: 10px; }
.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.dgrid .card { margin: 0; } .dgrid .card .item { padding: 0 0 6px; }
.row.sticky { position: sticky; bottom: -16px; background: #fafaf8; padding: 10px 0 14px; margin-bottom: -16px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 76px; height: 54px; border-radius: 14px; border: 2px solid transparent; position: relative; box-shadow: inset 0 -3px 0 rgba(0,0,0,0.1); }
.sw span { position: absolute; left: 0; right: 0; bottom: -18px; font-size: 11px; color: var(--muted); }
.sw.on { border-color: #222; }
.swatches { margin-bottom: 20px; }

/* 對話框 */
.modal { position: fixed; inset: 0; background: rgba(20,28,24,0.45); display: none; align-items: center; justify-content: center; z-index: 10; padding: 16px; }
.modal.open { display: flex; }
.mcard { background: #fafaf8; border-radius: 24px; padding: 20px; width: 420px; max-width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 5px 0 rgba(0,0,0,0.2); animation: pop .18s ease-out; }
@keyframes pop { from { transform: scale(0.94); opacity: 0; } }
.mcard p { line-height: 1.6; }
.evhead { display: flex; gap: 12px; align-items: center; }
.opts { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.opt { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; box-shadow: 0 2px 0 rgba(0,0,0,0.08); }
.opt:not(:disabled):hover { border-color: #222; }
.opt b { flex: 1; } .opt > span:nth-of-type(1) { font-weight: 700; } .opt .muted { flex-basis: 100%; }

/* 提示 */
#toasts { position: fixed; left: 50%; bottom: 60px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 20; pointer-events: none; }
.toast { background: #222; color: #fff; border-radius: 999px; padding: 9px 16px; font-size: 13px; max-width: 90vw; text-align: center; animation: pop .2s ease-out; transition: opacity .4s; }
.toast.out { opacity: 0; }
#fade { position: fixed; inset: 0; background: #1b231f; opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 30; }
#fade.on { opacity: 1; }

/* 室內 */
#roomui .rtop { position: fixed; left: 12px; right: 12px; top: 12px; display: flex; gap: 10px; align-items: center; background: #fff; border-radius: 20px;
  padding: 8px 10px; box-shadow: 0 3px 0 rgba(0,0,0,0.18); }
#roomui .rtop .chips { margin-top: 2px; }
#roomui .rtop .pill { background: var(--soft); color: var(--ink); font-weight: 500; }
#tray { position: fixed; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 8px; overflow-x: auto; background: #fff; border-radius: 20px; padding: 8px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.18); }
#tray .note { margin: 0; flex: 1; }
.ftile { flex: none; width: 82px; background: var(--soft); border-radius: 14px; padding: 4px 4px 6px; display: flex; flex-direction: column; align-items: center; font-size: 12px; }
.ftile img { width: 54px; height: 54px; image-rendering: pixelated; }
.ftile span { color: var(--muted); font-size: 11px; }
.ftile:hover { background: #ecebe7; }
.ftile.poor { opacity: 0.45; }
.seltool { position: fixed; left: 0; top: 0; display: flex; gap: 4px; background: #222; color: #fff; border-radius: 999px; padding: 4px; z-index: 4; font-size: 13px; align-items: center; }
.seltool button { color: #fff; padding: 6px 12px; border-radius: 999px; font-weight: 700; }
.seltool button:hover { background: #444; }
.seltool.hint { left: 50%; top: auto; bottom: 110px; transform: translateX(-50%) !important; padding-left: 16px; }

@media (max-width: 640px) {
  .sheet { left: 8px; right: 8px; width: auto; top: auto; bottom: 8px; height: 72vh; }
  .hudcard { min-width: 0; padding: 8px 12px; } .hudcard > b { font-size: 18px; }
  #topbtns { top: auto; bottom: 60px; right: 8px; } #topbtns button { padding: 8px 12px; font-size: 13px; }
  #ticker { bottom: 10px; font-size: 12px; }
  #roomui .rtop .chips .pill { font-size: 11px; }
}

body.inroom #toasts { bottom: 128px; }

/* 租客名牌、對話泡泡（3D 版） */
.tag.who { font-size: 11px; padding: 1px 8px; background: rgba(255,255,255,0.92); box-shadow: 0 1px 0 rgba(0,0,0,0.15); }
#speech { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.speech { position: absolute; left: 0; top: 0; background: #fff; border-radius: 16px; padding: 7px 13px; font-size: 14px; font-weight: 700;
  white-space: nowrap; box-shadow: 0 2px 0 rgba(0,0,0,0.18); border: 1px solid #e3e3e3; animation: sayin .2s ease-out; margin-top: -8px; }
@keyframes sayin { from { opacity: 0; } }
.speech::after { content: ''; position: absolute; left: 50%; bottom: -7px; margin-left: -7px; border: 7px solid transparent; border-bottom: 0; border-top-color: #fff; }
.speech.me { background: #fff4cc; } .speech.me::after { border-top-color: #fff4cc; }

/* 登入按鈕 */
.opt.login { justify-content: center; padding: 14px; }
.opt.login b { flex: none; display: flex; align-items: center; gap: 10px; font-size: 15px; }
.opt.login.line { background: #06c755; border-color: #06c755; color: #fff; }
.opt.login.g { background: #fff; border-color: #dadce0; color: #1f1f1f; }
.gmark { width: 20px; height: 20px; flex: none; }
.lmark { font-style: normal; background: #fff; color: #06c755; border-radius: 6px; padding: 1px 5px; font-size: 11px; font-weight: 800; }
@media (max-width: 640px) { #topbtns { flex-wrap: wrap; justify-content: flex-end; max-width: 70vw; } }

#mutebtn.off { color: #9a9a9a; }

/* 走到門口的「進去」提示 */
.tag.door { background: #222; color: #fff; border-color: #222; font-weight: 700; padding: 5px 12px; }
.tag.door .kbd { display: inline-block; margin-left: 8px; background: #fff; color: #222; border-radius: 6px; padding: 0 6px; font-size: 11px; }
/* 整棟樓清單 */
.unitno { min-width: 52px; font-variant-numeric: tabular-nums; }
.btn2.sm.back { padding: 6px 12px; font-size: 12px; margin: 0 0 6px; }
.pill.sale { background: #fbe4e2; color: #b8423a; }
/* 招租方式 */
.ways { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.way { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; border: 1px solid var(--line); border-radius: 14px; padding: 9px 12px; cursor: pointer; background: #fff; }
.way input { margin: 0; accent-color: #222; }
.way span { flex-basis: 100%; padding-left: 21px; }
.way.on { border-color: #222; box-shadow: inset 0 0 0 1px #222; }
.rentset input[type=range] { width: 100%; accent-color: #222; }
/* 手機搖桿（只在觸控裝置、街上顯示） */
#joy { position: fixed; left: 18px; bottom: 70px; width: 108px; height: 108px; border-radius: 50%; background: rgba(255,255,255,0.55); border: 2px solid rgba(0,0,0,0.12);
  display: none; touch-action: none; z-index: 4; }
#joy i { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%; background: #fff; box-shadow: 0 3px 0 rgba(0,0,0,0.2); }
@media (pointer: coarse) { #joy { display: block; } }
body.inroom #joy { display: none; }

/* 對話框（開場故事、引導） */
#dialog { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(640px, calc(100vw - 24px)); display: flex; gap: 14px; align-items: center;
  background: #fff; border-radius: 24px; padding: 14px 18px; box-shadow: 0 4px 0 rgba(0,0,0,0.2), 0 12px 30px rgba(0,0,0,0.18); z-index: 25; cursor: pointer; animation: sayin .2s ease-out; }
#dialog .face { width: 64px; height: 64px; flex: none; border-radius: 50%; overflow: hidden; }
#dialog .face svg { width: 100%; height: 100%; display: block; }
#dialog .who { display: inline-block; background: #222; color: #fff; border-radius: 999px; padding: 1px 10px; font-size: 12px; font-weight: 700; margin-bottom: 4px; }
#dialog .line { font-size: 16px; line-height: 1.6; min-height: 52px; }
#dialog .more { color: #b9b9b9; font-size: 12px; align-self: flex-end; animation: bob 1s ease-in-out infinite; }
#dialog.dlg-letter { background: #fbf6ec; }
#dialog.dlg-grandma .line { font-family: "Kaiti TC", "BiauKai", "PingFang TC", serif; }
/* 引導目標 */
#guide { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; background: #fff; border-radius: 999px;
  padding: 6px 8px 6px 10px; box-shadow: 0 3px 0 rgba(0,0,0,0.18); z-index: 6; font-size: 14px; max-width: calc(100vw - 24px); white-space: nowrap; }
#guide .skip { color: #999; font-size: 12px; padding: 4px 8px; border-radius: 999px; }
#guide .skip:hover { background: #f2f2f0; }
body.inroom #guide { top: 74px; }
.hl { position: relative; z-index: 5; animation: hlpulse 1.2s ease-in-out infinite; }
@keyframes hlpulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(242,193,78,0.0), 0 3px 0 rgba(0,0,0,0.18); } 50% { box-shadow: 0 0 0 6px rgba(242,193,78,0.85), 0 3px 0 rgba(0,0,0,0.18); } }
@media (max-width: 640px) { #guide { top: auto; bottom: 120px; font-size: 13px; } #dialog .line { font-size: 15px; } #dialog .face { width: 52px; height: 52px; } }
/* 室內上方：各類租客條件即時檢查 */
.needs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.need { font-size: 11px; background: #f2f2f0; color: #77777c; border-radius: 999px; padding: 2px 8px; }
.need em { font-style: normal; margin-left: 4px; color: #b8423a; }
.need.ok { background: #e3f3e9; color: #2f7d52; font-weight: 700; }
.sw.light { box-shadow: inset 0 -3px 0 rgba(0,0,0,0.1), 0 0 12px rgba(255,200,120,0.6); }
@media (max-width: 640px) { .need em { display: none; } }
/* 房屋面板分頁 */
.tabs { display: flex; background: #efefed; border-radius: 999px; padding: 3px; gap: 2px; margin: 10px 0 6px; }
.tabs button { flex: 1; border-radius: 999px; padding: 7px 4px; font-size: 13px; font-weight: 700; color: #77777c; }
.tabs button.on { background: #fff; color: #222; box-shadow: 0 1px 0 rgba(0,0,0,0.12); }

/* 排行榜：名次圓圈，前三名金銀銅 */
.rk { width: 28px; height: 28px; border-radius: 50%; background: #efefed; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex: none; min-width: 28px !important; color: #555 !important; }
.rk.gold { background: #f2c14e; color: #5a4310 !important; } .rk.silver { background: #cfd5da; color: #3d4a55 !important; } .rk.bronze { background: #d9a074; color: #5a3416 !important; }
.rankrow.me { background: #fff8de; }
.rankopt { border: 1px solid var(--line); border-radius: 16px; margin: 8px 0; }

/* 新版本提示（跟市長大人一樣的黑色膠囊） */
#updBtn { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom, 0px) + 110px); z-index: 30; display: flex; align-items: center;
  background: #222; color: #fff; border-radius: 999px; padding: 8px 8px 8px 14px; box-shadow: 0 4px 0 rgba(0,0,0,0.25); max-width: calc(100vw - 24px); font-size: 14px; }
#updBtn button { color: inherit; display: flex; gap: 10px; align-items: center; text-align: left; }
#updBtn #updGo { font-weight: 700; }
#updBtn .left { color: #b9b9b2; font-weight: 400; font-size: 12px; }
#updBtn #updX { padding: 2px 6px 2px 10px; margin-left: 8px; border-left: 1px solid rgba(255,255,255,0.25); font-size: 18px; line-height: 1; color: #b9b9b2; }
#updBtn .pulse { width: 10px; height: 10px; border-radius: 50%; background: #5fd06a; flex: none; animation: updpulse 1.4s ease-in-out infinite; }
@keyframes updpulse { 50% { box-shadow: 0 0 0 6px rgba(95,208,106,0.25); } }
@media (max-width: 420px) { #updBtn .left { display: none; } }

/* Google 廣告：面板最底下的橫幅、救急金列、測試用假廣告 */
#pageAd { flex: none; margin: 0 16px 14px; padding-top: 8px; border-top: 1px solid var(--line); }
#pageAd .lab { font-size: 10px; color: #8a867e; margin: 0 2px 4px; letter-spacing: .5px; }
#pageAd .box { border-radius: 12px; overflow: hidden; background: #f2f1ec; max-width: 100%; }
#pageAd ins, #pageAd .ph { display: block; width: 100%; height: 100px; overflow: hidden; }
#pageAd .ph { display: flex; align-items: center; justify-content: center; font-size: 12px; color: #8a867e; }
.adrw b i { font-style: normal; font-size: 10px; font-weight: 600; color: #8a867e; border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; margin-left: 4px; }
#fakeAd { position: fixed; inset: 0; z-index: 200; background: rgba(18,18,18,.88); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-size: 18px; }
#fakeAd span { font-size: 40px; font-weight: 800; }
/* 面板底部有廣告時，更新提示往上移，不要蓋住廣告 */
body:has(#pageAd) #updBtn { bottom: calc(env(safe-area-inset-bottom, 0px) + 240px); }
