/* Article Runner page. It follows the vocabulary page: one rounded card,
   square ruled controls, bold uppercase interface text and no accent
   colour. The game world inside the arena is drawn on its canvas. */
.runner-page {
  --background: #000;
  --card: #101010;
  --panel: #191919;
  --foreground: #fff;
  --muted: #9a9a9a;
  --rule: #3a3a3a;
  --line: #2b2b2b;
  --miss: #ff5a4f;

  margin: 0;
  padding: 14px;
  background: var(--background);
  color: var(--foreground);
  font-family: "Inter", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color-scheme: dark;
}

.runner-page *,
.runner-page *::before,
.runner-page *::after {
  box-sizing: border-box;
}

.runner-page [hidden] {
  display: none !important;
}

.runner-page :where(button, a) {
  -webkit-tap-highlight-color: transparent;
}

.runner-page :where(button, a):focus-visible {
  outline: 3px solid #fff;
  outline-offset: 4px;
}

/* :where keeps this weightless, so the button styles below set the colour. */
.runner-page :where(button) {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.runner-page button:disabled {
  cursor: default;
}

.runner-page a {
  color: inherit;
  text-decoration: none;
}

/* The gradients the target artwork shares; kept rendered so they resolve. */
.sprite-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* ---- Page frame ---------------------------------------------------------- */

/* The page sits inside one rounded card */
.runner-card {
  min-height: calc(100dvh - 28px);
  padding: 30px 40px 48px;
  border-radius: 30px;
  background: var(--card);
}

.runner-page .site-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin: 0 0 34px;
  font-size: clamp(0.75rem, 3.4vw, 3.25rem);
}

.runner-page .site-header h1 {
  margin: clamp(36px, 8vh, 96px) 0 0;
  font-family: inherit;
  font-size: 2em;
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.045em;
  text-transform: uppercase;
}

.runner-page .home-link {
  flex-shrink: 0;
  color: var(--foreground);
  font-family: inherit;
  font-size: 1em;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

/* ---- Buttons ------------------------------------------------------------- */

/* As on the vocabulary page: a grey square rule that turns white on hover,
   and a white button for the one thing to do next. */
.outline-button,
.solid-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 54px;
  padding: 0 22px;
  border: 2px solid var(--rule);
  border-radius: 0;
  background: transparent;
  color: var(--foreground);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.outline-button:hover:not(:disabled) {
  border-color: #fff;
}

.solid-button {
  border-color: #fff;
  background: #fff;
  color: #000;
}

.solid-button:hover:not(:disabled) {
  background: transparent;
  color: #fff;
}

.outline-button:disabled,
.solid-button:disabled {
  opacity: 0.35;
}

/* Small grey labels, as the vocabulary filters name their groups */
.hud-label,
.stat-label,
.overlay-label,
.result-label,
#instruction {
  display: block;
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---- The status bar ------------------------------------------------------ */

.run-hud {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) auto auto auto auto;
  grid-template-areas: "level progress score streak lives pause";
  align-items: center;
  column-gap: clamp(22px, 3vw, 44px);
  row-gap: 14px;
  padding: 0 0 18px;
}

.hud-level { grid-area: level; min-width: 0; }
.hud-progress { grid-area: progress; min-width: 0; }
.hud-score { grid-area: score; }
.hud-streak { grid-area: streak; }
.hud-lives { grid-area: lives; }
#pause-button { grid-area: pause; height: 44px; padding: 0 18px; font-size: 0.75rem; }

.hud-item .hud-label {
  margin-bottom: 8px;
  white-space: nowrap;
}

.hud-item strong {
  display: block;
  font-size: 1.3rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  line-height: 1;
  text-transform: uppercase;
  white-space: nowrap;
}

#course-count {
  margin-left: 6px;
  color: var(--foreground);
  font-variant-numeric: tabular-nums;
}

/* Three squares: white while you have the life, an empty rule once lost. */
#lives {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 1.3rem;
}

