/* Full Lock games: Parts Rush and the /play/ hub. Cream paper, ink lines, racing red.
   Loaded after /styles.css and /sketch.css; everything is scoped to .pr- classes. */

.pr-body {
  --pr-paper: #f6f1e6;
  --pr-card: #fbf8f1;
  --pr-ink: #24211c;
  --pr-wash: #ebe3d1;
  --pr-red: #d7141c;
  --pr-red-ink: #b3121a;
  --pr-muted: #5d564a;
  --pr-wobble: 22px 30px 24px 34px / 30px 22px 34px 24px;
  background: var(--pr-paper);
  color: var(--pr-ink);
}
.pr-main { background: var(--pr-paper); color: var(--pr-ink); }
.pr-main .eyebrow { color: var(--pr-red-ink); }
.pr-main .eyebrow a { color: inherit; text-decoration: none; }
.pr-main .eyebrow a:hover { text-decoration: underline; }
.pr-narrow { max-width: 640px; }
.pr-title { display: inline-block; margin: 0 0 12px; transform: rotate(-0.8deg); transform-origin: left; }
.pr-title::after {
  content: ""; display: block; width: 104%; height: 10px; margin-top: 4px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='12' viewBox='0 0 240 12' preserveAspectRatio='none'%3E%3Cpath d='M2 8 C 30 3, 60 10, 90 6 S 150 2, 180 7 S 225 9, 238 4' fill='none' stroke='%23d7141c' stroke-width='3.2' stroke-linecap='round'/%3E%3C/svg%3E") left center / 100% 100% no-repeat;
}
.pr-pitch { font-size: 1.1rem; max-width: 36em; }
.pr-h { font: 700 italic 1.35rem/1.1 var(--font-display); text-transform: uppercase; letter-spacing: 0.01em; margin: 0 0 8px; }
.pr-small { font-size: 0.88rem; color: var(--pr-muted); }
.pr-link-btn {
  background: none; border: 0; padding: 4px 2px; min-height: 32px; font: inherit; color: var(--pr-red-ink);
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.pr-main .btn-outline { color: var(--pr-ink); border-color: var(--pr-ink); background: transparent; }
.pr-main .btn-outline:hover { background: var(--pr-ink); color: var(--pr-card); }
.pr-main .btn { border-radius: var(--pr-wobble); }

/* ---------- start screen ---------- */
.pr-screen[hidden] { display: none !important; }
.pr-start, .pr-finish { padding: 28px 0 48px; }
.pr-how { border: 2px dashed var(--pr-ink); border-radius: var(--pr-wobble); padding: 14px 16px 4px; margin: 18px 0; background: var(--pr-card); }
.pr-how p { margin-bottom: 10px; }
.pr-keys { font-size: 0.9rem; color: var(--pr-muted); }
.pr-style { border: 0; padding: 0; margin: 18px 0; }
.pr-style legend { padding: 0; }
.pr-style label {
  display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; margin: 0 0 8px; min-height: 48px;
  border: 1.5px solid var(--pr-ink); border-radius: var(--pr-wobble); background: var(--pr-card); cursor: pointer;
}
.pr-style label:has(input:checked) { box-shadow: 3px 3px 0 var(--pr-red); border-width: 2.5px; }
.pr-style input { accent-color: var(--pr-red); width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.pr-style b { display: block; font: 700 italic 1.15rem/1.1 var(--font-display); text-transform: uppercase; }
.pr-go { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 8px; }
.pr-go .btn { flex: 1 1 140px; }
.pr-today { min-height: 1.5em; }
.pr-bests { margin: 22px 0; }
.pr-bests dl { display: grid; grid-template-columns: 1fr auto; gap: 0; margin: 0; }
.pr-bests dt, .pr-bests dd { margin: 0; padding: 7px 0; border-bottom: 1px dashed #b9ae95; }
.pr-bests dd { font: 500 1rem/1.4 var(--font-mono); text-align: right; }
.pr-settings { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }
.pr-toggle {
  min-height: 44px; padding: 8px 14px; border: 1.5px solid var(--pr-ink); border-radius: var(--pr-wobble);
  background: var(--pr-card); color: var(--pr-ink); font: 600 0.95rem/1 var(--font-body); cursor: pointer;
}
.pr-toggle[aria-pressed="true"] { background: var(--pr-ink); color: var(--pr-card); }
.pr-toggle-state { font-weight: 700; text-transform: uppercase; font-size: 0.8rem; letter-spacing: 0.06em; }
.pr-storage { font-size: 0.9rem; color: var(--pr-muted); }
.pr-cleared { color: var(--pr-ink); font-weight: 600; }

/* ---------- play screen: a fixed, full-viewport layout, so nothing scrolls during play ---------- */
html.pr-playing, html.pr-playing body { overflow: hidden; overscroll-behavior: none; }
.pr-play {
  position: fixed; inset: 0; z-index: 80; height: 100vh; height: 100dvh;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr);
  gap: 6px; padding: 8px 12px max(10px, env(safe-area-inset-bottom));
  background: var(--pr-paper); color: var(--pr-ink);
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.pr-bar { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; max-width: 1100px; width: 100%; margin: 0 auto; }
.pr-quit {
  min-height: 44px; min-width: 56px; padding: 6px 12px; border: 1.5px solid var(--pr-ink); border-radius: var(--pr-wobble);
  background: transparent; color: var(--pr-ink); font: 700 0.95rem/1 var(--font-display); text-transform: uppercase; letter-spacing: 0.06em; cursor: pointer;
}
.pr-progress { text-align: center; font: 700 italic 1.35rem/1 var(--font-display); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-syscount { color: var(--pr-red-ink); margin-left: 4px; }
.pr-pips { grid-column: 2; grid-row: 2; display: flex; justify-content: center; gap: 6px; list-style: none; margin: -2px 0 0; padding: 0; }
.pr-pips li { width: 18px; height: 6px; border: 1.5px solid var(--pr-ink); border-radius: 3px; }
.pr-pips li.done { background: var(--pr-ink); }
.pr-pips li.now { background: repeating-linear-gradient(-45deg, var(--pr-red) 0 3px, transparent 3px 6px); }
.pr-clock { grid-column: 3; grid-row: 1; position: relative; text-align: right; }
.pr-timer { font: 500 1.2rem/1 var(--font-mono); font-variant-numeric: tabular-nums; display: inline-block; min-width: 4.4em; }
.pr-relaxed .pr-timer { font: 700 italic 1.05rem/1 var(--font-display); text-transform: uppercase; min-width: 0; }
.pr-plus {
  position: absolute; right: 0; top: 100%; margin-top: 2px; padding: 1px 6px; border-radius: 3px;
  background: var(--pr-red); color: #fff; font: 700 0.85rem/1.3 var(--font-body); opacity: 0; pointer-events: none;
}
.pr-plus-show { animation: pr-plus 0.9s ease-out; }
@keyframes pr-plus { 0% { opacity: 0; transform: translateY(4px); } 15% { opacity: 1; transform: none; } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }

.pr-trayrow { display: flex; align-items: center; justify-content: center; gap: 8px; max-width: 1100px; width: 100%; margin: 0 auto; }
.pr-tray { display: flex; gap: 5px; list-style: none; margin: 0; padding: 4px 6px; border: 1.5px solid var(--pr-ink); border-radius: var(--pr-wobble); background: var(--pr-wash); }
.pr-tray li { width: 38px; height: 38px; border: 1.5px dashed #9c917b; border-radius: 8px; background: var(--pr-card); display: grid; place-items: center; }
.pr-tray li.filled { border-style: solid; border-color: var(--pr-ink); }
.pr-tray img { width: 32px; height: 32px; }
.pr-toggle-small { min-height: 44px; padding: 6px 10px; font-size: 0.85rem; }

.pr-cards { container-type: size; min-height: 0; position: relative; }
.pr-pair {
  --gap: 12px;
  --side: min(100cqw, calc((100cqh - var(--gap)) / 2));
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--gap);
}
@container (min-aspect-ratio: 1 / 1) {
  .pr-pair { --gap: 20px; --side: min(calc((100cqw - var(--gap)) / 2), 100cqh, 560px); flex-direction: row; }
}
.pr-card {
  position: relative; flex: none; width: var(--side); height: var(--side);
  background: var(--pr-card); border: 2.5px solid var(--pr-ink); border-radius: var(--pr-wobble);
  box-shadow: 3px 4px 0 rgba(36, 33, 28, 0.14);
}
.pr-card-a { transform: rotate(-0.6deg); }
.pr-card-b { transform: rotate(0.5deg); }
.pr-scatter { position: absolute; inset: 0; }
.pr-part {
  position: absolute; left: var(--x); top: var(--y); width: var(--d); height: var(--d);
  padding: 0; margin: 0; border: 0; border-radius: 50%; background: transparent; color: var(--pr-ink);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.pr-part img { width: 100%; height: 100%; transform: rotate(var(--rot, 0deg)); pointer-events: none; }
.pr-part:hover:not(:disabled) { background: rgba(235, 227, 209, 0.6); }
.pr-part:active:not(:disabled) img { transform: rotate(var(--rot, 0deg)) scale(0.94); }
.pr-part:focus-visible { outline: 3px dashed var(--pr-red); outline-offset: 2px; border-radius: 50%; }
.pr-part:disabled { cursor: not-allowed; }
.pr-part.pr-wrong img { opacity: 0.35; }
.pr-part.pr-wrong::after {
  content: ""; position: absolute; inset: 18%; pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M8 8 L32 32 M32 8 L8 32' stroke='%23fbf8f1' stroke-width='9' stroke-linecap='round'/%3E%3Cpath d='M8 8 L32 32 M32 8 L8 32' stroke='%23d7141c' stroke-width='5' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.pr-part.pr-wrong { outline: 2px dashed var(--pr-ink); outline-offset: -2px; }
.pr-name {
  display: none; position: absolute; left: 50%; bottom: -4px; transform: translateX(-50%);
  padding: 0 4px; border-radius: 3px; background: rgba(251, 248, 241, 0.92);
  font: 600 0.68rem/1.25 var(--font-body); white-space: nowrap; pointer-events: none;
}
.pr-show-names .pr-name { display: block; }
.pr-num {
  display: none; position: absolute; left: 2px; top: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--pr-ink); color: var(--pr-card); font: 700 0.72rem/18px var(--font-body); text-align: center; pointer-events: none;
}
html.pr-kbd .pr-num { display: block; }

.pr-shake { animation: pr-shake 0.28s ease-in-out; }
.pr-card-a.pr-shake { --tilt: -0.6deg; }
.pr-card-b.pr-shake { --tilt: 0.5deg; }
@keyframes pr-shake {
  0%, 100% { transform: rotate(var(--tilt)) translateX(0); }
  25% { transform: rotate(var(--tilt)) translateX(-6px); }
  50% { transform: rotate(var(--tilt)) translateX(5px); }
  75% { transform: rotate(var(--tilt)) translateX(-3px); }
}

.pr-ghost { position: fixed; z-index: 90; pointer-events: none; transform-origin: center; }

.pr-flash {
  position: absolute; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%) rotate(-1.5deg);
  width: min(86vw, 420px); padding: 18px 20px; text-align: center;
  background: var(--pr-card); border: 3px solid var(--pr-ink); border-radius: var(--pr-wobble);
  box-shadow: 5px 6px 0 var(--pr-red); animation: pr-pop 0.22s ease-out;
}
.pr-flash p { margin: 0; }
.pr-flash-kicker { font: 700 0.85rem/1.2 var(--font-display); letter-spacing: 0.14em; text-transform: uppercase; color: var(--pr-red-ink); }
.pr-flash-title { font: 700 italic clamp(2rem, 9vw, 3rem)/1 var(--font-display); text-transform: uppercase; margin: 4px 0 !important; }
.pr-flash-next { font-weight: 600; }
@keyframes pr-pop { from { opacity: 0; transform: translate(-50%, -50%) rotate(-1.5deg) scale(0.9); } }
.pr-tip {
  position: absolute; z-index: 6; left: 50%; top: 104px; transform: translateX(-50%);
  padding: 6px 12px; border-radius: 6px; background: var(--pr-ink); color: var(--pr-card); font-weight: 600; pointer-events: none;
}

/* Accessible mode: each card is a plain list of named buttons, side by side. */
.pr-accessible .pr-pair { flex-direction: row; align-items: flex-start; --side: auto; gap: 10px; }
.pr-accessible .pr-card { width: auto; flex: 1 1 0; max-width: 420px; height: auto; max-height: 100%; overflow-y: auto; transform: none; padding: 6px; }
.pr-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pr-accessible .pr-part {
  position: static; width: 100%; height: auto; min-height: 52px; border-radius: 10px;
  display: flex; align-items: center; gap: 8px; padding: 4px 8px; text-align: left;
  border: 1.5px solid #b9ae95; background: var(--pr-card); font: 600 0.92rem/1.2 var(--font-body);
}
.pr-accessible .pr-part img { width: 40px; height: 40px; flex: none; transform: none; }
.pr-accessible .pr-name { display: block; position: static; transform: none; background: none; padding: 0; white-space: normal; font-size: 0.9rem; }
.pr-accessible .pr-num { position: static; flex: none; order: -1; }
.pr-accessible .pr-part:focus-visible { border-radius: 10px; }
.pr-accessible .pr-part.pr-wrong::after { inset: auto 8px auto auto; width: 24px; height: 24px; }

/* ---------- finish screen ---------- */
.pr-car-stage { overflow: hidden; margin: 0 -16px 8px; padding: 0 16px; }
.pr-car { display: block; width: 100%; max-width: 520px; margin: 0 auto; overflow: visible; }
.pr-car-part { opacity: 1; }
.pr-car-go .pr-car-part { opacity: 0; animation: pr-bolt 0.3s ease-out forwards; }
.pr-car-go .pr-cp-engine { animation-delay: 0.15s; }
.pr-car-go .pr-cp-gearbox { animation-delay: 0.4s; }
.pr-car-go .pr-cp-suspension { animation-delay: 0.65s; }
.pr-car-go .pr-cp-brakes { animation-delay: 0.9s; }
.pr-car-go .pr-cp-wheels { animation-delay: 1.15s; }
.pr-car-go .pr-car-move { animation: pr-drive 2.4s ease-in-out 1.7s both; }
@keyframes pr-bolt { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: none; } }
@keyframes pr-drive {
  0% { transform: translateX(0); }
  45% { transform: translateX(380px); }
  46% { transform: translateX(-380px); }
  100% { transform: translateX(0); }
}
.pr-verdict { font-size: clamp(2.2rem, 9vw, 3.6rem); }
.pr-quote { font-size: 1.1rem; font-style: italic; }
.pr-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.pr-stats div { border: 2px solid var(--pr-ink); border-radius: var(--pr-wobble); background: var(--pr-card); padding: 8px 10px; text-align: center; }
.pr-stats dt { font: 700 0.8rem/1.2 var(--font-display); letter-spacing: 0.12em; text-transform: uppercase; color: var(--pr-muted); }
.pr-stats dd { margin: 2px 0 0; font: 500 1.35rem/1.2 var(--font-mono); font-variant-numeric: tabular-nums; }
.pr-share-preview {
  font: 500 0.95rem/1.45 var(--font-mono); white-space: pre-wrap; margin: 12px 0; padding: 12px 14px;
  background: #fffdf6 repeating-linear-gradient(transparent 0 21px, #c9d8ea 21px 22px); border-left: 3px solid var(--pr-red);
  box-shadow: 2px 3px 8px rgba(36, 33, 28, 0.16); user-select: text;
}
.pr-shared { min-height: 1.5em; font-weight: 600; }
.pr-countdown { font-weight: 600; }
.pr-reading { margin: 20px 0; }
.pr-reading ul { padding-left: 1.2em; }
.pr-reading li { margin: 6px 0; }
.pr-back { margin-top: 18px; }

/* ---------- the /play/ hub ---------- */
.pr-hub-head { padding: 32px 0 8px; }
.pr-hub { list-style: none; margin: 16px 0 24px; padding: 0; display: grid; gap: 18px; }
.pr-game-card { border: 2.5px solid var(--pr-ink); border-radius: var(--pr-wobble); background: var(--pr-card); padding: 18px; box-shadow: 3px 4px 0 rgba(36, 33, 28, 0.14); }
.pr-game-card h2 { margin-bottom: 8px; }
.pr-game-live { display: grid; gap: 16px; }
.pr-game-soon { border-style: dashed; background: transparent; box-shadow: none; }
.pr-game-soon h2 { font-size: 1.6rem; }
.pr-game-soon p:last-child { margin-bottom: 0; }
.pr-game-art { position: relative; height: 150px; }
.pr-mini-card {
  position: absolute; top: 10px; width: 120px; height: 120px; border: 2.5px solid var(--pr-ink); border-radius: var(--pr-wobble);
  background: var(--pr-paper) url("/play/parts-rush/parts/turbocharger.svg") 50% 50% / 46px no-repeat;
}
.pr-mini-a { left: calc(50% - 128px); transform: rotate(-5deg); background-image: url("/play/parts-rush/parts/turbocharger.svg"), url("/play/parts-rush/parts/spark-plug.svg"), url("/play/parts-rush/parts/tyre.svg"); background-position: 30% 28%, 76% 70%, 24% 80%; background-size: 50px, 38px, 34px; }
.pr-mini-b { left: calc(50% + 8px); transform: rotate(4deg); background-image: url("/play/parts-rush/parts/turbocharger.svg"), url("/play/parts-rush/parts/caliper.svg"), url("/play/parts-rush/parts/coilover.svg"); background-position: 70% 72%, 26% 28%, 76% 22%; background-size: 46px, 40px, 36px; }
.pr-hub-small { margin-bottom: 40px; }
@media (min-width: 760px) {
  .pr-hub { grid-template-columns: 1fr 1fr; }
  .pr-game-live { grid-column: 1 / -1; grid-template-columns: 300px 1fr; align-items: center; }
}

/* ---------- reduced motion: fades instead of shakes, flights and drives ---------- */
@media (prefers-reduced-motion: reduce) {
  .pr-shake { animation: pr-fade 0.3s ease-in-out; }
  .pr-flash { animation: pr-fade-in 0.2s ease-out; }
  .pr-plus-show { animation: pr-plus-fade 0.9s linear; }
  .pr-car-go .pr-car-part { animation: none; opacity: 1; }
  .pr-car-go .pr-car-move { animation: none; }
  .pr-car-go { animation: pr-fade-in 0.6s ease-out; }
  .pr-part:active:not(:disabled) img { transform: rotate(var(--rot, 0deg)); }
}
@keyframes pr-fade { 50% { opacity: 0.55; } }
@keyframes pr-fade-in { from { opacity: 0; } }
@keyframes pr-plus-fade { 0% { opacity: 0; } 15%, 75% { opacity: 1; } 100% { opacity: 0; } }

@media (min-width: 640px) {
  .pr-style { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .pr-style legend { grid-column: 1 / -1; }
  .pr-style label { margin: 0; flex-direction: column; gap: 4px; }
}
