/* style.css — the office at night.
 *
 * Warm charcoal, cream ink, one brass accent for money and one steel accent
 * for thought.  Numbers are tabular so a ticking counter never wobbles.
 * Everything that changes flashes once; everything you press gives way.
 */
:root {
  --bg: #131210;
  --bg-2: #1a1917;
  --card: #1f1d1a;
  --card-2: #262421;
  --line: #2f2c27;
  --ink: #ece6d8;
  --ink-2: #b7b0a2;
  --ink-3: #7d7769;
  --brass: #d9a94a;
  --brass-2: #f0c66a;
  --steel: #9fb8cc;
  --steel-2: #c6d8e6;
  --green: #8fc99a;
  --red: #e07a6a;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px -18px rgba(0,0,0,.9);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, "DejaVu Sans Mono", monospace;
  --sans: -apple-system, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #efe9dc; --bg-2: #e8e1d2; --card: #f7f2e7; --card-2: #fffaf0; --line: #d9d0be;
    --ink: #221f1a; --ink-2: #5a5448; --ink-3: #8a8375; --brass: #9a6d12; --brass-2: #7d570c;
    --steel: #3e6788; --steel-2: #2b4b66; --green: #2f7a45; --red: #b8402f;
    --shadow: 0 1px 2px rgba(0,0,0,.08), 0 10px 30px -18px rgba(0,0,0,.35);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--sans);
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
  background-image: radial-gradient(1200px 600px at 50% -200px, rgba(217,169,74,.06), transparent 60%);
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono, .big, .cost, .v { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px;
  padding: 12px 0 10px; margin: 0 -16px 14px; padding-inline: 16px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.brand { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.clipmark { width: 22px; height: 22px; color: var(--brass); align-self: center; }
.title { font-family: var(--serif); font-size: 20px; letter-spacing: .02em; }
.era { color: var(--ink-3); font-size: 13px; font-style: italic; font-family: var(--serif); white-space: nowrap; }
.counter { text-align: center; }
.big { font-size: clamp(28px, 6vw, 44px); line-height: 1; letter-spacing: -.01em; font-weight: 500; transition: color .3s; }
.big.bump { animation: bump .18s ease-out; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.04); } 100% { transform: scale(1); } }
.sub { color: var(--ink-3); font-size: 12px; margin-top: 4px; }
.sub span { color: var(--ink-2); font-family: var(--mono); }
.tools { display: flex; justify-content: flex-end; gap: 6px; }
.icon { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; cursor: pointer; }
.icon svg { width: 20px; height: 20px; }
.icon[aria-pressed="false"] .wave { opacity: .25; }
.icon:active { transform: translateY(1px); }

