@font-face { font-family: "Press Start 2P"; src: url("fonts/PressStart2P-Regular.ttf?v=19") format("truetype"); font-display: swap; }
@font-face { font-family: "VT323"; src: url("fonts/VT323-Regular.ttf?v=19") format("truetype"); font-display: swap; }
:root {
  --midnight: #111526; --panel: #1B2338; --steel: #425475; --cream: #F7EFD6; --gold: #F9DC89;
  --ghost: #B6A4FF; --replay: #72E0B4; --danger: #FF8994; --shadow: #070A14; --phosphor: #8CF5A6;
  --steel-light: #6378A0;
  --px: "Press Start 2P", monospace; --vt: "VT323", monospace;
}
* { box-sizing: border-box; }
/* Part D (Requirement 6.48/6.50 family): .play .controls is a sticky bar at the bottom. Keeping
   scroll-padding-bottom equal to the bar's height means a focused element (or a score tile) scrolled
   into view lands above the bar instead of under it. The bar is capped at 140 px (criterion 6.48);
   128 px matches its real height on desktop, 118 px on a phone. */
html { scroll-padding-bottom: 128px; }
@media (max-width: 700px) { html { scroll-padding-bottom: 118px; } }
html, body { margin: 0; background: var(--midnight); color: var(--cream); font-family: var(--vt); font-size: 22px; }
body { background-image: radial-gradient(#1f2742 1px, transparent 1px); background-size: 8px 8px; min-height: 100vh; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
h2 { font-family: var(--px); font-size: 15px; margin: 0; letter-spacing: 1px; color: var(--gold); }
b { color: var(--gold); font-weight: normal; }
a { color: var(--replay); }
:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }

.top { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 14px 24px; flex-wrap: wrap;
  background: var(--panel); border-bottom: 4px solid var(--shadow); box-shadow: 0 4px 0 var(--steel); }
.brand { display: flex; gap: 14px; align-items: center; }
.brand img { image-rendering: pixelated; }
.title { font-family: var(--px); font-size: 26px; font-weight: normal; line-height: 1.15; margin: 0; color: var(--gold); text-shadow: 4px 4px 0 var(--shadow); }
h1.title:focus { outline: none; }
.tag { margin: 6px 0 0; color: var(--cream); font-size: 22px; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; }

.btn { font-family: var(--px); font-size: 12px; color: var(--cream); background: var(--steel); border: 0; padding: 12px 14px; cursor: pointer;
  box-shadow: inset -4px -4px 0 var(--shadow), inset 4px 4px 0 #6378a0; display: inline-flex; gap: 8px; align-items: center;
  min-height: 44px; min-width: 44px; }
.btn:hover { filter: brightness(1.15); }
.btn:active { box-shadow: inset 4px 4px 0 var(--shadow); }
.btn img { image-rendering: pixelated; }
.btn-small { margin-top: 10px; }
.btn-gold { background: var(--gold); color: var(--shadow); box-shadow: inset -4px -4px 0 #b8922e, inset 4px 4px 0 #fff3c4; }
.btn-big { font-size: 16px; padding: 16px 22px; }
.btn-replay { background: #1f6e52; box-shadow: inset -4px -4px 0 #145a40, inset 4px 4px 0 var(--replay); }
.btn[aria-pressed="true"] { background: #6a58c4; }

.grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr);
  grid-template-areas: "register play"; gap: 20px; padding: 20px 24px; }
/* DOM order is Timeline (play) then register, so tab order follows reading order (Requirement 6.40);
   grid-template-areas keeps the register visually on the left on desktop. */
.grid > .register { grid-area: register; }
.grid > .play { grid-area: play; }
@media (max-width: 1100px) { .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "play" "register"; } }
.panel { background: var(--panel); padding: 16px 18px; border: 4px solid var(--steel); box-shadow: 8px 8px 0 var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.chip { font-family: var(--vt); background: var(--midnight); border: 2px solid var(--steel); padding: 2px 10px; }

.row-fields { display: flex; gap: 18px; margin-bottom: 10px; flex-wrap: wrap; }
input, select { font-family: var(--vt); font-size: 22px; color: var(--cream); background: var(--midnight); border: 2px solid var(--steel-light); padding: 2px 6px; }
.row-fields input { width: 120px; margin-left: 6px; }
.table-wrap { max-height: 520px; overflow: auto; border: 2px solid var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th { font-family: var(--px); font-size: 10px; text-align: left; padding: 8px 6px; background: var(--shadow); color: var(--gold); position: sticky; top: 0; }
td { padding: 3px 4px; border-bottom: 2px dashed #2a3452; }
td input { width: 100%; }
td.day input, td.alt input { width: 58px; }
td.amt input { width: 110px; text-align: right; }
tr.income td.amt input { color: var(--replay); }
tr.flexible td { background: rgba(182, 164, 255, 0.08); }
tr.moved td { background: rgba(114, 224, 180, 0.18); }
tr.moved td.day input { color: var(--replay); }
.del { background: none; border: 0; color: var(--danger); font-family: var(--px); font-size: 12px; cursor: pointer; padding: 6px; min-height: 44px; min-width: 44px; }
.hint { color: #cfd6ea; margin: 10px 0 0; }

/* Replay preview arrow beside the day cell */
.day-preview { display: inline-block; color: var(--replay); font-family: var(--px); font-size: 10px; margin-left: 4px; white-space: nowrap; }

.delay { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.delay-label { font-family: var(--px); font-size: 11px; color: var(--ghost); display: inline-flex; gap: 6px; align-items: center; }
.delay-label img { image-rendering: pixelated; }
#delay-btns { display: flex; gap: 4px; flex-wrap: wrap; }
#delay-btns button { font-family: var(--px); font-size: 11px; width: 44px; height: 44px; border: 0; cursor: pointer; color: var(--cream); background: var(--midnight); box-shadow: inset 0 0 0 2px var(--steel); }
#delay-btns button[aria-pressed="true"] { background: var(--ghost); color: var(--shadow); box-shadow: inset -3px -3px 0 #7c68d9; }
/* Narrow phones (<= 360px): shrink the delay buttons so all six stay inside the panel content box. */
@media (max-width: 360px) { #delay-btns button { width: 38px; font-size: 10px; } }

/* Payday stress test: six compact result buttons, one per delay (+0..+5). */
.stress { margin: 10px 0 2px; }
.stress-label { font-family: var(--px); font-size: 11px; color: var(--ghost); display: block; margin-bottom: 6px; }
.stress-btns { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }
.stress-btn { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 0; padding: 4px 1px; border: 0; cursor: pointer; color: var(--cream); background: var(--midnight); box-shadow: inset 0 0 0 2px var(--steel); font-family: var(--vt); line-height: 1.05; }
.stress-btn .st-d { font-family: var(--px); font-size: 11px; }
.stress-btn .st-tag { font-family: var(--px); font-size: 12px; letter-spacing: .5px; }
.stress-btn .st-moves, .stress-btn .st-worst { font-size: 15px; white-space: nowrap; }
.stress-btn.safe .st-tag { color: var(--replay); }
.stress-btn.short .st-tag { color: var(--danger); }
.stress-btn.short { box-shadow: inset 0 0 0 2px var(--danger); }
.stress-btn[aria-pressed="true"] { background: var(--ghost); color: var(--shadow); box-shadow: inset -3px -3px 0 #7c68d9; }
.stress-btn[aria-pressed="true"] .st-tag.safe, .stress-btn[aria-pressed="true"] .st-tag { color: var(--shadow); }
.stress-max { font-size: 20px; color: var(--cream); margin: 6px 0 2px; }
/* Narrow phones (320–400 px): shrink the stress numbers so six fit with no scroll. */
/* Narrow phones (<= 420 px): the SAFE/SHORT word stays 12 px (readable), which is too wide for a
   six-across row, so the six tiles wrap to two rows of three. Each tile is then wide enough for the
   word and the row never overflows horizontally. */
@media (max-width: 420px) {
  .stress-btns { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .stress-btn { padding: 5px 1px; }
  .stress-btn .st-moves, .stress-btn .st-worst { font-size: 14px; }
}

/* NO SAFE REPLAY cushion explanation: a short, informational list. */
.shortfall { margin: 8px 0 2px; border-left: 3px solid var(--danger); padding-left: 10px; }
.sample-warning { margin: 0 0 10px; border: 3px solid var(--danger); background: #4a1620; padding: 10px 12px; }
.sample-warning p { font-size: 20px; color: var(--cream); margin: 0 0 8px; }
/* Deep-link ignored-parameter notice (Requirement 10.8): one short line per ignored setting. */
.deeplink-notice { margin: 0 0 10px; border-left: 3px solid var(--gold); padding: 6px 10px; }
.deeplink-notice p { font-size: 20px; color: var(--cream); margin: 0 0 4px; }
/* SAVE PLAN button (Requirement 6.53): next to the result, at least 44 px tall. */
.plan-row { margin: 8px 0 2px; }
#btn-plan { min-height: 44px; }
/* Invalid field marking (Requirement 6.25): a red outline of at least 2px on a flagged input, so
   the cue is an outline plus the describing text, never colour alone. */
[aria-invalid="true"] { outline: 3px solid var(--danger); outline-offset: 1px; }
/* Invalid-field focus (Requirement 6.38): keep the gold focus ring and add a red box-shadow as a
   second cue, so focus is never lost on an invalid field and the red is not the only signal. */
[aria-invalid="true"]:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px;
  box-shadow: 0 0 0 3px var(--danger); }
.field-error { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.shortfall .sf-head { font-size: 20px; color: var(--cream); margin: 0 0 4px; }
.shortfall .sf-list { margin: 0 0 6px; padding-left: 20px; font-size: 20px; color: var(--cream); }
.shortfall .sf-list b { color: var(--gold); }
.shortfall .sf-note { font-size: 20px; color: #cfd6ea; margin: 0; font-style: italic; }

.chart { background: var(--shadow); border: 2px solid var(--steel); }
.chart svg { display: block; width: 100%; height: auto; }
.assumption-note { font-size: 20px; color: #cfd6ea; margin: 6px 0 2px; border-left: 3px solid var(--steel); padding-left: 8px; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin: 8px 0 12px; font-size: 20px; }
.legend i { display: inline-block; width: 28px; height: 0; border-top: 5px solid; vertical-align: middle; margin-right: 6px; }

.scores { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 1560px) { .scores { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.score { min-width: 0; overflow-wrap: anywhere; background: var(--midnight); border: 3px solid var(--gold); padding: 8px 10px; box-shadow: 4px 4px 0 var(--shadow); }
.score span { display: block; font-family: var(--px); font-size: 10px; color: var(--gold); }
.score b { display: block; font-family: var(--px); font-size: 22px; margin-top: 8px; color: var(--cream); white-space: nowrap; }
/* Item 6.36: long amounts (e.g. -$1,020.00) shrink by glyph length so they stay on one line inside
   the tile at every width, including 320 px. data-long is set in app.js from the rendered string. */
.score b[data-long="l"] { font-size: 19px; }
.score b[data-long="xl"] { font-size: 16px; }
.score.ghost { border-color: var(--ghost); } .score.ghost span { color: var(--ghost); }
.score.replay { border-color: var(--replay); } .score.replay span { color: var(--replay); }
.score b.neg { color: var(--danger); } .score b.pos { color: var(--replay); }
/* Second line under the ending: the late-payday (ghost) ending. VT323 20px so it reads on a phone. */
.score .s-end-ghost { display: block; margin-top: 6px; font-family: var(--vt); font-size: 20px; line-height: 1.15; color: var(--ghost); overflow-wrap: anywhere; }
/* Raised from 0.45 — still visually muted but legible at 0.72 */
.score.dim { opacity: 0.72; border-style: dashed; }

.controls { display: flex; gap: 14px; margin: 16px 0; }
.result { background: var(--midnight); border: 3px dashed var(--steel); padding: 10px 16px; min-height: 120px; }
.verdict { font-family: var(--px); font-size: 20px; margin: 6px 0; color: var(--gold); scroll-margin-top: 12px; }
.verdict.clear { color: var(--replay); text-shadow: 3px 3px 0 #145a40; }
.verdict.bad { color: var(--danger); }
.message-row { display: flex; align-items: flex-start; gap: 10px; margin: 4px 0; }
.message-row .msg-ghost { image-rendering: pixelated; flex-shrink: 0; margin-top: 2px; }
.message-row p { margin: 0; }
.moves { list-style: none; padding: 0; margin: 6px 0; }
.moves li { font-size: 24px; } .moves li::before { content: "\25B6  "; color: var(--replay); }
.proof { color: #cfd6ea; margin: 4px 0; }
.slot { display: block; margin-top: 12px; }
.slot input { width: 20px; height: 20px; vertical-align: middle; }

/* Error banner — no transform, constrained with left/right so it never causes horizontal scroll */
.errors { position: fixed; bottom: 20px; left: 16px; right: 16px; margin: 0 auto; width: fit-content;
  max-width: min(700px, calc(100vw - 32px));
  background: #4a1620; border: 4px solid var(--danger); padding: 12px 20px; z-index: 5; box-shadow: 8px 8px 0 var(--shadow); }
.errors ul { margin: 6px 0; padding-left: 22px; }
.ow-note { font-size: 20px; color: var(--cream); border-left: 4px solid var(--ghost); padding: 4px 10px; margin: 0 0 8px; background: rgba(182, 164, 255, 0.10); }
.foot { padding: 10px 24px 30px; color: #cfd6ea; font-size: 20px; }
.foot p { margin: 4px 0; }

.boot { position: fixed; inset: 0; background: #050806; z-index: 10; display: grid; place-items: center; }
.crt { width: min(900px, 92vw); padding: 30px; text-align: left; }
/* clamp so boot text doesn't overflow on narrow screens */
.boot-text { font-family: var(--vt); font-size: clamp(18px, 4.6vw, 30px); color: var(--phosphor); text-shadow: 0 0 8px rgba(140, 245, 166, 0.6); min-height: 300px; white-space: pre-wrap; margin: 0; }
.boot-bar { height: 22px; border: 3px solid var(--phosphor); margin: 18px 0; }
#boot-fill { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--phosphor) 0 14px, transparent 14px 18px); transition: width 0.3s steps(8); }
/* clamp so the logo doesn't overflow at 390px */
.boot-logo { font-family: var(--px); font-size: clamp(30px, 11vw, 56px); line-height: 1.2; color: var(--gold); text-shadow: 6px 6px 0 #7c68d9, 12px 12px 0 var(--shadow); margin: 10px 0 24px; }
.boot.color { background: var(--midnight); }
.boot.color .boot-text { color: var(--cream); text-shadow: none; }
.boot.color .boot-bar { border-color: var(--gold); }
.boot.color #boot-fill { background: repeating-linear-gradient(90deg, var(--gold) 0 14px, transparent 14px 18px); }
@keyframes blink { 50% { opacity: 0; } }
/* animation only while boot is showing (not after) to prevent endless blinking */
#start { font-size: 18px; }
.boot:not(.color) #start { animation: blink 1s steps(1) infinite; }
@media (prefers-reduced-motion: reduce) { #start { animation: none; } #boot-fill { transition: none; } }
.boot.color .crt { text-align: center; }
.title-art { display: flex; flex-wrap: wrap; justify-content: center; align-items: flex-end; gap: 28px; margin: 0 0 30px; }
.title-art img { image-rendering: pixelated; }
.title-art p { flex-basis: 100%; font-family: var(--px); font-size: 14px; line-height: 1.6; color: var(--ghost); margin: 8px 0 0; letter-spacing: 1px; }
.boot.color { background: var(--midnight) radial-gradient(#2a3452 2px, transparent 2px) 0 0 / 16px 16px; }

.noscript { position: fixed; inset: 0; z-index: 20; margin: 0; padding: 40px; background: var(--midnight); color: var(--cream); font-size: 26px; }

/* ---- Mobile layout: 390 px wide, no horizontal scroll ---- */
@media (max-width: 700px) {
  .top { padding: 12px; gap: 10px; }
  .grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "play" "register"; padding: 12px; gap: 14px; }
  /* Timeline and Replay first (also the DOM order now), the register below it */
  .panel { padding: 12px; box-shadow: 4px 4px 0 var(--shadow); }
  .table-wrap { max-height: none; overflow: visible; border: none; }
  /* Turn the table into stacked cards — each row is two wrapped lines with captions */
  .table-wrap table { display: block; }
  .table-wrap thead { display: none; }
  #rows { display: block; }
  #rows tr { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px 8px;
    padding: 8px 6px; border-bottom: 2px dashed #2a3452; }
  #rows td { padding: 0; border: 0; background: none !important; }
  /* Caption labels above each cell */
  #rows td[data-th]::before { content: attr(data-th); display: block; font-family: var(--px); font-size: 11px; color: var(--gold); margin-bottom: 4px; }
  /* Layout: day + description fill the first line; amount + type + alt + remove fill the second */
  #rows td.day  { flex: 0 0 56px; }
  #rows td.desc { flex: 1 1 calc(100% - 70px); min-width: 0; }
  #rows td.amt  { flex: 0 0 96px; }
  #rows td.kind { flex: 1 1 0; min-width: 112px; }
  #rows td.alt  { flex: 0 0 60px; }
  #rows td.rm   { flex: 0 0 44px; display: flex; align-items: flex-end; justify-content: center; }
  #rows td.kind select { padding: 2px 2px; }
  /* A fixed bill cannot move, so its empty MOVE TO box is hidden (the space stays so rows line up) */
  #rows tr.fixed td.alt { visibility: hidden; }
  /* The caption above the box already says CAN BE LATE */
  #rows td.alt .late-txt { display: none; }
  #rows td input, #rows td select { width: 100%; font-size: 20px; }
  #rows td.day input, #rows td.alt input { width: 100%; }
  /* restore row backgrounds that the per-cell override cleared */
  #rows tr.flexible { background: rgba(182, 164, 255, 0.08); }
  #rows tr.moved    { background: rgba(114, 224, 180, 0.18); }
  /* Score panel: single column */
  .scores { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .score { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; padding: 8px 10px; }
  .score span { font-size: 9px; }
  .score b { margin-top: 0; font-size: 16px; }
  .score b[data-long="l"] { font-size: 14px; }
  .score b[data-long="xl"] { font-size: 12px; }
  .btn-big { font-size: 13px; padding: 14px; }
  .controls { flex-wrap: wrap; }
  .verdict { font-size: 16px; line-height: 1.4; }
  .assumption-note { font-size: 20px; }
}
/* Item 6.27: under 375px the two-column tiles are narrow, so the Press Start 2P amount drops to a
   size where the longest sample amount (-$564.02, -$130.00) fits on one line without clipping.
   Placed after the 700px phone block so it wins at 320 and 360 px. */
@media (max-width: 374px) { .score b { font-size: 13px; }
  .score b[data-long="l"] { font-size: 11px; }
  .score b[data-long="xl"] { font-size: 10px; } }

.skip { position: absolute; left: 8px; top: -80px; z-index: 20; background: var(--gold); color: var(--shadow); font-family: var(--px); font-size: 12px; padding: 12px 14px; text-decoration: none; box-shadow: 4px 4px 0 var(--shadow); }
.skip:focus-visible { top: 8px; outline: 3px solid var(--cream); outline-offset: 2px; }
.chart-empty { margin: 0; padding: 60px 24px; text-align: center; color: var(--cream); font-size: 24px; }

/* ---------- IMPORT BILLS dialog ---------- */
dialog.bills { width: min(860px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto; background: var(--panel); color: var(--cream);
  border: 4px solid var(--steel); box-shadow: 8px 8px 0 var(--shadow); padding: 16px 20px; font-family: var(--vt); font-size: 22px; }
dialog.bills::backdrop { background: rgba(7, 10, 20, 0.82); }
dialog.bills h2 { margin-bottom: 10px; }
.bills-private { margin: 0 0 12px; }
.bills-status { min-height: 1.4em; margin: 8px 0; }
.bills-status.bad { color: var(--danger); }
.bill-head, .bill-row { display: grid; grid-template-columns: 34px minmax(0, 1.6fr) 120px 90px minmax(0, 1.4fr); gap: 8px; align-items: center; }
.bill-head { font-family: var(--px); font-size: 10px; color: var(--gold); padding: 0 0 6px; }
.bill-list { list-style: none; padding: 0; margin: 0 0 8px; }
.bill-row { padding: 6px 0; border-top: 2px solid var(--steel); }
.bill-row input[type="text"] { width: 100%; min-width: 0; font-size: 20px; }
.bill-row input[type="checkbox"] { width: 26px; height: 26px; }
.bill-row .conf { font-size: 20px; color: #cfd6ea; }
.bill-row.low .conf { color: var(--danger); }
.bills-actions { margin: 14px 0 0; text-align: right; }
@media (max-width: 700px) {
  .bill-head { display: none; }
  .bill-row { grid-template-columns: 34px minmax(0, 1fr) minmax(0, 1fr); }
  .bill-row input[type="text"][data-f="label"] { grid-column: 2 / -1; }
  .bill-row [data-f="amount"] { grid-column: 2; }
  .bill-row [data-f="day"] { grid-column: 3; }
  .bill-row .conf { grid-column: 2 / -1; }
}

/* row polish */
th { white-space: nowrap; }
#rows td { vertical-align: middle; }
.day-note { margin: 0 0 10px; }
.bills-pick { display: flex; gap: 10px; flex-wrap: wrap; margin: 0 0 8px; }
.day-preview:empty { display: none; }
td input, td select { vertical-align: middle; }

/* three step hint, import options, replace confirmation */
.steps { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; margin: 0 0 10px; padding: 8px 12px;
  background: var(--midnight); border: 3px dashed var(--steel); font-size: 21px; }
.steps li { display: flex; align-items: center; gap: 8px; }
.steps li b { display: inline-flex; width: 28px; height: 28px; align-items: center; justify-content: center; background: var(--gold); color: var(--shadow); font-family: var(--px); font-size: 13px; }
.steps .btn-small { margin: 0; min-height: 36px; padding: 8px 10px; }
.steps-x { margin-left: auto; }
/* Keep GOT IT clear of the sticky controls bar: any scrollIntoView or focus-driven
   scroll (Tab) leaves room for the bar below the button, so it is never parked under
   `.play .controls` on a phone (Requirement 6.56). Scroll anchoring only; the bar and
   the card are unchanged. 150px comfortably clears the bar (about 118-128px tall). */
#steps-x { scroll-margin-bottom: 150px; }
.bills-opts { border: 3px solid var(--steel); margin: 0 0 8px; padding: 8px 12px 10px; display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: center; }
.bills-opts legend { font-family: var(--px); font-size: 10px; color: var(--gold); padding: 0 6px; }
.bills-opts label { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bills-opts select { font-family: var(--vt); font-size: 20px; max-width: 100%; }
.bills-opts .hint { flex-basis: 100%; margin: 0; font-size: 20px; }
dialog.confirm { width: min(520px, calc(100vw - 24px)); }
dialog.confirm form { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
/* REPLAY stays on screen at every width while the timeline panel is in view, so it is in the first screen on a laptop too */
.play .controls { position: sticky; bottom: 0; z-index: 6; margin: 12px -18px 0; padding: 10px 18px; flex-wrap: wrap;
  background: var(--panel); border-top: 4px solid var(--steel); box-shadow: 0 -6px 0 var(--shadow); }
/* The two big buttons share the first row and never break their label; COPY SHARE LINK wraps below. */
.play .controls .btn-big { flex: 1 1 0; white-space: nowrap; justify-content: center; }
@media (max-width: 700px) {
  .steps { font-size: 20px; gap: 4px 12px; padding: 6px 8px; }
  .steps li b { width: 24px; height: 24px; font-size: 11px; }
  .play .controls { flex-wrap: wrap; gap: 10px; margin: 12px -12px 0; padding: 10px 12px; }
  .play .controls .btn-big { flex: 1 1 0; justify-content: center; padding: 12px 8px; }
}
@media (max-width: 360px) { .play .controls .btn-big { font-size: 12px; padding: 12px 6px; } }

.linkbtn { background: none; border: 0; padding: 4px 2px; margin: 0 6px; color: var(--replay); font: inherit; text-decoration: underline; cursor: pointer; min-height: 32px; }

/* COPY SHARE LINK sits in the controls row and wraps onto its own line under the big buttons */
.controls #btn-share { flex: 1 1 100%; justify-content: center; min-height: 40px; padding: 8px 12px; }
.share-live { font-family: var(--vt); font-size: 20px; color: #CFD6EA; margin: 8px 0 0; min-height: 1.2em; }
.share-field-wrap { display: block; font-family: var(--vt); font-size: 20px; color: #CFD6EA; margin: 8px 0 0; }
.share-field-wrap input { width: 100%; margin-top: 4px; box-sizing: border-box; }
.score .s-replay-day { display: block; margin-top: 6px; font-family: var(--vt); font-size: 20px; line-height: 1.15; color: #CFD6EA; overflow-wrap: anywhere; }
.linkbtn:focus-visible { outline: 4px solid var(--gold); outline-offset: 2px; }
.evidence-share { margin: 0 0 10px; }
.evidence-wrap { max-height: none; overflow-x: auto; }
.evidence-table { width: 100%; border-collapse: collapse; font-size: 20px; }
.evidence-table th, .evidence-table td { text-align: left; vertical-align: top; padding: 6px 8px; border-top: 2px solid var(--steel); }
.evidence-table th { font-family: var(--px); font-size: 10px; color: var(--gold); border-top: 0; }
.evidence-table code { font-family: var(--vt); font-size: 20px; color: var(--replay); word-break: break-word; }
@media (max-width: 700px) {
  .evidence-table thead { display: none; }
  .evidence-table, .evidence-table tbody, .evidence-table tr, .evidence-table td { display: block; width: 100%; }
  .evidence-table td:nth-child(2)::before { content: "Where: "; color: var(--gold); }
  .evidence-table td:nth-child(3)::before { content: "Test: "; color: var(--gold); }
  .evidence-table td { border-top: 0; padding: 2px 4px; }
  .evidence-table tr { border-top: 2px solid var(--steel); padding: 6px 0; }
}

/* running balance column (read only) */
td.bal { text-align: right; white-space: nowrap; padding-right: 8px; }
output.balance { font-family: var(--vt); font-size: 22px; color: var(--replay); display: inline-block; min-width: 4.6em; }
output.balance.neg { color: var(--danger); }
th.bal-h { text-align: right; line-height: 1.5; }

/* 1986 VIEW: the same register drawn as green text on black. Display only. */
.btn-view { margin-top: 0; font-size: 11px; min-height: 40px; }
.register.v1986 { background: #050806; border-color: var(--phosphor); }
.register.v1986 .table-wrap { border-color: var(--phosphor); }
.register.v1986 th { background: #050806; color: var(--phosphor); border-bottom: 2px solid var(--phosphor); }
.register.v1986 td { border-bottom: 1px dashed #2c5a36; background: none !important; }
.register.v1986 input, .register.v1986 select, .register.v1986 output.balance { background: #050806; color: var(--phosphor); font-family: var(--vt);
  font-size: 22px; border: 0; border-bottom: 1px solid #2c5a36; border-radius: 0; }
.register.v1986 tr.income td.amt input { color: var(--phosphor); }
.register.v1986 output.balance { border-bottom: 0; }
.register.v1986 output.balance.neg { color: #ff9aa4; text-shadow: 0 0 6px rgba(255, 137, 148, 0.5); }
.register.v1986 .hint, .register.v1986 .day-note, .register.v1986 label { color: var(--phosphor); }
.register.v1986 .chip { background: #050806; color: var(--phosphor); border: 2px solid var(--phosphor); }
@media (max-width: 700px) {
  #rows td.bal { flex: 0 0 auto; margin-left: auto; text-align: right; }
  #rows td.bal::before { text-align: right; }
}

/* phone header: brand on one line, the seven buttons in a three column grid, so the page starts about 160 px down */
@media (max-width: 700px) {
  .top { padding: 8px 10px; gap: 8px; }
  .brand { gap: 10px; }
  .brand img { width: 36px; height: 36px; }
  .title { font-size: 18px; }
  .tag { display: none; }
  .tools { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: 100%; }
  .tools .btn { font-size: 9px; padding: 6px 4px; min-height: 40px; min-width: 0; justify-content: center; text-align: center; gap: 4px; line-height: 1.3; }
  .tools .btn img { width: 14px; height: 14px; }
}

/* desktop register: six columns have to fit the panel without sideways scrolling */
@media (min-width: 701px) {
  .grid { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.2fr); }
  #rows td, thead th { padding-left: 3px; padding-right: 3px; }
  td.day input, td.alt input { width: 46px; padding: 2px 3px; }
  td.amt input { width: 92px; padding: 2px 4px; }
  td.desc input { min-width: 70px; padding: 2px 4px; }
  td.kind { min-width: 98px; }
  td.kind select { padding: 2px 0; font-size: 20px; width: 100%; }
  td.desc { min-width: 92px; }
  output.balance { font-size: 20px; min-width: 4.4em; }
  .del { min-width: 36px; padding: 6px 2px; }
}
@media (min-width: 701px) and (max-width: 1259px) { .grid { grid-template-columns: minmax(0, 1fr); } .grid > .play { order: -1; } }

/* Daily balance table: the text version of the chart */
.daily { margin: 4px 0 12px; }
.daily summary { font-family: var(--px); font-size: 11px; color: var(--gold); cursor: pointer; padding: 10px 0; min-height: 44px; }
.daily-wrap { max-height: 360px; overflow: auto; border: 2px solid var(--shadow); }
#daily-table caption { text-align: left; padding: 6px; color: #cfd6ea; font-size: 20px; }
#daily-table th, #daily-table td { padding: 3px 8px; text-align: right; white-space: nowrap; }
#daily-table th:first-child, #daily-table td:first-child { text-align: left; }
#daily-table td.neg { color: var(--danger); }
/* Per-paycheck Ghost Mode switch in the register */
td.alt label.late { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; min-height: 44px; }
td.alt input[type="checkbox"], #rows td.alt input[type="checkbox"] { width: 24px; height: 24px; accent-color: var(--replay); }
.build { color: #cfd6ea; }
#daily-table tbody th { position: static; background: none; font-family: var(--vt); font-size: 22px; color: var(--cream); }
#daily-table thead th { white-space: normal; vertical-align: bottom; }
.nowrap { white-space: nowrap; }
td.alt .late-txt { font-size: 17px; line-height: 0.95; max-width: 4.2em; }
.sample-list { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 10px; }
.sample-list li { display: grid; grid-template-columns: minmax(0, 16em) minmax(0, 1fr); gap: 4px 12px; align-items: center; }
.sample-list .btn { text-align: left; line-height: 1.5; }
.sample-list span { font-size: 20px; }
dialog.samples { width: min(760px, calc(100vw - 24px)); }
@media (max-width: 700px) { .sample-list li { grid-template-columns: minmax(0, 1fr); } }
