/* Race to the Bottom — plain, flat, black on white. */
* { box-sizing: border-box; }
[hidden] { display: none !important; }

:root {
  --ink: #111;
  --mid: #555;
  --soft: #888;
  --rule: #bbb;
  --hair: #e2e2e2;
  --btn: #efefef;
  --btn-hover: #e2e2e2;
  --btn-active: #d4d4d4;
  --red: #9b3b32;
  --gap: 12px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  padding: 14px 16px 20px;
  background: #fff;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
}
#app { max-width: 1280px; margin: 0 auto; }

h1 {
  font-size: 15px;
  font-weight: bold;
  letter-spacing: 0.02em;
  margin: 0;
}
h2 {
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mid);
  margin: 0 0 6px 0;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--hair);
}
p { margin: 0 0 8px 0; }
a { color: var(--ink); }

/* ---------- header ---------- */
#topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 18px;
  padding-bottom: 8px;
  margin-bottom: var(--gap);
  border-bottom: 1px solid var(--ink);
}
#statusline { color: var(--mid); font-variant-numeric: tabular-nums; }
#statusline span { color: var(--ink); }

/* ---------- figure + log ---------- */
#top {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  margin-bottom: var(--gap);
}
#viz { border: 1px solid var(--rule); min-width: 0; }
#viz canvas { display: block; }
.viz-caption {
  border-top: 1px solid var(--hair);
  padding: 4px 8px;
  font-size: 11px;
  font-style: italic;
  color: var(--mid);
}

#log, #p3-log {
  margin: 0;
  height: 112px;
  overflow-y: auto;
  border: 1px solid var(--rule);
  padding: 6px 8px;
  background: #fff;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: normal;
  overflow-wrap: anywhere;
  color: #333;
}
#log .lg, #p3-log .lg { margin-bottom: 2px; }
#log b, #p3-log b { font-weight: 700; color: #000; }
#log span b, #p3-log span b { color: inherit; }
/* milestones: the big beats get a rule and a little air; the key phrase inside is bolded in the string */
#log .ms, #p3-log .ms {
  color: #000;
  border-top: 1px solid var(--hair);
  margin-top: 5px;
  padding-top: 3px;
}
#log .ms:first-child, #p3-log .ms:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.lg-red { color: #a33; }
.lg-green { color: #3a7a3a; }
.lg-blue { color: #36a; }
/* the header log is always visible, so the phase-3 copy is redundant */
#p3-log { display: none; }

/* ---------- columns ---------- */
#columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--gap);
  align-items: start;
}
.col { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }

.box {
  border: 1px solid var(--rule);
  padding: 8px 10px 10px;
  background: #fff;
}
.box > div { margin: 1px 0; }

/* ---------- buttons ---------- */
button {
  font: inherit;
  font-size: 12px;
  line-height: 1.3;
  padding: 3px 9px;
  margin: 3px 3px 3px 0;
  border: 1px solid #999;
  border-radius: 0;
  background: var(--btn);
  color: var(--ink);
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--btn-hover); border-color: #666; }
button:active:not(:disabled) { background: var(--btn-active); }
button:focus-visible { outline: 1px dotted var(--ink); outline-offset: 1px; }
button:disabled {
  color: #b0b0b0;
  background: #f7f7f7;
  border-color: #ddd;
  cursor: default;
}

#dig-btn, #p3-dig-btn {
  display: block;
  width: 100%;
  font-size: 17px;
  font-weight: bold;
  letter-spacing: 0.25em;
  padding: 14px 0;
  margin: 0 0 6px 0;
  border-color: var(--ink);
}

input[type="checkbox"] { margin: 0 4px 0 0; vertical-align: -2px; }

.small { font-size: 11px; color: var(--mid); }
.warn-block { color: var(--red); font-size: 12px; min-height: 0; }
.warn-block:not(:empty) { margin-top: 4px; padding: 3px 6px; border-left: 1px solid var(--red); }
.warn-soft { color: var(--red); font-style: italic; font-size: 12px; }
.warn-soft:not(:empty) { margin-top: 4px; }

.sep { border-top: 1px solid var(--hair); margin: 6px 0; }

ul#finds-list { list-style: none; margin: 0 0 6px 0; padding: 0; }
ul#finds-list li { padding: 1px 0; }

.machine-row { border-bottom: 1px solid var(--hair); padding: 6px 0; }
.machine-row:first-child { padding-top: 0; }
.machine-row:last-child { border-bottom: none; padding-bottom: 0; }
.machine-row .name { font-weight: bold; }
.machine-row .desc { color: var(--mid); font-size: 11px; }
.machine-row .line { font-size: 12px; }

