:root {
  --bg:#0f0f13; --surface:#1a1a24; --surface2:#22223a; --border:#2e2e4a;
  --accent:#7c6af7; --accent2:#e06c9f; --green:#56c596; --red:#e05c5c;
  --yellow:#e0b95c; --blue:#5ca8e0; --text:#e8e8f0; --text2:#9090b0; --radius:10px;
}
:root.light {
  --bg:#f0f0f5; --surface:#ffffff; --surface2:#e8e8f0; --border:#d0d0e0;
  --accent:#6255d4; --accent2:#c4537e; --green:#2e9e6e; --red:#c04040;
  --yellow:#b07820; --blue:#3a7ab0; --text:#18181f; --text2:#505070;
}

/* Theme toggle button */
#theme-toggle {
  background:var(--surface2); border:1px solid var(--border);
  border-radius:20px; padding:5px 12px; cursor:pointer;
  font-size:.8rem; color:var(--text2); transition:all .2s;
  display:flex; align-items:center; gap:5px; white-space:nowrap;
  flex-shrink:0;
}
#theme-toggle:hover { border-color:var(--accent); color:var(--text); }

/* Desktop: toggle lives in the tab bar — hide the mobile one */
#theme-toggle-tabbar { display:none; margin-left:auto; padding-right:12px; align-items:center; }
#theme-toggle-me { display:none; }

