/* Holdings v2.1 — investor's ledger, warm copper/gold (v1-derived design language) */

:root {
  --bg: #efe6d6;
  --bg-deep: #e3d5b8;
  --paper: #f7f0e1;
  --ink: #1a1614;
  --ink-soft: #4a4239;
  --ink-faint: #8a7f6f;
  --line: #c9bba0;
  --accent: #b8742a;
  --accent-deep: #8a5419;
  --gain: #4a6b3a;
  --loss: #a83a2a;
  --gold: #d4a341;
  --shadow-lg: 0 24px 48px -16px rgba(26,22,20,.28), 0 8px 16px -8px rgba(26,22,20,.18);
  --shadow-md: 0 8px 16px -6px rgba(26,22,20,.18);
  --radius: 14px;
  --radius-sm: 8px;
  --display: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }   /* the rule that lets `hidden` actually win */
html, body { height: 100%; overflow: hidden; }
body { font-family: var(--display); background: var(--bg); color: var(--ink); font-size: 14px; -webkit-font-smoothing: antialiased; }
#app { position: fixed; inset: 0; }
#city { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#city.dragging { cursor: grabbing; }

button { font-family: var(--display); cursor: pointer; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Top bar ---------- */
#topbar {
  position: absolute; top: 14px; left: 14px; right: 14px;
  display: flex; align-items: center; gap: 16px;
  padding: 10px 16px;
  background: rgba(247,240,225,.86); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  z-index: 20; flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 7px; padding-right: 16px; border-right: 1px solid var(--line); }
.brand-mark { font-family: var(--display); font-weight: 700; font-size: 22px; color: var(--accent); line-height: 1; }
.brand-name { font-family: var(--display); font-weight: 600; font-style: italic; font-size: 19px; letter-spacing: .4px; }
.stats { display: flex; gap: 24px; flex: 1; }
.stat { display: flex; flex-direction: column; gap: 2px; line-height: 1.2; }
.stat-label { font-size: 10px; font-weight: 500; text-transform: uppercase; letter-spacing: 1.5px; color: var(--ink-faint); }
.stat-value { font-family: var(--mono); font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; transition: color .2s, transform .18s; }
.stat-value.flash-gain { color: var(--gain); transform: scale(1.07); }
.stat-value.flash-loss { color: var(--loss); transform: scale(1.07); }
#v-flow.pos { color: var(--gain); } #v-flow.neg { color: var(--loss); }
.stat-value.loss { color: var(--loss); }
.stat.market { flex-direction: row; align-items: center; gap: 8px; }
.stat.market .stat-value { display: flex; align-items: center; gap: 4px; }
.trend { font-size: 12px; }
.trend.up { color: var(--gain); } .trend.down { color: var(--loss); }
#spark { opacity: .9; }
.topbar-actions { display: flex; gap: 7px; }
.btn {
  font-weight: 500; font-size: 13px; letter-spacing: .4px;
  padding: 7px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink);
  transition: all .15s ease;
}
.btn:hover { background: var(--bg-deep); transform: translateY(-1px); box-shadow: 0 4px 8px -4px rgba(26,22,20,.2); }
.btn:active { transform: translateY(0); }
.btn.attn { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,116,42,.22); }
.btn-icon { width: 32px; height: 32px; padding: 0; display: grid; place-items: center; font-size: 13px; }

