:root {
  --dirt: #2a241c;
  --hazard: #e0a51e;
  --ink: #241c12;
  --card: #d9c9a3;
  --card-edge: #a8926a;
  --rust: #8a4a24;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--dirt);
  overflow: hidden;
  overscroll-behavior: none;
  font-family: "Courier New", Courier, monospace;
  color: var(--ink);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* Placed under the truck by main.js, on the foreground dirt. */
#controls {
  position: fixed;
  left: 50%;
  top: 85%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

#unload {
  pointer-events: auto;
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 14px 44px 13px;
  font: 800 clamp(18px, 2.2vw, 26px)/1 Impact, "Arial Black", system-ui, sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #1a1408;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(0, 0, 0, .16)),
    var(--hazard);
  border-radius: 3px;
  box-shadow:
    inset 0 0 0 3px #1a1408,
    inset 0 0 0 7px var(--hazard),
    inset 0 0 0 9px #1a1408,
    0 5px 0 #4d3a10,
    0 12px 20px rgba(0, 0, 0, .55);
  transition: transform .08s ease, box-shadow .08s ease, filter .2s ease;
}

#unload:hover:not(:disabled) { filter: brightness(1.1); }

#unload:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow:
    inset 0 0 0 3px #1a1408,
    inset 0 0 0 7px var(--hazard),
    inset 0 0 0 9px #1a1408,
    0 1px 0 #4d3a10,
    0 3px 8px rgba(0, 0, 0, .55);
}

#unload:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }

#unload:disabled {
  cursor: default;
  filter: grayscale(.8) brightness(.62);
}

#hint:empty { display: none; }

#hint {
  margin: 0;
  min-height: 1.3em;
  font-size: clamp(12px, 1.3vw, 15px);
  font-weight: 700;
  color: #d8cdb4;
  text-align: center;
  text-shadow: 0 1px 3px #000;
  max-width: min(86vw, 520px);
  padding: 2px 10px;
  background: rgba(20, 15, 9, .55);
  border-radius: 3px;
}

/* Game-style controls: hold an arrow to drive. */
#steer {
  --pad: clamp(72px, 11vmin, 104px);
  --edge: clamp(16px, 5vw, 96px);
  --lift: max(clamp(18px, 5vh, 56px), env(safe-area-inset-bottom));
  position: fixed;
  bottom: var(--lift);
  left: max(var(--edge), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.arrows {
  display: flex;
  gap: 10px;
}

.arrows button {
  width: var(--pad);
  height: var(--pad);
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 0;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .26), rgba(0, 0, 0, .14)),
    var(--hazard);
  color: #1a1408;
  font: 400 calc(var(--pad) * .5)/1 Arial, system-ui, sans-serif;
  box-shadow:
    inset 0 0 0 3px #1a1408,
    0 6px 0 #4d3a10,
    0 12px 20px rgba(0, 0, 0, .55);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.arrows button[aria-pressed="true"] {
  transform: translateY(5px);
  filter: brightness(1.2);
  box-shadow:
    inset 0 0 0 3px #1a1408,
    0 1px 0 #4d3a10,
    0 3px 8px rgba(0, 0, 0, .55);
}

.arrows button:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

.arrows button:disabled {
  cursor: default;
  filter: grayscale(.8) brightness(.6);
}

/* Touch screens and tall windows: one arrow under each thumb, Unload between
   them (main.js lines it up with this row). */
@media (pointer: coarse), (max-aspect-ratio: 23/20) {
  #steer {
    --pad: clamp(76px, 20vmin, 96px);
    right: max(var(--edge), env(safe-area-inset-right));
    align-items: stretch;
    pointer-events: none;
  }

  .arrows { justify-content: space-between; }
  .arrows button { pointer-events: auto; }
}

@media (max-aspect-ratio: 23/20) {
  #unload { padding-inline: clamp(20px, 6vw, 44px); }
}

#mute {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  min-height: 44px;
  padding: 6px 14px;
  border: 2px solid #1a1408;
  border-radius: 3px;
  background: rgba(32, 25, 15, .78);
  color: #d8cdb4;
  font: 700 13px/1 "Courier New", monospace;
  cursor: pointer;
}

#mute:hover { background: rgba(70, 52, 26, .9); }
#mute:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

/*
 * The text version: everything the scene shows, as plain headings, text and
 * links, for screen readers and search engines. Out of sight until it is
 * reached by keyboard, then it opens as a scrolling panel.
 */
.skip-link {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 10;
  padding: 10px 14px;
  background: var(--card);
  color: var(--ink);
  font: 700 14px/1 "Courier New", monospace;
  transform: translateY(calc(-100% - 24px));
}

.skip-link:focus { transform: none; outline: 3px solid #fff; outline-offset: 2px; }

#text:not(:focus):not(:focus-within) {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#text {
  position: fixed;
  inset: 12px;
  z-index: 9;
  overflow-y: auto;
  padding: 20px clamp(16px, 4vw, 40px);
  background: var(--card);
  color: var(--ink);
  font: 400 16px/1.55 Georgia, "Times New Roman", serif;
  outline: 3px solid #fff;
}

