/* Kriegsspiel — the apparatus.
   Two parties in separate rooms, an engraved sheet on a walnut table, and an
   umpire between them with the dice and the tables. The palette is taken from
   the apparatus itself: lacquered walnut, laid paper, engraved sepia, the two
   parties' colours, and brass for everything the umpire touches. */

:root {
  --walnut: #23201c;
  --walnut-lit: #2e2a24;
  --walnut-edge: #16130f;
  --paper: #dcdad2;
  --paper-deep: #cbc8bd;
  --paper-edge: #b6b1a2;
  --engrave: #3a3a34;
  --sepia: #8a7b5e;
  --blue: #2b4c7e;
  --blue-lit: #4a72ad;
  --red: #a33a2b;
  --red-lit: #cd6250;
  --brass: #b08d3f;
  --brass-lit: #d8b45f;
  --ink: #1a1815;
  --ink-soft: #55504a;

  --serif: Georgia, "Palatino Linotype", "Book Antiqua", Palatino, serif;
  --ledger: "Consolas", "DejaVu Sans Mono", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--walnut);
  color: var(--paper);
  font-family: var(--serif);
  font-size: 15px;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
}

button { font-family: inherit; font-size: inherit; color: inherit; }

.eyebrow {
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--brass); font-variant: small-caps;
}

/* ------------------------------------------------------------------ frame */

#app { display: flex; flex-direction: column; height: 100%; }

#head {
  display: flex; align-items: baseline; gap: 18px;
  padding: 9px 16px 8px;
  background: linear-gradient(var(--walnut-lit), var(--walnut));
  border-bottom: 1px solid var(--brass);
  flex: 0 0 auto;
}
#head .title {
  font-variant: small-caps; letter-spacing: 0.30em; font-size: 17px;
  color: var(--brass-lit); white-space: nowrap;
}
#head .sit { color: var(--paper-edge); font-size: 13px; font-style: italic; }
#head .clock {
  margin-left: auto; font-family: var(--ledger); font-size: 13px;
  color: var(--brass-lit); letter-spacing: 0.04em; white-space: nowrap;
}
#head .party { font-variant: small-caps; letter-spacing: 0.12em; font-size: 13px; }
#head .party.blue { color: var(--blue-lit); }
#head .party.red { color: var(--red-lit); }

#body { flex: 1 1 auto; display: flex; min-height: 0; }

/* ------------------------------------------------------------------ sheet */

#sheetwrap {
  flex: 1 1 auto; position: relative; min-width: 0;
  background: var(--walnut-edge);
  padding: 8px;
}
#sheet {
  width: 100%; height: 100%; display: block;
  background: var(--paper);
  box-shadow: 0 0 0 1px var(--paper-edge), 0 10px 26px rgba(0,0,0,.55);
  cursor: crosshair; touch-action: none;
}
#sheet.dragging { cursor: grabbing; }

#zoom {
  position: absolute; right: 18px; bottom: 18px;
  display: flex; flex-direction: column; gap: 4px;
}
#zoom button {
  width: 34px; height: 34px; border: 1px solid var(--paper-edge);
  background: rgba(220,218,210,.88); color: var(--ink);
  font-size: 17px; line-height: 1; cursor: pointer; border-radius: 2px;
}
#zoom button:hover { background: #fff; }
#zoom button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

/* the hovering block card */
#card {
  position: absolute; pointer-events: none; z-index: 40;
  min-width: 218px; max-width: 290px;
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--ink); border-left-width: 4px;
  box-shadow: 3px 4px 0 rgba(0,0,0,.35);
  padding: 8px 10px 9px; font-size: 12.5px; line-height: 1.42;
}
#card[hidden] { display: none; }
#card .desig { font-variant: small-caps; letter-spacing: 0.08em; font-size: 14px; }
#card .sub { color: var(--ink-soft); font-style: italic; margin-bottom: 5px; }
#card table { width: 100%; border-collapse: collapse; font-family: var(--ledger); font-size: 11px; }
#card td { padding: 1px 0; }
#card td:last-child { text-align: right; }
#card .rule { border-top: 1px solid var(--paper-edge); margin: 5px 0; }
#card .chip {
  display: inline-block; font-family: var(--ledger); font-size: 10px;
  border: 1px solid var(--ink); padding: 0 4px; margin: 3px 3px 0 0;
  text-transform: uppercase; letter-spacing: .06em;
}
#card .shot { margin-top: 5px; font-size: 11.5px; }
#card .verdict { font-style: italic; }

/* ------------------------------------------------------------------ aside */

#aside {
  flex: 0 0 340px; display: flex; flex-direction: column; min-height: 0;
  background: var(--walnut-lit);
  border-left: 1px solid rgba(176,141,63,.45);
}
#aside section { border-bottom: 1px solid rgba(176,141,63,.22); min-height: 0; }
#aside h2 {
  margin: 0; padding: 8px 12px 5px;
  font-size: 10px; letter-spacing: .22em; text-transform: uppercase;
  font-variant: small-caps; color: var(--brass); font-weight: normal;
}