#col-projects > h2 { margin-bottom: 0; }
.project-box, .contract-box {
  border: 1px solid var(--rule);
  padding: 7px 9px;
  margin-bottom: 8px;
}
.project-box.disabled, .contract-box.disabled { border-color: var(--hair); color: #999; }
.project-box.disabled .pcost, .project-box.disabled .pdesc,
.contract-box.disabled .ccost, .contract-box.disabled .cdesc { color: #aaa; }
.project-box .pname, .contract-box .cname { font-weight: bold; }
.project-box .pcost, .contract-box .ccost { font-size: 11px; color: var(--mid); font-variant-numeric: tabular-nums; }
.project-box .pdesc, .contract-box .cdesc { font-size: 11px; color: #333; margin: 3px 0 5px 0; }

/* ---------- phase 3 ---------- */
#phase3 { display: flex; flex-direction: column; gap: var(--gap); max-width: 720px; }
.buildrow { margin: 4px 0; }

/* ---------- overlays ---------- */
#ended-screen, #falseend-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#ended-screen .box, #falseend-overlay .box { border-color: var(--ink); padding: 18px 22px; }
#falseend-overlay h2 { font-size: 15px; color: var(--ink); border: 0; letter-spacing: 0.1em; }
.center { text-align: center; max-width: 440px; }

footer {
  margin-top: 20px;
  padding-top: 8px;
  border-top: 1px solid var(--hair);
  font-size: 11px;
  color: var(--soft);
  text-align: center;
}
footer a { color: var(--mid); }

/* ---------- responsive ---------- */
@media (min-width: 720px) {
  #columns { grid-template-columns: 1fr 1fr; }
  #col-projects { grid-column: 1 / -1; }
}
@media (min-width: 1100px) {
  #top { grid-template-columns: 2fr 1fr; }
  #log { height: auto; contain: size; min-height: 120px; }
  #columns { grid-template-columns: 1fr 1fr 1fr; }
  #col-projects { grid-column: auto; }
}

.muted { color: #777; font-size: 12px; }
.sell-machine { margin-left: 4px; }

/* progress bars (power, contract, phase-3 body): single 1px track, solid fill */
.bar { display: block; width: 100%; height: 8px; border: 1px solid #999; background: #fff; margin: 4px 0 2px; padding: 0; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: #555; width: 0; border: 0; margin: 0; }
.bar-fill.short { background: #a33; }
.warn-red { color: #a33; }

.small-btn { font-size: 11px; padding: 1px 6px; margin-left: 6px; }

.meters { margin: 4px 0; }
.meter b { font-weight: 600; }

.metals { border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.metals th, .metals td { text-align: left; padding: 2px 8px 2px 0; border-bottom: 1px solid #ddd; }
.metals th { font-weight: 600; color: #555; }

/* fixed columns so changing numbers don't shift the layout */
body { font-variant-numeric: tabular-nums; }
#metals-table { table-layout: fixed; width: 100%; }
#metals-table th:nth-child(1), #metals-table td:nth-child(1) { width: 20%; }
#metals-table th:nth-child(2), #metals-table td:nth-child(2) { width: 18%; }
#metals-table th:nth-child(3), #metals-table td:nth-child(3) { width: 16%; text-align: right; }
#metals-table th:nth-child(4), #metals-table td:nth-child(4) { width: 22%; text-align: right; }
#metals-table th:nth-child(5), #metals-table td:nth-child(5) { width: 24%; text-align: right; }
#metals-table td { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#metals-table button { min-width: 6.2em; text-align: center; padding-left: 3px; padding-right: 3px; font-size: 11px; }
#p3-stats { table-layout: fixed; width: 100%; }
#p3-stats td:nth-child(1) { width: 11em; }
#p3-design-table { table-layout: fixed; width: 100%; }
#p3-design-table td:nth-child(1) { width: 7em; }
#p3-design-table td:nth-child(2) { width: 7em; white-space: nowrap; }
#p3-design-table td:nth-child(2) b { display: inline-block; min-width: 1.5em; text-align: center; }

#smelter-row { white-space: nowrap; }
#refine-line { font-size: 11px; }

.req-ok { color: #595; }

#pause-btn { margin-left: 8px; vertical-align: middle; }
#pause-btn.paused { background: var(--ink); color: var(--paper, #fff); }
body.paused #s-clock { color: var(--ink); font-weight: bold; }
#statusline { flex: 1; display: flex; align-items: baseline; gap: 0 6px; }
#clock-wrap { margin-left: auto; white-space: nowrap; }

#heat-gauge { font-size: 12px; margin-top: 6px; }
#heat-gauge .bar-fill.hot { background: var(--red); }
#heat-gauge .bar-fill.warm { background: #c80; }
#refine-line { display: block; margin: 2px 0 4px; white-space: normal; }

/* list items leaving (animated out by ui.js syncList) */
.leaving { pointer-events: none; overflow: hidden; }

.pdesc.redacted { color: #999; }
.pdesc.redacted .rdx { color: #c8c8c8; letter-spacing: -0.5px; font-size: 9px; vertical-align: 1px; }