#text h1 { margin: 0; font-size: 28px; }
#text h2 { margin: 28px 0 6px; font-size: 21px; }
#text p { margin: 0 0 10px; max-width: 70ch; }
#text .text-lede { font-style: italic; }
#text dl { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 10px; font-size: 14px; }
#text dt { font-weight: 700; }
#text dd { margin: 0; }
#text a { color: var(--ink); }
#text .text-links { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 0 0 6px; padding: 0; list-style: none; }

#text button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
  color: inherit;
}

/* The project popup: an old, worn government salvage record. */
#tag {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(94vw, 600px);
  max-height: 92dvh;
  overflow: visible;
  color: var(--ink);
  transform: rotate(-.8deg);
  filter: drop-shadow(0 18px 28px rgba(0, 0, 0, .6));
}

#tag::backdrop {
  background: rgba(10, 8, 5, .68);
}

#tag[open] { animation: tag-in .3s cubic-bezier(.2, 1.2, .4, 1); }

@keyframes tag-in {
  from { transform: translateY(30px) rotate(-4deg) scale(.94); opacity: 0; }
  to { transform: rotate(-.8deg); opacity: 1; }
}

.paper {
  --paper-ink: #2b2418;
  --faded: #6a5638;
  --stamp-red: #a3261b;
  --stamp-blue: #2c4778;
  --rule: rgba(43, 36, 24, .42);
  position: relative;
  max-height: 92dvh;
  overflow-y: auto;
  padding: clamp(22px, 5vw, 38px) clamp(20px, 5.5vw, 44px) clamp(20px, 4vw, 30px);
  color: var(--paper-ink);
  background:
    /* grain and specks */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .24 0 0 0 0 .12 .7 0 0 0 -.25'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"),
    /* a coffee ring and old stains */
    radial-gradient(circle at 86% 88%, rgba(150, 105, 45, .07) 38px, rgba(122, 78, 30, .22) 40px, rgba(122, 78, 30, .08) 45px, transparent 50px),
    radial-gradient(ellipse 120px 80px at 10% 18%, rgba(150, 105, 45, .2), transparent),
    radial-gradient(circle 5px at 72% 12%, rgba(120, 80, 30, .35), transparent),
    radial-gradient(circle 4px at 18% 64%, rgba(120, 80, 30, .3), transparent),
    radial-gradient(circle 7px at 56% 94%, rgba(120, 80, 30, .25), transparent),
    /* where it was folded in three, and once down the middle */
    linear-gradient(180deg, transparent 33%, rgba(255, 250, 235, .5) 33%, rgba(255, 250, 235, .5) calc(33% + 1px), rgba(80, 60, 30, .2) calc(33% + 1px), transparent calc(33% + 4px)),
    linear-gradient(180deg, transparent 66%, rgba(255, 250, 235, .5) 66%, rgba(255, 250, 235, .5) calc(66% + 1px), rgba(80, 60, 30, .2) calc(66% + 1px), transparent calc(66% + 4px)),
    linear-gradient(90deg, transparent 50%, rgba(80, 60, 30, .12) 50%, transparent calc(50% + 2px)),
    /* yellowed, darker towards the edges */
    radial-gradient(ellipse at 50% 45%, #efe4c6 35%, #e0cd9f 75%, #c9b07a 100%);
  box-shadow:
    inset 0 0 46px rgba(118, 82, 32, .5),
    inset 0 0 5px rgba(80, 55, 20, .55);
  /* worn, slightly torn edges */
  outline: none;
  clip-path: polygon(0 1.2%, 6% 0, 14% .8%, 23% .2%, 31% 1%, 42% .3%, 55% .9%, 63% 0, 74% .7%, 86% .1%, 94% .9%, 100% 0,
    99.4% 9%, 100% 21%, 99.2% 33%, 100% 47%, 99.5% 60%, 100% 74%, 99.3% 88%, 100% 100%,
    91% 99.2%, 80% 100%, 68% 99.3%, 57% 100%, 44% 99.1%, 33% 100%, 21% 99.4%, 10% 100%, 0 99.2%,
    .6% 86%, 0 72%, .7% 58%, 0 45%, .5% 31%, 0 17%);
}

#tag-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border: 0;
  background: none;
  font: 400 32px/1 Georgia, "Times New Roman", serif;
  color: var(--paper-ink);
  cursor: pointer;
}

#tag-close:hover { color: var(--stamp-red); }
#tag-close:focus-visible { outline: 3px solid var(--stamp-red); outline-offset: -4px; }

.paper-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-right: 40px;
  padding-bottom: 12px;
  border-bottom: 4px double rgba(43, 36, 24, .75);
}

.paper-seal {
  position: relative;
  flex: none;
  width: 50px;
  height: 50px;
  border: 2px solid currentColor;
  border-radius: 50%;
  opacity: .7;
  box-shadow: inset 0 0 0 4px transparent, inset 0 0 0 5px currentColor;
}

.paper-seal::after {
  content: "★";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font: 20px/1 Georgia, serif;
}

