/* The whole interface is a duplicated staff form: buff paper, two process
   inks for the two commands, brass for anything the umpire scores. */
:root {
  --paper: #e9e2cf;
  --paper-deep: #ded3b6;
  --paper-card: #f2ecdc;
  --ink: #23201a;
  --ink-soft: #5b5548;
  --rule: #b3a988;
  --blue: #27568c;
  --red: #a03426;
  --brass: #a8791f;
  --olive: #6d7043;
  --display: 'Arial Narrow', 'Liberation Sans Narrow', 'Helvetica Neue Condensed',
    'DejaVu Sans Condensed', 'TeX Gyre Heros Cn', 'Nimbus Sans Narrow', system-ui, sans-serif;
  --mono: ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper-deep);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

[hidden] { display: none !important; }

button {
  font: inherit;
  font-family: var(--display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
  background: var(--paper-card);
  border: 1.5px solid var(--ink);
  border-radius: 1px;
  padding: 7px 11px;
  cursor: pointer;
  min-height: 34px;
}
button:hover:not(:disabled) { background: #fff8e8; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }
button.primary { background: var(--ink); color: var(--paper); }
button.primary:hover:not(:disabled) { background: #3a352b; }
button.on { background: var(--brass); color: #1b1710; border-color: var(--ink); }

#app {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 1fr 348px;
  grid-template-areas: 'bar bar' 'sheet docket';
  height: 100%;
}

#bar {
  grid-area: bar;
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 8px 14px 6px;
  background: var(--paper);
  border-bottom: 3px double var(--ink);
}
#title {
  font-family: var(--display);
  font-size: 21px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}
#title span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.34em;
  color: var(--ink-soft);
  font-weight: 400;
}
#situation { font-family: var(--display); letter-spacing: 0.12em; text-transform: uppercase; }
#clock { margin-left: auto; font-family: var(--display); letter-spacing: 0.12em; text-transform: uppercase; }

#sheetwrap { grid-area: sheet; position: relative; overflow: hidden; background: var(--paper-deep); }
#sheet { display: block; touch-action: none; cursor: crosshair; }

#camctl { position: absolute; left: 10px; bottom: 10px; display: flex; gap: 5px; }
#camctl button { min-width: 34px; padding: 5px 8px; opacity: 0.92; }

#flash {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  padding: 7px 14px;
  max-width: 82%;
  border-radius: 1px;
  box-shadow: 2px 2px 0 rgba(35, 32, 26, 0.3);
}

#docket {
  grid-area: docket;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-left: 3px double var(--ink);
  overflow: hidden;
}
#docket-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
#orders { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--rule); }
#ledger { padding: 8px 14px 12px; border-top: 3px double var(--ink); background: var(--paper-card); }

h1, h2, h3 { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.14em; margin: 0 0 6px; }
h1 { font-size: 26px; }
h2 { font-size: 16px; }
h3 { font-size: 12px; color: var(--ink-soft); margin-top: 14px; }
p { margin: 0 0 8px; }
.note { color: var(--ink-soft); font-size: 12px; }
.brief { border-left: 3px solid var(--brass); padding-left: 9px; }
.lead { font-size: 14px; }

.docket-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }

/* The stamp: the running purse, printed like a rubber stamp on a docket. */
.stamp {
  border: 2.5px solid var(--red);
  color: var(--red);
  padding: 3px 9px 4px;
  text-align: center;
  transform: rotate(-1.5deg);
  flex: 0 0 auto;
}
.stamp-num { display: block; font-family: var(--display); font-size: 24px; font-weight: 700; line-height: 1; }
.stamp-cap { display: block; font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; }

.catalogue { margin-top: 10px; }
.arm { border-top: 1px solid var(--rule); padding: 7px 0; display: grid; grid-template-columns: 1fr auto; grid-template-areas: 'name ctrl' 'line ctrl'; gap: 2px 8px; }
.arm-dear { opacity: 0.5; }
.arm-name { grid-area: name; display: flex; justify-content: space-between; gap: 8px; }
.arm-cost { color: var(--red); font-weight: 700; }
.arm-line { grid-area: line; font-size: 11px; color: var(--ink-soft); }
.arm-ctrl { grid-area: ctrl; display: flex; align-items: center; gap: 5px; }
.chip { min-width: 30px; padding: 3px 6px; min-height: 28px; }
.arm-count { min-width: 16px; text-align: center; font-weight: 700; }