/* Mobile: toggle lives in the Me panel — hide the tab bar one */
* { box-sizing:border-box; margin:0; padding:0; }
body { background:var(--bg); color:var(--text); font-family:'Segoe UI',system-ui,sans-serif; height:100vh; overflow:hidden; }
.screen { display:none; }
.screen.active { display:flex; flex-direction:column; }
#screen-start { align-items:center; justify-content:center; min-height:100vh; overflow-y:auto; background:radial-gradient(ellipse at 50% 30%,#1e1840 0%,#0f0f13 70%); }
#start-screen { background:radial-gradient(ellipse at 50% 30%,#1e1840 0%,#0f0f13 70%); position:relative; }
#theme-toggle-start { display:block; }
#dead-screen { background:radial-gradient(ellipse at 50% 30%,#1a0a0a 0%,#0f0f13 70%); }
:root.light #start-screen { background:radial-gradient(ellipse at 50% 30%,#d8d4f8 0%,#f0f0f5 70%); }
:root.light #dead-screen { background:radial-gradient(ellipse at 50% 30%,#f8d4d4 0%,#f0f0f5 70%); }
.logo { font-size:3rem; font-weight:900; letter-spacing:-2px; }
.logo span { color:var(--accent); }
.tagline { color:var(--text2); margin-top:6px; font-size:1rem; }
.start-form { margin-top:32px; display:flex; flex-direction:column; gap:14px; width:340px; }
.form-group label { display:block; font-size:.8rem; color:var(--text2); margin-bottom:4px; text-transform:uppercase; letter-spacing:1px; }
.form-group input, .form-group select { width:100%; padding:10px 14px; background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); color:var(--text); font-size:.95rem; outline:none; }
.form-group input:focus, .form-group select:focus { border-color:var(--accent); }
.label-row { display:flex; align-items:center; justify-content:space-between; margin-bottom:4px; }
.label-row label { margin-bottom:0; }
.rand-btn { background:none; border:1px solid var(--border); border-radius:6px; color:var(--text2); font-size:.78rem; cursor:pointer; padding:2px 8px; transition:all .2s; }
.rand-btn:hover { border-color:var(--accent); color:var(--accent); }
.rand-all-btn { padding:8px; background:var(--surface2); border:1px solid var(--border); border-radius:var(--radius); color:var(--text2); cursor:pointer; font-size:.85rem; transition:all .2s; text-align:center; }
.rand-all-btn:hover { border-color:var(--accent); color:var(--text); }
.sex-row { display:flex; gap:8px; }
.sex-btn { flex:1; padding:10px; border:1px solid var(--border); border-radius:var(--radius); background:var(--surface); color:var(--text2); cursor:pointer; font-size:.9rem; transition:all .2s; }
.sex-btn.selected { border-color:var(--accent); background:var(--surface2); color:var(--text); }
.btn-primary { padding:12px; background:var(--accent); color:#fff; border:none; border-radius:var(--radius); font-size:1rem; font-weight:700; cursor:pointer; transition:opacity .2s; letter-spacing:.5px; }
.btn-primary:hover { opacity:.85; }
/* ── GAME SCREEN BASE ─────────────────────────────────── */
#game-screen { height:100vh; overflow:hidden; }
.age-btn { width:100%; padding:11px; background:var(--accent); color:#fff; border:none; border-radius:var(--radius); font-size:.95rem; font-weight:700; cursor:pointer; transition:opacity .2s; flex-shrink:0; }
.age-btn:hover:not(:disabled) { opacity:.85; }
.age-btn:disabled { opacity:.4; cursor:not-allowed; background:var(--surface2); color:var(--text2); }
.age-btn-hint { font-size:.72rem; color:var(--yellow); text-align:center; padding:2px 0; display:none; }
.char-card { background:var(--surface2); border-radius:var(--radius); padding:14px; }
.char-name { font-weight:700; font-size:1rem; }
.char-meta { color:var(--text2); font-size:.8rem; margin-top:2px; }
.char-age { font-size:2rem; font-weight:900; color:var(--accent); margin-top:6px; }
.char-age-label { font-size:.75rem; color:var(--text2); }
.stats-section { display:flex; flex-direction:column; gap:8px; }
.stat-row { display:flex; align-items:center; gap:8px; }
.stat-label { font-size:.75rem; color:var(--text2); width:60px; flex-shrink:0; }
.stat-bar-bg { flex:1; height:7px; background:var(--border); border-radius:4px; overflow:hidden; }
.stat-bar { height:100%; border-radius:4px; transition:width .4s; }
.stat-val { font-size:.75rem; width:28px; text-align:right; }
.money-row { background:var(--surface2); border-radius:var(--radius); padding:10px 14px; display:flex; align-items:center; justify-content:space-between; }
.money-label { font-size:.8rem; color:var(--text2); }
.money-val { font-weight:700; font-size:1rem; color:var(--green); }
.net-worth-row { background:var(--surface2); border-radius:var(--radius); padding:6px 14px; display:flex; align-items:center; justify-content:space-between; }
.net-worth-val { font-weight:600; font-size:.9rem; }
.debt-row { background:var(--surface2); border-radius:var(--radius); padding:6px 14px; display:flex; align-items:center; justify-content:space-between; }
.debt-val { font-weight:600; font-size:.9rem; color:var(--red); }
.parents-wealth-row { font-size:.75rem; color:var(--text2); padding:2px 0; text-align:center; }
.main-area { flex:1; display:flex; flex-direction:column; overflow:hidden; }
.tab-bar { display:flex; border-bottom:1px solid var(--border); background:var(--surface); overflow-x:auto; flex-shrink:0; scrollbar-width:none; }
.tab-bar::-webkit-scrollbar { display:none; }
.tab { padding:12px 18px; font-size:.85rem; color:var(--text2); cursor:pointer; border-bottom:2px solid transparent; white-space:nowrap; transition:all .2s; }
.tab:hover { color:var(--text); }
.tab.active { color:var(--accent); border-bottom-color:var(--accent); }
.tab-content { flex:1; overflow-y:auto; padding:20px; display:none; }
.tab-content.active { display:block; }
.mobile-age-bar { display:none; }
.panel-end-life-mobile { display:none; }

/* ── DESKTOP LAYOUT (≥ 641px): player panel as fixed sidebar ── */
@media (min-width: 641px) {
  #game-screen.active { display:flex; flex-direction:row; }
  .player-panel {
    position:fixed; left:0; top:0;
    width:260px; height:100vh;
    display:flex !important; flex-direction:column;
    background:var(--surface); border-right:1px solid var(--border);
    padding:16px; gap:10px; overflow-y:auto; z-index:10; flex-shrink:0;
  }
  .main-area { margin-left:260px; height:100vh; }
  .tab[data-tab="info"] { display:none !important; }
  .panel-age-controls { display:flex; flex-direction:column; gap:4px; }
  /* Toggle in tab bar on desktop */
  #theme-toggle-tabbar { display:flex; }
  #theme-toggle-me { display:none !important; }
}

/* ── MOBILE LAYOUT (≤ 640px): bottom tab bar + floating age button ── */
@media (max-width: 640px) {
  body { overflow:hidden; }
  #game-screen.active { display:flex; flex-direction:column; height:100dvh; height:100vh; }
  .main-area { flex:1; min-height:0; display:flex; flex-direction:column; overflow:hidden; }

  /* Tab bar fixed at bottom */
  .tab-bar {
    position:fixed; bottom:0; left:0; right:0;
    height:56px; border-top:1px solid var(--border); border-bottom:none;
    background:var(--surface); z-index:50; overflow-x:auto;
    padding-bottom:env(safe-area-inset-bottom, 0px);
  }
  .tab { padding:10px 14px; font-size:.78rem; }

  /* Tab content fills screen minus the two bottom bars (56px tab + 60px age bar) */
  .tab-content { height:calc(100vh - 116px); height:calc(100dvh - 116px); overflow-y:auto; padding:16px; flex:none; }

  /* Player panel as "Me" tab on mobile */
  .player-panel { display:none !important; flex-direction:column; gap:10px; }
  .player-panel.active { display:flex !important; }
  .panel-age-controls { display:none; }
  /* Toggle in Me panel on mobile */
  #theme-toggle-tabbar { display:none !important; }
  #theme-toggle-me { display:flex; width:100%; justify-content:center; }
  .panel-end-life-mobile { display:block; margin-top:4px; }

  /* Floating age button above tab bar */
  .mobile-age-bar {
    display:flex; flex-direction:column; align-items:center; gap:4px;
    position:fixed; bottom:56px; left:0; right:0; z-index:55;
    background:var(--bg); border-top:1px solid var(--border);
    padding:8px 16px;
  }
  .mobile-age-bar .age-btn { max-width:360px; padding:10px; font-size:.9rem; }

  /* Start form mobile width */
  .start-form { width:min(340px, 92vw); }
}
.log-container { display:flex; flex-direction:column; gap:8px; }
.log-entry { background:var(--surface); border-left:3px solid var(--border); border-radius:0 var(--radius) var(--radius) 0; padding:10px 14px; font-size:.88rem; animation:fadeIn .3s ease; }
.log-entry.good { border-left-color:var(--green); }
.log-entry.bad { border-left-color:var(--red); }
.log-entry.neutral { border-left-color:var(--accent); }
.log-entry.event { border-left-color:var(--yellow); }
.log-age { font-size:.72rem; color:var(--text2); margin-bottom:2px; }
@keyframes fadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
.section-title { font-size:.75rem; color:var(--text2); text-transform:uppercase; letter-spacing:1px; margin-bottom:10px; margin-top:18px; }
.section-title:first-child { margin-top:0; }
.action-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:10px; }
.action-btn { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:12px 14px; cursor:pointer; text-align:left; transition:all .2s; color:var(--text); }
.action-btn:hover:not(:disabled) { border-color:var(--accent); background:var(--surface2); }
.action-btn:disabled { opacity:.4; cursor:not-allowed; }
.action-btn .a-icon { font-size:1.4rem; }
.action-btn .a-title { font-size:.85rem; font-weight:600; margin-top:4px; }
.action-btn .a-desc { font-size:.72rem; color:var(--text2); margin-top:2px; }
.modal-overlay { position:fixed; inset:0; background:rgba(0,0,0,.7); display:flex; align-items:center; justify-content:center; z-index:100; padding:16px; }
.modal-overlay.hidden { display:none; }
.modal { background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:24px; max-width:440px; width:100%; max-height:85vh; overflow-y:auto; position:relative; }
.modal.major { border-color:var(--accent); }
.modal h2 { font-size:1.1rem; margin-bottom:8px; }
.modal p { font-size:.9rem; color:var(--text2); margin-bottom:16px; line-height:1.5; }
.modal-choices { display:flex; flex-direction:column; gap:8px; }
.choice-btn { padding:10px 14px; background:var(--surface2); border:1px solid var(--border); border-radius:var(--radius); color:var(--text); font-size:.88rem; cursor:pointer; text-align:left; transition:all .2s; }
.choice-btn:hover { border-color:var(--accent); background:var(--border); }
.choice-btn.dismiss { opacity:.5; font-size:.8rem; text-align:center; }
.choice-btn.dismiss:hover { opacity:.8; }
.mandatory-banner { background:rgba(224,185,92,.1); border:1px solid var(--yellow); border-radius:var(--radius); padding:12px 16px; margin-bottom:16px; font-size:.88rem; color:var(--yellow); }
.job-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:10px; }
.job-card .job-title { font-weight:700; }
.job-card .job-meta { font-size:.8rem; color:var(--text2); margin-top:3px; }
.job-card .job-salary { color:var(--green); font-weight:700; margin-top:6px; }
.job-card .job-actions { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }
.btn-sm { padding:6px 14px; border-radius:6px; border:none; font-size:.8rem; font-weight:600; cursor:pointer; transition:opacity .2s; }
.btn-apply { background:var(--accent); color:#fff; }
.btn-apply:hover { opacity:.85; }
.btn-quit { background:var(--red); color:#fff; }
.btn-quit:hover { opacity:.85; }
.btn-promote { background:var(--green); color:#111; }
.btn-promote:hover:not(:disabled) { opacity:.85; }
.btn-promote:disabled { opacity:.4; cursor:not-allowed; }
.biz-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:10px; }
.biz-name { font-weight:700; }
.biz-meta { font-size:.8rem; color:var(--text2); margin-top:3px; }
.biz-revenue { color:var(--green); font-weight:700; margin-top:6px; }
.pill { display:inline-block; padding:2px 8px; border-radius:20px; font-size:.72rem; font-weight:600; margin-left:6px; }
.pill-green { background:rgba(86,197,150,.2); color:var(--green); }
.pill-red { background:rgba(224,92,92,.2); color:var(--red); }
.pill-yellow { background:rgba(224,185,92,.2); color:var(--yellow); }
.pill-blue { background:rgba(92,168,224,.2); color:var(--blue); }
.pill-parent { background:rgba(92,168,224,.2); color:var(--blue); }
.pill-sibling { background:rgba(86,197,150,.2); color:var(--green); }
.pill-friend { background:rgba(124,106,247,.2); color:var(--accent); }
.pill-partner { background:rgba(224,108,159,.2); color:var(--accent2); }
.pill-spouse { background:rgba(224,108,159,.3); color:var(--accent2); font-weight:700; }
.pill-child { background:rgba(224,185,92,.2); color:var(--yellow); }
.rel-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:10px; display:flex; align-items:center; gap:14px; }
.rel-avatar { width:44px; height:44px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-size:1.4rem; flex-shrink:0; background:var(--surface2); border:2px solid var(--border); }
.rel-name { font-weight:600; font-size:.95rem; }
.rel-type { font-size:.78rem; color:var(--text2); }
.rel-bar-row { display:flex; align-items:center; gap:8px; margin-top:6px; }
.rel-bar-bg { flex:1; height:5px; background:var(--border); border-radius:3px; overflow:hidden; }
.rel-bar { height:100%; background:var(--accent2); border-radius:3px; transition:width .4s; }
.asset-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:10px; display:flex; justify-content:space-between; align-items:center; }
.asset-info .asset-name { font-weight:600; }
.asset-info .asset-desc { font-size:.78rem; color:var(--text2); margin-top:2px; }
.asset-val { font-weight:700; color:var(--green); }
.edu-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:10px; }
.edu-progress-bar-bg { width:100%; height:8px; background:var(--border); border-radius:4px; margin-top:8px; overflow:hidden; }
.edu-progress-bar { height:100%; background:var(--blue); border-radius:4px; transition:width .5s; }
#screen-death { align-items:center; justify-content:center; min-height:100vh; background:radial-gradient(ellipse at 50% 30%,#1a0a0a 0%,#0f0f13 70%); }
.death-box { text-align:center; max-width:400px; padding:20px; }
.death-icon { font-size:5rem; }
.death-title { font-size:2rem; font-weight:900; margin-top:12px; }
.death-sub { color:var(--text2); margin-top:8px; }
.death-stats { background:var(--surface); border-radius:var(--radius); padding:20px; margin-top:24px; text-align:left; }
.death-stat-row { display:flex; justify-content:space-between; padding:6px 0; border-bottom:1px solid var(--border); font-size:.9rem; }
.death-stat-row:last-child { border-bottom:none; }
.d-label { color:var(--text2); }
.d-val { font-weight:600; }
.notif-stack { position:fixed; top:16px; right:16px; display:flex; flex-direction:column; gap:8px; z-index:200; pointer-events:none; }
.notif { background:var(--surface2); border:1px solid var(--border); border-radius:var(--radius); padding:10px 16px; font-size:.85rem; max-width:280px; animation:slideIn .3s ease; pointer-events:auto; }
.notif.fade-out { animation:fadeOut .4s ease forwards; }
@keyframes slideIn { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }
@keyframes fadeOut { to { opacity:0; transform:translateX(20px); } }
::-webkit-scrollbar { width:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }

/* Finance card */
.finance-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:10px; }
.finance-card .fc-title { font-weight:700; }
.finance-card .fc-meta { font-size:.8rem; color:var(--text2); margin-top:3px; }
.finance-card .fc-value { color:var(--green); font-weight:700; margin-top:6px; }
.finance-card .fc-actions { display:flex; gap:8px; margin-top:10px; flex-wrap:wrap; }

/* School type grid */
.school-type-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(180px,1fr)); gap:10px; }

/* School card */
.school-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px 16px; cursor:pointer; text-align:left; transition:all .2s; color:var(--text); display:flex; flex-direction:column; gap:4px; min-height:110px; }
.school-card:hover:not(:disabled) { border-color:var(--accent); background:var(--surface2); }
.school-card:disabled { opacity:.4; cursor:not-allowed; }
.school-card .sc-icon { font-size:2rem; }
.school-card .sc-label { font-weight:700; font-size:.88rem; margin-top:2px; }
.school-card .sc-cost { font-size:.78rem; color:var(--green); margin-top:2px; }
.school-card .sc-cost.free { color:var(--text2); }
.school-card .sc-req { font-size:.72rem; color:var(--text2); margin-top:2px; }

/* Major grid */
.major-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:10px; }

/* Major button */
.major-btn { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:12px 14px; cursor:pointer; text-align:left; transition:all .2s; color:var(--text); }
.major-btn:hover:not(:disabled) { border-color:var(--accent); background:var(--surface2); }
.major-btn:disabled { opacity:.4; cursor:not-allowed; }
.major-btn .m-title { font-size:.85rem; font-weight:700; }
.major-btn .m-desc { font-size:.72rem; color:var(--text2); margin-top:3px; }