/* ---------- Panels (shared card chrome) ---------- */
.panel {
  background: rgba(247,240,225,.92); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.panel-close {
  position: absolute; top: 10px; right: 10px; width: 28px; height: 28px;
  border: none; background: none; font-size: 20px; color: var(--ink-faint); line-height: 1; z-index: 1;
}
.panel-close:hover { color: var(--ink); }

/* ---------- Portfolio ---------- */
#folio {
  position: absolute; left: 14px; top: 86px; bottom: 46px; width: 250px;
  display: flex; flex-direction: column; overflow: hidden; z-index: 18;
}
.panel-head { padding: 13px 15px; border-bottom: 1px solid var(--line); }
.panel-head h2 { font-weight: 600; font-style: italic; font-size: 21px; line-height: 1; }
.panel-count { display: block; margin-top: 6px; font-family: var(--mono); font-size: 10.5px; letter-spacing: .4px; color: var(--ink-faint); }
#folio-list { list-style: none; overflow-y: auto; padding: 7px; flex: 1; }
.folio-empty { padding: 20px 14px; font-size: 13px; color: var(--ink-faint); font-style: italic; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius-sm); margin: 6px; }
.fi {
  display: grid; grid-template-columns: 30px 1fr auto; gap: 9px; align-items: center;
  padding: 8px 10px; border-radius: var(--radius-sm); cursor: pointer; transition: background .15s;
}
.fi:hover { background: var(--bg-deep); }
.fi.focused { background: var(--ink); }
.fi.focused .fi-name { color: var(--paper); }
.fi.focused .fi-rent { color: var(--gold); }
.fi-icon {
  width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center;
  font-family: var(--mono); font-weight: 600; font-size: 12px;
  background: var(--bg-deep); border: 1px solid var(--line); color: var(--ink);
}
.fi-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fi-name { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fi-sub { font-family: var(--mono); font-size: 9.5px; letter-spacing: .4px; color: var(--ink-faint); text-transform: uppercase; }
.fi-rent { font-family: var(--mono); font-size: 11.5px; font-weight: 600; color: var(--gain); }

/* ---------- Selection panel ---------- */
#panel {
  position: absolute; right: 14px; top: 86px; width: 296px; max-width: calc(100vw - 28px);
  padding: 16px; z-index: 25;
}
.panel-eyebrow { font-size: 10px; text-transform: uppercase; letter-spacing: 1.6px; color: var(--accent); font-weight: 600; }
.panel-title { font-weight: 600; font-style: italic; font-size: 23px; margin: 3px 0 10px; }
.panel-rows { border-top: 1px solid var(--line); }
.prow { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.prow .k { color: var(--ink-faint); }
.prow .v { font-family: var(--mono); font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.prow .v.good { color: var(--gain); }
.panel-actions { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.act {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  width: 100%; padding: 10px 13px; border-radius: var(--radius-sm); font-size: 13.5px; font-weight: 500;
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  transition: all .15s ease; text-align: left;
}
.act:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); transform: translateY(-1px); }
.act .price { font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--gold); white-space: nowrap; }
.act.secondary { background: var(--paper); color: var(--ink); border-color: var(--line); }
.act.secondary:hover:not(:disabled) { background: var(--bg-deep); border-color: var(--accent); }
.act.secondary .price { color: var(--accent-deep); }
.act.sell { background: var(--paper); color: var(--loss); border-color: var(--line); }
.act.sell:hover:not(:disabled) { border-color: var(--loss); background: var(--bg-deep); }
.act.sell .price { color: var(--loss); }
.act:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.act-note { font-size: 10.5px; font-style: italic; color: var(--ink-faint); font-weight: 400; }
.act .act-note { display: block; }

/* ---------- Event card ---------- */
#event-veil, #modal-veil {
  position: absolute; inset: 0; background: rgba(26,22,20,.5);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; z-index: 40; padding: 20px;
  animation: fadeIn .2s ease;
}
@keyframes fadeIn { from { opacity: 0; } }
#event-card {
  position: relative; width: 390px; max-width: 100%;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 24px;
  animation: cardIn .3s cubic-bezier(.22,1,.36,1);
}
@keyframes cardIn { from { transform: translateY(18px) scale(.96); opacity: 0; } }
.event-stamp {
  position: absolute; top: 16px; right: 16px;
  font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: 1.8px; text-transform: uppercase;
  color: var(--accent); border: 1.5px solid var(--accent); border-radius: 4px;
  padding: 4px 8px; transform: rotate(4deg);
}
#e-title { font-weight: 600; font-style: italic; font-size: 24px; margin-bottom: 8px; padding-right: 70px; line-height: 1.15; }
#e-body { font-size: 14px; line-height: 1.6; color: var(--ink-soft); margin-bottom: 16px; }
#e-body b { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.event-actions { display: flex; flex-direction: column; gap: 8px; }

/* ---------- Modal ---------- */
#modal {
  position: relative; width: min(480px, 100%); max-height: 86vh; overflow-y: auto;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 24px;
  animation: cardIn .25s cubic-bezier(.22,1,.36,1);
}
#modal h3 { font-weight: 600; font-style: italic; font-size: 25px; margin-bottom: 12px; }
#modal p { font-size: 13.5px; line-height: 1.65; color: var(--ink-soft); margin-bottom: 10px; }
#modal p b { font-family: var(--mono); font-size: 12.5px; color: var(--ink); }
.goal { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.goal .tick {
  width: 23px; height: 23px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--line); display: grid; place-items: center;
  font-size: 12px; color: var(--paper);
}
.goal.done .tick { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.goal.done .g-name { color: var(--ink-faint); text-decoration: line-through; }
.goal .g-reward { margin-left: auto; font-family: var(--mono); font-size: 10px; color: var(--accent-deep); font-weight: 700; white-space: nowrap; letter-spacing: .3px; }
.bank-row { display: flex; gap: 10px; margin: 14px 0; align-items: center; }
.bank-row input[type=range] { flex: 1; accent-color: var(--accent); }
.bank-amt { font-family: var(--mono); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 88px; text-align: right; }
.kbd { font-family: var(--mono); font-size: 10px; background: var(--bg-deep); border: 1px solid var(--line); border-radius: 3px; padding: 1px 5px; color: var(--ink-soft); }

/* Win screen */
.win-wrap { text-align: center; padding: 6px 0; }
.win-stamp {
  display: inline-block; font-family: var(--mono); font-weight: 700; font-size: 12px;
  letter-spacing: 2.2px; text-transform: uppercase; color: var(--accent);
  border: 2px solid var(--accent); border-radius: 6px; padding: 7px 16px;
  transform: rotate(-3deg); margin-bottom: 14px;
}
.win-wrap h3 { font-size: 30px !important; }
.win-stats { margin: 14px 0; text-align: left; }

/* ---------- Tutorial coach ---------- */
#coach {
  position: absolute; left: 14px; bottom: 46px; z-index: 30;
  width: 270px; max-width: calc(100vw - 28px);
  background: var(--ink); color: var(--paper); border-radius: var(--radius);
  padding: 16px 15px 12px; box-shadow: var(--shadow-lg);
}
.coach-step {
  position: absolute; top: -12px; left: 13px; width: 26px; height: 26px;
  background: var(--gold); color: var(--ink); font-family: var(--mono); font-weight: 700; font-size: 12px;
  border-radius: 50%; display: grid; place-items: center; box-shadow: var(--shadow-md);
}
#coach-text { font-size: 13.5px; line-height: 1.5; margin: 2px 0 8px; }
#coach-skip { background: none; border: none; color: var(--gold); font-size: 12px; font-style: italic; text-decoration: underline; padding: 0; }