#force { flex: 0 1 auto; overflow-y: auto; }
#force ul { list-style: none; margin: 0; padding: 0 6px 8px; }
#force li {
  padding: 5px 8px; margin-bottom: 2px; cursor: pointer;
  border-left: 3px solid transparent; font-size: 13px;
  display: flex; gap: 8px; align-items: baseline;
}
#force li:hover { background: rgba(220,218,210,.07); }
#force li.sel { background: rgba(176,141,63,.16); border-left-color: var(--brass-lit); }
#force li .d { flex: 1 1 auto; font-variant: small-caps; letter-spacing: .04em; }
#force li .n { font-family: var(--ledger); font-size: 11px; color: var(--paper-edge); }
#force li .f { font-family: var(--ledger); font-size: 10px; color: var(--sepia); width: 40px; text-align: right; }
#force li.shaken .d { color: #d9b98b; }
#force li.wavering .d { color: #d99a6b; }
#force li.broken .d { color: var(--red-lit); text-decoration: line-through; }
#force li.gone { opacity: .35; text-decoration: line-through; cursor: default; }

/* --------------------------------------------------------- the ruling slip
   The umpire's adjudication, laid on the table as a slip of paper: a ruled
   ledger of every modifier by name, the face of the die, and the verdict. */

#rulingsSec { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
#rulings { flex: 1 1 auto; overflow-y: auto; padding: 0 10px 12px; }
.slip {
  background: var(--paper); color: var(--ink);
  border: 1px solid var(--paper-edge);
  box-shadow: 2px 3px 0 rgba(0,0,0,.32);
  margin: 0 0 10px; padding: 9px 11px 10px;
  position: relative;
}
.slip::before {
  content: ""; position: absolute; inset: 3px; pointer-events: none;
  border: 1px solid rgba(58,58,52,.20);
}
.slip .head {
  font-variant: small-caps; letter-spacing: .09em; font-size: 13px;
  border-bottom: 1px solid var(--ink); padding-bottom: 3px; margin-bottom: 5px;
}
.slip .head .arrow { color: var(--sepia); }
.slip.blue .head { color: var(--blue); }
.slip.red .head { color: var(--red); }
.slip table { width: 100%; border-collapse: collapse; font-family: var(--ledger); font-size: 11px; }
.slip td { padding: 1px 0; vertical-align: baseline; }
.slip td.v { text-align: right; white-space: nowrap; padding-left: 8px; }
.slip tr.die td { border-top: 1px solid var(--paper-edge); padding-top: 3px; }
.slip .verdict {
  margin-top: 6px; padding-top: 5px; border-top: 2px solid var(--ink);
  font-size: 13px; font-style: italic;
}
.slip .verdict b { font-style: normal; font-variant: small-caps; letter-spacing: .06em; }
.slip .pip {
  display: inline-block; width: 15px; height: 15px; vertical-align: -3px;
  border: 1px solid var(--ink); border-radius: 2px; margin-right: 4px;
  font-family: var(--ledger); font-size: 10px; line-height: 13px; text-align: center;
  background: #fff;
}
#rulings .none { color: var(--sepia); font-style: italic; font-size: 12.5px; padding: 2px 2px 8px; }

/* ----------------------------------------------------------------- orders */

#orders {
  flex: 0 0 auto; background: var(--walnut);
  border-top: 1px solid var(--brass);
  padding: 9px 12px 11px;
}
.row { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 5px; }
.row .lbl {
  width: 100%; font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--sepia); margin-bottom: 1px;
}
.opt {
  border: 1px solid rgba(220,218,210,.28); background: transparent;
  padding: 3px 9px; cursor: pointer; border-radius: 2px;
  font-size: 12.5px; font-variant: small-caps; letter-spacing: .05em;
  color: var(--paper-edge);
}
.opt:hover { border-color: var(--brass); color: var(--paper); }
.opt.on { background: var(--brass); border-color: var(--brass); color: var(--walnut); }
.opt:disabled { opacity: .3; cursor: default; }
.opt:focus-visible { outline: 2px solid var(--brass-lit); outline-offset: 2px; }

#written {
  background: var(--paper); color: var(--ink);
  padding: 8px 11px 9px; margin: 7px 0 8px;
  font-style: italic; font-size: 13.5px; line-height: 1.45;
  border-left: 4px solid var(--brass);
  min-height: 54px;
}
#written .to { font-style: normal; font-variant: small-caps; letter-spacing: .07em; }
#written .courier {
  display: block; margin-top: 5px; font-style: normal;
  font-family: var(--ledger); font-size: 11px; color: var(--sepia);
}
#written .courier.slow { color: var(--red); }

