/* Clockwork Spins | slate charcoal, warm bronze and crimson */
:root {
  --slate-900: #14161a;
  --slate-800: #1c1f24;
  --slate-700: #2a2e35;
  --slate-600: #3a3f48;
  --slate-400: #6b7280;
  --bronze-200: #f0c48a;
  --bronze-400: #d9a066;
  --bronze-500: #b07a3c;
  --bronze-700: #6e4518;
  --brass: #c9a24a;
  --crimson: #c81e2c;
  --crimson-dark: #7a0d18;
  --parchment: #efe3cc;
  --ink: #1b1408;
  --slab: Rockwell, "Roboto Slab", "Rockwell Nova", "Courier New", serif;
  --mono: "Courier New", "Lucida Console", Consolas, monospace;
  --body: Georgia, "Times New Roman", serif;
  --rivet: radial-gradient(circle at 35% 30%, #f5dcae, #8a6a3a 60%, #3d2a10);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--parchment); font: 16px/1.5 var(--body);
  background-color: var(--slate-800);
  background-image:
    linear-gradient(rgba(255, 255, 255, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .025) 1px, transparent 1px),
    radial-gradient(ellipse at 50% 0%, #343943, var(--slate-900) 75%);
  background-size: 28px 28px, 28px 28px, 100% 100%;
  background-attachment: fixed;
}
body:has(dialog[open]) { overflow: hidden; }
[hidden] { display: none !important; }
h1, h2, h3, caption { font-family: var(--slab); margin: 0; }
p { margin: 0 0 .75em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.foundry { position: absolute; width: 0; height: 0; overflow: hidden; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.no-js { margin: 0; padding: 16px; background: var(--parchment); color: var(--ink); text-align: center; }

.shopfloor { max-width: 980px; margin: 0 auto; padding: 0 14px 26px; }
.shopfloor.is-sealed { filter: blur(12px) grayscale(.6); pointer-events: none; }

/* Riveted buttons */
.stud {
  padding: 8px 14px; border-radius: 4px; border: 1px solid #0b0c0e;
  background: linear-gradient(180deg, var(--slate-600), var(--slate-700));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 2px 0 #0b0c0e;
  font-family: var(--slab); font-size: .85rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--parchment);
}
.stud:hover:not(:disabled) { background: linear-gradient(180deg, #4a505b, var(--slate-600)); }
.stud:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18); }
.stud[aria-pressed="true"] { background: linear-gradient(180deg, var(--bronze-400), var(--bronze-500)); color: var(--ink); }
.stud-square { width: 38px; height: 38px; padding: 0; font-size: 1.15rem; line-height: 1; }
.stud-safe, .stud-go { background: linear-gradient(180deg, var(--bronze-400), var(--bronze-500)); color: var(--ink); }
.stud-safe:hover:not(:disabled), .stud-go:hover:not(:disabled) { background: linear-gradient(180deg, var(--bronze-200), var(--bronze-400)); }
.stud-danger { background: linear-gradient(180deg, #e0333f, var(--crimson-dark)); color: #fff; }
.stud-refill { background: linear-gradient(180deg, #fbe7a6, var(--brass)); color: var(--ink); animation: ic-throb 1.3s ease-in-out infinite; }
@keyframes ic-throb { 50% { box-shadow: 0 0 0 4px rgba(201, 162, 74, .4), 0 2px 0 #0b0c0e; } }
.stamp-18 { display: inline-block; padding: 4px 8px; border: 2px solid var(--crimson); border-radius: 4px; color: #ff8a8a; font: 700 .85rem var(--slab); transform: rotate(-6deg); }

/* Masthead */
.masthead { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; }
.marque { display: flex; align-items: center; gap: 10px; min-width: 0; }
.marque-cog { width: 44px; height: 44px; flex: none; animation: ic-turn 24s linear infinite; }
@keyframes ic-turn { to { transform: rotate(360deg); } }
.marque-name { font: 700 1.45rem var(--slab); letter-spacing: .12em; white-space: nowrap; color: var(--bronze-200); text-shadow: 0 2px 0 #000; }
.marque-name b { color: #ff5a5f; }
.dials { display: flex; align-items: center; gap: 8px; }
.dial { display: grid; justify-items: center; padding: 2px 12px 3px; border-radius: 4px; background: #0b0c0e; border: 2px solid var(--bronze-500); line-height: 1.15; }
.dial-cap { font: 700 .56rem var(--slab); letter-spacing: .2em; text-transform: uppercase; color: var(--bronze-400); }
.dial-num { font: 700 1.1rem var(--mono); color: #ffe9b8; }

/* Disclaimer */
.hazard {
  padding: 6px; border-radius: 4px;
  background: repeating-linear-gradient(-45deg, #e7b93a 0 14px, #1b1408 14px 28px);
}
.hazard p { margin: 0; padding: 8px 14px; background: var(--parchment); color: var(--ink); font: .82rem/1.4 var(--body); border-radius: 2px; }
.hazard strong { font-family: var(--slab); color: var(--crimson-dark); }

/* Machine */
main { padding-top: 14px; }
.machine {
  --w: min(100%, 860px, max(320px, calc((100vh - 400px) * 2.1)));
  position: relative; width: var(--w); margin: 0 auto; padding: 16px;
  display: grid; grid-template-columns: minmax(0, 1fr) 96px; gap: 12px 16px;
  grid-template-areas: "gauges lever" "window lever" "plate lever" "bench lever" "tally tally";
  border-radius: 10px; border: 3px solid #0b0c0e;
  background: linear-gradient(160deg, #464c57, var(--slate-700) 40%, #23262c);
  box-shadow: inset 0 0 0 3px var(--bronze-700), inset 0 0 0 5px #0b0c0e, 0 20px 50px rgba(0, 0, 0, .6);
}
.machine::before, .machine::after { content: ""; position: absolute; top: 9px; width: 9px; height: 9px; border-radius: 50%; background: var(--rivet); }
.machine::before { left: 9px; }
.machine::after { right: 9px; }
.machine[inert] { display: none; }

.gauges { grid-area: gauges; display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 10px; }
.gauge { display: grid; justify-items: center; padding: 5px 8px 6px; border-radius: 4px; background: #0b0c0e; border: 2px solid var(--bronze-500); box-shadow: inset 0 0 14px rgba(0, 0, 0, .9); min-width: 0; }
.gauge-cap { font: 700 .6rem var(--slab); letter-spacing: .16em; text-transform: uppercase; color: var(--bronze-400); white-space: nowrap; }
.gauge-num { font: 700 1.55rem/1.15 var(--mono); color: #ffe9b8; letter-spacing: .04em; }
.gauge-win .gauge-num { color: #ff7b80; }

.window { grid-area: window; position: relative; padding: 8px; border-radius: 6px; background: #0b0c0e; border: 3px solid var(--bronze-500); box-shadow: inset 0 0 0 2px #0b0c0e; }
.drum { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 5px; }
.spool { position: relative; aspect-ratio: 10 / 27; overflow: hidden; border-radius: 3px; background: linear-gradient(180deg, #8f8672 0%, #efe3cc 22%, #fbf3e0 50%, #efe3cc 78%, #8f8672 100%); }
.spool::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 14px 14px -8px rgba(0, 0, 0, .75), inset 0 -14px 14px -8px rgba(0, 0, 0, .75); }
.belt { position: absolute; left: 0; top: 0; width: 100%; height: 100%; display: flex; flex-direction: column; }
.tile { flex: 1 1 0; min-height: 0; padding: 8% 10%; display: grid; place-items: center; border-bottom: 1px solid rgba(27, 20, 8, .18); }
.tile svg { width: 100%; height: 100%; filter: drop-shadow(0 2px 1px rgba(0, 0, 0, .45)); }
.spool.is-running .belt { filter: blur(2px); }
.spool.is-clunk { animation: ic-clunk .22s ease-out; }
@keyframes ic-clunk { 40% { transform: translateY(4px); } }
.drum.has-hits .tile { opacity: .35; }
.drum.has-hits .tile.is-hit { opacity: 1; background: rgba(200, 30, 44, .16); box-shadow: inset 0 0 0 3px var(--crimson); animation: ic-stamp .7s steps(2, jump-none) infinite; }
@keyframes ic-stamp { 50% { box-shadow: inset 0 0 0 3px var(--brass); } }
.wires { position: absolute; inset: 8px; width: calc(100% - 16px); height: calc(100% - 16px); pointer-events: none; }
.wires polyline { fill: none; stroke-width: 5; stroke-linejoin: miter; vector-effect: non-scaling-stroke; opacity: .9; }

.plate { grid-area: plate; margin: 0; min-height: 3em; display: grid; place-items: center; text-align: center; padding: 6px 12px; border-radius: 3px; color: var(--ink); font: 700 .95rem/1.35 var(--slab); background: linear-gradient(180deg, var(--bronze-200), var(--bronze-400)); border: 1px solid #0b0c0e; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5); }
.plate.is-win { background: linear-gradient(180deg, #fff0b0, #e0b040); }
.plate.is-stop { background: linear-gradient(180deg, #ffb3b3, #e0666e); }

.lever { grid-area: lever; position: relative; align-self: stretch; min-height: 260px; padding: 0; border: 0; background: none; }
.lever-base { position: absolute; left: 50%; bottom: 0; width: 70px; height: 54px; transform: translateX(-50%); border-radius: 6px; background: linear-gradient(180deg, var(--slate-600), #17191d); border: 2px solid #0b0c0e; box-shadow: inset 0 0 0 2px var(--bronze-700); }
.lever-rod { position: absolute; left: 50%; bottom: 40px; width: 12px; height: calc(100% - 110px); transform: translateX(-50%); transform-origin: 50% 100%; border-radius: 6px; background: linear-gradient(90deg, #6b7280, #e5e7eb 45%, #4b5563); border: 1px solid #0b0c0e; transition: height .18s ease-in; }
.lever-knob { position: absolute; left: 50%; top: 0; width: 84px; height: 84px; transform: translateX(-50%); display: grid; place-items: center; border-radius: 50%; color: #fff; font: 700 1.05rem var(--slab); letter-spacing: .1em; text-shadow: 0 2px 0 rgba(0, 0, 0, .5); background: radial-gradient(circle at 35% 28%, #ff8a8a, var(--crimson) 55%, var(--crimson-dark)); border: 3px solid #0b0c0e; box-shadow: inset 0 -6px 10px rgba(0, 0, 0, .35), 0 6px 12px rgba(0, 0, 0, .5); transition: top .18s ease-in; }
.lever:hover:not(:disabled) .lever-knob { filter: brightness(1.12); }
.lever.is-pulled .lever-knob { top: calc(100% - 170px); }
.lever.is-pulled .lever-rod { height: 60px; }

.bench { grid-area: bench; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.bench-group { display: flex; align-items: center; gap: 6px; }
.bench-readout { min-width: 5.2em; text-align: center; padding: 6px 8px; border-radius: 4px; background: #0b0c0e; border: 1px solid var(--bronze-700); font: 700 .95rem var(--mono); color: #ffe9b8; }
.switch { display: inline-flex; align-items: center; gap: 8px; font: 700 .78rem var(--slab); letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch-track { position: relative; width: 44px; height: 22px; border-radius: 11px; background: #0b0c0e; border: 1px solid var(--bronze-700); }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--rivet); transition: left .15s; }
.switch input:checked + .switch-track { background: var(--crimson-dark); }
.switch input:checked + .switch-track::after { left: 24px; }
.switch input:focus-visible + .switch-track { outline: 3px solid #fff; outline-offset: 2px; }

.tally { grid-area: tally; list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tally li { padding: 3px 9px; border-radius: 3px; background: #0b0c0e; border-left: 5px solid var(--wire, var(--brass)); font: .8rem var(--mono); color: #ffe9b8; }
.machine.is-jackpot { animation: ic-shake .4s linear 3; }
@keyframes ic-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

.lockout { max-width: 560px; margin: 0 auto; padding: 30px 20px; text-align: center; border-radius: 10px; border: 3px solid var(--bronze-500); background: var(--slate-700); }
.lockout h2 { margin-bottom: 10px; color: var(--bronze-200); }
.lockout-clock { font: 700 2rem var(--mono); color: #ff7b80; }

.rail { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }

/* Footer */
.baseplate { margin-top: 26px; padding: 18px; border-top: 4px double var(--bronze-500); font-size: .88rem; }
.baseplate-row { display: grid; grid-template-columns: 1.15fr 1fr; gap: 28px; }
.baseplate h2 { font-size: .95rem; letter-spacing: .1em; text-transform: uppercase; color: var(--bronze-200); margin-bottom: 8px; }
.imprint { border-collapse: collapse; width: 100%; }
.imprint th, .imprint td { text-align: left; vertical-align: top; padding: 3px 0; font-weight: 400; }
.imprint th { padding-right: 14px; white-space: nowrap; color: var(--bronze-400); font-family: var(--slab); font-size: .82em; }
.imprint td { overflow-wrap: anywhere; }
.baseplate-fine { margin: 16px 0 0; font-size: .78rem; color: #b9b2a2; }

/* Dialog "manuals" */
.book { border: 0; padding: 0; background: none; color: var(--ink); width: min(740px, calc(100vw - 20px)); max-width: none; max-height: none; overflow: visible; }
.book::backdrop { background: rgba(10, 11, 13, .88); }
.book-entry::backdrop { background: repeating-linear-gradient(-45deg, rgba(231, 185, 58, .08) 0 20px, transparent 20px 40px), rgba(10, 11, 13, .98); }
.page { display: flex; flex-direction: column; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow: hidden; border-radius: 6px; background: var(--parchment); border: 3px solid #0b0c0e; box-shadow: 0 0 0 3px var(--bronze-500), 0 26px 70px rgba(0, 0, 0, .8); }
.page-slim, .page-entry { max-width: 500px; margin: 0 auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px; color: var(--parchment); background: linear-gradient(180deg, var(--slate-600), var(--slate-800)); border-bottom: 3px solid var(--bronze-500); }
.page-head h2 { font-size: 1.15rem; letter-spacing: .08em; text-transform: uppercase; }
.page-body { padding: 16px 18px 20px; overflow-y: auto; overscroll-behavior: contain; }
.page-body h3 { font-size: 1rem; margin: 1.3em 0 .45em; color: var(--crimson-dark); letter-spacing: .03em; }
.page-body ul, .page-body ol { margin: 0 0 .8em; padding-left: 1.4em; }
.page-body li { margin-bottom: .3em; }
.page-lede { font-style: italic; }
.legal { font-size: .93rem; }
.book .stud:not(.stud-go):not(.stud-danger):not([aria-pressed="true"]) { color: var(--parchment); }
.book :focus-visible { outline-color: var(--crimson); }
code { font: .86em var(--mono); background: rgba(27, 20, 8, .08); padding: 0 3px; border-radius: 2px; overflow-wrap: anywhere; }

.page-entry { padding: 26px 22px 20px; text-align: center; overflow-y: auto; }
.entry-mark { display: inline-block; margin: 0 0 12px; padding: 6px 16px; border: 4px solid var(--crimson); border-radius: 6px; color: var(--crimson); font: 700 1.9rem var(--slab); transform: rotate(-5deg); }
.page-entry h2 { font-size: 1.5rem; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 10px; }
.entry-buttons { display: grid; gap: 10px; margin: 16px 0 12px; }
.entry-buttons .stud { padding: 13px 14px; font-size: .92rem; }
.entry-small { margin: 0; font-size: .8rem; color: #5b5142; }

.ledger { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
.ledger th, .ledger td { padding: 6px 8px; border: 1px solid rgba(27, 20, 8, .3); text-align: right; font-family: var(--mono); }
.ledger thead th { background: var(--slate-700); color: var(--parchment); font: 700 .8rem var(--slab); letter-spacing: .08em; }
.ledger th:first-child, .ledger td:first-child { text-align: left; }
.ledger tbody tr:nth-child(odd) { background: rgba(27, 20, 8, .05); }
.ledger td:last-child { font-weight: 700; color: var(--crimson-dark); }
.ledger.keys td { text-align: left; font-family: var(--body); color: var(--ink); font-weight: 400; vertical-align: top; }
.ledger.keys ul { margin: 0; padding-left: 1.1em; }
.sym-cell { display: flex; align-items: center; gap: 10px; font: 700 .9rem var(--slab); }
.sym-cell svg { width: 42px; height: 42px; flex: none; }
.sym-cell small { display: block; font: 400 .74rem var(--body); color: #5b5142; }
.linecards { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.linecards figure { margin: 0; text-align: center; font: 700 .74rem var(--slab); }
.linecards svg { display: block; width: 100%; height: auto; margin-bottom: 3px; }

.shiftlog { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.shiftlog caption { text-align: left; font-size: 1rem; color: var(--crimson-dark); margin-bottom: 6px; }
.shiftlog th, .shiftlog td { padding: 5px 8px; border-bottom: 1px dashed rgba(27, 20, 8, .4); }
.shiftlog th { text-align: left; font-weight: 400; }
.shiftlog td { text-align: right; font: 700 1rem var(--mono); }
.tool { padding: 2px 14px 12px; margin-bottom: 12px; border: 1px solid rgba(27, 20, 8, .35); border-left: 6px solid var(--bronze-500); border-radius: 3px; background: rgba(255, 255, 255, .35); }
.tool h3 { margin-top: .8em; }
.tool p { font-size: .92rem; }
.segments { display: flex; flex-wrap: wrap; gap: 6px; }
.limit-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.limit-form label { font-size: .88rem; }
.limit-form input[type="number"], .limit-form select { padding: 8px 10px; border-radius: 3px; border: 2px solid var(--slate-600); background: #fffaf0; color: var(--ink); font-family: var(--mono); width: 10em; }
.tick { display: inline-flex; align-items: center; gap: 6px; flex-basis: 100%; }
.tick input { width: 18px; height: 18px; accent-color: var(--crimson); }
.tool-msg { margin: 10px 0 0; min-height: 1.3em; font: 700 .86rem var(--slab); color: #2f5d1f; }
.tool-msg.is-bad { color: var(--crimson-dark); }
.confirm { padding: 12px; border: 2px solid var(--crimson); border-radius: 3px; background: rgba(200, 30, 44, .08); }
.helplines { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: .8em; }
.helplines th, .helplines td { padding: 5px 6px; border-bottom: 1px solid rgba(27, 20, 8, .2); text-align: left; vertical-align: top; }
.helplines th { font-family: var(--slab); font-size: .82rem; }
.helplines td:last-child { font: 700 .92rem var(--mono); white-space: nowrap; }

.gone { min-height: 100vh; display: grid; place-content: center; gap: 8px; padding: 24px; text-align: center; }

/* Responsive */
@media (max-width: 720px) {
  .machine { grid-template-columns: minmax(0, 1fr); grid-template-areas: "gauges" "window" "plate" "lever" "bench" "tally"; padding: 12px; gap: 9px; }
  .lever { min-height: 0; height: 58px; }
  .lever-rod, .lever-base { display: none; }
  .lever-knob { position: static; transform: none; width: 100%; height: 100%; border-radius: 6px; font-size: 1.3rem; letter-spacing: .3em; transition: transform .1s; }
  .lever.is-pulled .lever-knob { transform: translateY(3px); }
  .baseplate-row { grid-template-columns: 1fr; gap: 16px; }
  .bench { justify-content: center; }
}
@media (max-width: 600px) {
  .shopfloor { padding: 0 8px 20px; }
  .masthead { padding: 6px 0; gap: 6px; }
  .marque-cog { width: 30px; height: 30px; }
  .marque-name { font-size: .92rem; letter-spacing: .04em; }
  .dials { gap: 5px; }
  .dials .stamp-18 { display: none; }
  .dials .stud { padding: 7px 8px; font-size: .68rem; letter-spacing: .02em; }
  .dial { padding: 1px 7px 2px; }
  .dial-num { font-size: .95rem; }
  .hazard { padding: 4px; }
  .hazard p { padding: 5px 8px; font-size: .68rem; line-height: 1.3; }
  main { padding-top: 8px; }
  .machine { padding: 10px 8px; }
  .gauges { gap: 5px; }
  .gauge { padding: 3px 4px; }
  .gauge-cap { font-size: .5rem; letter-spacing: .06em; }
  .gauge-num { font-size: 1.15rem; }
  .window { padding: 4px; border-width: 2px; }
  .drum { gap: 3px; }
  .wires { inset: 4px; width: calc(100% - 8px); height: calc(100% - 8px); }
  .plate { font-size: .82rem; min-height: 2.8em; }
  .rail .stud { font-size: .72rem; padding: 7px 10px; }
  .page-body { padding: 12px; }
  .ledger th, .ledger td { padding: 5px; font-size: .86rem; }
  .sym-cell svg { width: 32px; height: 32px; }
  .helplines { font-size: .8rem; }
  .helplines th, .helplines td { padding: 4px 3px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