/* ---------- Toasts ---------- */
#toasts { position: absolute; left: 50%; top: 84px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; gap: 7px; pointer-events: none; align-items: center; }
.toast {
  background: var(--ink); color: var(--paper); border-radius: 100px;
  padding: 10px 19px; font-size: 13.5px; box-shadow: var(--shadow-md);
  animation: toastIn .3s ease;
  max-width: min(480px, 90vw); text-align: center;
}
.toast b { color: var(--gold); font-weight: 600; }
.toast.gold { background: var(--accent); color: #fff; border: 1px solid var(--gold); }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0; } }
.toast.bye { opacity: 0; transform: translateY(-8px); transition: all .35s; }

/* ---------- Camera controls ---------- */
#camctl { position: absolute; right: 14px; bottom: 42px; z-index: 20; display: flex; flex-direction: column; gap: 6px; }
#camctl button {
  width: 36px; height: 36px; border-radius: var(--radius-sm); font-size: 16px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow-md); transition: all .15s;
}
#camctl button:hover { background: var(--bg-deep); transform: translateY(-1px); }
#rot-l, #rot-r { font-size: 17px; color: var(--accent-deep); }

/* ---------- Footer ---------- */
#credit {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 15;
  text-align: center; font-size: 11px; font-style: italic; color: var(--ink-faint);
  padding: 7px; pointer-events: none;
}
#credit a { color: var(--accent-deep); pointer-events: auto; }

/* ---------- Mobile ---------- */
@media (max-width: 980px) { #folio { display: none; } }
@media (max-width: 720px) {
  #topbar { top: 8px; left: 8px; right: 8px; gap: 10px; padding: 8px 12px; }
  .brand { padding-right: 10px; }
  .brand-name { display: none; }
  .stats { gap: 12px; }
  .stat-value { font-size: 13px; }
  .stat-label { font-size: 8.5px; letter-spacing: 1px; }
  .stat.market #spark { display: none; }
  .btn { padding: 6px 9px; font-size: 12px; }
  #panel { left: 8px; right: 8px; top: auto; bottom: 34px; width: auto; max-height: 52vh; overflow-y: auto; }
  #coach { bottom: auto; top: 100px; }
  #camctl { bottom: 120px; right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}


/* ---------- 3D overlays ---------- */
#floats, #dlabels { position: absolute; inset: 0; pointer-events: none; z-index: 12; overflow: hidden; }
.world-float {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--mono); font-weight: 600; font-size: 14px; color: var(--gain);
  text-shadow: 0 1px 2px rgba(255,255,255,.65), 0 2px 8px rgba(74,107,58,.35);
  animation: float-up 1.6s cubic-bezier(.22,1,.36,1) forwards;
  white-space: nowrap;
}
.world-float.loss { color: var(--loss); text-shadow: 0 1px 2px rgba(255,255,255,.65), 0 2px 8px rgba(168,58,42,.35); }
.world-float.spend { color: var(--ink-soft); }
.world-float.deal { color: var(--accent-deep); text-shadow: 0 1px 2px rgba(255,255,255,.7), 0 2px 8px rgba(184,116,42,.4); }
@keyframes float-up {
  0% { opacity: 0; margin-top: 0; scale: .7; }
  18% { opacity: 1; scale: 1.08; }
  100% { opacity: 0; margin-top: -58px; scale: .92; }
}
.dlabel {
  position: absolute; left: 0; top: 0; will-change: transform;
  font-family: var(--display); font-weight: 600; font-size: 17px; letter-spacing: 2.5px;
  color: rgba(26,22,20,.72); text-transform: uppercase; text-align: center;
  text-shadow: 0 1px 0 rgba(247,240,225,.8);
}
.dlabel.locked { color: rgba(26,22,20,.45); }
.dlabel .sub {
  display: block; font-family: var(--mono); font-size: 11px; font-weight: 500;
  letter-spacing: .4px; text-transform: none; color: var(--accent-deep); margin-top: 3px;
}
#loading {
  position: absolute; inset: 0; z-index: 60;
  display: grid; place-items: center;
  background: var(--bg);
  font-family: var(--display); font-style: italic; font-size: 19px; color: var(--ink-soft);
  text-align: center; line-height: 1.6;
}

/* cinematic grade */
#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 10;
  background: radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(26,22,20,.16) 100%);
}
