/* ===========================================================================
   RUMMAGE -- Ashgate field, 1977.
   Everything here is wet cardboard, tarpaulin, brass and weak tea. The UI is
   deliberately drab so that the objects, which are the only painted things on
   the page, are the only things with colour in them.
   The phone layer is scoped under body.touch (set from pointer:coarse) plus
   width queries, so the desktop rules are never touched by it.
   =========================================================================== */

:root {
  --ink: #14120e;
  --board: #1c1a16;
  --board-2: #24211b;
  --paper: #ded5c1;
  --paper-2: #cdc2aa;
  --paper-dim: #a99e88;
  --line: #3a352c;
  --tarp: #2e4250;
  --rust: #93502c;
  --brass: #b8934e;
  --tag: #8d2f27;
  --good: #7c9a5e;
  --bad: #b1503f;
  --ward: #6fa3a8;
  --shadow: 0 10px 30px rgba(0,0,0,.45);
  --serif: Georgia, 'Iowan Old Style', 'Times New Roman', serif;
  --sans: 'Helvetica Neue', Arial, 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--board);
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(80,74,60,.28), transparent 60%),
    repeating-linear-gradient(0deg, rgba(255,255,255,.012) 0 2px, transparent 2px 4px);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0 0 .35em; letter-spacing: .01em; }
p { margin: 0 0 .8em; }
button { font-family: var(--sans); font-size: 14px; }
input { font-family: var(--sans); }

/* ------------------------------------------------------------------ header */
#hdr {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 18px;
  padding: 10px 20px;
  background: linear-gradient(180deg, #17150f, #17150fe6);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.hdr-l .sun { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--paper-dim); }
.hdr-l .sun-name { font-family: var(--serif); font-size: 18px; color: var(--paper); }
.hdr-stats { display: flex; gap: 18px; margin-left: auto; flex-wrap: wrap; }
.hdr-stats .stat { text-align: right; line-height: 1.25; }
.hdr-stats .stat span { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper-dim); }
.hdr-stats .stat b { font-family: var(--serif); font-size: 17px; }
.hdr-stats .stat.bad b { color: var(--bad); }
.hdr-stats .stat.good b { color: var(--good); }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; border: 1px solid var(--paper-dim); display: block; }
.dots i.on { background: var(--tag); border-color: var(--tag); box-shadow: 0 0 8px rgba(160,50,40,.7); }
.hdr-r { margin-left: 8px; }

