/* Spent. Square, ruled, no motion. Inside #keys and #sheet only fixed hex. */

*, *::before, *::after { box-sizing: border-box; border-radius: 0; transition: none; animation: none; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.defs { position: absolute; width: 0; height: 0; overflow: hidden; }
main { max-width: 960px; margin: 0 auto; padding: 28px 16px 48px; }
[hidden] { display: none !important; }

h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 44px;
  line-height: 1;
  letter-spacing: -0.5px;
  color: var(--c-earth);
  margin: 0 0 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) h1 { color: var(--ink); }
}
[data-theme="dark"] h1 { color: var(--ink); }
h1 .logo-x { width: 12px; height: 12px; margin-left: 5px; color: var(--ink-soft); vertical-align: baseline; }
.rule { font-size: 18px; margin: 0 0 4px; max-width: 34em; }
.sub { font-size: 14px; color: var(--ink-soft); margin: 0 0 24px; max-width: 40em; }

button:not(.key), select {
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--ink);
  padding: 6px 12px;
  cursor: pointer;
}
select { padding: 5px 8px; background: var(--bg); }
button:not(.key):hover, select:hover { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* the instrument */
#keys {
  --w: clamp(40px, calc((100vw - 32px) / 7), 72px);
  position: relative;
  width: calc(var(--w) * 7 + 1px);
  height: calc(var(--w) * 3.2);
  margin: 0 0 22px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.key {
  position: absolute;
  top: 0;
  margin: 0;
  padding: 4px 0 6px;
  border: 1px solid #1A1A1A;
  font: inherit;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  text-align: center;
}
.key.white { width: calc(var(--w) + 1px); height: 100%; background: #FFFFFF; color: #1A1A1A; z-index: 1; }
.key.white.spent { background: var(--c-teal); }
.key.dark { width: calc(var(--w) * 0.62); height: 60%; background: var(--c-indigo); color: #FCF0DD; z-index: 2; padding-bottom: 4px; }
.key.dark.spent { background: var(--c-moss); }
.key:focus-visible { z-index: 3; }
.key[data-pc="0"] { left: 0; }
.key[data-pc="2"] { left: var(--w); }
.key[data-pc="4"] { left: calc(var(--w) * 2); }
.key[data-pc="5"] { left: calc(var(--w) * 3); }
.key[data-pc="7"] { left: calc(var(--w) * 4); }
.key[data-pc="9"] { left: calc(var(--w) * 5); }
.key[data-pc="11"] { left: calc(var(--w) * 6); }
.key[data-pc="1"] { left: calc(var(--w) * 0.69); }
.key[data-pc="3"] { left: calc(var(--w) * 1.69); }
.key[data-pc="6"] { left: calc(var(--w) * 3.69); }
.key[data-pc="8"] { left: calc(var(--w) * 4.69); }
.key[data-pc="10"] { left: calc(var(--w) * 5.69); }
.key .ord { font-size: 11px; min-height: 14px; line-height: 14px; }
.key .cap { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.key .name { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; column-gap: 2px; font-size: 15px; line-height: 16px; }
.key.dark .name { font-size: 12px; line-height: 14px; }
.key .letter { font-size: 10px; line-height: 12px; }
.key .key-marks:empty { display: none; }
.key .mark { display: inline-flex; align-items: center; font-size: 10px; line-height: 10px; color: inherit; }
.key .mark svg { width: 10px; height: 10px; }
.key .mark .n { font-style: normal; }

/* the strip, fluid on screen */
.strip .slot { min-width: 0; }
.strip .mark { display: flex; align-items: center; justify-content: center; gap: 1px; white-space: nowrap; color: var(--ink-soft); }
.mark b { font-weight: 400; }
.mark i { font-style: normal; }
.ledger .mark { display: flex; align-items: center; justify-content: center; gap: 1px; white-space: nowrap; color: var(--ink-soft); }
.strip.fluid .s-names, .strip.fluid .s-margin,
.ledger .s-names, .ledger .s-margin { display: grid; grid-template-columns: repeat(12, 1fr); column-gap: 6px; }
.strip.fluid .s-names .slot { height: 30px; line-height: 30px; text-align: center; font-weight: 700; border-bottom: 1px solid var(--ink); }
.strip.fluid .s-margin .slot { min-height: 24px; padding: 3px 0 2px; border-bottom: 1px solid var(--ink-soft); font-size: 11px; }
.strip.fluid .mark svg, .ledger .mark svg { width: 9px; height: 9px; flex: none; }

#now { margin-bottom: 8px; }
#counter { margin: 0 0 4px; font-size: 15px; }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 18px; font-size: 14px; }
.controls label { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-soft); }

/* the register */
#register { margin-top: 44px; }
.scroll { overflow-x: auto; }
.ledger { width: 100%; min-width: 560px; border-collapse: collapse; table-layout: fixed; }
.ledger col.c-no { width: 7%; }
.ledger col.c-taken { width: 23%; }
.ledger col.c-row { width: 62%; }
.ledger col.c-margin { width: 8%; }
.ledger thead { display: table-header-group; }
.ledger .h-title th { text-align: left; padding: 0 0 8px; font-weight: 400; }
.ledger h2 { margin: 0; font-size: 18px; font-weight: 700; }
.ledger .h-cols th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-soft); padding: 4px 6px; border: 1px solid var(--ink); }
.ledger td { border-left: 1px solid var(--ink); border-right: 1px solid var(--ink); padding: 0 6px; font-size: 14px; }
.ledger tbody.entry tr:last-child td, .ledger td[rowspan] { border-bottom: 1px solid var(--ink); }
.ledger td.no, .ledger td.taken, .ledger td.margin-n { vertical-align: top; padding-top: 6px; }
.ledger td.row-h { height: 32px; padding: 3px 6px; border-bottom: 1px solid var(--ink-soft); }
.ledger td.row-names { border-bottom: 1px solid var(--ink-soft); }
.ledger .s-names .slot { height: 28px; line-height: 28px; text-align: center; font-weight: 700; }
.ledger .s-margin .slot { min-height: 22px; padding: 3px 0 2px; font-size: 11px; display: flex; flex-direction: column; align-items: center; }
.ledger button.show { font-size: 12px; padding: 2px 8px; }
.print-only { display: none; }
#empty { color: var(--ink-soft); font-size: 14px; margin: 12px 0 0; }
.totals { margin-top: 16px; }
#total { margin: 0 0 12px; }
.totals h3 { font-size: 13px; font-weight: 500; color: var(--ink-soft); margin: 0 0 4px; }
.tally { display: grid; grid-template-columns: repeat(12, 1fr); border-left: 1px solid var(--ink); max-width: 560px; }
.tally .cell { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--ink); border-left: 0; padding: 3px 0; font-size: 13px; }
#storage { margin: 12px 0 0; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