/* Finance breakdown */
.finance-breakdown { display:flex; flex-direction:column; }
.finance-breakdown .fb-row { display:flex; justify-content:space-between; align-items:center; padding:4px 0; border-bottom:1px solid var(--border); font-size:.85rem; }
.finance-breakdown .fb-row:last-child { border-bottom:none; }

/* Income / expense items */
.income-item { color:var(--green); }
.expense-item { color:var(--red); }

/* Yearly done overlay */
.yearly-done { opacity:.4; cursor:not-allowed; }

/* Debt row label */
.debt-label { font-size:.8rem; color:var(--text2); }

/* Stat bar fill (with high/mid/low color tiers) */
.stat-bar-fill { height:100%; border-radius:4px; transition:width .4s; }
.stat-bar-fill.high { background:var(--green); }
.stat-bar-fill.mid  { background:var(--yellow); }
.stat-bar-fill.low  { background:var(--red); }

/* Activity grid (same look as action-grid) */
.activity-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(150px,1fr)); gap:10px; margin-bottom:16px; }
.activity-btn { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:12px 14px; cursor:pointer; text-align:left; transition:all .2s; color:var(--text); }
.activity-btn:hover:not(:disabled) { border-color:var(--accent); background:var(--surface2); }
.activity-btn:disabled { opacity:.4; cursor:not-allowed; }
.activity-btn .a-icon { font-size:1.4rem; }
.activity-btn .a-title { font-size:.85rem; font-weight:600; margin-top:4px; }
.activity-btn .a-desc { font-size:.72rem; color:var(--text2); margin-top:2px; }