/* -------------------------------------------------------------- buttons -- */
button {
  cursor: pointer; border-radius: 3px; border: 1px solid var(--line);
  background: #2b2720; color: var(--paper); padding: 8px 14px;
  transition: background .12s, border-color .12s, transform .06s;
}
button:hover:not(:disabled) { background: #383229; border-color: #5b5142; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .38; cursor: not-allowed; }
button.primary { background: var(--rust); border-color: #b0653a; color: #fbf3e2; }
button.primary:hover:not(:disabled) { background: #a75c33; }
button.good { background: #4a5f3a; border-color: #6b8354; }
button.danger { background: #7b3128; border-color: #a2483a; }
button.warnbtn { background: #4b3f24; border-color: #7d6a3c; color: #f0dfb6; }
button.ghost { background: transparent; }
button.big { padding: 12px 22px; font-size: 15px; }
button.small { padding: 6px 10px; font-size: 13px; }
button.quick { padding: 4px 9px; font-size: 12px; background: #241f19; }

/* ---------------------------------------------------------------- layout */
#view { max-width: 1240px; margin: 0 auto; padding: 18px 20px 90px; }
.sec {
  font-size: 12px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--paper-dim); border-bottom: 1px solid var(--line);
  padding-bottom: 6px; margin: 26px 0 14px;
}
.panel {
  background: #201d18; border: 1px solid var(--line); border-radius: 4px;
  padding: 16px 18px; margin: 18px 0;
}
.empty { color: var(--paper-dim); font-style: italic; }

/* ------------------------------------------------------------------- hero */
.hero { position: relative; border-radius: 4px; overflow: hidden; border: 1px solid var(--line); }
.hero-canvas { display: block; width: 100%; height: 340px; }
.hero.short .hero-canvas { height: 210px; }
.hero.tall .hero-canvas { height: 62vh; min-height: 420px; }
.hero-cap {
  position: absolute; inset: auto 0 0 0; padding: 26px 28px 22px;
  background: linear-gradient(180deg, rgba(16,14,10,0), rgba(16,14,10,.82) 46%, rgba(16,14,10,.95));
}
.hero-cap.center { inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; }
.hero-cap .kicker { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--brass); }
.hero-cap h1 { font-size: 34px; margin: 4px 0 6px; }
.hero-cap .weather { color: var(--paper-2); max-width: 70ch; margin: 0; }
.hero-cap .note { color: var(--brass); font-style: italic; margin-top: 6px; max-width: 70ch; }
.title-main { font-size: clamp(48px, 9vw, 104px); letter-spacing: .10em; margin: 0; text-shadow: 0 6px 30px rgba(0,0,0,.7); }
.title-main.small { font-size: clamp(30px, 5vw, 54px); letter-spacing: .04em; }
.title-sub { font-size: clamp(15px, 2vw, 22px); color: var(--brass); letter-spacing: .12em; text-transform: uppercase; margin-bottom: 18px; }
.blurb { max-width: 62ch; color: var(--paper-2); font-family: var(--serif); font-size: 16px; }
.blurb.dim { color: var(--paper-dim); font-size: 14px; }
.title-btns { display: flex; gap: 12px; margin-top: 18px; flex-wrap: wrap; justify-content: center; }

/* -------------------------------------------------------------------- bar */
.bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #201d18; border: 1px solid var(--line); border-radius: 4px;
  padding: 12px 16px; margin: 16px 0;
}
.bar-l { color: var(--paper-2); flex: 1 1 320px; }
.bar-l b { color: var(--paper); font-family: var(--serif); }
.bar.sticky { position: sticky; bottom: 12px; z-index: 30; box-shadow: var(--shadow); background: #241f18; }

/* ------------------------------------------------------------------ cards */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.card {
  background:
    linear-gradient(180deg, rgba(255,255,255,.03), rgba(0,0,0,.10)),
    #262219;
  border: 1px solid var(--line); border-radius: 4px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
  position: relative;
}
.card.tainted { border-color: #55707a; box-shadow: inset 0 0 40px rgba(70,130,140,.10); }
.card.clean { border-color: #6b8354; }
.card-top { display: flex; gap: 12px; align-items: flex-start; }
.card-head h3 { font-size: 17px; margin: 0 0 2px; }
.card-head .cls { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--paper-dim); }
.card-head .sub { font-size: 12px; color: var(--brass); margin-top: 4px; }
.thumb {
  flex: 0 0 auto; border-radius: 3px; overflow: hidden;
  background: radial-gradient(60% 60% at 40% 30%, #3a3428, #1b1813);
  border: 1px solid #38312690;
}
.thumb-c { display: block; }

.facts { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-size: 13px; }
.facts dt { color: var(--paper-dim); font-size: 11px; letter-spacing: .10em; text-transform: uppercase; padding-top: 2px; }
.facts dd { margin: 0; color: var(--paper-2); }
.facts dd.good { color: var(--good); }
.facts dd.bad { color: var(--bad); }
.facts dd.ward { color: var(--ward); }
.facts dd.dim { color: var(--paper-dim); font-style: italic; }

.card-foot { border-top: 1px dashed var(--line); padding-top: 10px; margin-top: auto; }
.card-foot.col { display: flex; flex-direction: column; gap: 8px; }
.card-foot .paid { font-size: 12px; color: var(--paper-dim); }
.sellerline { font-family: var(--serif); font-style: italic; color: var(--paper-2); margin: 0; font-size: 13.5px; }
.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.btn-row.wrap { flex-wrap: wrap; }
.ask { margin-right: auto; line-height: 1.1; }
.ask span { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper-dim); }
.ask b { font-family: var(--serif); font-size: 19px; color: var(--brass); }
.wardtag {
  display: inline-block; font-size: 11px; letter-spacing: .06em;
  border: 1px solid var(--ward); color: var(--ward); border-radius: 2px; padding: 2px 7px;
}
.wardtag.bad { border-color: var(--bad); color: var(--bad); }
.chip { font-size: 12px; padding: 4px 10px; border-radius: 999px; }
.chip.on { background: #3c4a33; border-color: #6b8354; color: #dbe7cd; }

/* ------------------------------------------------------------- the tools */
.tools { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.tool {
  display: flex; justify-content: space-between; gap: 8px; align-items: baseline;
  padding: 6px 9px; font-size: 12.5px; text-align: left; background: #221e18;
}
.tool .tm { color: var(--paper-dim); font-size: 11px; white-space: nowrap; }
.tool.done { opacity: .35; }

/* -------------------------------------------------------------- timeline */
.timeline { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 28px 10px; }
.timeline .track {
  position: relative; height: 6px; border-radius: 3px;
  background: rgba(0,0,0,.55); border: 1px solid var(--line);
}
.timeline .mk {
  position: absolute; top: -5px; width: 10px; height: 16px; margin-left: -5px;
  background: var(--brass); border-radius: 2px; box-shadow: 0 0 8px rgba(184,147,78,.5);
}
.timeline .mk.done { background: #4a453b; box-shadow: none; }
.timeline .mk.fence { background: #6b4f36; }
.timeline .cursor {
  position: absolute; top: -9px; width: 2px; height: 24px; margin-left: -1px;
  background: #f3e6c8; box-shadow: 0 0 10px rgba(243,230,200,.8);
}
.tl-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--paper-dim); margin-top: 4px; }

/* --------------------------------------------------------------- modals */
.modal-back {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(8,7,5,.72); backdrop-filter: blur(3px); padding: 24px;
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: #221f19; border: 1px solid #443c30; border-radius: 5px;
  max-width: 620px; width: 100%; max-height: 86vh; overflow: auto;
  padding: 22px 24px; box-shadow: var(--shadow);
}
.modal.wide { max-width: 980px; }
.modal h2 { font-size: 22px; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.prose { font-family: var(--serif); font-size: 15.5px; color: var(--paper-2); }
.prose p.note { color: var(--brass); font-style: italic; font-size: 14px; }
.peeklist { display: flex; flex-direction: column; gap: 8px; }
.row-btn { text-align: left; padding: 10px 12px; }
.row-btn i { color: var(--paper-dim); font-style: normal; font-size: 12px; }
.help h3 { font-size: 15px; letter-spacing: .1em; text-transform: uppercase; color: var(--brass); margin-top: 16px; }
.help p { font-family: var(--serif); color: var(--paper-2); }

/* ------------------------------------------------------------- haggling */
.hag { display: flex; flex-direction: column; gap: 14px; }
.hag-who .tagline { color: var(--brass); font-size: 13px; letter-spacing: .08em; text-transform: uppercase; }
.hag-who .tell { font-family: var(--serif); font-style: italic; color: var(--paper-2); }
.hag-item { display: flex; gap: 14px; align-items: center; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 12px 0; }
.hag-meta h3 { margin: 0; }
.hag-meta .yourguess { font-size: 13px; color: var(--paper-dim); }
.hag-meta .warn { color: var(--bad); font-size: 13px; margin-top: 4px; }
.hag-talk { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; padding-right: 4px; }
.hag-talk p { font-family: var(--serif); margin: 0; padding: 6px 10px; border-radius: 3px; font-size: 14.5px; }
.hag-talk p.them { background: #2a251d; color: var(--paper); }
.hag-talk p.you { background: #23291f; color: #d5e0c6; margin-left: 22px; }
.hag-talk p.note { color: var(--brass); font-style: italic; background: none; padding-left: 0; }
.hag-ctl { display: flex; flex-direction: column; gap: 10px; }
.price-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.price-in {
  width: 110px; padding: 8px 10px; background: #17150f; color: var(--paper);
  border: 1px solid var(--line); border-radius: 3px; font-size: 16px; font-family: var(--serif);
}
.patience { font-size: 12px; color: var(--paper-dim); letter-spacing: .18em; }

/* ---------------------------------------------------------------- ledger */
.ledger .grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.ledger-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.ledger-sum div span { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper-dim); }
.ledger-sum div b { font-family: var(--serif); font-size: 20px; }
.ledger-sum.big div b { font-size: 26px; }
.ledger-sum b.good { color: var(--good); }
.ledger-sum b.bad { color: var(--bad); }
.ledger-sum b.warn { color: var(--brass); }

/* ---------------------------------------------------------------- settle */
.settle { background: #201d18; border: 1px solid var(--line); border-radius: 4px; padding: 22px 24px; }
.settle .kicker { font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--brass); }
.settle h1 { font-size: 30px; }
.settle-rows { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 14px; }
.settle-rows div span { display: block; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--paper-dim); }
.settle-rows div b { font-family: var(--serif); font-size: 22px; }
.settle-rows b.bad { color: var(--bad); } .settle-rows b.good { color: var(--good); }
.supgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.supitem { background: #262219; border: 1px solid var(--line); border-radius: 3px; padding: 12px; }
.supitem b { font-family: var(--serif); font-size: 16px; }
.supitem p { font-size: 12.5px; color: var(--paper-dim); margin: 4px 0 8px; }
.supitem .have { font-size: 11px; color: var(--brass); margin-bottom: 8px; }

/* ----------------------------------------------------------------- night */
body[data-phase="night"] { background: #0a0c10; }
.night-stage { position: relative; border: 1px solid #1b2028; border-radius: 4px; overflow: hidden; }
.night-canvas { display: block; width: 100%; height: 46vh; min-height: 300px; }
.bellbar {
  position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 6px;
  padding: 10px 14px; background: linear-gradient(180deg, rgba(6,8,12,.85), rgba(6,8,12,0));
}
.bell { width: 12px; height: 12px; border-radius: 50%; border: 1px solid #4a5666; display: block; }
.bell.past { background: #35404e; }
.bell.now { background: #d8c48a; border-color: #d8c48a; box-shadow: 0 0 12px rgba(216,196,138,.8); }
.belllab { margin-left: 12px; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: #98a6b6; }
.night-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 16px; }
.night-log { max-height: 62vh; overflow: auto; padding-right: 6px; }
.logblock { border-left: 2px solid #2a323d; padding: 4px 0 10px 12px; margin-bottom: 10px; }
.logbell { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: #7f8ea0; }
.night-log p, .morning .logblock p { font-family: var(--serif); margin: 4px 0; font-size: 14.5px; color: #b9c3cf; }
.night-log p.bad, .morning p.bad { color: #d08a72; }
.night-log p.harm, .morning p.harm { color: #e26a52; font-weight: 600; }
.night-log p.good, .morning p.good { color: #93c07c; }
.night-log p.rite { color: #83bcc2; }
.night-log p.dim { color: #6d7a89; font-style: italic; }
.night-log p.you, .night-log p.note { color: #c9b98e; }

.nightlist { display: flex; flex-direction: column; gap: 8px; }
.nrow {
  display: flex; gap: 10px; align-items: center; text-align: left; width: 100%;
  background: #12161c; border: 1px solid #232b35; padding: 8px;
}
.nrow.sel { border-color: #6f8598; background: #182028; }
.nrow.close { border-color: #8c4536; box-shadow: 0 0 0 1px rgba(140,69,54,.4) inset; }
.nrow .thumb { background: #0b0e13; }
.nmeta { flex: 1; min-width: 0; }
.nmeta b { font-family: var(--serif); font-size: 15px; display: block; }
.nknow { font-size: 12px; }
.nknow .ward { color: var(--ward); }
.nknow .dim { color: #6d7a89; font-style: italic; }
.nknow .good { color: var(--good); }
.dread { height: 5px; background: #1a212a; border-radius: 3px; margin-top: 6px; overflow: hidden; }
.dread i { display: block; height: 100%; background: linear-gradient(90deg, #55707a, #c2523c); }
.nflags { font-size: 11px; color: #7f8ea0; margin-top: 3px; }

.actlist { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.act { text-align: left; display: flex; flex-direction: column; gap: 2px; background: #12161c; border-color: #232b35; padding: 8px 12px; }
.act.sel { border-color: #d8c48a; background: #201d16; }
.act .al { font-size: 14px; }
.act .al em { color: var(--brass); font-style: normal; }
.act .ah { font-size: 11.5px; color: #6d7a89; }
.supply { font-size: 12px; color: #7f8ea0; margin-top: 10px; letter-spacing: .06em; }
.nightover { text-align: center; padding: 30px 0; }
.nightover h2 { font-size: 26px; }

/* ---------------------------------------------------------------- toast */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 24px);
  background: #2a251c; border: 1px solid #4c4234; color: var(--paper);
  padding: 10px 18px; border-radius: 3px; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 200;
  font-family: var(--serif);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { border-color: var(--good); }
.toast.bad { border-color: var(--bad); }

#mute {
  position: fixed; right: 14px; bottom: 14px; z-index: 60;
  width: 38px; height: 38px; border-radius: 50%; padding: 0; font-size: 16px;
  background: #241f18cc; border-color: var(--line);
}
#rotate { display: none; }

/* =========================================================== phone layer */
@media (max-width: 900px) {
  #view { padding: 14px 12px 80px; }
  .night-cols { grid-template-columns: 1fr; }
  .hero-canvas { height: 240px; }
  .hero.tall .hero-canvas { height: 56vh; min-height: 340px; }
  .hero-cap { padding: 18px 16px 16px; }
  .hero-cap h1 { font-size: 26px; }
  .grid { grid-template-columns: 1fr; }
  .hdr-stats { gap: 12px; }
  .hdr-stats .stat b { font-size: 15px; }
}

/* 44px is the smallest thing a thumb reliably hits. The audit found chips at
   24px and tool buttons at 28px, which is fine for a mouse and not for a hand. */
body.touch button { min-height: 44px; }
body.touch .tool { min-height: 44px; }
body.touch .chip { min-height: 44px; padding: 10px 16px; }
body.touch .quick { min-height: 44px; min-width: 48px; }
body.touch .nrow { min-height: 60px; }
body.touch .act { min-height: 52px; }
body.touch .modal { padding: 16px; max-height: 92vh; }
body.touch .hag-talk { max-height: 180px; }
body.touch .night-canvas { height: 34vh; min-height: 220px; }
body.touch .night-log { max-height: 34vh; }
body.touch #hdr { padding: 8px 12px; gap: 10px; }
body.touch .hdr-l .sun-name { font-size: 15px; }
body.touch .card-top { gap: 10px; }
body.touch .price-in { width: 92px; font-size: 17px; }

/* Portrait phones get told to turn round: the table is a landscape object. */
@media (max-width: 760px) and (orientation: portrait) {
  body.touch #rotate {
    display: flex; position: fixed; inset: 0; z-index: 500;
    flex-direction: column; align-items: center; justify-content: center;
    background: #14120e; text-align: center; padding: 30px;
    font-family: var(--serif); color: var(--paper-2);
  }
  body.touch #rotate b { color: var(--brass); }
  body.touch #view, body.touch #hdr, body.touch #mute { filter: blur(2px); }
}


/* ------------------------------------------------------------- keyboard --- */
.kbd {
  display: inline-block; min-width: 17px; text-align: center;
  font-family: var(--sans); font-size: 10px; line-height: 15px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 3px;
  background: #1a1712; color: var(--paper-dim); margin-right: 7px; padding: 0 3px;
}
.act.sel .kbd, button:hover .kbd { color: var(--paper); border-color: #6b6152; }
body.touch .kbd { display: none; }
.hint-bar {
  font-size: 11px; color: var(--paper-dim); letter-spacing: .04em;
  margin-top: 10px; text-align: right;
}
body.touch .hint-bar { display: none; }
