/* Original CSS pixel scenery: a daytime city and a quiet rural night. */
.runner-monitor {
  --monitor-case: var(--subtle);
  --monitor-edge: var(--line);
  --runner-dot-warm: #edb477;
  --runner-dot-coral: #df928b;
  display: inline-block;
  vertical-align: top;
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 240px;
  margin: 20px auto 24px;
  padding: 10px;
  border: 1px solid var(--monitor-edge);
  border-radius: 8px 8px 18px 8px;
  background: var(--monitor-case);
  box-shadow: 0 4px 12px #20292320;
}

.runner-monitor::before,
.runner-monitor::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

/* Separate from the clipped road: circles move down and outward along both verges. */
.runner-monitor::before {
  z-index: 2;
  top: 12px;
  left: 12px;
  right: 12px;
  height: 108px;
  border-radius: 4px;
  background:
    radial-gradient(circle, var(--runner-dot-warm) 60%, transparent 70%),
    radial-gradient(circle, var(--runner-dot-coral) 60%, transparent 70%),
    radial-gradient(circle, var(--runner-dot-warm) 60%, transparent 70%),
    radial-gradient(circle, var(--runner-dot-coral) 60%, transparent 70%),
    radial-gradient(circle, var(--runner-dot-warm) 60%, transparent 70%),
    radial-gradient(circle, var(--runner-dot-coral) 60%, transparent 70%);
  background-repeat: no-repeat;
  background-position:
    calc(50% - 24px) 68px, calc(50% + 24px) 68px,
    calc(50% - 40px) 82px, calc(50% + 40px) 82px,
    calc(50% - 56px) 96px, calc(50% + 56px) 96px;
  background-size: 4px 4px, 4px 4px, 5px 5px, 5px 5px, 6px 6px, 6px 6px;
  mask-image: linear-gradient(transparent 72px, #000 80px 100px, transparent 108px);
}

/* Match the rounded screen's inner edge, above scenery AND sprite, not the bezel. */
.runner-monitor::after {
  z-index: 3;
  top: 12px;
  left: 12px;
  right: 12px;
  height: 108px;
  border-radius: 4px;
  background: repeating-linear-gradient(0deg, #102b2310 0 1px, transparent 1px 3px);
}

body[data-theme="dark"] .runner-monitor {
  --runner-dot-warm: #dfc17e;
  --runner-dot-coral: #cd9c9e;
  box-shadow: 0 4px 12px #00000040;
}

/* Flat, inert handheld controls use the existing aria-hidden decorative markup. */
.monitor-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 24px;
  margin: 9px 4px 0;
}

.monitor-controls::before,
.monitor-controls::after {
  content: "";
  display: block;
  background: var(--muted);
  opacity: .6;
}

.monitor-controls::before {
  width: 18px;
  height: 18px;
  clip-path: polygon(6px 0, 12px 0, 12px 6px, 18px 6px,
    18px 12px, 12px 12px, 12px 18px, 6px 18px, 6px 12px,
    0 12px, 0 6px, 6px 6px);
}

.monitor-controls::after {
  width: 9px;
  height: 9px;
  margin-right: 17px;
  border-radius: 50%;
  box-shadow: 16px -4px var(--muted);
}

.walkway {
  --runner-sky: #e3ebe7;
  --runner-cloud: #f2f3e9;
  --runner-building: #91a6a1;
  --runner-window: #dbe3cf;
  --runner-path: #6c8389;
  --runner-mark: #c3d7cd;
  position: relative;
  height: 112px;
  margin: 0;
  border: 2px solid #8c9e93;
  border-radius: 6px;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(var(--runner-cloud) 0 0) 12px 14px / 32px 6px no-repeat,
    linear-gradient(var(--runner-cloud) 0 0) 20px 10px / 16px 4px no-repeat,
    linear-gradient(var(--runner-cloud) 0 0) calc(100% - 14px) 24px / 30px 6px no-repeat,
    linear-gradient(var(--runner-cloud) 0 0) calc(100% - 20px) 20px / 18px 4px no-repeat,
    linear-gradient(transparent 76px, #b0bea8 76px),
    linear-gradient(#c5d2c8 0 0) 0 49px / 12% 30px no-repeat,
    linear-gradient(#bacbc4 0 0) 19% 38px / 15% 42px no-repeat,
    linear-gradient(#c5d2c8 0 0) 51% 32px / 12% 48px no-repeat,
    linear-gradient(#bacbc4 0 0) 78% 45px / 14% 35px no-repeat,
    linear-gradient(#c5d2c8 0 0) right 37px / 9% 43px no-repeat,
    var(--runner-sky);
}

.walkway::before,
.walkway::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

/* Window grids are clipped to individual rooflines, leaving a readable city silhouette. */
.walkway::before {
  inset: 27px 0 29px;
  z-index: 0;
  clip-path: polygon(
    0 23px, 8% 23px, 8% 10px, 22% 10px, 22% 29px,
    27% 29px, 27% 0, 43% 0, 43% 27px, 54% 27px,
    54% 15px, 68% 15px, 68% 32px, 75% 32px,
    75% 5px, 90% 5px, 90% 22px, 100% 22px,
    100% 100%, 0 100%
  );
  background:
    repeating-linear-gradient(90deg, transparent 0 4px, var(--runner-building) 4px 8px),
    repeating-linear-gradient(0deg, transparent 0 3px, var(--runner-building) 3px 8px),
    var(--runner-window);
}

/* Only the center dashes belong on the road. */
.walkway::after {
  z-index: 1;
  top: 72px;
  left: 50%;
  width: 124px;
  height: 40px;
  transform: translateX(-50%);
  clip-path: polygon(38% 0, 62% 0, 100% 100%, 0 100%);
  background:
    repeating-linear-gradient(0deg, transparent 0 8px, var(--runner-mark) 8px 12px) center top / 2px 12px repeat-y,
    linear-gradient(var(--runner-path) 0 0);
}

body[data-theme="dark"] .walkway {
  --runner-sky: #193b3b;
  --runner-path: #49635b;
  --runner-mark: #a6ad80;
  border-color: #142d2b;
  background:
    linear-gradient(#ded9b4 0 0) 83% 10px / 10px 14px no-repeat,
    linear-gradient(#ded9b4 0 0) 84% 12px / 14px 10px no-repeat,
    linear-gradient(#b7cdc1 0 0) 9% 11px / 2px 2px no-repeat,
    linear-gradient(#b7cdc1 0 0) 28% 26px / 2px 2px no-repeat,
    linear-gradient(#ddc895 0 0) 43% 8px / 2px 2px no-repeat,
    linear-gradient(#b7cdc1 0 0) 61% 20px / 2px 2px no-repeat,
    linear-gradient(#b7cdc1 0 0) 94% 33px / 2px 2px no-repeat,
    linear-gradient(#b7cdc1 0 0) 17% 37px / 2px 2px no-repeat,
    linear-gradient(#b7cdc1 0 0) 70% 5px / 2px 2px no-repeat,
    linear-gradient(#ddc895 0 0) 36% 18px / 2px 2px no-repeat,
    linear-gradient(#b7cdc1 0 0) 53% 38px / 2px 2px no-repeat,
    linear-gradient(transparent 80px, #345346 80px),
    linear-gradient(#355b50 0 0) left 49px / 20% 35px no-repeat,
    linear-gradient(#355b50 0 0) 20% 42px / 26% 42px no-repeat,
    linear-gradient(#355b50 0 0) 40% 50px / 20% 34px no-repeat,
    linear-gradient(#2d4e43 0 0) 65% 57px / 30% 27px no-repeat,
    linear-gradient(#2d4e43 0 0) right 48px / 27% 36px no-repeat,
    var(--runner-sky);
}

/* Two pitched-roof cottages replace the city, with amber windows facing the lane. */
body[data-theme="dark"] .walkway::before {
  inset: 47px 0 29px;
  clip-path: polygon(
    0 100%, 7% 100%, 7% 13px, 11% 13px, 11% 7px, 15% 7px,
    15% 2px, 19% 2px, 19% 7px, 23% 7px, 23% 13px, 27% 13px, 27% 100%,
    70% 100%, 70% 17px, 74% 17px, 74% 11px, 78% 11px,
    78% 6px, 82% 6px, 82% 11px, 86% 11px, 86% 17px, 90% 17px, 90% 100%, 100% 100%
  );
  background:
    linear-gradient(#e0b66c 0 0) 15% 20px / 5px 5px no-repeat,
    linear-gradient(#e0b66c 0 0) 83% 23px / 5px 5px no-repeat,
    linear-gradient(#253e34 0 0) 23% bottom / 4px 9px no-repeat,
    linear-gradient(#253e34 0 0) 74% bottom / 4px 9px no-repeat,
    linear-gradient(#244338 0 16px, #78907a 16px);
}

/* One size and anchor on every viewport and theme; only the GIF's own frames move. */
.walkway .walker {
  position: absolute;
  z-index: 2;
  height: 90px;
  width: auto;
  max-width: none;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  animation: none;
}

@keyframes runner-road {
  from { background-position: center 0, center 0; }
  to { background-position: center 24px, center 0; }
}

@keyframes runner-roadside {
  from {
    background-position:
      calc(50% - 24px) 68px, calc(50% + 24px) 68px,
      calc(50% - 40px) 82px, calc(50% + 40px) 82px,
      calc(50% - 56px) 96px, calc(50% + 56px) 96px;
    background-size: 4px 4px, 4px 4px, 5px 5px, 5px 5px, 6px 6px, 6px 6px;
  }
  to {
    background-position:
      calc(50% - 40px) 82px, calc(50% + 40px) 82px,
      calc(50% - 56px) 96px, calc(50% + 56px) 96px,
      calc(50% - 72px) 110px, calc(50% + 72px) 110px;
    background-size: 5px 5px, 5px 5px, 6px 6px, 6px 6px, 7px 7px, 7px 7px;
  }
}

/* Opt in for pseudo-elements too; both preference paths leave a complete static scene. */
@media (prefers-reduced-motion: no-preference) {
  body:not(.motion-off) .walkway::after {
    animation: runner-road 1.6s linear infinite reverse;
  }
  body:not(.motion-off) .runner-monitor::before {
    animation: runner-roadside 1.6s linear infinite reverse;
  }
}

@media (max-width: 760px) {
  .runner-monitor { display: none; }
}
