/* MONSTER MASH MOTORS — the Paint Shop, plus the pieces Make a Poster and the
   Pit Pass share (.mk-*: tokens, big buttons, the how-to line, badge toasts,
   print-one-picture). Arena-bill look: poster paper, key-black outlines, hard
   offset shadows, Anton titles, Lexend for reading, Bangers for sound words.
   Everything is scoped under .mk so it never leaks into the site's pages. */

.mk {
  --mk-key: #15110F;
  --mk-paper: #F4EBDD;
  --mk-paper-hi: #FFF9EE;
  --mk-orange: #FB652D;
  --mk-blue: #6AB9D7;
  --mk-yellow: #FFB23F;
  --mk-steel: #5E5A55;
  --mk-dirt: #996D54;
  --mk-focus: #1A4AA6;
  --mk-radius: 14px;
  --mk-shadow: 4px 4px 0 var(--mk-key);
  --mk-title: Anton, 'Arial Narrow', Impact, sans-serif;
  --mk-read: Lexend, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mk-sfx: Bangers, Impact, sans-serif;
  font-family: var(--mk-read);
  font-size: 18px;
  line-height: 1.45;
  color: var(--mk-key);
  max-width: 1200px;
  margin: 0 auto;
  box-sizing: border-box;
  overflow-wrap: break-word;
}
/* Typed names and titles may be one long word: let those break anywhere. */
.mk .ps-plate-name, .mk .ps-name-now, .mk .pz-selname { overflow-wrap: anywhere; }
.mk *, .mk *::before, .mk *::after { box-sizing: border-box; }
.mk .mk-ico { overflow: visible; }
.mk [hidden] { display: none !important; }

