/* Ink Run (SAT Run parkour). Black and white, shares Graphite's buttons and question styles. */

body.mode-run .toolbar,
body.mode-run .main,
body.mode-run .header-right {
  display: none;
}

.r-shell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.r-stage {
  position: relative;
  height: var(--g-stage-h);
  overflow: hidden;
  border: 1.5px solid var(--text);
  border-radius: var(--g-radius);
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.r-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.r-stage:not(.is-touch) .r-canvas:hover {
  cursor: none;
}

.r-help {
  font-size: 0.78rem;
  line-height: 1.6;
  text-align: center;
  color: var(--muted);
}

.r-help b {
  color: var(--text);
}

/* ---------- HUD ---------- */

.r-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.r-hud-left,
.r-hud-right,
.r-hud-mid {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border: 1.5px solid var(--text);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.82rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  pointer-events: auto;
}

.r-hud-mid {
  flex: 0 1 260px;
  min-width: 0;
}

.r-hud-right {
  padding: 3px 4px 3px 10px;
}

.r-level {
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.r-hearts {
  display: inline-flex;
  gap: 1px;
  font-size: 0.95rem;
  line-height: 1;
}

.r-hearts i {
  font-style: normal;
  color: #d4d4d4;
}

.r-hearts i.on {
  color: var(--text);
}

.r-seed {
  flex: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.r-progress {
  position: relative;
  flex: 1 1 auto;
  min-width: 40px;
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--text);
  border-radius: 3px;
}

.r-progress i {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--text);
}

.r-time {
  min-width: 3.2em;
  color: var(--muted);
}

.r-combo {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--text);
  color: #fff;
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  animation: r-pop 0.18s ease;
}

.r-combo.hidden {
  display: none;
}

@keyframes r-pop {
  from {
    transform: scale(1.35);
  }
}

/* ---------- Ink (ammo) ---------- */

.r-ink {
  position: absolute;
  left: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 6px 5px 10px;
  border: 1.5px solid var(--text);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  font-size: 0.78rem;
  font-weight: 800;
}

.r-ink.hidden {
  display: none;
}

.r-ink-label {
  letter-spacing: 0.08em;
}

.r-ink-pips {
  display: inline-flex;
  gap: 2px;
}

.r-ink-pips i {
  width: 6px;
  height: 14px;
  border: 1.5px solid var(--text);
  border-radius: 2px;
}

.r-ink-pips i.on {
  background: var(--text);
}

.r-ink-pips i.power {
  background: repeating-linear-gradient(45deg, var(--text) 0 2px, #fff 2px 4px);
}

.r-ink-extra {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.r-ink-extra:empty {
  display: none;
}

.r-refill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  border: 1.5px solid var(--text);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.r-refill kbd {
  padding: 0 4px;
  font: inherit;
  font-size: 0.68rem;
  border: 1px solid currentColor;
  border-radius: 3px;
}

.r-refill:hover,
.r-ink.is-empty .r-refill {
  background: var(--text);
  color: #fff;
}

.r-ink.is-empty .r-refill {
  animation: r-pulse 0.9s ease-in-out infinite;
}

.r-ink.is-low .r-ink-label,
.r-ink.is-empty .r-ink-label {
  text-decoration: underline wavy;
}

.r-ink.is-dry {
  animation: r-shake 0.3s linear;
}

@keyframes r-pulse {
  50% {
    transform: scale(1.08);
  }
}

@keyframes r-shake {
  25% {
    transform: translateX(-4px);
  }
  75% {
    transform: translateX(4px);
  }
}

/* ---------- Boss bar ---------- */

.r-bossbar {
  position: absolute;
  top: 54px;
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: min(420px, 70%);
  transform: translateX(-50%);
  pointer-events: none;
}

.r-bossbar.hidden {
  display: none;
}

.r-boss-name {
  padding: 1px 8px;
  border-radius: 4px;
  background: var(--text);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.r-boss-hp {
  position: relative;
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 2px solid var(--text);
  border-radius: 4px;
  background: #fff;
}

.r-boss-hp i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text);
  transition: width 0.15s ease;
}

.r-bossbar.is-shield .r-boss-hp {
  border-style: dashed;
}

.r-bossbar.is-shield .r-boss-hp i {
  background: repeating-linear-gradient(45deg, var(--text) 0 4px, #fff 4px 8px);
}

.r-bossbar.is-stun .r-boss-name::after {
  content: " · stunned ×2";
}

.r-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  font: inherit;
  font-weight: 800;
  border: 1.5px solid var(--text);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.r-icon:hover {
  background: var(--text);
  color: #fff;
}

/* ---------- Screens & cards ---------- */

.r-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  pointer-events: none;
}

.r-screen.hidden {
  display: none;
}

.r-screen > * {
  pointer-events: auto;
}

.r-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 20px;
  border: 2px solid var(--text);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--g-shadow);
  text-align: center;
}

.r-card-title {
  margin: 2px 0 6px;
  font-size: 1.5rem;
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.r-card-sub {
  font-size: 0.86rem;
  color: #444;
}

.r-card-hint {
  margin: 8px 0 14px;
  font-size: 0.78rem;
  color: var(--muted);
}

.r-card .g-btn-wide {
  width: 100%;
  margin-top: 6px;
}

.r-card .r-end {
  width: 100%;
  margin-top: 6px;
}

.r-card-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.r-card .g-results-grid {
  grid-template-columns: repeat(2, 1fr);
}

/* ---------- Title ---------- */

.r-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 560px;
  padding: 18px 22px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
  text-align: center;
}