/* Act special card (move out, etc.) */
.act-special-card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); padding:14px; margin-bottom:10px; }

/* Finance summary */
.finance-summary { background:var(--surface2); border-radius:var(--radius); padding:16px; margin-bottom:16px; display:flex; flex-direction:column; gap:8px; }
.finance-big-row { display:flex; justify-content:space-between; align-items:center; }
.f-label { font-size:.82rem; color:var(--text2); }
.f-value { font-weight:700; font-size:1rem; }
.f-value.green { color:var(--green); }
.f-value.red   { color:var(--red); }

/* Relationship depth bar */
.rel-depth-bar-bg { width:100%; height:5px; background:var(--border); border-radius:3px; overflow:hidden; margin-top:4px; }
.rel-depth-bar { height:100%; background:var(--accent2); border-radius:3px; transition:width .4s; }

/* Deceased relationship card */
.rel-card.deceased { opacity:.5; filter:grayscale(1); }

/* Revised rel-card for column layout */
.rel-card { display:block !important; }
.rel-name { font-weight:600; font-size:.95rem; }
.rel-meta { font-size:.78rem; color:var(--text2); margin-top:2px; margin-bottom:4px; }

/* Asset card adjusted */
.asset-card { display:block; }
.asset-name { font-weight:700; }
.asset-meta { font-size:.8rem; color:var(--text2); margin-top:3px; }
.asset-meta.debt { color:var(--red); }

/* Wealth slider */
.wealth-slider { width:100%; accent-color:var(--accent); }
.wealth-label { font-size:.82rem; color:var(--text2); text-align:center; margin-top:4px; }

/* Hidden utility */
.hidden { display:none !important; }
