:root {
  --bg: #0d1117; --panel: #161b22; --panel2: #1c2230; --border: #30363d; --text: #e6edf3; --muted: #8b949e;
  --green: #3fb950; --green-d: #238636; --red: #f85149; --orange: #f0883e; --blue: #58a6ff; --purple: #a371f7; --gold: #e3b341;
  --radius: 12px; --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  -webkit-tap-highlight-color: transparent; padding-bottom: 84px; overflow-x: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
p { margin: 0 0 8px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); } .small { font-size: 12px; } .hidden { display: none !important; }
.center { text-align: center; }
.c-up { color: var(--green); } .c-down { color: var(--red); } .c-warn { color: var(--orange); }
.label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(13, 17, 23, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 6px; font-size: 17px; white-space: nowrap; }
.company { flex: 1; min-width: 0; text-align: left; background: none; border: 0; padding: 4px 8px; border-radius: 8px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.company:hover { background: var(--panel); color: var(--text); }
.clock { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; line-height: 1.25; }
.clock b { color: var(--text); display: block; }
.clock.paused b { color: var(--orange); }
.pausebar {
  position: sticky; top: 55px; z-index: 19; display: flex; gap: 10px; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: #3d2a0c; border-bottom: 2px solid var(--orange); color: #ffe6c7; font-size: 14px;
}
.pausebar .btn { white-space: nowrap; }
.pausebar.danger { background: #3d0c0f; border-color: var(--red); color: #ffdcd7; }

/* ---------- layout ---------- */
.screens { max-width: 1100px; margin: 0 auto; padding: 12px; }
.screen { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .screen.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; } .span2 { grid-column: 1 / -1; } }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.card-head h3, .card h3 { margin: 0; font-size: 15px; }
.card h3 { margin-bottom: 8px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(7, 1fr);
  background: rgba(13, 17, 23, .96); backdrop-filter: blur(8px); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab { background: none; border: 0; padding: 8px 0 6px; min-width: 0; color: var(--muted); font-size: 10px; white-space: nowrap; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.tab-ico { font-size: 20px; line-height: 1; }
.tab.active { color: var(--text); }
.tab.active .tab-ico { filter: drop-shadow(0 0 6px rgba(240, 136, 62, .7)); }
.badge { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--red); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; }
.badge.soft { background: var(--green-d); }
@media (min-width: 900px) {
  body { padding-bottom: 20px; padding-top: 101px; }
  .topbar { position: fixed; top: 0; left: 0; right: 0; height: 55px; }
  .tabbar { position: fixed; top: 55px; bottom: auto; grid-template-columns: repeat(7, auto); justify-content: center; gap: 4px; border-top: 0; border-bottom: 1px solid var(--border); }
  .tab { flex-direction: row; gap: 6px; font-size: 14px; padding: 10px 16px; }
  .tab-ico { font-size: 18px; }
  .badge { top: 4px; right: 4px; }
  .pausebar { top: 101px; }
}

/* ---------- dashboard ---------- */
.cash-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.cash { font-size: 34px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; }
.cash.neg { color: var(--red); }
.pill { padding: 6px 10px; border-radius: 999px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.pill.ok { background: rgba(63, 185, 80, .12); color: var(--green); border: 1px solid rgba(63, 185, 80, .35); }
.pill.warn { background: rgba(240, 136, 62, .12); color: var(--orange); border: 1px solid rgba(240, 136, 62, .4); }
.pill.dead { background: rgba(248, 81, 73, .12); color: var(--red); border: 1px solid rgba(248, 81, 73, .4); }
.runway-note { margin-top: 6px; font-size: 13px; color: var(--muted); }
.runway-note.warn { color: var(--orange); }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-width: 0; }
.stat-v { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clockcard { display: flex; flex-direction: column; gap: 8px; }
.clock-big { font-size: 20px; font-weight: 700; }
.clock-sub { color: var(--muted); font-size: 13px; }
.scene-card { padding: 0; overflow: hidden; }
.scene { position: relative; height: 130px; overflow: hidden; background: linear-gradient(180deg, var(--sky1, #1f6feb) 0%, var(--sky2, #79c0ff) 100%); transition: background 2s linear; }
.scene::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 24px; background: linear-gradient(180deg, #2d333b, #22272e); border-top: 2px solid #444c56; }
.sky-body { position: absolute; font-size: 24px; left: 12px; top: 12px; }
.building { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 70px; line-height: 1; z-index: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,.35)); }
.crew { position: absolute; left: 8px; right: 8px; bottom: 3px; z-index: 2; display: flex; justify-content: center; gap: 1px; font-size: 16px; overflow: hidden; }
.crew span { animation: bob 1.6s ease-in-out infinite; display: inline-block; }
@keyframes bob { 50% { transform: translateY(-2px); } }
.scene-info { padding: 10px 14px 12px; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border); white-space: nowrap; }
.chip.good { border-color: rgba(63, 185, 80, .5); color: var(--green); }
.chip.bad { border-color: rgba(248, 81, 73, .5); color: var(--red); }
.meters { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.meter-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
.bar { height: 8px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--border); overflow: hidden; margin-top: 5px; }
.bar-fill { height: 100%; width: 0; border-radius: 999px; transition: width .4s; background: var(--blue); }
.bar-fill.debt { background: linear-gradient(90deg, var(--gold), var(--orange), var(--red)); }
.bar-fill.good { background: var(--green); } .bar-fill.energy { background: linear-gradient(90deg, var(--red), var(--gold), var(--green)); }
.bar-fill.purple { background: var(--purple); }
.slots { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.slot { font: inherit; color: inherit; border: 1px dashed var(--border); border-radius: 10px; padding: 8px; text-align: center; background: var(--panel2); min-height: 64px; display: flex; flex-direction: column; justify-content: center; gap: 2px; }
.slot.set { border-style: solid; border-color: #4a5566; }
.slot b { font-size: 14px; } .slot .small { font-size: 11px; }
.slot-pick { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 8px; }
.slot-pick button { border: 1px solid var(--border); background: var(--panel2); border-radius: 10px; padding: 8px 4px; font-size: 12px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.slot-pick button span:first-child { font-size: 20px; }
.slot-pick button:disabled { opacity: .4; cursor: default; }
.insight { padding: 8px 10px; border-left: 3px solid var(--blue); background: rgba(88, 166, 255, .08); border-radius: 6px; font-size: 13px; margin-bottom: 6px; }
.chart { width: 100%; height: 140px; display: block; }

/* ---------- inbox ---------- */
.mail { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); padding: 14px; }
.mail.urgent { border-color: var(--red); box-shadow: inset 0 0 0 1px rgba(248, 81, 73, .3); }
.mail.info { border-color: rgba(88, 166, 255, .4); }
.mail-from { font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.mail-title { font-weight: 800; font-size: 17px; margin: 2px 0 6px; }
.mail-text { margin-bottom: 10px; }
.opts { display: grid; gap: 6px; }
.opt { text-align: left; border: 1px solid var(--border); background: var(--panel2); border-radius: 10px; padding: 10px 12px; font-weight: 600; }
.opt:hover { border-color: #8b949e; }
.empty { padding: 30px 10px; text-align: center; color: var(--muted); }
.empty .big { font-size: 40px; margin-bottom: 6px; }

/* ---------- lists / rows ---------- */
.row { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; background: var(--panel2); }
.row.locked { opacity: .55; }
.row-emoji { font-size: 28px; text-align: center; }
.row-name { font-weight: 700; }
.row-desc { font-size: 12px; color: var(--muted); }
.row-stats { font-size: 12px; margin-top: 2px; }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; }
.kv span:first-child { color: var(--muted); }
.progress { height: 6px; border-radius: 999px; background: var(--bg); overflow: hidden; margin-top: 4px; }
.progress i { display: block; height: 100%; background: var(--green); }

/* ---------- buttons ---------- */
.btn { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; font-weight: 600; }
.btn:hover:not(:disabled) { border-color: #8b949e; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn-primary { background: var(--green-d); border-color: #2ea043; color: #fff; }
.btn-danger { background: #8e1519; border-color: var(--red); color: #fff; }
.btn-gold { background: #7d5a0b; border-color: var(--gold); color: #fff; }
.btn-block { width: 100%; }
.btn-ghost { background: none; color: var(--muted); }

/* ---------- investors ---------- */
.sheet { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--panel2); margin-bottom: 10px; }
.sheet.walked { opacity: .5; }
.sheet-top { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; }
.sheet-emoji { font-size: 30px; }
.sheet-name { font-weight: 800; }
.terms { font-size: 13px; color: var(--muted); margin: 6px 0; }

/* ---------- founder / legend ---------- */
.section { margin-bottom: 18px; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.ach div { padding: 8px; border-radius: 10px; border: 1px solid var(--border); background: var(--panel2); font-size: 12px; }
.ach div.no { opacity: .4; filter: grayscale(1); }
.ach b { display: block; font-size: 13px; }
.tomb { padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel2); margin-bottom: 6px; font-size: 13px; }
.idea-dex { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.idea-dex div { font-size: 22px; text-align: center; padding: 6px 0; border-radius: 8px; background: var(--panel2); border: 1px solid var(--border); }
.idea-dex .unknown { opacity: .35; filter: grayscale(1); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .7); display: flex; align-items: flex-end; justify-content: center; padding: 0; }
.modal-box { background: var(--panel); border: 1px solid var(--border); border-radius: 16px 16px 0 0; padding: 18px 16px; width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; padding-bottom: max(18px, env(safe-area-inset-bottom)); }
@media (min-width: 600px) { .modal { align-items: center; padding: 20px; } .modal-box { border-radius: 16px; } }
.modal h2 { margin: 0 0 10px; font-size: 22px; }
.modal-actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; }
.ideas { display: grid; gap: 8px; }
.idea { text-align: left; border: 1px solid var(--border); background: var(--panel2); border-radius: 12px; padding: 12px; display: grid; grid-template-columns: 44px 1fr; gap: 10px; align-items: center; }
.idea:hover { border-color: var(--orange); }
.idea-emoji { font-size: 34px; text-align: center; }
.idea-name { font-weight: 800; }
.idea-pitch { font-size: 13px; color: var(--muted); }
.idea-mods { margin-top: 4px; }
.name-input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font: inherit; margin-bottom: 12px; }
.tombstone .stone { background: linear-gradient(180deg, #3b4048, #22272e); border: 2px solid #555c66; border-radius: 60px 60px 8px 8px; padding: 22px 16px 14px; text-align: center; margin: 0 auto 14px; max-width: 320px; }
.rip { font-size: 12px; letter-spacing: .3em; color: var(--muted); }
.stone .nm { font-size: 22px; font-weight: 800; margin: 6px 0; }
.stone .dates { font-size: 13px; color: var(--muted); }
.last-words { font-style: italic; color: var(--muted); }
.review-week { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 10px; }
.review-week:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.review-nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 6px 0; }
.review-nums div { background: var(--panel2); border-radius: 8px; padding: 6px 8px; font-size: 12px; }
.review-nums b { display: block; font-size: 15px; }
.review-notes { font-size: 13px; }
.review-notes li { margin-bottom: 3px; }
ul { padding-left: 20px; margin: 6px 0; }

/* ---------- toasts ---------- */
.toasts { position: fixed; left: 12px; right: 12px; top: 70px; z-index: 40; display: flex; flex-direction: column; gap: 6px; pointer-events: none; }
.toast { background: var(--panel2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: toastin .25s ease, toastout .4s ease 5s forwards; max-width: 560px; margin: 0 auto; width: 100%; }
.toast.good { border-color: var(--green-d); } .toast.bad { border-color: var(--red); } .toast.gold { border-color: var(--gold); }
@keyframes toastin { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toastout { to { opacity: 0; transform: translateY(-8px); } }
@media (min-width: 900px) {
  .toasts { top: auto; bottom: 20px; left: auto; right: 20px; width: 380px; }
}

/* ---------- the office (3D) ---------- */
body.in-office { overflow: hidden; }
body.in-office .pausebar { display: none; }
.screen.office { position: fixed; inset: 0; z-index: 5; display: block; padding: 0; margin: 0; max-width: none; overflow: hidden; touch-action: none; background: #0b1020; }
#office-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.office-overlay { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.office-hud { position: absolute; left: 10px; right: 10px; top: calc(58px + env(safe-area-inset-top)); display: flex; flex-wrap: wrap; gap: 6px; pointer-events: none; z-index: 6; }
.office-hud > * { pointer-events: auto; }
.hud-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: rgba(13, 17, 23, .78); border: 1px solid var(--border); backdrop-filter: blur(6px); font-size: 13px; color: var(--text); }
.hud-pill .label { font-size: 10px; }
.hud-pill.paused { background: #3d2a0c; border-color: var(--orange); color: #ffe6c7; cursor: pointer; }
.hud-pill.stage { color: var(--muted); font-size: 12px; }
.office-tip { position: absolute; left: 0; right: 0; bottom: calc(76px + env(safe-area-inset-bottom)); text-align: center; font-size: 11px; color: rgba(230, 237, 243, .55); pointer-events: none; text-shadow: 0 1px 2px #000; display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 10px; }
.cam-btns { display: flex; gap: 8px; pointer-events: auto; }
.cam-btns button { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border); background: rgba(13, 17, 23, .78); color: var(--text); font-size: 18px; line-height: 1; backdrop-filter: blur(6px); }
.cam-btns button:active { background: var(--panel2); }
.tip-mouse { display: none; }
@media (hover: hover) and (pointer: fine) { .tip-touch { display: none; } .tip-mouse { display: inline; } }
.bubble { position: absolute; transform: translate(-50%, -100%); pointer-events: auto; cursor: pointer; max-width: 160px; padding: 6px 10px; border-radius: 12px; background: #fff; color: #111; font-size: 12px; font-weight: 700; line-height: 1.2; box-shadow: 0 3px 10px rgba(0, 0, 0, .35); animation: bubble-in .3s ease-out, bubble-bob 2.4s ease-in-out infinite; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -6px; width: 10px; height: 10px; background: inherit; transform: translateX(-50%) rotate(45deg); }
.bubble.below { transform: translate(-50%, 0); animation: bubble-in-below .3s ease-out, bubble-bob 2.4s ease-in-out infinite; }
.bubble.below::after { bottom: auto; top: -6px; }
.bubble.urgent { background: var(--red); color: #fff; }
.bubble.money { background: var(--gold); color: #1a1200; }
.bubble.info { background: #dbe9ff; }
.bubble.tutor { background: #f0883e; color: #1a0f00; white-space: normal; width: 240px; max-width: 240px; text-align: left; }
.tut-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.tut-step { font-size: 10px; opacity: .7; }
.tut-skip { border: 0; background: rgba(0, 0, 0, .18); color: inherit; border-radius: 999px; padding: 2px 10px; font-size: 11px; font-weight: 700; }
.bubble.more { background: rgba(13, 17, 23, .85); color: var(--text); border: 1px solid var(--border); font-weight: 600; }
.bubble .who { display: block; font-weight: 500; font-size: 10px; opacity: .7; }
.ping { position: absolute; transform: translate(-50%, -50%); pointer-events: none; font: 700 13px var(--mono); color: var(--green); text-shadow: 0 1px 2px #000, 0 0 6px rgba(0, 0, 0, .6); animation: ping-up 1.7s ease-out forwards; }
.ping.neg { color: var(--red); }
.name-tag { position: absolute; transform: translate(-50%, -100%); pointer-events: none; font-size: 11px; color: #fff; background: rgba(0, 0, 0, .6); padding: 2px 7px; border-radius: 999px; white-space: nowrap; }
.office-paused-veil { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px rgba(240, 136, 62, .35); }
.office-paused-clock { position: absolute; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); font-size: 42px; pointer-events: none; animation: clock-pulse 1.6s ease-in-out infinite; filter: drop-shadow(0 2px 4px #000); }
.card-sheet .mail { border: 0; padding: 0; background: none; }
@keyframes bubble-in { from { opacity: 0; transform: translate(-50%, -80%) scale(.6); } to { opacity: 1; transform: translate(-50%, -100%) scale(1); } }
@keyframes bubble-in-below { from { opacity: 0; transform: translate(-50%, -20%) scale(.6); } to { opacity: 1; transform: translate(-50%, 0) scale(1); } }
@keyframes bubble-bob { 0%, 100% { margin-top: 0; } 50% { margin-top: -4px; } }
@keyframes ping-up { 0% { opacity: 0; margin-top: 0; } 15% { opacity: 1; } 100% { opacity: 0; margin-top: -70px; } }
@keyframes clock-pulse { 0%, 100% { transform: scale(1); opacity: .85; } 50% { transform: scale(1.12); opacity: 1; } }
@media (min-width: 900px) { .office-hud { top: 110px; } .office-tip { bottom: 12px; } .bubble { max-width: 220px; font-size: 13px; } }
body.in-office .toasts { top: auto; bottom: calc(100px + env(safe-area-inset-bottom)); }