/* Visually hidden, still read out. */
.mk-sr, .mk-sr-input {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.mk-sr-input { opacity: 0; }
.mk-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ------------------------------------------------------------ how to play */
.mk-howto {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px;
  margin: 0 0 14px; padding: 10px 14px;
  background: var(--mk-paper-hi); border: 3px solid var(--mk-key); border-radius: var(--mk-radius);
  box-shadow: var(--mk-shadow); font-weight: 700; font-size: 17px;
}
.mk-howto span:not(.mk-arrow) { display: inline-flex; align-items: center; gap: 6px; }
.mk-howto .mk-ico { width: 30px; height: 30px; }
.mk-arrow { font-family: var(--mk-title); color: var(--mk-orange); font-size: 22px; }

/* --------------------------------------------------------------- buttons */
.mk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; min-width: 56px; padding: 8px 18px;
  font: 700 18px/1.1 var(--mk-read); color: var(--mk-key); text-decoration: none;
  background: var(--mk-paper-hi); border: 3px solid var(--mk-key); border-radius: var(--mk-radius);
  box-shadow: var(--mk-shadow); cursor: pointer; touch-action: manipulation;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.mk-btn:hover { background: #FFF3DC; }
.mk-btn:active { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--mk-key); }
.mk-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.mk-btn .mk-ico { width: 30px; height: 30px; flex: none; }
.mk-btn-go { background: var(--mk-orange); font-family: var(--mk-title); font-weight: 400; font-size: 26px; letter-spacing: 1px; text-transform: uppercase; min-height: 68px; padding: 8px 24px; }
.mk-btn-go:hover { background: #FF7A47; }
.mk-btn-quiet { background: var(--mk-paper); }
.mk-btn-small { min-height: 48px; min-width: 48px; padding: 6px 14px; font-size: 16px; }
.mk-btn-small .mk-ico { width: 24px; height: 24px; }
.mk-btn-danger { background: #F7C6B6; }

.mk :focus-visible,
.mk-sr-input:focus-visible + .ps-tile-face,
.mk-sr-input:focus-visible + .pp-x {
  outline: 4px solid var(--mk-focus); outline-offset: 3px;
}

/* ---------------------------------------------------------- badge toasts */
.mk-toast {
  position: relative; display: flex; align-items: center; gap: 12px; text-align: left;
  width: min(520px, 100%); margin: 14px auto; padding: 12px 56px 12px 12px;
  background: var(--mk-paper-hi); border: 4px solid var(--mk-key); border-radius: 18px;
  box-shadow: 6px 6px 0 var(--mk-orange);
}
.mk-toast.mk-toast-in { animation: mk-pop 0.35s ease-out; }
.mk-toast-art { flex: none; width: 72px; height: 72px; border: 3px solid var(--mk-key); border-radius: 50%; background: var(--mk-yellow); overflow: hidden; display: grid; place-items: center; }
.mk-toast-art svg { width: 64px; height: 64px; }
.mk-toast-text { display: flex; flex-direction: column; gap: 2px; font-size: 16px; }
.mk-toast-text strong { font-family: var(--mk-title); font-weight: 400; font-size: 22px; letter-spacing: 0.5px; }
.mk-toast-text a { color: var(--mk-focus); font-weight: 700; min-height: 32px; display: inline-flex; align-items: center; }
.mk-toast-x { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; border-radius: 10px; }
.mk-toast-x .mk-ico { width: 22px; height: 22px; }
@keyframes mk-pop { from { transform: translateY(14px) scale(0.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* In-page confirm (used instead of any browser dialog). */
.mk-confirm {
  margin: 12px 0 0; padding: 14px; border: 3px solid var(--mk-key); border-radius: var(--mk-radius);
  background: #FFE9D6; box-shadow: var(--mk-shadow);
}
.mk-confirm p { margin: 0 0 10px; font-weight: 700; }
.mk-confirm .mk-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ============================================================ PAINT SHOP */
.ps-build { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) {
  .ps-build { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); align-items: start; }
  .ps-show { position: sticky; top: 12px; }
}

.ps-show {
  position: relative; margin: 0 auto; padding: 0 0 8px; width: 100%;
  /* Short landscape screens: the whole truck stays in view. */
  max-width: calc((100vh - 90px) * 1.3); max-width: calc((100svh - 90px) * 1.3);
  background: var(--mk-blue); border: 4px solid var(--mk-key); border-radius: 20px;
  box-shadow: 6px 6px 0 var(--mk-key); overflow: hidden;
}
.ps-show::before { /* the floodlight starburst behind the truck: hard rays, no blends */
  content: ''; position: absolute; left: 45%; top: 55%; width: 170%; aspect-ratio: 1; transform: translate(-50%, -50%);
  background: repeating-conic-gradient(from 4deg, #FFCB52 0deg 8deg, transparent 8deg 22.5deg);
  pointer-events: none;
}
.ps-show::after { /* the dirt floor */
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 17%;
  background: var(--mk-dirt); border-top: 4px solid var(--mk-key); pointer-events: none;
}
.ps-plate {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; margin: 0;
  padding: 8px calc(clamp(78px, 22%, 128px) + 18px) 8px 12px; min-height: 56px;
  background: var(--mk-key); color: var(--mk-paper-hi);
}
.ps-plate-tag { flex: none; padding: 2px 8px; background: var(--mk-orange); color: var(--mk-key); font-family: var(--mk-title); font-size: 16px; letter-spacing: 1px; text-transform: uppercase; border-radius: 6px; }
.ps-plate-name { font-family: var(--mk-title); font-size: clamp(22px, 5vw, 36px); letter-spacing: 1px; line-height: 1.1; text-shadow: 2px 2px 0 var(--mk-orange); min-width: 0; }
.ps-side { position: relative; z-index: 1; padding: 6px 4% 0; }
.ps-side svg { display: block; width: 100%; height: auto; }
/* The head-on view: a round medallion pinned over the nameplate's right end. */
.ps-front {
  position: absolute; z-index: 3; right: 8px; top: 6px; width: clamp(78px, 22%, 128px); aspect-ratio: 1;
  background: var(--mk-paper-hi); border: 3px solid var(--mk-key); border-radius: 50%; box-shadow: 3px 3px 0 var(--mk-orange);
  display: grid; place-items: center; overflow: hidden;
}
.ps-front svg { width: 86%; height: auto; margin-top: 8%; }
.ps-bounce .ps-side svg { animation: ps-bounce 0.42s ease-out; }
@keyframes ps-bounce { 0% { transform: translateY(0); } 30% { transform: translateY(-4%); } 60% { transform: translateY(1%); } 100% { transform: translateY(0); } }

/* Tabs */
.ps-tools { min-width: 0; }
.ps-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
@media (min-width: 560px) { .ps-tabs { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.ps-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 68px; padding: 6px 2px; font: 700 15px/1.1 var(--mk-read); color: var(--mk-key);
  background: var(--mk-paper-hi); border: 3px solid var(--mk-key); border-radius: 12px; box-shadow: 3px 3px 0 var(--mk-key);
  cursor: pointer; touch-action: manipulation;
}
.ps-tab .mk-ico { width: 30px; height: 30px; }
.ps-tab[aria-selected='true'] { background: var(--mk-yellow); transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--mk-key); }

.ps-panel {
  background: var(--mk-paper-hi); border: 3px solid var(--mk-key); border-radius: var(--mk-radius);
  box-shadow: var(--mk-shadow); padding: 12px; min-height: 220px;
}
.ps-group { border: 0; margin: 0 0 8px; padding: 0; min-width: 0; }
.ps-group legend { font-weight: 800; font-size: 17px; margin: 0 0 6px; padding: 0; }
.ps-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.ps-tile { position: relative; display: block; cursor: pointer; min-width: 0; }
.ps-tile-face {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 92px; height: 100%; padding: 6px 4px; background: var(--mk-paper);
  border: 3px solid var(--mk-key); border-radius: 12px; text-align: center;
}
.ps-tile-art { display: grid; place-items: center; width: 100%; }
.ps-tile-art svg { width: 100%; max-width: 110px; height: 58px; }
.ps-tile-word { font-weight: 700; font-size: 15px; line-height: 1.1; }
.ps-tile:hover .ps-tile-face { background: #FFF3DC; }
.mk-sr-input:checked + .ps-tile-face { background: var(--mk-yellow); box-shadow: inset 0 0 0 3px var(--mk-key); }
.mk-sr-input:checked + .ps-tile-face::after {
  content: ''; position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--mk-key) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M9 21l8 8 15-17' stroke='%23FFF9EE' stroke-width='6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 18px no-repeat;
}

/* Paint swatches */
.ps-swatches .ps-grid { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 8px; }
.ps-swatches .ps-tile-face { min-height: 50px; background: var(--sw); }
.ps-swatches .ps-tile:hover .ps-tile-face { background: var(--sw); filter: brightness(1.06); }
.ps-swatches .mk-sr-input:checked + .ps-tile-face { background: var(--sw); box-shadow: inset 0 0 0 4px var(--mk-paper-hi), inset 0 0 0 7px var(--mk-key); }
.ps-picked { margin: 2px 0 12px; font-weight: 700; font-size: 16px; }
.ps-lenses .ps-grid { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
.ps-lenses .ps-tile-face { min-height: 58px; }
.ps-lenses .ps-tile-art svg { height: 42px; }
.ps-faces .ps-grid { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); }
.ps-faces .ps-tile-art svg { height: 50px; }
.ps-powers .ps-tile-art svg { height: 52px; }

/* Name */
.ps-name-now {
  margin: 0 0 10px; padding: 8px 12px; text-align: center;
  font-family: var(--mk-title); font-size: clamp(26px, 7vw, 40px); letter-spacing: 1px; line-height: 1.1;
  background: var(--mk-key); color: var(--mk-paper-hi); border-radius: 10px; text-shadow: 2px 2px 0 var(--mk-orange);
}
.ps-chips .ps-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.ps-chips .ps-tile-face { min-height: 48px; padding: 6px 12px; flex-direction: row; }
.ps-chips .ps-tile-art { display: none; }
.ps-chips .ps-tile-word { font-size: 16px; }
.ps-namebox > .mk-btn { margin: 4px 0 12px; }
.ps-own-wrap label { display: block; font-weight: 800; font-size: 17px; margin-bottom: 6px; }
.ps-own {
  width: 100%; max-width: 420px; min-height: 56px; padding: 8px 12px;
  font: 400 26px/1.1 var(--mk-title); letter-spacing: 1px; text-transform: uppercase; color: var(--mk-key);
  background: #FFFFFF; border: 3px solid var(--mk-key); border-radius: 12px;
}
.ps-hint, .ps-note { margin: 6px 0 0; font-size: 15px; color: #3D3935; }

/* Actions */
.ps-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin: 18px 0 4px; }
.ps-actions .mk-btn-go { flex: 1 1 220px; max-width: 420px; min-height: 76px; font-size: 32px; }

/* Drive and license */
.ps-result { display: grid; gap: 14px; }
.ps-canvas {
  display: block; width: 100%; aspect-ratio: 16 / 10; margin: 0 auto;
  max-width: calc((100vh - 110px) * 1.6); max-width: calc((100svh - 110px) * 1.6);
  border: 4px solid var(--mk-key); border-radius: 18px; background: var(--mk-paper); box-shadow: 6px 6px 0 var(--mk-key);
}
.ps-stage-ctrl { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.ps-licence { text-align: center; }
.ps-card-head { margin: 4px 0 12px; font-family: var(--mk-title); font-weight: 400; font-size: clamp(28px, 7vw, 46px); letter-spacing: 1px; line-height: 1.1; text-shadow: 3px 3px 0 var(--mk-blue); }
.ps-card {
  display: block; width: 100%; height: auto; margin: 0 auto; filter: drop-shadow(6px 6px 0 rgba(21, 17, 15, 0.9));
  max-width: min(900px, calc((100vh - 60px) * 1.6)); max-width: min(900px, calc((100svh - 60px) * 1.6));
}
.ps-card-wait { font-weight: 700; padding: 40px 0; }
.ps-stamp-in .ps-card { animation: ps-stamp 0.4s ease-out; }
@keyframes ps-stamp { from { transform: scale(1.06) rotate(-2deg); opacity: 0; } to { transform: none; opacity: 1; } }
.ps-licence-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 18px 0 6px; }

/* ------------------------------------------------------------ reduced motion */
@media (prefers-reduced-motion: reduce) {
  .mk *, .mk *::before, .mk *::after, .mk-toast { animation: none !important; transition: none !important; }
}
html[data-motion='off'] .mk *, html[data-motion='off'] .mk *::before, html[data-motion='off'] .mk *::after,
html[data-motion='off'] .mk-toast { animation: none !important; transition: none !important; }

/* ----------------------------------------------------- print one picture */
.mk-print { display: none; }
@page mkposter { size: landscape; margin: 8mm; }
@media print {
  html[data-mk-print] body > *:not(.mk-print) { display: none !important; }
  html[data-mk-print], html[data-mk-print] body { background: #FFFFFF !important; margin: 0 !important; }
  html[data-mk-print] .mk-print { display: block !important; }
  .mk-print img { display: block; width: 100%; height: auto; }
  .mk-print p { font: 12pt/1.3 Lexend, sans-serif; text-align: center; margin: 3mm 0 0; }
  .mk-print-licence { width: 150mm; margin: 12mm auto 0; padding: 4mm; border: 0.6mm dashed #15110F; border-radius: 5mm; }
  .mk-print-poster { page: mkposter; width: 100%; }
  .mk-print-poster img { max-height: 190mm; width: auto; max-width: 100%; margin: 0 auto; }
}