.shape { margin-top: 12px; border-top: 3px double var(--ink); border-bottom: 3px double var(--ink); padding: 8px 0 6px; }
.bar { display: grid; grid-template-columns: 92px 1fr 30px; align-items: center; gap: 7px; margin-bottom: 4px; font-size: 11px; }
.bar-label { color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; }
.bar-track { height: 10px; background: repeating-linear-gradient(90deg, var(--rule) 0 1px, transparent 1px 6px); border-bottom: 1px solid var(--rule); position: relative; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; background: var(--ink); }
.bar-fill.blue { background: var(--blue); }
.bar-fill.red { background: var(--red); }
.bar-fill.brass { background: var(--brass); }
.bar-value { text-align: right; font-weight: 700; }

.roster, .shooters { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.unit-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  text-transform: none; letter-spacing: 0; font-family: var(--mono); font-size: 12px;
  text-align: left; padding: 5px 8px;
}
.unit-row.spent { opacity: 0.55; }
.unit-row.on { background: var(--brass); }
.unit-abbr { font-family: var(--display); font-weight: 700; letter-spacing: 0.08em; border: 1.5px solid var(--blue); color: var(--blue); padding: 0 4px; }
.unit-abbr.red { border-color: var(--red); color: var(--red); }
.unit-name { flex: 1; }
.unit-note { color: var(--ink-soft); font-size: 11px; }

.dossier { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 8px 0; margin: 8px 0; }
.dossier-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 10px; }
.cell { display: flex; justify-content: space-between; border-bottom: 1px dotted var(--rule); font-size: 12px; }
.cell .k { color: var(--ink-soft); }
.cell .v { font-weight: 700; }

.odds { display: flex; align-items: baseline; gap: 6px; flex: 1; flex-wrap: wrap; }
.odds-p { font-family: var(--display); font-size: 16px; font-weight: 700; color: var(--red); }
.odds-txt { font-size: 11px; }
.odds-note { font-size: 10px; color: var(--ink-soft); font-style: italic; }
.odds-no { font-size: 11px; color: var(--ink-soft); }

.score-line { display: flex; justify-content: space-between; font-family: var(--display); font-size: 18px; letter-spacing: 0.1em; text-transform: uppercase; }
.score-line .blue { color: var(--blue); }
.score-line .red { color: var(--red); }
.log { margin-top: 6px; max-height: 108px; overflow-y: auto; font-size: 11px; }
.log-row { border-bottom: 1px dotted var(--rule); padding: 1px 0; }
.log-row.mine { color: var(--blue); }
.log-row.theirs { color: var(--red); }
.whose { font-family: var(--display); text-transform: uppercase; letter-spacing: 0.1em; padding: 2px 6px; border: 1.5px solid currentColor; }
.whose.mine { color: var(--blue); }
.whose.theirs { color: var(--red); }

#curtain {
  position: fixed; inset: 0; background: rgba(35, 32, 26, 0.72);
  display: flex; align-items: center; justify-content: center; padding: 18px; z-index: 5;
  overflow-y: auto;
}
/* The cover page: the art is the page, edge to edge, with the wordmark set on
   it and the choices in a band along the foot. */
