:root {
  --ink: #e8eef1;
  --dim: #8fa3ad;
  --paper: #f2ece0;
  --paper-ink: #23201b;
  --line: #cdc3ae;
  --bg: #10171b;
  --panel: #172128;
  --edge: #26343d;
  --amber: #e8a33d;
  --teal: #4fbfae;
  --red: #e2685f;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 "Helvetica Neue", Helvetica, Arial, sans-serif;
  overflow: hidden;
}
#app {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 384px 1fr;
  grid-template-rows: 44px 1fr 30px;
  grid-template-areas: "hdr hdr" "left right" "keys keys";
  gap: 10px;
  padding: 10px;
}
#hdr {
  grid-area: hdr;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
  letter-spacing: 0.08em;
  font-size: 13px;
  text-transform: uppercase;
}
#hdr .case { font-weight: 700; color: var(--amber); }
#hdr .ward { color: var(--dim); }
#hdr .spacer { flex: 1; }
#hdr-count { color: var(--teal); font-weight: 700; }
#hdr-par { color: var(--dim); }
#hdr-time { font-weight: 700; font-size: 16px; letter-spacing: 0.04em; }
#hdr-time.low { color: var(--red); }

#left { grid-area: left; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
#right { grid-area: right; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
#stmtcard { flex: 1 1 auto; min-height: 0; }
#wardcard { flex: 0 0 auto; height: 250px; }
#readercard { flex: 0 0 auto; }
#logcard { flex: 1 1 auto; min-height: 0; }

