:root {
  font-family: Arial, Helvetica, sans-serif;
  color: #293e34;
  background: #d6dfc3;
  font-synthesis: none;
  --ink: #293e34;
}
* { box-sizing: border-box; }
body { margin: 0; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
button, input, a { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 2px solid #df763e; outline-offset: 4px; }
button:disabled { opacity: .6; cursor: wait; }
.stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
#game { display: block; width: 100%; height: 100%; outline: none; touch-action: none; cursor: crosshair; }
.stage-tools {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  border: 1px solid #ffffff90;
  border-radius: 5px;
  box-shadow: 0 3px 18px #293e340a;
}
.stage-tools {
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  display: flex;
  background: #f6f5eeeb;
  backdrop-filter: blur(8px);
}
.stage-tools button { width: 44px; height: 44px; border: 0; border-radius: 4px; background: none; color: #516346; font-size: 23px; }
.stage-tools button:hover, .stage-tools button[aria-pressed=true] { background: #dbe2cc; }
.stage-tools #random-seed { font-size: 27px; line-height: 1; }
.stage-tools #random-seed:disabled { opacity: .5; }
.stage-tools #snapshot { display: grid; place-items: center; }
.snap-flash { position: absolute; inset: 0; z-index: 3; background: #fffdf4; pointer-events: none; animation: snap-flash .45s ease-out forwards; }
@keyframes snap-flash { from { opacity: .7; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .snap-flash { animation-duration: .2s; } }
.stage-tools #music { position: relative; font-size: 21px; }
.stage-tools #music.off { color: #8a9680; }
.stage-tools #music.off::after { content: ''; position: absolute; left: 12px; right: 12px; top: 50%; height: 2px; background: currentColor; transform: rotate(-45deg); border-radius: 1px; }
.controls {
  flex-shrink: 0;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 26px;
  padding: 6px max(20px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  border-top: 1px solid #dcded3;
  background: #f6f5ee;
  font-size: 11px;
  color: #6e7d62;
}
.brand { display: inline-flex; align-items: center; gap: 9px; margin-right: 6px; color: #20438f; font: bold 15px Georgia, serif; letter-spacing: .2px; white-space: nowrap; }
.brand img { display: block; width: 34px; height: auto; }
.controls button, .key-help { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.controls button { min-height: 44px; padding: 0; border: 0; background: none; color: inherit; font-size: inherit; }
kbd { display: inline-grid; place-items: center; height: 23px; min-width: 23px; border: 1px solid #d2d7c9; border-bottom-width: 2px; border-radius: 3px; font: 10px monospace; }
.trip-distance { margin-left: auto; white-space: nowrap; font: 14px monospace; font-variant-numeric: tabular-nums; color: var(--ink); }
.loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at 50% 0%, #f8d2a055, transparent 60%), #d6dfc3;
  transition: opacity .6s ease, visibility 0s linear .6s;
}
/* The first loading screen comes up out of the dark: a deep green-black veil over
   the whole screen lifts, so the blue logo darkens with the ground instead of
   standing out against it, and the card itself only rises once the ground is light. */
.loader::before { content: ""; position: absolute; inset: 0; z-index: 1; background: #0b120d; pointer-events: none; animation: loader-dawn 3.2s cubic-bezier(.45, 0, .25, 1) forwards; }
.loader.over::before { display: none; }
.loader-card { position: relative; }
.loader:not(.over) .loader-card { animation: loader-card-in 1.4s ease-out 1.1s both; }
@keyframes loader-dawn { from { opacity: 1; } to { opacity: 0; } }
@keyframes loader-card-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.loader.over { background: #d6dfc3b8; backdrop-filter: blur(6px); }
.loader.done { opacity: 0; visibility: hidden; pointer-events: none; }
.loader:not(.done) { transition: opacity .25s ease; }
.loader-card { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.loader-card img { display: block; width: 88px; height: auto; filter: drop-shadow(0 6px 14px #293e341f); }
.loader-title { margin: 0; color: #20438f; font: bold 26px Georgia, serif; letter-spacing: .3px; }
.loader-text { min-height: 1.3em; margin: 0; color: #516346; font: 12px monospace; letter-spacing: .5px; }
.loader.failed .loader-text { color: #a2472a; max-width: 280px; white-space: normal; }
@media (prefers-reduced-motion: reduce) {
  .loader::before { animation: none; opacity: 0; }
  .loader:not(.over) .loader-card { animation: none; }
  .loader, .loader:not(.done) { transition: none; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
body.fullscreen .controls { display: none; }
body.fullscreen #game { cursor: default; }
body.fullscreen .stage-tools { top: max(20px, env(safe-area-inset-top)); }
.session-distance {
  display: none;
  position: absolute;
  left: max(20px, env(safe-area-inset-left));
  bottom: max(20px, env(safe-area-inset-bottom));
  padding: 8px 14px;
  background: #f6f5ec70;
  backdrop-filter: blur(3px);
  border-radius: 4px;
  font: 13px monospace;
  color: #293e34c9;
  pointer-events: none;
}
body.fullscreen .session-distance { display: block; }
/* Touch screens have no keyboard: no key row; the session distance shows as in full screen. */
@media (pointer: coarse) {
  .controls { display: none; }
  .session-distance { display: block; }
}
#session-km { font: 26px Georgia, serif; font-variant-numeric: tabular-nums; }
@media (max-width: 480px) {
  .controls { gap: 12px; padding-left: 12px; padding-right: 12px; font-size: 10px; }
  .controls button, .key-help { gap: 4px; }
  .brand { margin-right: 0; }
  .brand-name { display: none; }
  .trip-distance { font-size: 12px; }
  .stage-tools { right: 12px; }
}

@media (max-width: 640px) {
  .stage-tools { right: 12px; }
  .stage-tools button { width: 36px; }
}

/* About dialog: opens over the loading screen when the page loads. The dialog itself
   is only a frame; .about-body scrolls, so a click on the dialog element is the backdrop. */
.stage-tools #about-open { font: italic bold 21px Georgia, serif; }
.about {
  width: min(560px, calc(100% - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  padding: 0;
  border: 1px solid #ffffff90;
  border-radius: 8px;
  background: #f6f5ee;
  color: var(--ink);
  box-shadow: 0 24px 70px #0b120d40, 0 3px 12px #293e3418;
  overflow: hidden;
}
.about[open] { display: flex; flex-direction: column; animation: about-in .5s ease-out both; }
.about::backdrop { background: #0b120d5c; backdrop-filter: blur(3px); animation: about-fade .5s ease-out both; }
@keyframes about-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes about-fade { from { opacity: 0; } to { opacity: 1; } }
.about-frame { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.about-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 30px 32px 8px; }
.about-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.about-head img { display: block; width: 56px; height: auto; filter: drop-shadow(0 4px 10px #293e341f); }
.about-head h2 { margin: 0; color: #20438f; font: bold 28px Georgia, serif; letter-spacing: .3px; }
.about .about-lead { margin: 0 0 12px; font: 19px/1.45 Georgia, serif; color: #293e34; }
.about p { margin: 0 0 12px; font-size: 14px; line-height: 1.6; color: #3c5046; }
.about-keys { list-style: none; margin: 18px 0; padding: 14px 16px; display: grid; grid-template-columns: auto 1fr; gap: 9px 14px; align-items: center; border-radius: 6px; background: #e9ecdf; font-size: 13px; color: #3c5046; }
.about-keys li { display: contents; }
.about-keys .key { justify-self: start; white-space: nowrap; font: 11px monospace; color: #516346; }
.about-keys kbd { background: #f6f5ee; }
.about details { margin: 6px 0 18px; border-top: 1px solid #dcded3; }
.about summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 6px; cursor: pointer; list-style: none; color: #20438f; font: bold 16px Georgia, serif; }
.about summary::-webkit-details-marker { display: none; }
.about summary::after { content: "+"; flex-shrink: 0; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #e9ecdf; color: #516346; font: 18px monospace; }
.about details[open] summary::after { content: "–"; }
.about summary:hover::after { background: #dbe2cc; }
.about-tech { padding-top: 4px; }
.about-tech h3 { margin: 22px 0 6px; color: #293e34; font: bold 15px Georgia, serif; }
.about-tech h3 .step { display: inline-block; min-width: 28px; color: #b0643a; font: 11px monospace; letter-spacing: .5px; }
.about-tech code { padding: 1px 4px; border-radius: 3px; background: #e9ecdf; font: 12px monospace; color: #3c5046; }
.about-tech .about-note { margin-top: 20px; padding: 12px 14px; border-left: 3px solid #df763e; background: #f1ede1; font-size: 13px; }
.about-foot { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 32px; border-top: 1px solid #dcded3; background: #f6f5ee; }
.about-foot small { color: #6e7d62; font: 10px monospace; letter-spacing: .5px; }
.about-go { flex-shrink: 0; white-space: nowrap; min-height: 44px; padding: 0 22px; border: 0; border-radius: 5px; background: #20438f; color: #fff; font: bold 15px Georgia, serif; letter-spacing: .3px; }
.about-go:hover { background: #2a52a8; }
/* Phones and tablets: no keyboard shortcuts in the list, only what a tap does. Any of a
   coarse pointer, no hover or a phone-wide window counts, since not every device reports
   its touch screen the same way. */
@media (pointer: coarse), (hover: none), (max-width: 640px) { .about-keys .desk { display: none; } }
@media (max-width: 480px) {
  .about-body { padding: 22px 20px 6px; }
  .about-foot { padding: 12px 20px; }
  .about-head h2 { font-size: 24px; }
  .about-go { padding: 0 16px; }
  .about .about-lead { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) {
  .about[open], .about::backdrop { animation: none; }
}
