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

.k-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.k-main {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.k-board {
  flex: 1 1 60%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.k-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1.5px solid var(--text);
  border-radius: 8px;
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
}

.k-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
}

.k-screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

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

.k-hud-btns {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
}

.k-hud-btns.hidden {
  display: none;
}

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

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

/* ---------- title & cards ---------- */

.k-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  max-width: 520px;
  padding: 16px 22px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  text-align: center;
}

.k-logo {
  font-size: clamp(2.6rem, 8vw, 5.4rem);
  font-weight: 900;
  font-style: italic;
  line-height: 0.9;
  letter-spacing: -0.05em;
  text-transform: uppercase;
}

.k-logo-sm {
  font-size: clamp(2rem, 6vw, 3.6rem);
}

.k-logo::after {
  content: "";
  display: block;
  width: 70%;
  height: 8px;
  margin: 12px auto 0;
  background: repeating-linear-gradient(90deg, var(--text) 0 12px, #fff 12px 24px);
  border: 1.5px solid var(--text);
}

.k-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: 4px 4px 0 var(--text);
  text-align: center;
}

.k-card-title {
  margin: 2px 0 8px;
  font-size: 1.5rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

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

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

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

.k-live-result {
  margin-top: 8px;
}

.k-load {
  position: relative;
  height: 8px;
  margin-top: 10px;
  overflow: hidden;
  border: 1.5px solid var(--text);
  border-radius: 4px;
}

.k-load i {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--text);
  transition: width 0.2s ease;
}

/* ---------- driving controls (shown on every device; essential on touch) ---------- */

.k-controls {
  display: grid;
  grid-template-columns: 56px 56px 1fr 1fr;
  gap: 8px;
}

.k-controls.hidden {
  display: none;
}

.k-ctl {
  height: 44px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  border: 1.5px solid var(--text);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}

.k-ctl.on,
.k-ctl:active {
  background: var(--text);
  color: #fff;
}

.k-ctl-wide {
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

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

/* ---------- side panel ---------- */

.k-side {
  flex: 0 0 38%;
  max-width: 520px;
  max-height: min(78vh, 760px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 14px 14px;
  border: 1.5px solid var(--text);
  border-radius: 8px;
  background: #fff;
}

.k-side.hidden {
  display: none;
}

.k-side.k-blur {
  filter: blur(7px);
  pointer-events: none;
  user-select: none;
}

.k-setup {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.k-setup .q-pool-card {
  width: 100%;
}

.k-setup .g-btn small {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  font-weight: 500;
  opacity: 0.75;
}

.k-h {
  font-size: 1.08rem;
  font-weight: 900;
}

.k-len {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 700;
}

.k-len span {
  margin-right: 4px;
  color: var(--muted);
}

.k-len button {
  min-width: 40px;
  padding: 6px 10px;
  font: inherit;
  font-weight: 800;
  border: 1.5px solid var(--text);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
}

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

.k-code-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-dark, #bdbdbd);
}

.k-code-form label,
.k-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.k-code-form label span {
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--muted);
}

.k-code-row {
  display: flex;
  gap: 6px;
}

.k-input {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1.5px solid var(--text);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
}

#k-name.k-input {
  text-transform: none;
  letter-spacing: 0;
}

.k-note {
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--muted);
}

.k-or {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  color: var(--muted);
}

.k-or::before,
.k-or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.k-room-code {
  display: inline-block;
  margin: 4px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.8rem;
  letter-spacing: 0.22em;
  color: var(--text);
}

.k-lobby-status .g-btn {
  margin-top: 8px;
}

/* question while racing */

.k-q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.k-q-skill {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 10px;
  margin: 4px 0 10px;
  padding-bottom: 8px;
  font-size: 0.76rem;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.k-eta {
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.k-q-body .viewer-stimulus,
.k-q-body .viewer-stem {
  margin-bottom: 10px;
}

.k-choice {
  position: relative;
  padding-right: 64px;
}

.k-lane-tag {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 0.64rem;
  font-style: normal;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.k-choice.is-lane {
  box-shadow: inset 0 0 0 2px var(--text), 3px 3px 0 var(--text);
}

.k-choice.is-lane .k-lane-tag {
  color: var(--text);
}

.k-choice.is-lane .k-lane-tag::before {
  content: "▶ you · ";
}

.k-pit-go {
  margin: 4px 0 10px;
}

.k-pit-go kbd {
  padding: 0 4px;
  font: inherit;
  font-size: 0.7rem;
  border: 1px solid currentColor;
  border-radius: 3px;
}

.k-q-tools {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.k-between .g-review {
  margin-top: 0;
}

.k-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 10px 0;
}

.k-dots i {
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--text);
  border-radius: 50%;
}

.k-dots i.ok {
  background: var(--text);
}

.k-dots i.no {
  background: repeating-linear-gradient(45deg, var(--text) 0 2px, #fff 2px 4px);
}

/* post-race review */

.k-rev {
  margin-top: 8px;
  border: 1.5px solid var(--text);
  border-radius: 8px;
}

.k-rev.no {
  border-style: dashed;
}

.k-rev summary {
  display: grid;
  grid-template-columns: auto auto 1fr;
  align-items: baseline;
  gap: 2px 8px;
  padding: 8px 10px;
  font-size: 0.82rem;
  cursor: pointer;
}

.k-rev summary small {
  grid-column: 3;
  color: var(--muted);
}

.k-rev-mark {
  font-weight: 900;
}

.k-rev-body {
  padding: 0 12px 12px;
}

.k-rev-body .g-explain-body {
  margin-top: 10px;
}

/* ---------- phones: the race view stays pinned while the question scrolls ---------- */

@media (max-width: 719px) {
  .k-main {
    flex-direction: column;
    align-items: stretch;
  }

  .k-board {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 6px 0;
    background: var(--bg);
  }

  .k-stage {
    aspect-ratio: 16 / 10;
  }

  .k-controls {
    grid-template-columns: 50px 50px 1fr 1fr;
    gap: 6px;
  }

  .k-ctl {
    height: 40px;
  }

  .k-side {
    flex: none;
    max-width: none;
    max-height: none;
    overflow: visible;
  }

  .k-help {
    display: none;
  }
}
