:root {
  --ink: #25302a;
  --cream: #f2e6cc;
  --paper: #fffaf0;
  --red: #d84a3b;
  --blue: #1d6f83;
  --yellow: #efbc3b;
  --green: #4c765f;
  --line: rgba(49, 54, 45, .2);
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 13% 20%, rgba(255,255,255,.34) 0 2px, transparent 3px),
    repeating-linear-gradient(102deg, rgba(82,62,34,.035) 0 1px, transparent 1px 7px),
    #d9b77d;
  font-family: "Courier New", ui-monospace, monospace;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 140px rgba(75, 45, 15, .2);
}

button { font: inherit; color: inherit; }
button:not(:disabled) { cursor: pointer; }

.desk { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 36px; }
.masthead { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid var(--ink); padding-bottom: 12px; }
.kicker { margin: 0 0 3px; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; }
h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(42px, 7vw, 74px); line-height: .8; letter-spacing: -.065em; }
h1 span { color: var(--red); }
.sound { border: 1px solid var(--ink); background: transparent; border-radius: 99px; padding: 8px 13px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.sound:hover { background: var(--ink); color: var(--cream); }

.score-strip { display: grid; grid-template-columns: repeat(5, 1fr); border-bottom: 1px solid rgba(37,48,42,.4); }
.score-strip > div { padding: 11px 16px 9px; border-right: 1px solid rgba(37,48,42,.25); }
.score-strip > div:first-child { padding-left: 0; }
.score-strip > div:last-child { border-right: 0; text-align: right; padding-right: 0; }
.score-strip small { display: block; font-size: 8px; letter-spacing: .14em; text-transform: uppercase; opacity: .62; }
.score-strip strong { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 24px; line-height: 1; }
.score-strip .urgent strong { color: var(--red); animation: blink .55s steps(2) infinite; }
.brief { margin: 11px 0; min-height: 20px; font-size: 12px; text-align: center; }
.brief[data-tone="good"] { color: #285e42; font-weight: 700; }
.brief[data-tone="bad"], .brief[data-tone="warn"] { color: #a42922; font-weight: 700; }

.workbench { display: grid; grid-template-columns: minmax(250px, .72fr) minmax(430px, 1.28fr); gap: clamp(24px, 5vw, 72px); align-items: center; min-height: 540px; }
.order-card { position: relative; justify-self: center; width: min(100%, 360px); padding: 35px 34px 25px; background: #f7edda; box-shadow: 4px 7px 0 rgba(79,52,24,.14), 0 16px 36px rgba(72,48,22,.16); transform: rotate(-1.2deg); }
.order-card::after { content: ""; position: absolute; inset: 0; pointer-events: none; border: 1px solid rgba(37,48,42,.12); }
.clip { position: absolute; z-index: 2; top: -9px; left: 50%; width: 86px; height: 25px; transform: translateX(-50%); background: #79817a; border-radius: 4px 4px 9px 9px; box-shadow: inset 0 5px 4px rgba(255,255,255,.32), 0 3px 4px rgba(0,0,0,.24); }
.label { margin: 0 0 18px; color: var(--red); font-weight: 700; font-size: 11px; letter-spacing: .2em; text-align: center; }
.paper { display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr); background: var(--paper); }
.target { width: 100%; aspect-ratio: 1; border: 1px solid rgba(37,48,42,.45); }
.cell { position: relative; min-width: 0; min-height: 0; padding: 0; border: 0; border-right: 1px dotted var(--line); border-bottom: 1px dotted var(--line); background: transparent; }
.cell:nth-child(8n) { border-right: 0; }
.cell.hole::after { content: ""; position: absolute; width: 46%; aspect-ratio: 1; top: 50%; left: 50%; border-radius: 50%; transform: translate(-50%, -50%); background: var(--ink); box-shadow: inset 1px 1px 2px #000; }
.target .cell { cursor: default; }
.target.reveal.right { animation: success .48s ease; box-shadow: 0 0 0 8px rgba(76,118,95,.15); }
.target.reveal.wrong { animation: shake .34s ease; }
.target .cell.missing { background: rgba(216,74,59,.18); }
.target .cell.missing::after { background: transparent; border: 2px dashed var(--red); box-shadow: none; }
.target .cell.extra { background: rgba(216,74,59,.4); }
.allowance { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 12px; border-top: 2px solid var(--ink); text-transform: uppercase; font-size: 10px; }
.allowance b { color: var(--red); font-family: Georgia, "Times New Roman", serif; font-size: 18px; }
.order-no { margin: 17px 0 0; font-size: 8px; letter-spacing: .15em; opacity: .55; text-align: right; }

.work-area { display: grid; justify-items: center; grid-template-columns: 1fr; align-items: center; }
.work-row { display: grid; grid-template-columns: 72px minmax(270px, 430px) 72px; align-items: center; width: 100%; justify-content: center; }
.paper-wrap { position: relative; width: min(43vw, 430px); aspect-ratio: 1; display: grid; place-items: center; }
.paper-shadow { position: absolute; z-index: -1; inset: 7%; background: rgba(73,47,18,.2); filter: blur(16px); }
.working { position: relative; width: 100%; height: 100%; border: 1px solid rgba(37,48,42,.35); box-shadow: 3px 4px 0 #dfd2b7, 6px 8px 0 #cbbd9e; transition: width .28s ease, height .28s ease; }
.working[style*="--cols: 4"] { width: 52%; }
.working[style*="--cols: 2"] { width: 28%; }
.working[style*="--cols: 1"] { width: 15%; }
.working[style*="--rows: 4"] { height: 52%; }
.working[style*="--rows: 2"] { height: 28%; }
.working[style*="--rows: 1"] { height: 15%; }
.working .cell { background: rgba(255,250,240, calc(.77 + var(--layers) * .23)); transition: background .15s; }
.working .cell:not(:disabled):hover { background: #f4cf6e; box-shadow: inset 0 0 0 2px var(--ink); }
.working .cell.hole::after { width: min(46%, 34px); background: #57351c; box-shadow: inset 2px 3px 3px #1f140a, 0 0 0 3px rgba(37,48,42,.16); }
.working.folding { animation: fold-pop .3s ease; }
.working.punching { animation: punch .22s ease; }

.fold-control button { border: 0; background: transparent; font-weight: 700; font-size: 27px; opacity: .75; transition: transform .14s, opacity .14s; }
.fold-control button span { font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }
.fold-control button:not(:disabled):hover { color: var(--red); opacity: 1; transform: scale(1.08); }
.fold-control button:disabled { opacity: .18; }
.fold-control.top, .fold-control.bottom { height: 48px; }
.fold-control.top button, .fold-control.bottom button { display: flex; gap: 8px; align-items: center; flex-direction: column; line-height: .55; }
.fold-control.bottom button { flex-direction: column-reverse; }
.fold-control.side button { display: flex; align-items: center; gap: 7px; line-height: 1; text-align: center; }
.fold-control.side:last-child { justify-self: end; }
.sheet-note { margin: 10px 0 0; font-size: 9px; letter-spacing: .08em; text-transform: uppercase; opacity: .65; }

.actions { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.actions button, .primary { min-height: 44px; border: 2px solid var(--ink); padding: 10px 18px; text-transform: uppercase; letter-spacing: .08em; font-size: 10px; font-weight: 700; box-shadow: 3px 3px 0 var(--ink); }
.actions button:active:not(:disabled), .primary:active { transform: translate(3px, 3px); box-shadow: none; }
.actions button:disabled { opacity: .28; box-shadow: none; cursor: not-allowed; }
.utility { background: var(--cream); }
.primary { background: var(--red); color: white; }
.danger { color: #9c2e27; }
.keyboard-tip { margin: 19px 0 0; text-align: center; font-size: 9px; opacity: .6; }
kbd { border: 1px solid currentColor; border-radius: 3px; padding: 1px 4px; }

.overlay { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(45,33,19,.64); backdrop-filter: blur(5px); }
.overlay[hidden] { display: none; }
.intro { position: relative; width: min(530px, 100%); padding: clamp(30px, 6vw, 58px); background: var(--paper); box-shadow: 10px 12px 0 rgba(37,48,42,.7); transform: rotate(.5deg); }
.intro::before { content: ""; position: absolute; inset: 11px; border: 1px solid rgba(37,48,42,.18); pointer-events: none; }
.intro h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(40px, 8vw, 64px); line-height: .9; letter-spacing: -.04em; }
.intro p, .intro li { font-size: 12px; line-height: 1.65; }
.intro ol { padding-left: 20px; }
.stamp { position: absolute; right: 24px; top: 25px; margin: 0; padding: 6px 9px; border: 3px double var(--red); color: var(--red); font-weight: 700; letter-spacing: .12em; transform: rotate(8deg); }
.start { position: relative; margin-top: 8px; width: 100%; }
.final-score { margin: 22px 0 0 !important; color: var(--red); font-family: Georgia, "Times New Roman", serif; font-size: 38px !important; font-weight: 900; }
.final-score small { color: var(--ink); font: 10px "Courier New", monospace; text-transform: uppercase; }

@keyframes fold-pop { 50% { transform: scale(.95); } }
@keyframes punch { 45% { transform: scale(.98) rotate(-.4deg); } }
@keyframes success { 50% { transform: rotate(1deg) scale(1.025); } }
@keyframes shake { 25% { transform: translateX(-7px); } 65% { transform: translateX(6px); } }
@keyframes blink { 50% { opacity: .35; } }

@media (max-width: 760px) {
  .desk { width: min(100% - 20px, 580px); padding-top: 18px; }
  .score-strip { grid-template-columns: repeat(5, 1fr); }
  .score-strip > div { padding: 9px 5px; }
  .score-strip strong { font-size: 17px; }
  .workbench { grid-template-columns: 1fr 1.15fr; gap: 12px; min-height: 430px; }
  .order-card { padding: 27px 18px 16px; }
  .work-row { grid-template-columns: 38px minmax(190px, 1fr) 38px; }
  .paper-wrap { width: min(51vw, 360px); }
  .fold-control button { font-size: 21px; padding: 2px; }
  .fold-control button span { display: none; }
  .keyboard-tip { display: none; }
}

@media (max-width: 540px) {
  .masthead { align-items: center; }
  .kicker { display: none; }
  h1 { font-size: 38px; }
  .workbench { grid-template-columns: .68fr 1.32fr; min-height: 380px; }
  .order-card { padding: 24px 10px 12px; }
  .label { font-size: 8px; margin-bottom: 9px; }
  .allowance { display: block; font-size: 8px; margin-top: 9px; padding-top: 7px; }
  .allowance span { display: block; }
  .allowance b { font-size: 14px; }
  .order-no, .clip { display: none; }
  .work-row { grid-template-columns: 24px minmax(154px, 1fr) 24px; }
  .paper-wrap { width: min(53vw, 290px); }
  .actions { margin-top: 2px; gap: 7px; }
  .actions button { padding: 8px 9px; font-size: 8px; min-height: 39px; }
  .brief { font-size: 10px; margin: 8px 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