#lives .life {
  width: 16px;
  height: 16px;
  background: #fff;
  transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

#lives .life.lost {
  background: transparent;
  box-shadow: inset 0 0 0 2px var(--rule);
}

#lives.life-lost {
  animation: life-loss 0.45s ease-out;
}

/* Fifteen steps; the three doors stand taller. */
.progress-track {
  display: grid;
  grid-auto-columns: minmax(0, 1fr);
  grid-auto-flow: column;
  align-items: center;
  gap: 3px;
  height: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress-step {
  height: 6px;
  background: var(--line);
  transition: background-color 0.2s ease;
}

.progress-step.door {
  height: 14px;
  border: 2px solid var(--rule);
  background: transparent;
}

.progress-step.hit {
  border-color: #fff;
  background: #fff;
}

.progress-step.miss {
  border-color: var(--miss);
  background: var(--miss);
}

.progress-step.current {
  border-color: #fff;
  background: #fff;
  animation: step-pulse 0.8s ease-in-out infinite alternate;
}

/* ---- The sentence -------------------------------------------------------- */

/* In the panel the vocabulary page gives a word's details */
.sentence-panel {
  position: relative;
  padding: 20px 24px 24px;
  background: var(--panel);
}

.sentence-caption {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sentence-panel.is-door #instruction {
  color: var(--foreground);
}

.time-left {
  font-size: 0.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.06em;
}

#sentence {
  min-height: 1.3em;
  margin: 10px 0 0;
  font-size: clamp(19px, 2.55vw, 31px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

#sentence:focus {
  outline: none;
}

.sentence-blank {
  display: inline-block;
  min-width: 2.1em;
  font-weight: 400;
  letter-spacing: 0.05em;
  text-align: center;
}

.timer-track {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  overflow: hidden;
  background: var(--line);
}

#timer-fill {
  height: 100%;
  background: #fff;
  transform-origin: left;
  will-change: transform;
}

.sentence-panel.urgent .time-left {
  color: var(--miss);
}

.sentence-panel.urgent #timer-fill {
  background: var(--miss);
}

/* ---- The arena ----------------------------------------------------------- */

.arena {
  position: relative;
  isolation: isolate;
  height: clamp(380px, 40vw, 500px);
  overflow: hidden;
  background: #050505;
  touch-action: manipulation;
}

/* The world is drawn at about two hundred lines and scaled up with hard
   pixels, as the old games were. */
#world {
  position: absolute;
  z-index: -1;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
}

.targets {
  position: absolute;
  inset: 0;
}

/* Each target is a button laid over its sprite, moved every frame by the
   controller. The article sits on the sprite's plate as real text, so it
   is read out and never blurs. */
.article-target {
  position: absolute;
  top: 0;
  left: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  touch-action: manipulation;
  cursor: crosshair;
}

.article-target:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

.target-label {
  position: absolute;
  display: grid;
  place-items: center;
  font-weight: 900;
  letter-spacing: -0.02em;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  animation: label-in 0.3s ease-out both;
}

/* The article in a colour that suits what it is written on. */
.article-target[data-plate="metal"] .target-label {
  color: #f2f4f0;
  text-shadow: 0 0 6px rgba(255, 230, 160, 0.45);
}

.article-target[data-plate="slate"] .target-label {
  color: #c8f6ff;
  text-shadow: 0 0 8px rgba(127, 232, 255, 0.8);
}

.article-target[data-plate="parchment"] .target-label {
  color: #2a1a0a;
}

.article-target[data-plate="board"] .target-label {
  color: #f4f4f6;
}

.article-target[data-plate="banner"] .target-label,
.article-target[data-plate="door-slope"] .target-label {
  color: #12233a;
}

.article-target[data-plate="door-base"] .target-label {
  color: #a8ffbe;
  text-shadow: 0 0 8px rgba(90, 255, 122, 0.7);
}

