/* Bit's game inherits the live palette and typefaces of the personal site. */
.runner {
  width: min(820px, calc(100% - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--card);
  color: var(--text);
  font-family: 'Quicksand', sans-serif;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--accent-2) var(--card);
}
.runner::backdrop { background: rgb(0 0 0 / 72%); }
.runner[open] { animation: runner-arrive 240ms cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes runner-arrive {
  from { opacity: 0.5; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: none; }
}
.runner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 24px 8px;
}
.runner-header h2 {
  flex: 1;
  margin: 0;
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(1.4rem, 4vw, 1.75rem);
  font-weight: 600;
  line-height: 1.15;
  color: var(--accent-bright);
}
.runner button { font: inherit; cursor: pointer; touch-action: manipulation; }
.runner button:focus-visible,
.runner-stage:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: -4px; }
.runner-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 0 -8px 0 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text-soft);
}
.runner-icon:hover { background: var(--surface-2); color: var(--text); }
.runner svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.runner-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px 16px;
}
.runner-scores { display: flex; gap: 24px; }
.runner-controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.runner-sound { margin: 0; }
.runner-sound[hidden] { display: none; }
.runner-sound-muted,
.runner-sound[aria-pressed="false"] .runner-sound-waves { display: none; }
.runner-sound[aria-pressed="false"] .runner-sound-muted { display: block; }
.runner-scores > span { display: flex; flex-direction: column; gap: 2px; color: var(--text-soft); font-size: 0.75rem; line-height: 1.3; }
.runner-scores strong {
  display: inline-block;
  min-width: 4ch;
  color: var(--accent-bright);
  font-family: 'Space Mono', monospace;
  font-size: 1.15rem;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.runner-pause {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 88px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  font-size: 0.82rem !important;
}
.runner-pause:hover:enabled { background: var(--surface-2); }
.runner-pause:disabled { opacity: 0.4; cursor: default; }
.runner-pause svg { width: 16px; height: 16px; }
.runner-resume-symbol,
.runner[data-state="paused"] .runner-pause-symbol { display: none; }
.runner[data-state="paused"] .runner-resume-symbol { display: block; }
.runner-stage {
  position: relative;
  isolation: isolate;
  height: clamp(260px, 34vw, 300px);
  background: var(--bg);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}
.runner-stage canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.runner-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 24px 36px;
  text-align: center;
  background: color-mix(in srgb, var(--bg) 60%, transparent);
}
.runner-overlay[hidden] { display: none; }
.runner-overlay h3 {
  margin: 0 0 20px;
  max-width: 24ch;
  color: var(--accent-bright);
  font-family: 'Fredoka', sans-serif;
  font-size: clamp(1.4rem, 3.6vw, 1.8rem);
  font-weight: 400;
  line-height: 1.2;
  text-wrap: balance;
}
.runner-overlay p {
  max-width: 38ch;
  margin: 0 0 22px;
  color: var(--text-soft);
  font-size: 0.9rem;
  line-height: 1.6;
  text-wrap: pretty;
}
.runner-overlay p[hidden] { display: none; }
.runner[data-state="over"] .runner-overlay h3 { margin-bottom: 8px; }
.runner-action {
  min-width: 144px;
  min-height: 46px;
  padding: 10px 24px;
  border: 0;
  border-radius: 12px;
  background: var(--accent-bright);
  color: var(--on-accent);
  font-weight: 700 !important;
  transition: transform 120ms ease-out, background 120ms ease-out;
}
.runner-action:hover { background: var(--accent); }
.runner-action:active { transform: scale(0.96); }
.runner-action:focus-visible { outline-color: var(--on-accent) !important; }
.runner-footer { padding: 14px 24px; text-align: center; }
.runner-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; }
.runner-footer p { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 20px; margin: 0; color: var(--text-soft); font-size: 0.78rem; line-height: 1.5; }
.runner-footer kbd { font: inherit; color: var(--accent-bright); }
.runner-touch { display: none; }
.runner [hidden] { display: none; }
.runner-text-button {
  min-height: 44px;
  padding: 8px 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--accent-bright);
  font-size: 0.82rem !important;
  text-underline-offset: 4px;
}
.runner-text-button:hover { text-decoration: underline; }
.runner-board-toggle { flex-shrink: 0; }
.runner-share { margin-top: 6px; }
.runner[data-state="ready"] .runner-share { display: none; }
.runner[data-state="over"] .runner-overlay { padding-block: 16px; }
.runner[data-state="over"] .runner-overlay p { margin-bottom: 14px; }
.runner-board-back { margin: 0 -8px 0 -8px; }
.runner-board { padding: 4px 24px 20px; min-height: 200px; }
.runner-score-form { padding: 8px 0 20px; }
.runner-share-result { margin: 0 0 16px; color: var(--accent-bright); font-size: 1.15rem; font-weight: 700; }
.runner-score-form label { display: block; margin-bottom: 6px; color: var(--text-soft); font-size: 0.8rem; }
.runner-name-row { display: flex; align-items: center; gap: 8px; }
.runner-name-row input {
  width: 100%;
  min-width: 0;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  color: var(--text);
  caret-color: var(--accent-bright);
  font: inherit;
  font-size: 16px;
}
.runner-name-row input::placeholder { color: var(--text-soft); }
.runner-name-row input:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
.runner-save { flex-shrink: 0; min-width: 112px; padding-inline: 16px; }
.runner-save:disabled { opacity: 0.6; cursor: wait; }
.runner-board-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.runner-board-table th { padding: 10px 8px; color: var(--text-soft); font-size: 0.75rem; font-weight: 400; text-align: left; }
.runner-board-table td { padding: 11px 8px; border-top: 1px solid var(--line); font-size: 0.9rem; overflow-wrap: anywhere; }
.runner-board-table :is(th, td):first-child { width: 36px; padding-left: 0; color: var(--text-soft); }
.runner-board-table :is(th, td):last-child { width: 88px; padding-right: 0; text-align: right; font-variant-numeric: tabular-nums; }
.runner-board-table .is-you td { color: var(--accent-bright); font-weight: 700; }
.runner-board-message, .runner-share-feedback, .runner-board-own { margin: 8px 0; color: var(--text-soft); font-size: 0.85rem; line-height: 1.5; }
.runner-board-message:empty, .runner-share-feedback:empty { display: none; }
.bit-is-playing .bit-track { visibility: hidden; }
.bit-is-playing .bit, .bit-is-playing .bit-flip, .bit-is-playing .bit-leg { animation-play-state: paused !important; }
.bit-flip:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 4px; }
/* Freeze Bit while someone aims for the tiny moving sprite. The extra hit
   area makes him catchable with a thumb without changing his visible size. */