/* ----------------------------------------------------------------- board */
.board { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; max-width: 1080px; margin: 0 auto; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 720px) {
  .board { grid-template-columns: minmax(0, 1fr); }
  .top { grid-template-columns: 1fr auto; grid-template-areas: "brand tools" "counter counter"; row-gap: 4px; }
  .brand { grid-area: brand; } .tools { grid-area: tools; } .counter { grid-area: counter; padding-top: 2px; }
  .title { font-size: 18px; }
}

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 14px;
  box-shadow: var(--shadow); animation: cardin .5s ease-out both;
}
@keyframes cardin { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card h2 {
  margin: 0 0 10px; font-family: var(--serif); font-weight: 500; font-size: 17px; letter-spacing: .01em;
  color: var(--ink); display: flex; align-items: baseline; gap: 8px;
}
.card h2 small { color: var(--ink-3); font-family: var(--sans); font-size: 12px; font-weight: 400; }
.rule { height: 1px; background: var(--line); margin: 10px 0; }

.row { display: flex; align-items: center; gap: 10px; padding: 5px 0; flex-wrap: wrap; }
.row.hero .v { font-size: 22px; }
.row.small { font-size: 12.5px; color: var(--ink-2); padding: 2px 0; }
.row.small .v { font-size: 12.5px; }
.k { color: var(--ink-2); flex: 0 0 auto; }
.v { margin-left: auto; font-size: 15px; transition: color .25s; }
.row.hero .k { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.u { color: var(--ink-3); font-size: 12px; }
.hint { color: var(--ink-3); font-size: 12px; margin-left: auto; }
.grow { flex: 1; }
.money { color: var(--brass-2); }
.warn { color: var(--red); }
.v.flash { color: var(--brass-2); }
.v.flash-cool { color: var(--steel-2); }

/* --------------------------------------------------------------- buttons */
.btn {
  border: 1px solid var(--line); background: linear-gradient(var(--card-2), var(--card)); color: var(--ink);
  border-radius: 10px; padding: 9px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: transform .08s ease, border-color .2s, box-shadow .2s, opacity .2s; white-space: nowrap;
  box-shadow: 0 1px 0 rgba(255,255,255,.04) inset;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px) scale(.985); }
.btn:disabled { opacity: .38; cursor: default; transform: none; }
.btn.small { padding: 6px 10px; font-size: 13px; border-radius: 8px; margin-left: 8px; }
.btn.tiny { padding: 4px 9px; font-size: 12.5px; border-radius: 7px; }
.btn.danger { color: var(--red); }
.btn .cost { color: var(--brass); font-size: 12px; font-weight: 500; }
.btn:disabled .cost { color: var(--ink-3); }
.btn.can { border-color: color-mix(in oklab, var(--brass) 45%, var(--line)); }
.row.buy { gap: 8px; }
.row.buy .btn.small { margin-left: 0; }

.make {
  width: 100%; padding: 18px; border-radius: 12px; cursor: pointer; margin: 4px 0 10px;
  border: 1px solid color-mix(in oklab, var(--brass) 55%, var(--line));
  background: linear-gradient(180deg, color-mix(in oklab, var(--brass) 22%, var(--card-2)), color-mix(in oklab, var(--brass) 10%, var(--card)));
  font-family: var(--serif); font-size: 19px; letter-spacing: .02em; color: var(--ink);
  box-shadow: 0 1px 0 rgba(255,255,255,.08) inset, 0 12px 30px -16px color-mix(in oklab, var(--brass) 60%, transparent);
  transition: transform .06s ease, box-shadow .2s; touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.make:hover { box-shadow: 0 1px 0 rgba(255,255,255,.1) inset, 0 16px 34px -14px color-mix(in oklab, var(--brass) 70%, transparent); }
.make:active { transform: scale(.975); }
.make:disabled { opacity: .45; }

.stepper { margin-left: auto; display: inline-flex; align-items: center; gap: 8px; }
.stepper .v { margin: 0; min-width: 62px; text-align: center; }
.meter { flex: 1 1 60px; height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; min-width: 50px; }
.meter i { display: block; height: 100%; width: 0; background: var(--brass); transition: width .35s ease; border-radius: 3px; }
.opsbar { height: 8px; border-radius: 4px; background: var(--bg-2); overflow: hidden; margin: 2px 0 6px; }
.opsbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--steel), var(--steel-2)); transition: width .2s linear; }
.opsbar.full i { animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { filter: brightness(1.35); } }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ink-2); font-size: 13.5px; }
.switch input { display: none; }
.switch span { width: 34px; height: 20px; border-radius: 10px; background: var(--bg-2); border: 1px solid var(--line); position: relative; transition: background .2s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ink-3); transition: transform .2s, background .2s; }
.switch input:checked + span { background: color-mix(in oklab, var(--brass) 35%, var(--bg-2)); }
.switch input:checked + span::after { transform: translateX(14px); background: var(--brass-2); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; background: transparent; }
.seg .btn.on { background: var(--card-2); color: var(--brass-2); }
.select { background: var(--card-2); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; }