/* the sheet, white paper at its printed size */
.sheet-area { margin-top: 48px; }
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.paper-scroll { overflow-x: auto; padding-bottom: 6px; }
#sheet {
  background: #FFFFFF;
  color: #1A1A1A;
  width: 210mm;
  min-height: 297mm;
  padding: 14mm;
  border: 1px solid #1A1A1A;
  font-family: var(--font-body);
  font-size: 9pt;
  line-height: 1.2;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
#sheet.paper-letter { width: 215.9mm; min-height: 279.4mm; }
#sheet.blank { width: auto; max-width: 210mm; min-height: 0; padding: 8mm 10mm; }
#sheet .none { margin: 0; color: #5B5B5B; font-size: 10pt; }
#sheet .sh-top { height: 4mm; margin-bottom: 2mm; display: flex; align-items: flex-end; gap: 1.6mm; font-size: 8pt; line-height: 1; color: #5B5B5B; }
#sheet .sh-top .word { font-family: var(--font-display); font-weight: 400; display: inline-flex; align-items: flex-end; }
#sheet .logo-x { width: 2.8mm; height: 2.8mm; margin-left: 0.8mm; color: #5B5B5B; }
#sheet .boxes { display: flex; height: 14mm; margin-bottom: 4mm; }
#sheet .box { height: 14mm; border: 0.5pt solid #1A1A1A; padding: 1.2mm 1.6mm; display: flex; flex-direction: column; justify-content: space-between; }
#sheet .box + .box { border-left: 0; }
#sheet .box .lab { font-size: 6.5pt; color: #5B5B5B; }
#sheet .box .val { font-size: 9pt; white-space: nowrap; }
#sheet .strip.fixed { display: flex; width: 174mm; margin: 4mm 0 5mm; }
#sheet .s-labels { width: 12mm; flex: none; font-size: 6.5pt; color: #5B5B5B; }
#sheet .s-labels .l-row { height: 10mm; display: flex; align-items: flex-end; padding-bottom: 1.2mm; }
#sheet .s-labels .l-margin { display: block; height: calc(7mm + var(--extra, 0) * 2.8mm); padding-top: 1.2mm; }
#sheet .s-body { width: 150mm; flex: none; }
#sheet .s-names, #sheet .s-margin { display: grid; grid-template-columns: repeat(12, 12.5mm); }
#sheet .s-names .slot { height: 10mm; margin: 0 1mm; display: flex; align-items: flex-end; justify-content: center; padding-bottom: 1mm; font-size: 10pt; font-weight: 700; border-bottom: 0.5pt solid #1A1A1A; }
#sheet .s-margin .slot { height: calc(7mm + var(--extra, 0) * 2.8mm); margin: 0 1mm; padding-top: 1mm; display: flex; flex-direction: column; align-items: center; border-bottom: 0.25pt solid #5B5B5B; }
#sheet .mark { height: 2.8mm; font-size: 6.5pt; line-height: 1; gap: 0.3mm; color: #5B5B5B; }
#sheet .mark svg { width: 2.4mm; height: 2.4mm; flex: none; }
#sheet .written { height: 6mm; margin: 0; font-size: 8pt; }
#sheet .matrix { width: 174mm; border-collapse: collapse; table-layout: fixed; }
#sheet .matrix col.lab { width: 12mm; }
#sheet .matrix col.cell { width: 12.5mm; }
#sheet .matrix td, #sheet .matrix th { padding: 0; text-align: center; vertical-align: middle; }
#sheet .matrix td.c { height: 10mm; border: 0.25pt solid #1A1A1A; font-size: 9pt; }
#sheet .matrix tr.prime td.c { background: var(--c-lavlt); font-weight: 700; }
#sheet .matrix tr.top td, #sheet .matrix tr.bottom td { height: 6mm; font-size: 6.5pt; color: #5B5B5B; }
#sheet .matrix th.lab { font-weight: 400; font-size: 6.5pt; color: #5B5B5B; }
#sheet .legend { min-height: 12mm; margin: 0; padding-top: 2.5mm; font-size: 7pt; color: #5B5B5B; max-width: 174mm; }
#sheet .check { height: 6mm; margin: 0; display: flex; align-items: center; font-size: 8pt; }
#sheet .sh-colo { height: 10mm; display: flex; align-items: center; gap: 3mm; font-size: 7pt; color: #5B5B5B; }
#sheet .sh-colo img { width: 22mm; height: auto; display: block; }