.article-target[data-plate="door-school"] .target-label {
  color: #f0e8ff;
  text-shadow: 0 0 8px rgba(200, 180, 255, 0.8);
}

/* After a shot: the hit target's article goes with it, a miss turns red,
   the others dim, and when the run moves on they are gone. */
.targets.resolved .article-target {
  pointer-events: none;
}

.article-target.shot-correct .target-label {
  animation: label-out 0.3s ease-in forwards;
}

.article-target.shot-wrong .target-label {
  color: var(--miss);
  text-shadow: none;
}

.targets.resolved .article-target:not(.shot-correct):not(.shot-wrong) .target-label {
  opacity: 0.35;
}

.targets.leaving .article-target {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.hit-feedback {
  position: absolute;
  z-index: 1;
  top: 14px;
  left: 50%;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 7px 14px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--foreground);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-align: center;
  text-transform: uppercase;
  translate: -50% 0;
  pointer-events: none;
}

.hit-feedback:empty {
  padding: 0;
  background: none;
}

.hit-feedback:not(:empty) {
  animation: pop 0.3s ease-out;
}

.hit-feedback.miss {
  color: var(--miss);
}

/* Where the run has got to; it lands large, then settles in the corner. */
.zone-label {
  --zone-scale: 1.9;
  position: absolute;
  z-index: 1;
  bottom: 14px;
  left: 16px;
  margin: 0;
  padding: 5px 9px;
  background: rgba(0, 0, 0, 0.5);
  color: var(--foreground);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.17em;
  text-transform: uppercase;
  transform-origin: 0 100%;
  pointer-events: none;
}

.zone-label:empty {
  display: none;
}

.zone-label.show {
  animation: zone-in 2.6s ease-out both;
}

/* ---- Briefing and pause -------------------------------------------------- */

.arena-overlay {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgb(10 10 10 / 70%);
  text-align: center;
  backdrop-filter: blur(2px);
}

.overlay-card {
  max-width: 600px;
  max-height: 100%;
  padding: 5px;
  overflow: auto;
  scrollbar-width: thin;
}

.overlay-card h2 {
  margin: 10px 0 18px;
  font-size: clamp(30px, 4.6vw, 54px);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1;
  text-transform: uppercase;
}

.overlay-card h2:first-child {
  margin-top: 0;
}

/* What the level asks, split by quiet slashes as on the games page */
.run-facts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 22px;
  margin: 0 0 26px;
  padding: 0;
  list-style: none;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.run-facts li {
  position: relative;
  white-space: nowrap;
}

.run-facts li + li::before {
  position: absolute;
  left: -14px;
  color: #555;
  content: "/";
}

.load-status {
  max-width: 420px;
  margin: 14px auto 0;
  color: var(--miss);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.load-status:empty {
  display: none;
}

#retry-button {
  margin-top: 14px;
}

/* ---- Results ------------------------------------------------------------- */

.results-screen {
  animation: results-in 0.45s ease-out;
}

#result-title {
  margin: 10px 0 0;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  font-weight: 900;
  letter-spacing: -0.045em;
  line-height: 1;
  text-transform: uppercase;
  outline: none;
}

.results-screen[data-mode="over"] #result-label {
  color: var(--miss);
}

/* One row of figures: grey label, white number */
.result-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px 52px;
  margin: 34px 0 0;
  padding: 0;
  list-style: none;
}

.result-stat .stat-label {
  margin-bottom: 8px;
}