.bit-flip::after { content: ''; position: absolute; inset: -9px; }
.bit-track:has(.bit-flip:hover) .bit,
.bit-track:has(.bit-flip:focus-visible) .bit,
.bit-track:has(.bit-flip:hover) .bit-flip,
.bit-track:has(.bit-flip:focus-visible) .bit-flip { animation-play-state: paused; }
.bit-track:has(.bit-flip:focus-visible) .bit { animation: none; transform: translateX(calc(50% - 17px)); }
.bit-flip:focus-visible { animation: none; transform: none; }
@media (pointer: coarse), (max-width: 520px) {
  .runner-keyboard { display: none; }
  .runner-touch { display: inline; }
}
@media (max-width: 520px) {
  .runner { width: calc(100% - 24px); border-radius: 20px; }
  .runner-header { padding: 12px 16px 4px; }
  .runner-toolbar { padding: 0 16px 12px; }
  .runner-scores { gap: 20px; }
  .runner-controls { gap: 4px; }
  .runner-pause { width: 44px; min-width: 44px; border: 0; }
  .runner-pause span { display: none; }
  .runner-pause svg { width: 20px; height: 20px; }
  .runner-stage { height: clamp(220px, 65vw, 300px); }
  .runner-footer { padding: 12px 16px; }
  .runner-footer p { gap: 6px 16px; }
  .runner-footer p { justify-content: flex-start; gap: 2px; }
  .runner-footer p > span { flex-basis: 100%; }
  .runner-board { padding-inline: 16px; }
}
@media (max-height: 500px) {
  .runner-header { padding-top: 8px; padding-bottom: 4px; }
  .runner-stage { height: 200px; }
  .runner-toolbar { padding-bottom: 8px; }
  .runner-footer { padding-block: 10px; }
  .runner[data-state="over"] .runner-overlay { padding-block: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  .runner[open] { animation: none; }
  .runner-action { transition: none; }
}