#act { display: flex; gap: 8px; }
#send, #resolve {
  flex: 1 1 auto; padding: 8px 10px; cursor: pointer; border-radius: 2px;
  font-variant: small-caps; letter-spacing: .12em; font-size: 14px;
}
#send { background: transparent; border: 1px solid var(--brass); color: var(--brass-lit); }
#send:hover:not(:disabled) { background: rgba(176,141,63,.18); }
#resolve { background: var(--brass); border: 1px solid var(--brass); color: var(--walnut); }
#resolve:hover:not(:disabled) { background: var(--brass-lit); }
#send:disabled, #resolve:disabled { opacity: .35; cursor: default; }
#send:focus-visible, #resolve:focus-visible { outline: 2px solid var(--brass-lit); outline-offset: 2px; }

/* ------------------------------------------------------------------ sheets
   Full-screen leaves: the opening, the rules, the after-action. */

.veil {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(20,17,14,.93);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
}
/* an author display rule outranks the browser's [hidden] rule, so it has to
   be stated explicitly or hiding the element does nothing */
.veil[hidden] { display: none; }

.leaf {
  background: var(--paper); color: var(--ink);
  max-width: 760px; width: 100%; max-height: 92vh; overflow-y: auto;
  padding: 26px 30px 28px;
  box-shadow: 0 18px 50px rgba(0,0,0,.7);
  border: 1px solid var(--paper-edge);
}
.leaf h1 {
  margin: 0 0 2px; font-size: 27px; font-weight: normal;
  font-variant: small-caps; letter-spacing: .16em;
}
.leaf .kicker {
  font-size: 11px; letter-spacing: .24em; text-transform: uppercase;
  color: var(--sepia); margin-bottom: 18px;
}
.leaf h2 {
  font-size: 13px; letter-spacing: .18em; text-transform: uppercase;
  font-variant: small-caps; font-weight: normal; color: var(--sepia);
  border-bottom: 1px solid var(--paper-edge); padding-bottom: 3px;
  margin: 20px 0 8px;
}
.leaf p { line-height: 1.6; margin: 0 0 10px; }
.leaf ul { line-height: 1.55; padding-left: 20px; }
.leaf .lede { font-size: 16px; font-style: italic; }
.leaf table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 6px 0 12px; }
.leaf th, .leaf td { text-align: left; padding: 3px 8px 3px 0; border-bottom: 1px solid rgba(58,58,52,.14); }
.leaf th { font-variant: small-caps; letter-spacing: .08em; font-weight: normal; color: var(--sepia); }
.leaf td.n { font-family: var(--ledger); text-align: right; }

.pick { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 8px; margin: 4px 0 14px; }
.pick button {
  text-align: left; padding: 9px 12px; cursor: pointer;
  background: transparent; border: 1px solid var(--paper-edge); border-radius: 2px;
  color: var(--ink);
}
.pick button:hover { border-color: var(--ink); background: rgba(58,58,52,.05); }
.pick button.on { border-color: var(--brass); background: rgba(176,141,63,.16); box-shadow: inset 3px 0 0 var(--brass); }
.pick button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.pick .nm { font-variant: small-caps; letter-spacing: .07em; font-size: 15px; display: block; }
.pick .ds { font-size: 12px; color: var(--ink-soft); font-style: italic; display: block; margin-top: 2px; }

.leaf .go {
  display: inline-block; margin-top: 8px; padding: 9px 22px; cursor: pointer;
  background: var(--ink); color: var(--paper); border: none; border-radius: 2px;
  font-variant: small-caps; letter-spacing: .14em; font-size: 15px;
}
.leaf .go:hover { background: #000; }
.leaf .go.ghost { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.leaf .go:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.leaf .go[disabled] { opacity: .35; cursor: default; }
.leaf .acts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.stamp {
  border: 3px double var(--red); color: var(--red);
  display: inline-block; padding: 6px 18px; margin: 6px 0 14px;
  font-variant: small-caps; letter-spacing: .18em; font-size: 19px;
  transform: rotate(-1.6deg);
}
.stamp.blue { border-color: var(--blue); color: var(--blue); }
.stamp.draw { border-color: var(--sepia); color: var(--sepia); }

/* ----------------------------------------------------------------- mobile */

@media (max-width: 900px) {
  #body { flex-direction: column; }
  #aside { flex: 0 0 auto; max-height: 47%; border-left: none; border-top: 1px solid rgba(176,141,63,.45); }
  #sheetwrap { flex: 1 1 auto; padding: 4px; }
  #head { flex-wrap: wrap; gap: 8px 14px; padding: 7px 10px 6px; }
  #head .title { font-size: 14px; letter-spacing: .2em; }
  #head .sit { font-size: 12px; }
  #rulings { max-height: 30vh; }
  #force { max-height: 22vh; }
  .leaf { padding: 20px 18px 22px; }
  .leaf h1 { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}