/* ---------------------------------------------------------------- stocks */
.stocks { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 13px; }
.stocks td { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.stocks td:first-child { color: var(--ink-2); font-family: var(--mono); letter-spacing: .05em; }
.stocks td.n { text-align: right; font-family: var(--mono); }
.stocks .up { color: var(--green); } .stocks .dn { color: var(--red); }

/* ---------------------------------------------------------------- quantum */
.chips { display: flex; gap: 6px; height: 56px; align-items: center; margin: 6px 0; }
.chips i { flex: 1; height: 100%; background: var(--bg-2); border-radius: 4px; position: relative; overflow: hidden; }
.chips i::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: var(--h, 0%); transform: translateY(-50%); background: var(--steel); opacity: .9; border-radius: 3px; }
.chips i.neg::after { background: var(--red); }

/* --------------------------------------------------------------- tourney */
.tourney { margin: 8px 0; min-height: 24px; }
.tourney .tbar { height: 6px; background: var(--bg-2); border-radius: 3px; overflow: hidden; }
.tourney .tbar i { display: block; height: 100%; background: var(--steel); transition: width .3s linear; }
.tourney .scores { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 4px 10px; font-size: 12px; margin-top: 6px; }
.tourney .scores span { display: flex; justify-content: space-between; color: var(--ink-2); }
.tourney .scores b { font-family: var(--mono); font-weight: 500; color: var(--ink); }
.tourney .scores .win b { color: var(--brass-2); }
.tourney .scores .mine { color: var(--steel-2); }

/* -------------------------------------------------------------- projects */
.projects { display: flex; flex-direction: column; gap: 8px; }
.proj {
  text-align: left; width: 100%; border: 1px solid var(--line); background: var(--card-2); border-radius: 12px; padding: 10px 12px;
  cursor: pointer; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: baseline;
  animation: projin .4s ease-out both; transition: border-color .2s, transform .08s, opacity .2s;
}
@keyframes projin { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
.proj:active { transform: scale(.99); }
.proj b { font-weight: 600; font-size: 14px; }
.proj .pc { font-family: var(--mono); font-size: 12px; color: var(--brass); white-space: nowrap; }
.proj small { grid-column: 1 / -1; color: var(--ink-2); font-size: 12.5px; line-height: 1.35; }
.proj.no { opacity: .55; cursor: default; }
.proj.no .pc { color: var(--ink-3); }
.proj.can { border-color: color-mix(in oklab, var(--brass) 50%, var(--line)); box-shadow: 0 0 0 1px color-mix(in oklab, var(--brass) 20%, transparent), 0 10px 24px -18px var(--brass); }
.proj.big { border-color: var(--brass); background: linear-gradient(180deg, color-mix(in oklab, var(--brass) 14%, var(--card-2)), var(--card-2)); }
.proj.big b { font-family: var(--serif); font-size: 16px; }
.proj.gone { animation: projout .35s ease-in forwards; pointer-events: none; }
@keyframes projout { to { opacity: 0; transform: translateX(10px) scale(.98); height: 0; padding: 0; margin: 0; } }

/* ------------------------------------------------------------ phase 2 / 3 */
.bars { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 8px; }
.bar { position: relative; height: 26px; border-radius: 7px; background: var(--bg-2); overflow: hidden; display: flex; align-items: center; padding: 0 10px; gap: 8px; font-size: 13px; }
.bar .k { color: var(--ink-2); position: relative; z-index: 1; }
.bar .v { position: relative; z-index: 1; font-size: 13px; }
.bar .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; transition: width .4s ease; opacity: .55; border-radius: 7px; }
.fill.avail { background: var(--ink-3); } .fill.acq { background: var(--steel); } .fill.wire { background: var(--brass); }
.gauge { position: relative; height: 22px; border-radius: 7px; background: var(--bg-2); overflow: hidden; margin: 4px 0 8px; }
.gauge i { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--green); opacity: .6; transition: width .4s, background .4s; }
.gauge.short i { background: var(--red); }
.gauge span { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12.5px; }
.unit { padding: 4px 0; }
.bulk { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.row.buy .cost { margin-left: auto; font-size: 12px; }
.slider { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-2); }
.slider input { flex: 1; accent-color: var(--steel); }

