/* The slope: a white field, a 16-colour window manager, one readout in the corner. */
:root {
  --navy: #000080; --gray: #c0c0c0; --dark: #808080; --ink: #000; --paper: #fff;
  --sys: "Arial", "Helvetica Neue", Helvetica, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #fff; overflow: hidden; overscroll-behavior: none; }
body { font: bold 13px/1.25 var(--sys); color: var(--ink); -webkit-text-size-adjust: 100%; }
body.loading, body.loading * { cursor: wait !important; }

#slope { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; touch-action: none; outline: none; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
#slope.over { cursor: pointer; }

/* the readout, top right, exactly where it always was */
#stats { position: fixed; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); pointer-events: none;
  background: #fff; border: 1px solid #000; padding: 3px 7px 4px; font: bold 13px/1.3 var(--sys); min-width: 150px; user-select: none; }
#stats div { display: flex; justify-content: space-between; gap: 10px; }
#stats b { font-weight: bold; font-variant-numeric: tabular-nums; }
body.loading #stats, body.loading #tools { visibility: hidden; }

/* buttons: raised gray, two-pixel bevel */
.w31-btn { font: bold 13px/1 var(--sys); color: #000; background: var(--gray); border: 1px solid #000; border-radius: 2px; padding: 6px 14px; cursor: pointer;
  box-shadow: inset 2px 2px 0 #fff, inset -2px -2px 0 var(--dark); min-height: 30px; }
.w31-btn:active { box-shadow: inset 2px 2px 0 var(--dark), inset -1px -1px 0 #fff; padding: 7px 13px 5px 15px; }
.w31-btn:focus-visible { outline: 1px dotted #000; outline-offset: -6px; }
.w31-btn.icon { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; }
.w31-btn.icon:active { padding: 1px 0 0 1px; }
.w31-btn.icon svg { width: 20px; height: 20px; }
#tools { position: fixed; top: max(8px, env(safe-area-inset-top)); left: max(8px, env(safe-area-inset-left)); display: flex; gap: 6px; }
#btn-sound .mute { display: none; }
#btn-sound[aria-pressed="false"] .mute { display: inline; }
#btn-sound[aria-pressed="false"] .waves { display: none; }
#again { position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); padding: 10px 22px; font-size: 15px; }
#again:active { transform: translateX(-50%); }

/* windows */
dialog.w31 { padding: 0; border: 1px solid #000; background: var(--gray); color: #000; box-shadow: inset 1px 1px 0 #fff, inset -1px -1px 0 var(--dark), 4px 4px 0 rgba(0,0,0,.35);
  width: min(880px, calc(100vw - 24px)); max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); display: none; flex-direction: column; overflow: hidden; }
dialog.w31[open] { display: flex; }
dialog.w31::backdrop { background: transparent; }
.w31-title { flex: none; display: flex; align-items: stretch; height: 24px; background: var(--navy); color: #fff; border: 3px solid var(--gray); border-bottom: 0; }
.w31-title h2 { flex: 1; margin: 0; font: bold 13px/22px var(--sys); text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 8px; }
.w31-ctl { flex: none; width: 24px; height: 21px; margin: 0; padding: 0; border: 0; border-right: 1px solid #000; background: var(--gray); cursor: pointer; display: grid; place-items: center; }
.w31-ctl i { display: block; width: 13px; height: 3px; background: #fff; border: 1px solid #000; box-shadow: 1px 1px 0 var(--dark); }
.w31-ctl:focus-visible { outline: 1px dotted #000; outline-offset: -3px; }
.w31-body { flex: 1 1 auto; min-height: 0; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; background: #fff; margin: 0 3px; border: 1px solid #000; border-top: 1px solid #000; padding: 14px 16px 18px;
  font: 14px/1.45 var(--sys); }
.w31-foot { flex: none; display: flex; justify-content: flex-end; gap: 8px; padding: 8px 6px 7px; }
#btn-about { margin-right: auto; }
.w31-foot .ok { min-width: 84px; }
.w31-client { margin: 0 0 10px; font: bold 12px/1.2 var(--sys); letter-spacing: .04em; color: var(--dark); }

/* the kit, dressed for the window */
#reader-media { --ab-fg: #000; --ab-muted: #555; --ab-accent: var(--navy); }
#reader-media .ab-media { --ab-chrome: 150px; }
#reader-media .ab-lede { font-weight: bold; }
#reader-media .ab-heading { font-weight: bold; border-bottom: 1px solid var(--dark); padding-bottom: 2px; }
#reader-media .ab-frame { border: 1px solid #000; }

/* trail map: every run, a sprite and its name */
#map { width: min(560px, calc(100vw - 24px)); }
#runs { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
#runs button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%; padding: 4px 8px; cursor: pointer; font: 14px/1.2 var(--sys); min-height: 52px; }
#runs button:hover { background: #e8e8e8; }
#runs button:focus-visible { background: var(--navy); color: #fff; outline: 1px dotted #fff; outline-offset: -3px; }
#runs button:focus-visible small { color: #ddd; }
#runs .spr { flex: none; width: 64px; height: 48px; display: grid; place-items: center; }
#runs .spr img { max-width: 64px; max-height: 48px; image-rendering: pixelated; }
#runs b { display: block; font-weight: bold; }
#runs small { display: block; font: bold 11px/1.3 var(--sys); color: var(--dark); letter-spacing: .04em; }

/* loading: the hourglass */
#loader { position: fixed; inset: 0; display: grid; place-items: center; background: #fff; transition: opacity .2s; }
#loader svg { width: 32px; height: 44px; image-rendering: pixelated; }
#loader.done { opacity: 0; pointer-events: none; }

@media (max-width: 600px) {
  #stats { font-size: 11px; min-width: 118px; padding: 2px 5px 3px; }
  dialog.w31 { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); }
  .w31-body { padding: 12px 12px 16px; }
}
@media (prefers-reduced-motion: reduce) { #loader { transition: none; } }

/* about box */
#about { width: min(440px, calc(100vw - 24px)); }
.about { display: flex; gap: 16px; align-items: flex-start; }
.about img { flex: none; width: 44px; height: 52px; image-rendering: pixelated; }
.about h3 { margin: 0 0 4px; font: bold 16px/1.2 var(--sys); }
.about p { margin: 0 0 8px; }
#about-role { font-weight: bold; }
.about a { color: var(--navy); }