#curtain.cover-mode { padding: 0; background: var(--ink); align-items: stretch; overflow: hidden; }
.cover { position: relative; width: 100%; height: 100%; overflow: hidden; }
#coverPlate { position: absolute; inset: 0; }
#coverPlate svg { width: 100%; height: 100%; display: block; }
.coverhead {
  position: absolute; left: 5%; top: 6%; right: 5%;
  text-shadow: 0 2px 10px rgba(20, 18, 14, 0.55);
}
.coverhead h1 {
  font-size: clamp(38px, 7.4vw, 104px);
  line-height: 0.92; margin: 0; color: var(--paper);
  border-bottom: 4px solid rgba(233, 226, 207, 0.9);
  padding-bottom: 10px; max-width: 12ch;
}
.coversub {
  font-family: var(--display); text-transform: uppercase; letter-spacing: 0.34em;
  font-size: clamp(10px, 1.1vw, 14px); color: rgba(233, 226, 207, 0.85); margin: 12px 0 0;
}
.coverline { color: var(--paper); font-size: clamp(12px, 1.3vw, 17px); margin: 14px 0 0; max-width: 34ch; }
.coverfoot {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: linear-gradient(180deg, rgba(35, 32, 26, 0) 0, rgba(35, 32, 26, 0.86) 46px, rgba(35, 32, 26, 0.95) 100%);
  color: var(--paper); padding: 40px clamp(16px, 5%, 64px) clamp(14px, 3vh, 26px);
  max-height: 54%; overflow-y: auto;
}
.coverfoot .lead { color: rgba(233, 226, 207, 0.9); max-width: 78ch; margin-bottom: 14px; }
.coverfoot .note { color: rgba(233, 226, 207, 0.55); margin-top: 12px; }
.coverfoot h3 { color: rgba(233, 226, 207, 0.7); margin-top: 0; }
.pickers { display: flex; gap: 22px; flex-wrap: wrap; }
.pickers .picker { flex: 1 1 260px; margin: 0; }
.coverfoot .choice {
  background: rgba(233, 226, 207, 0.1); color: var(--paper); border-color: rgba(233, 226, 207, 0.55);
}
.coverfoot .choice:hover { background: rgba(233, 226, 207, 0.2); }
.coverfoot .choice span { color: rgba(233, 226, 207, 0.6); }
.coverfoot .choice.on { background: var(--brass); color: #1b1710; border-color: var(--paper); }
.coverfoot .choice.on span { color: #35291a; }
.coverorders { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.coverorders button { flex: 0 1 auto; }
.coverorders .primary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.coverorders .primary:hover { background: #fff8e8; }
.coverorders button:not(.primary) { background: transparent; color: var(--paper); border-color: rgba(233, 226, 207, 0.6); }
.card {
  background: var(--paper-card);
  border: 2px solid var(--ink);
  box-shadow: 6px 6px 0 rgba(35, 32, 26, 0.35);
  padding: 20px 22px;
  max-width: 520px;
  width: 100%;
}
.card h1 { border-bottom: 3px double var(--ink); padding-bottom: 6px; }
.picker { margin: 12px 0; }
.choice {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; margin-bottom: 5px; text-transform: none; letter-spacing: 0; font-family: var(--mono);
}
.choice strong { font-family: var(--display); letter-spacing: 0.1em; text-transform: uppercase; }
.choice span { font-size: 11px; color: var(--ink-soft); }
.choice.on { background: var(--brass); }
.choice.on span { color: #35291a; }
.card .primary { width: 100%; margin-top: 8px; }
.card button:not(.primary):not(.choice) { width: 100%; margin-top: 6px; }

/* On a wide glass the choices stand in a column at the right, so the ground
   and the counters keep the whole lower half of the picture. */
@media (min-width: 821px) {
  .coverfoot {
    left: auto; top: 0; width: min(470px, 40%); max-height: none; height: 100%;
    display: flex; flex-direction: column; justify-content: flex-end;
    padding: 40px 44px 34px 60px;
    background: linear-gradient(90deg, rgba(35, 32, 26, 0) 0, rgba(35, 32, 26, 0.86) 90px, rgba(35, 32, 26, 0.96) 100%);
  }
  .pickers { flex-direction: column; gap: 10px; }
  .coverhead { max-width: 58%; }
}

@media (max-width: 820px) {
  .coverhead h1 { max-width: 9ch; }
  .coverfoot { max-height: 74%; padding-top: 30px; }
  .pickers { gap: 12px; }
  #app { grid-template-columns: 1fr; grid-template-rows: auto 46vh 1fr; grid-template-areas: 'bar' 'sheet' 'docket'; }
  #docket { border-left: none; border-top: 3px double var(--ink); }
  #title { font-size: 17px; }
}

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