.paper-gov {
  margin: 0;
  font: 700 clamp(15px, 3.8vw, 19px)/1.15 Georgia, "Times New Roman", serif;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.paper-dept {
  margin: 3px 0 0;
  font: italic 400 clamp(13px, 3.2vw, 15px)/1.2 Georgia, "Times New Roman", serif;
  color: var(--faded);
}

.paper-form {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 16px;
  margin: 10px 0 20px;
  font: 700 11px/1.4 "Courier New", Courier, monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faded);
}

.paper-typed {
  color: var(--paper-ink);
  border-bottom: 1px dotted var(--rule);
}

#tag-name {
  margin: 0 0 14px;
  padding-right: 8px;
  font: 700 clamp(24px, 6vw, 32px)/1.12 Georgia, "Times New Roman", serif;
  letter-spacing: .02em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

/* Rubber stamp beside the title, a little patchy, as if the pad was running dry. */
.paper-stamp {
  float: right;
  margin: 6px 2px 10px 14px;
  padding: 7px 12px 6px;
  border: 4px double var(--stamp-red);
  border-radius: 4px;
  font: 400 clamp(14px, 3.6vw, 19px)/1 Impact, "Arial Black", system-ui, sans-serif;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--stamp-red);
  transform: rotate(-11deg);
  opacity: .8;
  mix-blend-mode: multiply;
  pointer-events: none;
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.6' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 0 0 0 2.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.6' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3 0 0 0 2.3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.paper-stamp.is-pending {
  border-color: var(--stamp-blue);
  color: var(--stamp-blue);
}

#tag-brief {
  margin: 0 0 20px;
  font: 700 clamp(14px, 3.6vw, 16px)/1.6 "Courier New", Courier, monospace;
}

#tag-brief p { margin: 0 0 12px; }
#tag-brief p:last-child { margin-bottom: 0; }

button.paper-btn { cursor: pointer; }

/* Read by screen readers, not shown. */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

#tag-fields {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 16px;
  margin: 0 0 24px;
  padding: 14px 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}

#tag-fields:empty { display: none; }

#tag-fields dt {
  padding-top: 2px;
  font: 700 11px/1.5 Georgia, "Times New Roman", serif;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faded);
}

#tag-fields dd {
  margin: 0;
  padding-bottom: 3px;
  font: 700 clamp(13px, 3.4vw, 15px)/1.45 "Courier New", Courier, monospace;
  border-bottom: 1px dotted var(--rule);
}

@media (max-width: 430px) {
  #tag-fields { grid-template-columns: 1fr; gap: 2px; }
  #tag-fields dd { margin-bottom: 8px; }
}

.paper-actions:empty { display: none; }

#tag-brief a,
#tag-fields dd a {
  color: inherit;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
}

#tag-brief a:hover,
#tag-fields dd a:hover { color: var(--stamp-red); }
#tag-brief a:focus-visible,
#tag-fields dd a:focus-visible { outline: 2px solid var(--stamp-red); outline-offset: 2px; }

.paper-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.paper-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  padding: 12px 22px;
  border: 2px solid var(--paper-ink);
  background: rgba(255, 250, 235, .18);
  color: var(--paper-ink);
  font: 700 15px/1 "Courier New", Courier, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background .15s ease, color .15s ease, transform .08s ease;
}

.paper-btn:hover { background: rgba(43, 36, 24, .12); }
.paper-btn:active { transform: translateY(2px); }
.paper-btn:focus-visible { outline: 3px solid var(--stamp-red); outline-offset: 3px; }
.paper-btn[hidden] { display: none; }

.paper-btn.is-main {
  background: var(--paper-ink);
  color: #efe4c6;
}

.paper-btn.is-main:hover { background: #4a3a22; }

@media (max-width: 430px) {
  .paper-btn { flex: 1 1 100%; }
}

.paper-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-top: 28px;
  font: 700 10px/1.3 "Courier New", Courier, monospace;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faded);
}

.paper-officer {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 130px;
  padding-top: 0;
  text-align: center;
}

.paper-sign {
  margin-bottom: 2px;
  padding: 0 10px 2px;
  border-bottom: 1px solid var(--rule);
  font: 400 26px/1 "Segoe Script", "Brush Script MT", "Apple Chancery", cursive;
  letter-spacing: 0;
  text-transform: none;
  color: var(--stamp-blue);
  transform: rotate(-4deg);
}

.noscript {
  position: fixed;
  inset: 40% 0 auto;
  text-align: center;
  color: #d8cdb4;
}

@media (prefers-reduced-motion: reduce) {
  #tag[open] { animation: none; }
}

/* The 404 page */
body.not-found {
  display: grid;
  place-items: center;
  padding: 24px;
  color: #d8cdb4;
  font: 400 18px/1.5 Georgia, "Times New Roman", serif;
  text-align: center;
}

.not-found h1 { margin: 0 0 8px; font: 400 clamp(36px, 8vw, 64px)/1 Impact, "Arial Black", sans-serif; letter-spacing: .04em; color: var(--hazard); }
.not-found a { color: var(--hazard); }