.result-stat strong {
  display: block;
  font-size: clamp(1.4rem, 2.4vw, 2rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 36px;
}

/* The mistakes: a heading ruled like the letters on the vocabulary page,
   then one sentence after another. */
.review {
  margin-top: 56px;
}

.review-heading {
  margin: 0;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.review-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.review-card {
  padding: 20px 0;
}

.review-card + .review-card {
  border-top: 1px solid var(--line);
}

.review-meta {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* The German and its explanation keep their own case. */
.review-sentence {
  margin: 10px 0 6px;
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.35;
}

.review-sentence mark {
  padding: 0 0.2em;
  background: #fff;
  color: #000;
}

.review-explanation {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ---- Motion -------------------------------------------------------------- */

@keyframes label-in {
  from { opacity: 0; }
}

@keyframes label-out {
  to { opacity: 0; transform: scale(1.3); }
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.85); }
}

@keyframes zone-in {
  0% { opacity: 0; transform: scale(var(--zone-scale)) translateY(-4px); }
  12%, 62% { opacity: 1; transform: scale(var(--zone-scale)); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes step-pulse {
  to { opacity: 0.45; }
}

@keyframes life-loss {
  50% { transform: scale(1.15); }
}

@keyframes results-in {
  from { opacity: 0; transform: translateY(12px); }
}

/* ---- Smaller screens ----------------------------------------------------- */

@media (max-width: 860px) {
  .runner-page {
    padding: 10px;
  }

  .runner-card {
    min-height: calc(100dvh - 20px);
    padding: 22px 20px 40px;
    border-radius: 22px;
  }
}

@media (max-width: 820px) {
  .run-hud {
    grid-template-columns: minmax(0, 1fr) auto auto;
    grid-template-areas:
      "level lives pause"
      "progress score streak";
    column-gap: 22px;
  }

  #level-name {
    white-space: normal;
    line-height: 1.1;
  }
}

@media (max-width: 650px) {
  .run-hud {
    column-gap: 16px;
    row-gap: 12px;
    padding-bottom: 14px;
  }

  .hud-item strong {
    font-size: 1.1rem;
  }

  #pause-button {
    height: 40px;
    padding: 0 12px;
    font-size: 0.7rem;
  }

  .sentence-panel {
    padding: 15px 16px 19px;
  }

  #sentence {
    min-height: 2.6em;
  }

  .arena {
    height: 380px;
  }


  .hit-feedback {
    top: 10px;
    font-size: 11px;
  }

  .zone-label {
    --zone-scale: 1.3;
    max-width: calc(100% - 32px);
  }

  .overlay-card h2 {
    font-size: 32px;
  }

  .run-facts {
    gap: 6px 18px;
    font-size: 0.68rem;
  }

  .run-facts li + li::before {
    left: -12px;
  }

  .outline-button,
  .solid-button {
    height: 44px;
    padding: 0 14px;
    font-size: 0.72rem;
  }

  .result-stats {
    gap: 18px 32px;
  }

  .review-meta {
    flex-direction: column;
    gap: 4px;
  }
}

@media (max-width: 350px) {
  .run-hud {
    column-gap: 12px;
  }

  .hud-item strong {
    font-size: 1rem;
  }

  .arena {
    height: 360px;
  }

  .arena-overlay {
    padding: 16px;
  }

  .overlay-card h2 {
    font-size: 28px;
  }
}

/* Phones on their side: keep the sentence and the targets on one screen. */
@media (max-height: 500px) and (min-width: 651px) {
  .run-hud {
    column-gap: 26px;
    padding-bottom: 8px;
  }

  .hud-item .hud-label {
    margin-bottom: 4px;
    font-size: 0.6rem;
  }

  .hud-item strong {
    font-size: 1.05rem;
  }

  #pause-button {
    height: 36px;
  }

  .sentence-panel {
    padding: 9px 17px 13px;
  }

  #sentence {
    margin-top: 3px;
    font-size: 20px;
  }

  .arena {
    height: clamp(230px, 58vh, 280px);
  }

  .hit-feedback {
    top: 7px;
    font-size: 11px;
  }

  .arena-overlay {
    padding: 14px;
  }

  .overlay-card h2 {
    margin: 8px 0 12px;
    font-size: 26px;
  }

  .run-facts {
    margin-bottom: 12px;
  }

  .overlay-card .solid-button {
    height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .runner-page *,
  .runner-page *::before,
  .runner-page *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }

}