.card {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 4px;
  padding: 10px 12px 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.card h2 {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.card h2 .hint {
  margin-left: auto;
  color: var(--dim);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 400;
  font-size: 12px;
}

/* ---- statements ---- */
#statements { overflow: auto; display: flex; flex-direction: column; gap: 4px; }
.stmt {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  background: #1d2930;
}
.stmt:hover { background: #24333c; }
.stmt.sel { border-color: var(--amber); background: #2b2417; }
.stmt.named { opacity: 0.55; }
.stmt .nm { font-weight: 700; font-size: 14px; letter-spacing: 0.02em; }
.stmt .rl { color: var(--dim); font-size: 12px; margin-left: 6px; font-weight: 400; }
.stmt .says { color: var(--teal); font-size: 13px; white-space: nowrap; }
.stmt.named .says { color: var(--red); }
.stmt .card-tag {
  font-size: 12px;
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: 2px;
  padding: 0 4px;
  margin-left: 6px;
}

/* ---- ward map ---- */
#ward { width: 100%; flex: 1 1 auto; min-height: 0; display: block; border-radius: 3px; }

/* ---- readers ---- */
#readers { display: flex; flex-wrap: wrap; gap: 6px; }
.door {
  border: 1px solid var(--edge);
  background: #1d2930;
  color: var(--ink);
  border-radius: 3px;
  padding: 5px 9px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.door:hover:not(:disabled) { border-color: var(--amber); background: #24333c; }
.door .price { color: var(--dim); font-size: 12px; }
.door.pulled { border-color: var(--teal); color: var(--teal); }
.door.pulled .price { color: var(--teal); }
.door.dark { color: #7c6a55; border-style: dashed; cursor: not-allowed; }
.door.dark .price { color: #7c6a55; }
.door:disabled { opacity: 0.55; cursor: not-allowed; }

/* ---- logs ---- */
#logs { overflow: auto; display: flex; flex-wrap: wrap; gap: 8px; align-content: flex-start; }
.log {
  background: var(--paper);
  color: var(--paper-ink);
  border-radius: 2px;
  width: 186px;
  padding: 7px 8px 9px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}
.log.badge { width: 208px; background: #e6ecef; }
.log h3 {
  margin: 0 0 2px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--line);
  padding-bottom: 3px;
}
.log .sub { font-size: 12px; color: #6c6355; margin-bottom: 4px; }
.log .line {
  display: flex;
  gap: 7px;
  font-size: 13px;
  font-family: "SF Mono", Menlo, monospace;
  padding: 2px 3px;
  border-radius: 2px;
  cursor: pointer;
  white-space: nowrap;
}
.log .line:hover { background: #e2d9c6; }
.log .line.hi { background: #f6e3a8; }
.log .line.cited { background: #2b3a20; color: #f2ece0; }
.log .line.after { color: #9a8f7c; }
.log .line .t { font-weight: 700; }
.log .line .who { overflow: hidden; text-overflow: ellipsis; }
.log .cut {
  font-size: 12px;
  color: #8a7f6b;
  border-top: 1px dashed var(--line);
  margin-top: 4px;
  padding-top: 3px;
}
.empty-note { color: var(--dim); font-size: 13px; max-width: 460px; }

#keys {
  grid-area: keys;
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 0 6px;
  color: var(--dim);
  font-size: 12.5px;
  pointer-events: none;
}
#keys b { color: var(--ink); }

#coach {
  position: fixed;
  left: 404px;
  right: 14px;
  bottom: 44px;
  background: #2b2417;
  border: 1px solid var(--amber);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13.5px;
  pointer-events: none;
  z-index: 40;
}
#coach .who {
  display: block;
  color: var(--amber);
  font-size: 12px;
  letter-spacing: 0.12em;
  margin-bottom: 2px;
}
#toasts {
  position: fixed;
  right: 14px;
  bottom: 120px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  z-index: 50;
  max-width: 420px;
}
.toast {
  background: #1d2930;
  border-left: 3px solid var(--teal);
  padding: 7px 11px;
  border-radius: 3px;
  font-size: 13px;
}
.toast.refuse { border-left-color: var(--red); }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 15, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.overlay[hidden] { display: none; }
.sheet {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 5px;
  padding: 26px 30px;
  max-width: 760px;
  width: min(760px, 92vw);
  max-height: 88vh;
  overflow: auto;
}
.sheet h1 {
  margin: 0 0 10px;
  font-size: 40px;
  letter-spacing: 0.16em;
  color: var(--ink);
}
.sheet h3 {
  margin: 16px 0 6px;
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--amber);
  text-transform: uppercase;
}
.sheet .pitch { color: #c6d3da; font-size: 15px; line-height: 1.6; }
.sheet .go { margin: 18px 0 0; color: var(--teal); font-size: 15px; }
.sheet .reads { color: #c6d3da; font-size: 14px; border-left: 2px solid var(--edge); padding-left: 10px; }
.ladder { width: 100%; border-collapse: collapse; font-size: 14px; }
.ladder td { padding: 4px 0; border-bottom: 1px solid var(--edge); }
.ladder td:last-child { text-align: right; }
.ladder .stars { color: var(--amber); letter-spacing: 0.1em; }
.ladder .locked { color: var(--dim); }
.btnrow { display: flex; gap: 10px; margin-top: 20px; }
button.big {
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.1em;
  padding: 10px 18px;
  background: var(--amber);
  color: #1a1208;
  border: 0;
  border-radius: 3px;
  cursor: pointer;
  font-weight: 700;
}
button.big.ghostbtn { background: transparent; color: var(--dim); border: 1px solid var(--edge); }
button.big:disabled { opacity: 0.45; cursor: not-allowed; }
#r-accused, #r-cites, #card-rows, #guide-body { font-size: 14.5px; line-height: 1.6; }
.citeline {
  font-family: "SF Mono", Menlo, monospace;
  background: #1d2930;
  border-left: 3px solid var(--amber);
  padding: 6px 10px;
  margin: 4px 0;
  border-radius: 2px;
  font-size: 13.5px;
}
.citeline.empty { border-left-color: var(--edge); color: var(--dim); font-family: inherit; }
.rowline { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--edge); }
.rowline .mark { width: 22px; color: var(--amber); font-weight: 700; }
.rowline .lbl { width: 190px; letter-spacing: 0.1em; font-size: 12.5px; text-transform: uppercase; color: var(--ink); }
.rowline .txt { flex: 1; color: #c6d3da; font-size: 13.5px; }
.rowline.miss .mark { color: var(--dim); }
.finding-line { color: var(--teal); font-size: 15px; }
.signed { color: var(--dim); font-size: 13px; }

/* Narrow (and the portal's 600x375 card shot): the two-column desk does not fit, so
   the page becomes one scrolling column that leads with the paper. The floor plan is an
   aid; the logs are the game. */
@media (max-width: 960px) {
  html,
  body {
    overflow: auto;
    height: auto;
  }
  #app {
    position: static;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100%;
    gap: 8px;
    padding: 8px 8px 78px;
  }
  #hdr {
    order: 0;
    height: auto;
    flex-wrap: wrap;
    gap: 10px;
    padding: 6px 10px;
    font-size: 12px;
  }
  #hdr .ward { display: none; }
  #hdr-time { font-size: 14px; }
  #right { order: 1; }
  #left { order: 2; }
  #keys { display: none; }
  #left,
  #right {
    display: block;
    min-height: 0;
  }
  .card {
    padding: 8px 10px 10px;
    margin-bottom: 8px;
  }
  #readers { overflow: visible; }
  .door { padding: 3px 7px; font-size: 12px; }
  #logcard { min-height: 236px; }
  #stmtcard { min-height: 0; }
  #statements { overflow: visible; }
  #wardcard { display: none; }
  #coach { left: 8px; right: 8px; bottom: 8px; }
  #toasts { top: 46px; bottom: auto; left: 8px; right: 8px; max-width: none; }
  .log { width: 172px; }
}
