/* Stall Tycoon — friendly tycoon look: chunky game panels, clean readable type */
:root {
  --desk: #2d8f86; --desk2: #1f6f8b;
  --face: #eef1f5; --line: #c9d1dc; --line-dk: #9aa6b5;
  --t1: #1d4e89; --t2: #2f80c9; --ink: #1d2433; --muted: #637083;
  --good: #1b8a3a; --bad: #c62839; --warn: #a35f00;
  --gold: #ffd84a; --paper: #ffffff; --soft: #f6f8fb;
  --r: 10px; --r-sm: 7px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: linear-gradient(160deg, var(--desk), var(--desk2)) fixed;
  font-family: 'Nunito', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', system-ui, sans-serif;
  color: var(--ink); font-size: 16px; line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
html[lang="zh-Hans"] body { font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', 'Nunito', sans-serif; font-size: 15px; }
button, select { font: inherit; color: var(--ink); }

/* ---------- panels ---------- */
.win { background: var(--face); border-radius: var(--r); box-shadow: 0 4px 0 rgba(0,0,0,.18), 0 8px 24px rgba(0,0,0,.18); padding: 6px; }
.inset { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); }
.titlebar { background: linear-gradient(90deg, var(--t1), var(--t2)); color: #fff; font-weight: 800; padding: 6px 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 34px; border-radius: var(--r-sm); }
.titlebar select { max-width: 55%; font-size: 13px; }
button {
  background: #fff; border: 1px solid var(--line-dk); border-bottom-width: 3px; border-radius: var(--r-sm);
  padding: 6px 11px; cursor: pointer; line-height: 1.2; font-weight: 700; transition: transform .05s, background .1s;
}
button:hover:not(:disabled) { background: #f0f6ff; border-color: var(--t2); }
button:active:not(:disabled) { transform: translateY(2px); border-bottom-width: 1px; margin-bottom: 2px; }
button.on { background: #dcebff; border-color: var(--t2); color: var(--t1); }
button:disabled { color: #a9b1bd; background: #f3f4f6; border-color: #dde1e7; cursor: not-allowed; }
button:focus-visible { outline: 2px solid var(--t2); outline-offset: 2px; }
button.sm { padding: 4px 8px; font-size: 13px; }
button.danger { color: var(--bad); }
button em { display: block; font-style: normal; font-size: 11px; color: var(--good); font-weight: 800; }
button.q { padding: 0 6px; font-size: 11px; font-weight: 800; border-radius: 50%; border-bottom-width: 1px; vertical-align: middle; background: #fff7cc; border-color: #e3c75a; min-width: 20px; height: 20px; }
select { background: #fff; border: 1px solid var(--line-dk); border-radius: var(--r-sm); padding: 4px 6px; }

/* ---------- layout ---------- */
#app { max-width: 1440px; margin: 0 auto; padding: 10px; display: flex; flex-direction: column; gap: 10px; }
main { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 1fr); gap: 10px; align-items: start; }
@media (max-width: 960px) { main { grid-template-columns: minmax(0, 1fr); } }

/* ---------- HUD ---------- */
#hud { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }
.logo { display: flex; align-items: center; gap: 10px; padding: 4px 14px 4px 8px; background: linear-gradient(90deg, var(--t1), var(--t2)); color: #fff; border-radius: var(--r-sm); }
.logo-ic { font-size: 30px; filter: drop-shadow(0 2px 0 rgba(0,0,0,.35)); }
.logo b { font-size: 20px; font-weight: 900; display: block; text-shadow: 2px 2px 0 rgba(0,0,0,.45); color: var(--gold); letter-spacing: .5px; }
html[lang="zh-Hans"] .logo b { font-family: 'Noto Sans SC', sans-serif; font-size: 20px; font-weight: 900; }
.logo small { font-size: 12px; opacity: .9; }
.hud-cell { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px 10px; display: flex; flex-direction: column; justify-content: center; min-width: 84px; }
.hud-cell small { font-size: 12px; color: var(--muted); }
.hud-cell b { font-size: 17px; font-weight: 800; white-space: nowrap; }
.hud-cell.cash b { color: var(--good); font-size: 20px; font-weight: 900; }
.hud-cell.stage { min-width: 170px; flex: 1; }
.bar { height: 8px; background: #e6ebf1; border-radius: 4px; margin: 3px 0; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #2f80c9, #5fb0f0); border-radius: 4px; }
.hud-btns { display: flex; gap: 4px; align-items: center; margin-left: auto; }
.hud-btns button { min-width: 44px; height: 44px; font-size: 18px; }
.hud-btns .lang { font-size: 14px; font-weight: 800; }

/* ---------- stage ---------- */
#stage-wrap { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 10px; }
@media (max-width: 960px) { #stage-wrap { position: static; } }
#canvas-box { padding: 0; line-height: 0; background: #000; overflow: hidden; }
#scene { width: 100%; aspect-ratio: 16 / 9; image-rendering: pixelated; image-rendering: crisp-edges; display: block; }
#livebar { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 6px 10px; background: #17202e; color: #b8f5b8; border-color: #17202e; }
#livebar span { font-size: 15px; font-weight: 700; }
#controls { display: flex; gap: 6px; }
#controls .start { flex: 1; padding: 13px; font-size: 19px; font-weight: 900; background: #3fae49; border-color: #2a7d32; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
#controls .start:hover { background: #4cc757; border-color: #2a7d32; }
.speeds { display: flex; gap: 5px; flex: 1; }
.speeds button { flex: 1; padding: 10px; font-size: 15px; }
#ticker { font-size: 14px; padding: 6px 10px; height: 136px; overflow: auto; }
#ticker div { padding: 3px 0; border-bottom: 1px solid #eef1f5; }
#ticker b { color: var(--muted); font-weight: 600; margin-right: 6px; }
#ticker .good { color: var(--good); } #ticker .bad { color: var(--bad); }

/* ---------- panel ---------- */
#panel { display: flex; flex-direction: column; gap: 6px; position: relative; }
#tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
.tabbtn { display: flex; flex-direction: column; align-items: center; padding: 5px 2px; }
.tabbtn span { font-size: 22px; line-height: 1.15; }
.tabbtn small { font-size: 12px; white-space: nowrap; font-weight: 700; }
.tabbtn.locked { opacity: .55; }
#tab-body { padding: 10px 12px 16px; max-height: calc(100vh - 240px); min-height: 420px; overflow: auto; }
@media (max-width: 960px) { #tab-body { max-height: none; } }
body.running #tab-body { opacity: .55; pointer-events: none; filter: grayscale(.4); }
body.running #tabs { pointer-events: none; }
#tab-body h2 { margin: 0 0 10px; font-size: 19px; font-weight: 900; color: var(--t1); border-bottom: 2px solid #dbe5f1; padding-bottom: 5px; }
#tab-body h3 { margin: 16px 0 6px; font-size: 16px; font-weight: 800; color: var(--t1); }
#tab-body h4 { margin: 0 0 6px; font-size: 15px; font-weight: 800; }
p { margin: 6px 0; }
.small { font-size: 13px; } .muted { color: var(--muted); } .center { text-align: center; }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
.row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; }
.row.q3 > * { flex: 1; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 10px; margin: 5px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.chip { font-size: 14px; padding: 5px 11px; border-radius: 999px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; margin: 7px 0; }
.card.sel { border-color: var(--t2); box-shadow: 0 0 0 2px #cfe3fa; }
.card.dim { opacity: .6; }
.box { background: var(--soft); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; margin: 12px 0; }
.box label { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin: 5px 0; font-weight: 700; }
.box select { min-width: 55%; }
.callout { background: #fff8dc; border: 1px solid #ecd27a; border-radius: var(--r-sm); padding: 7px 10px; margin: 8px 0; }
.callout.bad { background: #ffeaea; border-color: #efb1b1; } .callout.good { background: #e8f8ea; border-color: #9fd9a8; }
.tip { background: #fffbe6; border: 1px solid #ecd27a; border-left: 4px solid #e0b400; border-radius: var(--r-sm); padding: 7px 10px; margin: 12px 0; font-size: 14px; }
.tip.muted { background: #f3f5f8; border-color: #d6dbe2; border-left-color: #b4bcc8; }
.badge { display: inline-block; background: #eef1f5; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; font-size: 13px; font-weight: 700; }
.badge.good { background: #e8f8ea; border-color: #9fd9a8; }
.ic { font-size: 18px; }
.meter { flex: 1; height: 20px; background: #e6ebf1; border-radius: 10px; position: relative; overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 10px; }
.meter span { position: absolute; inset: 0; text-align: center; font-size: 12px; font-weight: 800; line-height: 20px; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.price { display: flex; align-items: center; gap: 5px; }
.price b { font-size: 18px; font-weight: 900; min-width: 80px; text-align: center; background: #17202e; color: var(--gold); padding: 6px 6px; border-radius: var(--r-sm); }
.price button { width: 36px; height: 36px; font-size: 20px; font-weight: 900; padding: 0; }
.qual { padding: 7px 4px; font-size: 13px; }
.qual b { color: #d29a00; font-size: 16px; }

.tbl, .pl { width: 100%; border-collapse: collapse; font-size: 15px; background: #fff; }
.tbl th { background: #eef2f7; border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: left; font-size: 13px; color: var(--muted); }
.tbl td { border-bottom: 1px solid #eef1f5; padding: 6px; vertical-align: top; }
.tbl .num, .pl .num { text-align: right; white-space: nowrap; }
.tbl .buys { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.tbl .buys button { min-width: 64px; }
.tbl tr.tot td, .pl tr.tot td { border-top: 2px solid var(--ink); font-weight: 800; }
.pl td { padding: 5px 8px; border-bottom: 1px solid #eef1f5; }
.pl tr.sec td { background: #eaf1fa; font-weight: 800; color: var(--t1); }
.pl tr.grand td { border-top: 2px solid var(--ink); font-weight: 900; font-size: 17px; }
.pl tr.grand.pos td { background: #e8f8ea; } .pl tr.grand.neg td { background: #ffeaea; }
#chart { width: 100%; height: auto; border: 1px solid var(--line); border-radius: var(--r-sm); background: #fff; }
.legend .lg-rev { color: #2e9e44; } .legend .lg-pro { color: #1d70b8; }
.goals { padding-left: 0; list-style: none; margin: 0; }
.goals li { display: flex; justify-content: space-between; padding: 7px 8px; border-bottom: 1px solid #eef1f5; font-size: 14px; }
.goals li.done { color: var(--muted); } .goals li.next { background: #fffbe6; font-weight: 800; border-radius: var(--r-sm); }
details.learn { background: #fff; border: 1px solid var(--line); border-radius: var(--r-sm); margin: 6px 0; }
details.learn summary { padding: 8px 10px; cursor: pointer; font-weight: 800; }
details.learn p { padding: 0 12px 10px; margin: 0; }
.locked-panel { text-align: center; padding: 40px 10px; }
.locked-panel .big { font-size: 54px; }

/* ---------- modals ---------- */
#modal-root .overlay { position: fixed; inset: 0; background: rgba(10, 30, 45, .55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal { width: min(460px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; animation: pop .16s ease-out; }
.modal.wide { width: min(640px, 100%); }
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-body { background: var(--paper); margin: 6px 0; padding: 12px 14px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.modal-btns { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.modal-btns button { min-width: 100px; padding: 9px 16px; }
.learn-big { font-size: 46px; text-align: center; margin: 4px 0; }
.steps { padding-left: 22px; } .steps li { margin: 5px 0; }
.stats { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-bottom: 8px; }
@media (max-width: 560px) { .stats { grid-template-columns: repeat(3, 1fr); } }
.stats div { background: var(--soft); border: 1px solid var(--line); border-radius: var(--r-sm); text-align: center; padding: 6px 2px; }
.stats b { display: block; font-size: 22px; font-weight: 900; line-height: 1.2; }
.stats small { font-size: 12px; color: var(--muted); font-weight: 700; }
.advisor { display: flex; gap: 10px; background: #fffbe6; border: 1px solid #ecd27a; border-radius: var(--r-sm); padding: 10px; margin-top: 12px; }
.adv-face { font-size: 38px; }
.advisor ul { margin: 4px 0 0; padding-left: 18px; font-size: 15px; }
.quiz-q { font-weight: 800; font-size: 18px; }
.quiz-a { display: flex; flex-direction: column; gap: 6px; }
.quiz-a button { text-align: left; padding: 9px 12px; }
.quiz-a button.right { background: #c9f0cf; border-color: var(--good); color: #000; } .quiz-a button.wrong { background: #f8cdd2; border-color: var(--bad); color: #000; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #fffbe6; border: 1px solid #ecd27a; border-radius: var(--r); padding: 9px 16px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.25); transition: opacity .4s; max-width: calc(100% - 32px); font-weight: 700; }
.toast.bad { background: #ffeaea; border-color: #efb1b1; } .toast.good { background: #e8f8ea; border-color: #9fd9a8; }
.toast.out { opacity: 0; }

@media (max-width: 600px) {
  #app { padding: 8px; }
  .hud-cell { min-width: 0; flex: 1 1 28%; }
  .logo { flex: 1 1 100%; }
  .hud-btns { margin-left: 0; }
  .tabbtn small { font-size: 10px; }
  .grid2 { grid-template-columns: 1fr; }
}

.nick-row { display: flex; align-items: center; gap: 8px; font-weight: 800; margin-top: 10px; }
.nick-row input { flex: 1; font: inherit; font-size: 17px; padding: 8px 10px; border: 1px solid var(--line-dk); border-radius: var(--r-sm); }
.nick-row input:focus { outline: 2px solid var(--t2); border-color: var(--t2); }
.tbl.lb tr.me td { background: #fff3c4; }