.r-logo {
  font-size: clamp(3rem, 9vw, 6.2rem);
  font-weight: 900;
  font-style: italic;
  line-height: 0.9;
  letter-spacing: -0.05em;
  text-transform: uppercase;
}

.r-logo::after {
  content: "";
  display: block;
  width: 70%;
  height: 7px;
  margin: 12px auto 0;
  border-radius: 4px;
  background: var(--text);
  clip-path: polygon(0 0, 96% 0, 100% 50%, 96% 100%, 0 100%);
}

.r-title .g-tagline {
  max-width: 440px;
  margin-bottom: 8px;
}

.r-subjects {
  display: inline-flex;
  margin-bottom: 10px;
  border: 1.5px solid var(--text);
  border-radius: 8px;
  overflow: hidden;
}

.r-subjects button {
  padding: 7px 14px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  border: 0;
  border-left: 1.5px solid var(--text);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.r-subjects button:first-child {
  border-left: 0;
}

.r-subjects button.on {
  background: var(--text);
  color: #fff;
}

.r-subjects button:focus-visible {
  outline: 2px dashed var(--text);
  outline-offset: -4px;
}

.r-start {
  min-width: 220px;
  padding: 12px 22px;
  font-size: 1rem;
}

.r-title-foot {
  margin-top: 8px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

/* ---------- Touch controls ---------- */

.r-touch {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  pointer-events: none;
}

.r-touch.hidden {
  display: none;
}

.r-touch-move,
.r-touch-act {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.r-touch button {
  width: 64px;
  height: 64px;
  font: inherit;
  font-size: 1.3rem;
  font-weight: 800;
  border: 2px solid var(--text);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  pointer-events: auto;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.r-touch .r-touch-jump,
.r-touch .r-touch-fire {
  width: 78px;
  height: 78px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

.r-touch .r-touch-fire {
  margin-bottom: 40px;
}

.r-touch .r-touch-dash {
  width: 54px;
  height: 54px;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
}

/* touch players: ink gauge moves up out of the thumbs' way */
.r-stage.is-touch .r-ink {
  left: 50%;
  bottom: auto;
  top: 52px;
  transform: translateX(-50%);
}

.r-stage.is-touch .r-bossbar {
  top: 92px;
}

.r-touch button.on {
  background: var(--text);
  color: #fff;
}

/* ---------- Question modal ---------- */

.r-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(2px);
}

.r-modal.hidden {
  display: none;
}

.r-modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 20px;
  border: 2px solid var(--text);
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--g-shadow);
}

.r-q-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 30px 10px;
  font-size: 0.9rem;
  text-align: center;
  color: var(--muted);
}

.r-q-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.r-q-head h3 {
  margin: 2px 0 0;
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.2;
}

.r-q-skill {
  margin: 4px 0 12px;
  padding-bottom: 10px;
  font-size: 0.78rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.r-q-body .viewer-stimulus {
  margin-bottom: 12px;
}

.r-q-body .viewer-stem {
  margin-bottom: 12px;
}

.r-q-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.r-q-actions .r-lock {
  min-width: 140px;
}

.r-q-result:not(:empty) {
  margin-top: 12px;
}

.r-q-result .r-continue {
  margin-top: 10px;
}

@media (max-width: 640px) {
  .r-stage {
    height: min(var(--g-stage-h), 115vw);
  }

  .r-hud {
    top: 6px;
    left: 6px;
    right: 6px;
    flex-wrap: wrap;
    gap: 6px;
  }

  .r-hud-mid {
    order: 3;
    flex: 1 1 100%;
  }

  .r-hud-left,
  .r-hud-right,
  .r-hud-mid {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .r-hud-right {
    padding: 2px 3px 2px 8px;
    gap: 5px;
  }

  .r-hud-left {
    gap: 5px;
  }

  .r-time {
    display: none;
  }

  .r-hearts {
    font-size: 0.8rem;
  }

  .r-icon {
    width: 24px;
    height: 24px;
  }

  .r-help {
    display: none;
  }

  .r-touch button {
    width: 50px;
    height: 50px;
  }

  .r-touch .r-touch-jump,
  .r-touch .r-touch-fire {
    width: 64px;
    height: 64px;
  }

  .r-touch .r-touch-fire {
    margin-bottom: 34px;
  }

  .r-touch .r-touch-dash {
    width: 46px;
    height: 46px;
  }

  .r-touch-move,
  .r-touch-act {
    gap: 6px;
  }

  .r-stage.is-touch .r-ink,
  .r-ink {
    top: 76px;
    bottom: auto;
    left: 50%;
    transform: translateX(-50%);
    gap: 5px;
    padding: 3px 4px 3px 8px;
  }

  .r-ink-pips i {
    width: 4px;
    height: 12px;
  }

  .r-refill kbd {
    display: none;
  }

  .r-bossbar,
  .r-stage.is-touch .r-bossbar {
    top: 112px;
    width: 86%;
  }

  .r-modal {
    align-items: flex-end;
    padding: 0;
  }

  .r-modal-card {
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 12px 12px 0 0;
    border-bottom: 0;
    box-shadow: none;
  }
}