.colophon { margin-top: 56px; padding-top: 14px; border-top: 1px solid var(--ink); display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 13px; color: var(--ink-soft); }
.colophon p { margin: 0; }
.colophon img { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .colophon img { background: #FCF0DD; padding: 3px 6px; box-sizing: content-box; }
}
[data-theme="dark"] .colophon img { background: #FCF0DD; padding: 3px 6px; box-sizing: content-box; }

@media (max-width: 480px) {
  h1 { font-size: 38px; }
  .rule { font-size: 16px; }
  .sub { font-size: 13px; margin-bottom: 18px; }
  main { padding-top: 20px; }
  .strip.fluid .s-names, .strip.fluid .s-margin { column-gap: 3px; }
  .strip.fluid .s-names .slot { font-size: 13px; }
  .strip.fluid .s-margin .slot { font-size: 9px; }
  .strip.fluid .mark svg { width: 7px; height: 7px; }
}

/* print: fixed ink on white, whatever the scheme */
@media print {
  :root { color-scheme: light; }
  body { background: #FFFFFF; color: #1A1A1A; }
  main { max-width: none; margin: 0; padding: 0; }
  .sheet-area { margin: 0; }
  button, select, .print-hide { display: none !important; }

  body:not([data-print="register"]) main > :not(.sheet-area) { display: none !important; }
  body:not([data-print="register"]) .sheet-head { display: none !important; }
  .paper-scroll { overflow: visible; padding: 0; }
  #sheet, #sheet.paper-letter { width: 174mm; min-height: 0; padding: 0; border: 0; margin: 0; }
  #sheet.blank { padding: 0; }

  body[data-print="register"] main > :not(#register) { display: none !important; }
  #register { margin: 0; color: #1A1A1A; }
  #register .scroll { overflow: visible; }
  #empty, #storage, #reg-buttons { display: none !important; }
  .ledger { width: 174mm; min-width: 0; }
  .ledger col.c-no { width: 12mm; }
  .ledger col.c-taken { width: 40mm; }
  .ledger col.c-row { width: 108mm; }
  .ledger col.c-margin { width: 14mm; }
  .ledger th, .ledger td { color: #1A1A1A; border-color: #1A1A1A !important; border-width: 0.25pt !important; }
  .ledger .h-title th { height: 4mm; padding: 0; line-height: 1; vertical-align: top; border: 0 !important; }
  .ledger h2 { font-size: 9pt; line-height: 1; }
  .ledger .h-cols th { height: 4mm; padding: 0 1mm; font-size: 6.5pt; line-height: 1; color: #1A1A1A; vertical-align: middle; }
  .ledger tbody.entry { break-inside: avoid; page-break-inside: avoid; }
  .ledger tbody.entry tr:not(:last-child) { break-after: avoid; page-break-after: avoid; }
  .ledger td { padding: 0 1mm; font-size: 7.5pt; line-height: 1; }
  .ledger td.no, .ledger td.taken, .ledger td.margin-n { padding-top: 1.2mm; }
  .ledger td.row-h { height: 5mm; padding: 0 1mm; font-size: 6.5pt; vertical-align: middle; }
  .ledger td.row-names, .ledger td.row-margin { padding: 0; }
  .print-only { display: inline; color: #5B5B5B; }
  .ledger .s-names, .ledger .s-margin { grid-template-columns: repeat(12, 9mm); column-gap: 0; }
  .ledger .s-names .slot { height: 7mm; line-height: 7mm; font-size: 8pt; }
  .ledger .s-margin .slot { height: calc(7mm + var(--extra, 0) * 2.8mm); min-height: 0; padding: 1mm 0 0; display: flex; flex-direction: column; align-items: center; }
  .ledger .mark { height: 2.8mm; font-size: 6.5pt; line-height: 1; gap: 0.3mm; color: #5B5B5B; }
  .ledger .mark svg { width: 2.2mm; height: 2.2mm; }
  .totals { margin: 0; padding: 0; height: 30mm; break-inside: avoid; page-break-inside: avoid; color: #1A1A1A; }
  #total { height: 8mm; margin: 0 0 4mm; font-size: 8pt; line-height: 1; padding-top: 3.5mm; }
  .totals h3 { height: 6mm; margin: 0; font-size: 7.5pt; line-height: 6mm; color: #1A1A1A; }
  .tally { width: 174mm; max-width: none; height: 12mm; border-color: #1A1A1A; }
  .tally .cell { height: 12mm; padding: 1mm 0; font-size: 7.5pt; border-color: #1A1A1A; border-width: 0.25pt; }
}
