/* Shanghai Life — light, warm UI */
:root {
  --bg: #f6f1e7; --card: #ffffff; --ink: #1f2933; --mut: #6b7280; --line: #e7e0d2;
  --pri: #d64545; --pri2: #b83232; --good: #2f9e6b; --warn: #d9822b; --bad: #d64545;
  --r: 14px; --sh: 0 1px 2px rgba(31,41,51,.06), 0 4px 14px rgba(31,41,51,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: #ece6d9; color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC", "Noto Sans SC", sans-serif; -webkit-tap-highlight-color: transparent; }
#app { max-width: 480px; min-height: 100vh; min-height: 100dvh; margin: 0 auto; background: var(--bg); position: relative; box-shadow: 0 0 40px rgba(0,0,0,.06); }
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
a { color: var(--pri); }
h4 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--mut); }
.muted { color: var(--mut); }
.small { font-size: 13px; }
.center { text-align: center; }
.fine { font-size: 12px; color: var(--mut); text-align: center; margin: 14px 8px; }
.warn { color: var(--warn); font-style: normal; font-weight: 600; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--mut); }

/* buttons */
.btn { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 16px; font-weight: 600; transition: transform .08s, background .15s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn:active { transform: scale(.98); }
.btn.pri { background: var(--pri); border-color: var(--pri); color: #fff; }
.btn.pri:hover { background: var(--pri2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--mut); }
.btn.danger { color: var(--bad); border-color: #f0c9c9; }
.btn.big { width: 100%; padding: 14px 18px; font-size: 16px; }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn small { display: block; font-weight: 400; font-size: 12px; opacity: .75; }
.btn .av { border-radius: 50%; }
.iconbtn { border: 0; background: transparent; font-size: 20px; width: 40px; height: 40px; border-radius: 10px; }
.iconbtn:hover { background: rgba(0,0,0,.05); }
.iconbtn.sm { width: 34px; height: 34px; font-size: 16px; }

/* landing */
.landing { padding: 0 18px 24px; }
.hero { text-align: center; padding-top: 28px; }
.skyline svg { width: 100%; height: 130px; display: block; }
.hero h1 { font-size: 44px; margin: 8px 0 4px; letter-spacing: -.02em; }
.hero h1 span { color: var(--pri); }
.tag { color: var(--mut); margin: 0 0 20px; }
.lcard { display: grid; gap: 10px; background: var(--card); padding: 16px; border-radius: 18px; box-shadow: var(--sh); text-align: center; }
.lcard .btn.big small { display: inline; margin-left: 6px; opacity: .8; }
.feat { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.feat div { background: var(--card); border-radius: var(--r); padding: 12px; font-size: 22px; box-shadow: var(--sh); }
.feat b { display: block; font-size: 14px; margin-top: 4px; }
.feat span { display: block; font-size: 12.5px; color: var(--mut); }

/* create / auth */
.create, .auth { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.chead { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 2; }
.steps { display: flex; gap: 6px; overflow-x: auto; font-size: 12.5px; }
.steps span { padding: 4px 9px; border-radius: 20px; background: #ebe4d6; color: var(--mut); white-space: nowrap; }
.steps span.on { background: var(--pri); color: #fff; }
.steps span.done { background: #f3d9d9; color: var(--pri2); }
.cbody, .abody { flex: 1; padding: 16px; overflow-y: auto; }
.cfoot { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); position: sticky; bottom: 0; }
.lead { margin: 0 0 12px; color: var(--mut); }
.look .bigav { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 8px; }
.look .bigav .av { border-radius: 50%; box-shadow: var(--sh); }
.field { margin: 12px 0; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 14px; }
.field input, .row input, input.full { width: 100%; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; outline: none; transition: border-color .15s; }
.field input:focus, .row input:focus { border-color: var(--pri); }
.hint { font-size: 12.5px; color: var(--mut); margin-top: 5px; min-height: 18px; }
.hint.good { color: var(--good); } .hint.bad { color: var(--bad); }
.optrow { margin: 10px 0; }
.optrow label { display: block; font-size: 13px; color: var(--mut); margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1.5px solid var(--line); background: #fff; border-radius: 20px; padding: 6px 12px; font-size: 13px; }
.chip.sel { border-color: var(--pri); background: #fdeeee; color: var(--pri2); font-weight: 600; }
.chip.sw { width: 34px; height: 34px; padding: 0; border-radius: 50%; border-width: 3px; border-color: #fff; box-shadow: 0 0 0 1px var(--line); }
.chip.sw.sel { box-shadow: 0 0 0 2.5px var(--pri); background-clip: padding-box; }
.cards { display: grid; gap: 10px; }
.cards.grid2 { grid-template-columns: 1fr 1fr; }
.pcard { display: flex; gap: 12px; text-align: left; border: 2px solid transparent; background: var(--card); border-radius: var(--r); padding: 12px; box-shadow: var(--sh); }
.grid2 .pcard { flex-direction: column; gap: 4px; }
.pcard.sel { border-color: var(--pri); background: #fffafa; }
.pcard .pi { font-size: 28px; line-height: 1; }
.pcard p { margin: 3px 0 6px; font-size: 13px; color: var(--mut); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.tags span { font-size: 11.5px; background: #f1ece2; border-radius: 6px; padding: 2px 7px; }
.who { display: flex; gap: 12px; align-items: center; background: var(--card); padding: 12px; border-radius: var(--r); margin-bottom: 14px; box-shadow: var(--sh); }
.who .av { border-radius: 50%; flex: none; }
.seg { display: flex; background: #ebe4d6; border-radius: 12px; padding: 3px; margin-bottom: 6px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 9px; border-radius: 10px; font-weight: 600; color: var(--mut); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--sh); }
.pw { position: relative; }
.pw input { padding-right: 44px; }
.pw .iconbtn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.meter { height: 5px; background: #ebe4d6; border-radius: 3px; margin-top: 7px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--good); transition: width .2s; border-radius: 3px; }
.meter i.weak { background: var(--bad); } .meter i.ok { background: var(--warn); } .meter i.strong { background: var(--good); }
.meter.big { height: 10px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 8px 0 12px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin-bottom: 8px; }
.abody > .btn.ghost { width: 100%; margin-top: 10px; }

/* game */
.game { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.stick { position: sticky; top: 0; background: var(--bg); z-index: 3; box-shadow: 0 6px 10px -8px rgba(31,41,51,.18); }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; }
.me { border: 0; background: none; padding: 0; border-radius: 50%; }
.me .av { border-radius: 50%; display: block; box-shadow: var(--sh); }
.tinfo { flex: 1; min-width: 0; }
.tinfo b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tinfo span { font-size: 13px; color: var(--mut); }
.clock { color: var(--ink); font-variant-numeric: tabular-nums; }
.money { font-weight: 800; font-size: 18px; background: #fff; border-radius: 12px; padding: 6px 10px; box-shadow: var(--sh); font-variant-numeric: tabular-nums; }
.money.neg { color: var(--bad); }
.needs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 10px; padding: 4px 12px 8px; }
.need { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.need .bar { flex: 1; height: 7px; background: #e6dfd1; border-radius: 4px; overflow: hidden; }
.need .bar i { display: block; height: 100%; background: var(--good); border-radius: 4px; transition: width .4s; }
.need.low .bar i { background: var(--warn); }
.need.bad .bar i { background: var(--bad); }
.need.bad { animation: blink 1.4s infinite; }
.need em { font-style: normal; font-size: 11px; color: var(--mut); width: 18px; text-align: right; font-variant-numeric: tabular-nums; }
@keyframes blink { 50% { opacity: .55; } }
.where { margin: 0 12px; padding: 12px 14px; border-radius: var(--r); background: #fff; box-shadow: var(--sh); border-left: 5px solid var(--dc); }
.where small { color: var(--mut); font-size: 12px; }
.where b { display: block; font-size: 17px; }
.where span { font-size: 13px; color: var(--mut); }
.jobpill { margin-top: 8px; font-size: 12.5px; background: #f6f1e7; border-radius: 8px; padding: 5px 8px; display: inline-block; }
.tabs { display: flex; gap: 6px; padding: 10px 12px 4px; }
.tabs button { flex: 1; border: 0; background: #ebe4d6; padding: 9px; border-radius: 12px; font-weight: 600; color: var(--mut); }
.tabs button.on { background: var(--ink); color: #fff; }
.main { flex: 1; padding: 8px 12px 12px; }
.acts { display: grid; gap: 8px; }
.act { display: flex; gap: 12px; align-items: center; text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: var(--r); padding: 10px 12px; transition: transform .08s; }
.act:active { transform: scale(.99); }
.act.hl { border-color: var(--pri); box-shadow: 0 0 0 3px #fbe1e1; }
.act.dis { opacity: .5; }
.act .ai { font-size: 26px; width: 34px; text-align: center; flex: none; }
.act .at { flex: 1; min-width: 0; }
.act b { display: block; font-size: 14.5px; }
.act small { display: block; color: var(--mut); font-size: 12.5px; }
.fx { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.fx span { font-size: 11.5px; border-radius: 6px; padding: 1px 6px; }
.fx .up { background: #e3f4ea; color: #1f7a50; }
.fx .dn { background: #fbe7e2; color: #b4472f; }
.logbar { padding: 8px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #fbf8f2; font-size: 12.5px; position: sticky; bottom: 0; }
.logbar p { margin: 2px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #44505c; }
.logbar time { color: var(--mut); font-variant-numeric: tabular-nums; margin-right: 4px; }
#sync { font-size: 11px; color: var(--mut); float: right; }

/* map */
.mapwrap { background: #fff; border-radius: var(--r); padding: 8px; box-shadow: var(--sh); }
.map { width: 100%; height: auto; display: block; border-radius: 10px; }
.map .node { cursor: pointer; }
.map .node:hover circle:first-child { fill: #fff8e8; }
.map .lbl { font-size: 12px; font-weight: 700; fill: #2c3440; paint-order: stroke; stroke: #f4efe4; stroke-width: 3px; }
.map .river { font-size: 10px; fill: #6aa7cf; font-style: italic; }
.pulse { animation: pulse 2s infinite; transform-origin: center; transform-box: fill-box; }
@keyframes pulse { 0% { opacity: .6; transform: scale(.8); } 100% { opacity: 0; transform: scale(1.4); } }
.legend { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; font-size: 12px; margin-top: 6px; }
.legend i { display: inline-block; width: 14px; height: 4px; border-radius: 2px; margin-right: 4px; vertical-align: middle; }

/* phone */
.phone { background: #fff; border-radius: 20px; box-shadow: var(--sh); padding: 12px; min-height: 300px; }
.apps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px 6px; padding: 8px 2px; }
.app { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; color: var(--ink); }
.app span { width: 54px; height: 54px; display: grid; place-items: center; font-size: 26px; background: #f3eee5; border-radius: 16px; }
.app:hover span { background: #ebe3d4; }
.apphead { display: flex; align-items: center; gap: 4px; margin: -4px 0 6px; }
.apphead b { font-size: 16px; }
.appbody .act { margin-bottom: 8px; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: #fff; }
.card.cur { background: #fbf8f2; }
.card.locked { opacity: .7; }
.card p { margin: 4px 0; font-size: 13px; }
.card .pay { float: right; font-weight: 700; color: var(--good); }
.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 20px; background: #e3f4ea; color: #1f7a50; font-weight: 600; }
.badge.lock { background: #f1ece2; color: var(--mut); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; }
.bookcount { font-size: 15px; }
.bookgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.bk { background: #f3eee5; border-radius: 10px; padding: 8px 4px; text-align: center; font-size: 11.5px; color: var(--mut); }
.bk span { display: block; font-size: 22px; filter: grayscale(1); opacity: .5; }
.bk.got { background: #fff7e6; color: var(--ink); }
.bk.got span { filter: none; opacity: 1; }
.statshead { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.statshead .av { border-radius: 50%; }
ul.stats { list-style: none; padding: 0; margin: 0; }
ul.stats li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.nb { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.nb .av { border-radius: 50%; flex: none; }
.nb p { margin: 3px 0 0; font-size: 13.5px; }
.nb small { font-size: 12px; }
.nb.npc { opacity: .85; }
.lbrow { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.lbrow em { font-style: normal; font-weight: 800; width: 22px; color: var(--mut); }
.lbrow div { flex: 1; }
.lbrow .av { border-radius: 50%; }
.lbrow.me { background: #fff7e6; border-radius: 8px; }

/* modal */
#modal { position: fixed; inset: 0; display: none; align-items: flex-end; justify-content: center; background: rgba(31,41,51,.35); z-index: 50; padding: 12px; }
#modal.show { display: flex; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.mbox { background: var(--card); width: 100%; max-width: 440px; border-radius: 20px; padding: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.2); max-height: 88vh; overflow-y: auto; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); } }
@media (min-width: 600px) { #modal { align-items: center; } }
.micon { font-size: 40px; text-align: center; }
.mbox h3 { margin: 4px 0 8px; text-align: center; font-size: 19px; }
.mbody { font-size: 14.5px; color: #36414d; }
.mbtns { display: flex; gap: 8px; margin-top: 16px; }
.mbtns .btn { flex: 1; }
.mbtns.col { flex-direction: column; }
.mbtns .btn.opt { justify-content: flex-start; text-align: left; flex-direction: column; align-items: flex-start; gap: 0; }
.recap .rrow { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--line); }
.recap .high { background: #fff7e6; padding: 8px 10px; border-radius: 10px; }

/* toast */
#toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%) translateY(-20px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 60; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 3D city */
.mapseg { margin-bottom: 8px; }
.c3dwrap { position: relative; border-radius: var(--r); overflow: hidden; box-shadow: var(--sh); background: #d7eaf5; }
.c3d { width: 100%; height: max(320px, calc(100vh - 470px)); height: max(320px, calc(100dvh - 470px)); }
.c3dcanvas { display: block; width: 100% !important; height: 100% !important; cursor: grab; }
.c3d-load { display: grid; place-items: center; height: 100%; color: var(--mut); font-size: 14px; padding: 20px; text-align: center; }
.c3dhud { position: absolute; left: 10px; top: 10px; background: rgba(255,255,255,.92); border-radius: 10px; padding: 5px 10px; font-size: 13px; font-weight: 600; box-shadow: var(--sh); pointer-events: none; }
.c3dctl { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.c3dctl button { width: 38px; height: 38px; border-radius: 10px; border: 0; background: rgba(255,255,255,.94); font-size: 18px; font-weight: 700; box-shadow: var(--sh); }

/* social */
.tright { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.online { border: 0; background: #e3f4ea; color: #1f7a50; font-size: 11.5px; font-weight: 700; border-radius: 20px; padding: 2px 8px; display: inline-flex; align-items: center; gap: 5px; }
.online i { width: 7px; height: 7px; border-radius: 50%; background: #2f9e6b; box-shadow: 0 0 0 0 rgba(47,158,107,.6); animation: ping 1.8s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 6px rgba(47,158,107,0); } 100% { box-shadow: 0 0 0 0 rgba(47,158,107,0); } }
.nearby { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 8px 10px; margin-bottom: 8px; }
.nearby h5 { margin: 0 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--mut); }
.nearby.empty { font-size: 13px; color: var(--mut); }
.prow, .frow { display: flex; gap: 10px; align-items: center; width: 100%; border: 0; background: none; text-align: left; padding: 7px 2px; border-bottom: 1px solid #f0eadf; }
.prow:last-child, .frow:last-child { border-bottom: 0; }
.prow .av, .frow .av { border-radius: 50%; flex: none; }
.prow span, .frow span { flex: 1; min-width: 0; font-size: 13.5px; }
.prow small, .frow small { display: block; color: var(--mut); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prow em { font-style: normal; font-size: 11.5px; color: var(--mut); }
.dot.on, .on { color: #2f9e6b; }
i.dot.on { display: inline-block; width: 7px; height: 7px; background: #2f9e6b; border-radius: 50%; margin-left: 5px; vertical-align: middle; }
.citystat { font-size: 13.5px; margin: 0 0 8px; }
.badge2 { position: absolute; top: -4px; right: -4px; background: #2f9e6b; color: #fff; font-size: 10px; border-radius: 10px; padding: 1px 5px; font-style: normal; }
.app span { position: relative; }
.prof { display: flex; gap: 12px; align-items: center; }
.prof .av { border-radius: 50%; flex: none; }
.nowline { background: #f6f1e7; border-radius: 10px; padding: 7px 10px; font-size: 13.5px; margin: 10px 0 4px; }
.nbbtn { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.nbbtn:hover { background: #fbf8f2; }

/* ads & links */
.links { text-align: center; font-size: 13px; margin: 6px 0 18px; }
.links a { color: var(--mut); }
.adslot { max-width: 480px; margin: 0 auto; background: var(--bg); padding: 6px 12px 14px; }
.adslot small { display: block; font-size: 10.5px; color: var(--mut); text-align: center; margin-bottom: 3px; letter-spacing: .05em; text-transform: uppercase; }
body[data-screen="landing"] #app { min-height: 0; }

/* ---------- desktop (≥1000px) ---------- */
@media (min-width: 1000px) {
  body.wide[data-screen="landing"], body.wide[data-screen="create"], body.wide[data-screen="auth"] {
    background: #dfe9d3 url(city-bg.jpg) center / cover no-repeat fixed;
  }
  body.wide[data-screen="landing"] #app, body.wide[data-screen="create"] #app, body.wide[data-screen="auth"] #app {
    margin: 40px auto; border-radius: 22px; overflow: hidden; box-shadow: 0 20px 60px rgba(31,41,51,.25); min-height: 0;
  }
  body.wide[data-screen="create"] .create, body.wide[data-screen="auth"] .auth { min-height: 0; max-height: calc(100vh - 80px); }
  body.wide[data-screen="landing"] .adslot { border-radius: 0 0 16px 16px; margin-top: -30px; }
  body.wide[data-screen="game"] { background: var(--bg); }
  body.wide[data-screen="game"] #app { max-width: none; box-shadow: none; min-height: 100vh; }
  .desk { display: flex; flex-direction: column; height: 100vh; }
  .deskbar { display: flex; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: #fbf8f2; }
  .deskbar .brand { font-size: 20px; letter-spacing: -.01em; }
  .deskbar .brand span { color: var(--pri); }
  .deskbar .online { font-size: 13px; padding: 4px 10px; }
  .deskbar .sp { flex: 1; }
  .deskbar .links { margin: 0; }
  .deskbody { flex: 1; display: flex; min-height: 0; }
  .deskmap { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 12px; gap: 8px; }
  .deskmap .mapseg { width: 320px; margin: 0; }
  .deskmap .c3dwrap { flex: 1; min-height: 0; }
  .deskmap .c3d { height: 100% !important; min-height: 0; }
  .deskmap > p.muted { margin: 0; }
  .deskmap .mapwrap { flex: 1; min-height: 0; display: flex; flex-direction: column; }
  .deskmap .mapwrap .map { flex: 1; min-height: 0; width: 100%; height: 100%; }
  .deskside { width: 440px; flex: none; border-left: 1px solid var(--line); overflow-y: auto; background: var(--bg); }
  .deskside .game { min-height: 100%; }
  .deskside .stick { top: 0; }
  #ad-phone { display: none; }
}