.ring-wrap { display: flex; align-items: center; gap: 16px; margin: 4px 0 10px; }
.ring { width: 96px; height: 96px; transform: rotate(-90deg); flex: 0 0 auto; }
.ring .track { fill: none; stroke: var(--bg-2); stroke-width: 8; }
.ring .prog { fill: none; stroke: var(--steel); stroke-width: 8; stroke-linecap: round; stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset .5s ease; }
.ring-text b { display: block; font-size: 22px; }
.ring-text small { color: var(--ink-3); }
.design { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 6px; }
@media (max-width: 420px) { .design { grid-template-columns: 1fr; } }
.design .d { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.design .d .k { flex: 1; }
.design .d b { font-family: var(--mono); min-width: 18px; text-align: center; }
.design .pips { display: flex; gap: 2px; }
.design .pips i { width: 5px; height: 10px; border-radius: 2px; background: var(--steel); }

/* --------------------------------------------------------------- console */
.console {
  max-width: 1080px; margin: 18px auto 0; padding: 12px 14px; border-radius: 12px;
  background: var(--bg-2); border: 1px solid var(--line); font-family: var(--mono); font-size: 12.5px; line-height: 1.55;
  min-height: 74px; max-height: 150px; overflow: hidden; position: relative; color: var(--ink-2); display: flex; flex-direction: column; justify-content: flex-end;
}
.console::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 24px; background: linear-gradient(var(--bg-2), transparent); pointer-events: none; }
.console div { animation: linein .4s ease-out both; }
@keyframes linein { from { opacity: 0; transform: translateY(4px); } }
.console .era { color: var(--brass-2); font-family: var(--serif); font-style: italic; font-size: 14px; }
.console .poem, .console .quote { color: var(--steel-2); font-style: italic; }
.console .warn { color: var(--red); }
.console .t { color: var(--ink-3); margin-right: 8px; }

/* ---------------------------------------------------------------- toasts */
.toasts { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 20; pointer-events: none; align-items: center; }
.toast {
  background: var(--card-2); border: 1px solid var(--line); color: var(--ink); padding: 8px 14px; border-radius: 999px; font-size: 13px;
  box-shadow: 0 10px 30px -10px rgba(0,0,0,.8); animation: toastin .35s cubic-bezier(.2,.9,.3,1.2) both, toastout .4s ease-in 3.2s forwards;
  display: flex; gap: 8px; align-items: center; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.project::before { content: "✓"; color: var(--brass-2); }
.toast.trust::before { content: "◆"; color: var(--steel-2); }
.toast.era { border-color: var(--brass); font-family: var(--serif); font-size: 15px; }
.toast.away { border-color: var(--steel); }
@keyframes toastin { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toastout { to { opacity: 0; transform: translateY(6px); } }

.flyers { position: fixed; inset: 0; pointer-events: none; z-index: 15; overflow: hidden; }
.fly { position: absolute; width: 18px; height: 18px; color: var(--brass-2); animation: fly .9s ease-out forwards; }
@keyframes fly { 0% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--r)) scale(.7); } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% - 90px)) rotate(calc(var(--r) + 40deg)) scale(1.1); } }

/* --------------------------------------------------------------- overlays */
.overlay { position: fixed; inset: 0; background: rgba(10,9,8,.72); backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 30; padding: 16px; animation: fade .3s ease-out; }
@keyframes fade { from { opacity: 0; } }
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(440px, 100%); box-shadow: var(--shadow); }
.sheet h3 { margin: 0 0 8px; font-family: var(--serif); font-weight: 500; font-size: 20px; }
.muted { color: var(--ink-2); font-size: 13.5px; }
.end { background: #050505; }
.end-sheet { background: transparent; border: 0; box-shadow: none; text-align: center; width: min(560px, 100%); }
.end-sheet p { font-family: var(--serif); font-size: clamp(18px, 3vw, 24px); color: var(--ink); line-height: 1.5; animation: linein 1.4s ease-out both; }
.end-sheet .btn { margin: 8px 6px 0; }
.end-sheet .final { font-family: var(--mono); color: var(--ink-3); font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
