:root {
  --bg: #f3f0e8;
  --panel: #fffdf7;
  --ink: #111111;
  --line: #242424;
  --guide: rgba(17, 17, 17, 0.16);
  /* type: system stacks only — UI sans for chrome, mono for numbers/params */
  --font-ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas,
    "Liberation Mono", monospace;
  /* ink alpha ramp (one palette everywhere instead of ad-hoc rgba values) */
  --ink-strong: rgba(17, 17, 17, 0.9);
  --ink-soft: rgba(17, 17, 17, 0.62);
  --ink-faint: rgba(17, 17, 17, 0.45);
  --ink-ghost: rgba(17, 17, 17, 0.3);
  /* hairlines and interactive accents */
  --hairline: rgba(17, 17, 17, 0.1);
  --hairline-strong: rgba(17, 17, 17, 0.16);
  --accent: #1a73e8;
  --accent-soft: rgba(26, 115, 232, 0.08);
  --accent-ring: rgba(26, 115, 232, 0.18);
  --up: #188038;
  --down: #d93025;
  /* warm shadows: tinted with the paper hue, never pure black */
  --shadow-sm: 0 1px 3px rgba(48, 39, 24, 0.07);
  --shadow-md: 0 4px 14px rgba(48, 39, 24, 0.09);
  --shadow-lg: 0 12px 32px rgba(48, 39, 24, 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --control-h: 38px;
  --ease: 140ms ease;
}

* {
  box-sizing: border-box;
  margin: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at top, #fffdf8 0%, var(--bg) 68%);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.mobile-body,
.display-body {
  display: flex;
  touch-action: none;
}

.mobile-stage,
.display-stage {
  position: relative;
  width: 100%;
  height: 100%;
  -webkit-user-select: none;
  user-select: none;
}

#mobile-canvas,
.display-frame,
#display-canvas {
  width: 100%;
  height: 100%;
}

.display-stage {
  padding: 4vmin;
}

.display-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  /* anchored layout: top bar pinned up; flexible pseudo-element spacers
     position the main block slightly below center (see ::before/::after) */
  justify-content: flex-start;
  gap: 0;
  border: 2px solid rgba(17, 17, 17, 0.14);
  border-radius: 28px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(255, 252, 245, 0.94));
  box-shadow: 0 28px 60px rgba(48, 39, 24, 0.08);
  overflow: hidden;
}

.top-bar {
  position: relative;
  z-index: 3;
  order: -2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  padding: 16px 20px 0;
}

/* flexible spacers: whitespace splits ~50:50 above/below the main block,
   so it sits slightly below center and stays put as the window resizes */
.display-frame::before {
  content: "";
  order: -1;
  flex: 1 1 0;
}

.display-frame::after {
  content: "";
  flex: 1 1 0;
}

#mobile-canvas,
#display-canvas {
  display: block;
}

.mobile-stage #mobile-canvas {
  position: absolute;
  inset: 0;
  z-index: 4;
  touch-action: none;
}

#display-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.cursor-marker {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 22px;
  height: 22px;
  border: 3px solid #111111;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 0 0 5px rgba(255, 204, 51, 0.28), 0 8px 18px rgba(17, 17, 17, 0.18);
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end; /* controls share a common 38px baseline row */
  gap: 8px 12px;
}

.setting {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.setting-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-left: 2px;
  white-space: nowrap;
}

.text-row {
  position: relative;
  z-index: 3;
  width: min(95%, 1260px);
  margin-bottom: 7vmin;
}

.decoded-text {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 78px;
  border: none;
  color: var(--ink);
  font: inherit;
  font-size: 1.8rem;
  letter-spacing: 0.01em;
  padding: 10px 32px;
  overflow: hidden;
  white-space: nowrap;
  /* open ends: solid center fading out at both sides; drop-shadow follows the
     alpha silhouette, so the shadow fades with the edges (mask would clip it) */
  background: linear-gradient(
    to right,
    transparent,
    #fffdf7 9%,
    #fffdf7 91%,
    transparent
  );
  filter: drop-shadow(0 5px 12px rgba(48, 39, 24, 0.2));
}

.mode-select {
  height: var(--control-h);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
  padding: 0 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}

.mode-select:hover:not(:disabled) {
  border-color: rgba(17, 17, 17, 0.32);
  box-shadow: 0 2px 6px rgba(48, 39, 24, 0.1);
}

.mode-select:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.mode-select:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.text-action {
  height: 48px;
  border: 1.5px solid rgba(17, 17, 17, 0.24);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.74);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 0.95rem;
  padding: 0 14px;
  transition: background-color var(--ease), border-color var(--ease);
}

.text-action:hover {
  background: #ffffff;
  border-color: rgba(17, 17, 17, 0.4);
}

.text-action:active {
  transform: translateY(1px);
}

.keyboard-shell {
  --key-width: 8.4vmin;
  --key-height: 10vmin;
  --key-border: 1.5px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  width: fit-content;
  max-width: 100%;
  padding: 0;
}

.keyboard-row {
  display: flex;
  gap: 0;
}

.key {
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--key-width);
  height: var(--key-height);
  max-height: 112px;
  border: var(--key-border) solid rgba(17, 17, 17, 0.2);
  border-radius: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(247, 242, 231, 0.93));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), inset 0 -2px 0 rgba(48, 39, 24, 0.04);
  color: var(--ink-strong);
  font-size: clamp(1rem, 2.5vmin, 1.8rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  margin-left: calc(-1 * var(--key-border));
  margin-top: calc(-1 * var(--key-border));
  -webkit-user-select: none;
  user-select: none;
}

.keyboard-row .key:first-child {
  margin-left: 0;
}

.keyboard-row:first-child .key,
.candidate-strip + .keyboard-row .key {
  margin-top: 0;
}

.keyboard-row-offset-sm {
  margin-left: calc(var(--key-width) / 2);
}

.keyboard-row-offset-lg {
  margin-left: var(--key-width);
}

.key-anchor {
  background: linear-gradient(180deg, rgba(255, 244, 199, 0.98), rgba(245, 223, 143, 0.92));
}

.is-continuous-mode .key-anchor,
.is-absolute-mode .key-anchor {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.97), rgba(247, 242, 231, 0.93));
}

.mobile-keyboard-overlay {
  --overlay-x: 50%;
  --overlay-y: 50%;
  position: absolute;
  left: var(--overlay-x);
  top: var(--overlay-y);
  transform: translate(-50%, -50%);
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease-out;
}

.mobile-keyboard-overlay.is-visible {
  opacity: 1;
}

.is-mobile-keyboard-hidden .mobile-keyboard-overlay.is-visible {
  opacity: 0;
}

.is-absolute-mode .mobile-keyboard-overlay {
  left: 50%;
  top: auto;
  bottom: max(44px, 7vh);
  transform: translateX(-50%);
  opacity: 1;
}

.is-absolute-mode.is-mobile-keyboard-hidden .mobile-keyboard-overlay {
  opacity: 0;
}

.keyboard-shell-mobile {
  --key-width: clamp(18px, 4.6vw, 22px);
  --key-height: calc(var(--key-width) * 3);
  --key-border: 1px;
  padding: 0;
  margin-bottom: 0;
  filter: drop-shadow(0 10px 18px rgba(17, 17, 17, 0.18));
}

.keyboard-shell-mobile .key {
  height: var(--key-height);
  max-height: none;
  font-size: clamp(0.72rem, 2.1vw, 0.92rem);
  font-weight: 500;
  color: rgba(17, 17, 17, 0.88);
}

.is-absolute-mode .keyboard-shell-mobile {
  --key-width: min(9.4vw, 44px);
  --key-height: min(8vh, 72px);
  opacity: 0.92;
}

@media (max-width: 900px) {
  .top-bar {
    padding: 10px 12px 0;
  }

  .text-row {
    width: 96%;
    margin-bottom: 4vmin;
  }

  .mode-select {
    height: 34px;
    font-size: 0.8rem;
    max-width: 110px;
    padding: 0 6px;
  }

  .decoded-text {
    min-height: 50px;
    font-size: 1.15rem;
    padding: 8px 20px;
  }

  .keyboard-shell {
    --key-width: 8.4vmin;
    --key-height: 9vmin;
    padding: 0;
  }

  .keyboard-shell-mobile {
    --key-width: clamp(18px, 4.6vw, 22px);
    --key-height: calc(var(--key-width) * 3);
    padding: 0;
  }

  .is-absolute-mode .keyboard-shell-mobile {
    --key-width: min(9.4vw, 44px);
    --key-height: min(8vh, 72px);
  }

  .key {
    font-size: clamp(0.9rem, 2.3vmin, 1.4rem);
  }

  .keyboard-shell-mobile .key {
    font-size: clamp(0.72rem, 2.1vw, 0.92rem);
  }
}

/* ---- pairing: room code badge (display top bar) ---- */
.room-code {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  background: rgba(20, 22, 28, 0.88);
  color: #e8eaed;
  font-family: var(--font-ui);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}
.room-code-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.6;
}
.room-code-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.18em;
  line-height: 1;
}
.room-code-status {
  font-size: 11px;
  opacity: 0.7;
}
.room-code.is-paired {
  background: rgba(20, 60, 35, 0.9);
}
.room-code.is-paired .room-code-status {
  color: #7ee2a8;
  opacity: 1;
}

/* ---- pairing: session picker (mobile) ---- */
.session-picker {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0f1115;
  color: #e8eaed;
  font-family: var(--font-ui);
}
.session-picker.is-hidden {
  display: none;
}
.picker-card {
  width: min(88vw, 22rem);
  text-align: center;
  padding: 1.5rem;
}
.picker-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.3rem;
  letter-spacing: 0.01em;
}
.picker-hint {
  margin: 0 0 1.25rem;
  color: #9aa0a6;
  font-size: 0.95rem;
}
.session-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  min-height: 3.3rem;
}
.session-item {
  min-width: 5.5rem;
  padding: 0.9rem 1.1rem;
  font-size: 1.6rem;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
  border: none;
  border-radius: 0.7rem;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(26, 115, 232, 0.3);
  transition: background-color var(--ease);
}
.session-item:active {
  background: #155ab6;
}
.session-empty {
  color: #9aa0a6;
  font-size: 0.9rem;
  padding: 0.75rem 0;
}
.picker-status {
  min-height: 1.1rem;
  margin: 1rem 0 0.5rem;
  color: #f0a0a0;
  font-size: 0.9rem;
}
.picker-refresh {
  margin-top: 0.5rem;
  padding: 0.6rem 1.4rem;
  border: 1px solid #3a3f4a;
  border-radius: 0.6rem;
  background: transparent;
  color: #e8eaed;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color var(--ease), border-color var(--ease);
}
.picker-refresh:active {
  background: rgba(255, 255, 255, 0.08);
}

/* ---- candidate bar: permanent in-flow row inside the keyboard shell,
        aligned with the top key row (spans keyboard x in [-5, 5]) ---- */
.candidate-strip {
  display: flex;
  width: 100%;
  height: 3.3rem;
  margin-bottom: 2vmin; /* the buffer gap that guards against accidental entry */
  border: 1px solid rgba(17, 17, 17, 0.14);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}
.candidate-seg {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.4rem;
  border: none;
  border-right: 1px solid #ece9e1;
  background: transparent;
  color: #202124;
  font: inherit;
  font-size: 1rem;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: background-color var(--ease), color var(--ease);
}
.candidate-seg:last-child {
  border-right: none;
}
.candidate-seg.is-top {
  font-weight: 700;
}
.candidate-seg.is-hover {
  background: var(--accent);
  color: #ffffff;
}

/* The phone shows no candidate UI; selection is decided from the display cursor
   position on the server. See server.py candidate_slot / mobile.js. */

/* backspace / clear segments in the candidate bar (touchpad-only, like candidates) */
.candidate-seg.candidate-action {
  color: #5f6368;
  background: #f4f2ec;
  font-weight: 600;
}
.candidate-seg.candidate-action.is-hover {
  background: var(--accent);
  color: #ffffff;
}

/* ---- build version badge (bottom-right, both pages) ---- */
.build-badge {
  position: fixed;
  right: 8px;
  bottom: 6px;
  z-index: 60;
  font-size: 10px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  color: var(--ink-faint);
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

/* ---- v3 letter input: mode badge + insertion caret ---- */
.letter-badge {
  position: absolute;
  top: -14px;
  right: 8px;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 3px 10px rgba(26, 115, 232, 0.35);
  font-family: var(--font-ui);
  z-index: 6;
}
.letter-badge.is-visible {
  display: flex;
}
.lb-letter {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.lb-hint {
  font-size: 0.72rem;
  opacity: 0.85;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.text-caret {
  display: inline-block;
  width: 3px;
  height: 1.25em;
  margin: 0 1px;
  vertical-align: text-bottom;
  background: var(--accent);
  border-radius: 2px;
  animation: caret-blink 0.85s steps(1) infinite;
}
@keyframes caret-blink {
  50% { opacity: 0.15; }
}

/* ---- LAN mode: direct-link indicator (bottom-left) ---- */
.lan-badge {
  position: fixed;
  left: 8px;
  bottom: 6px;
  z-index: 60;
  display: none;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(20, 60, 35, 0.9);
  color: #7ee2a8;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: var(--font-ui);
  pointer-events: none;
}
.lan-badge.is-visible {
  display: block;
}

/* USB direct link: button matches the settings row; status is a pill in the
   same family as the LAN badge (stacked above it, bottom-left). */
.usb-connect {
  padding: 0 14px;
  font-weight: 600;
}

.usb-status {
  position: fixed;
  left: 8px;
  bottom: 34px;
  z-index: 60;
  max-width: 60vw;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(30, 41, 59, 0.9);
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-family: var(--font-ui);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Decode-score panel: pre/post-bigram top-k side by side, right of the frame */
.display-stage {
  display: flex;
  gap: 16px;
  align-items: stretch;
}

.display-frame {
  flex: 1 1 auto;
  min-width: 0;
}

.score-panel {
  flex: 0 0 400px;
  align-self: stretch;
  display: flex;
  flex-direction: column;
  padding: 16px 16px 12px;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: #fffefb;
  box-shadow: var(--shadow-md);
}

.score-panel .score-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  /* keep content clear of the scrollbar gutter */
  padding-right: 4px;
  margin-right: -4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(17, 17, 17, 0.22) transparent;
}

/* WebKit scrollbar, matched to the thin Firefox styling above */
.score-panel .score-body::-webkit-scrollbar {
  width: 8px;
}
.score-panel .score-body::-webkit-scrollbar-track {
  background: transparent;
}
.score-panel .score-body::-webkit-scrollbar-thumb {
  background: rgba(17, 17, 17, 0.18);
  border-radius: 4px;
  border: 2px solid #fffefb;
}
.score-panel .score-body::-webkit-scrollbar-thumb:hover {
  background: rgba(17, 17, 17, 0.32);
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.score-cell {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: #ffffff;
}

.score-list {
  min-height: 212px; /* 10 rows reserved even when empty — no layout jumps */
}

.score-list.is-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

.score-list.is-placeholder {
  border: 1px dashed var(--hairline-strong);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--ink-ghost);
  text-align: center;
}

.score-params {
  border-top: 1px solid var(--hairline);
  padding-top: 12px;
}

.score-param-group {
  margin-bottom: 8px;
}

.score-param-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  padding: 2px 4px;
  border-radius: 4px;
}

.score-param-row:hover {
  background: rgba(17, 17, 17, 0.03);
}

.score-param-row .k {
  color: var(--ink-soft);
}

.score-param-row .v {
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.score-param-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin: 8px 0 4px;
}

.score-panel.collapsed {
  display: none;
}

.score-chevron {
  border: 1px solid var(--hairline-strong);
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  color: var(--ink-soft);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background-color var(--ease), color var(--ease), border-color var(--ease);
}

.score-chevron:hover {
  background: rgba(17, 17, 17, 0.06);
  color: var(--ink-strong);
}

.score-chevron:active {
  background: rgba(17, 17, 17, 0.1);
}

.score-expand-tab {
  position: fixed;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 65;
  width: 26px;
  height: 58px;
  border: 1px solid var(--hairline-strong);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.92);
  cursor: pointer;
  font-size: 14px;
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--ease), color var(--ease), box-shadow var(--ease);
}

.score-expand-tab:hover {
  color: var(--ink-strong);
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.score-expand-tab:active {
  background: rgba(17, 17, 17, 0.05);
}

.score-panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-strong);
  margin-bottom: 12px;
}

.score-panel-note {
  font-weight: 500;
  color: var(--ink-faint);
  text-transform: none;
  letter-spacing: 0.01em;
  font-family: var(--font-mono);
  font-size: 11px;
}

.score-cols {
  display: flex;
  gap: 16px;
}

.score-col {
  flex: 1 1 0;
  min-width: 0;
}

.score-col-head {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--hairline);
  padding-bottom: 6px;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12.5px;
  padding: 2px 4px;
  border-radius: 4px;
  /* the row's background doubles as the score bar (set inline via --w);
     the gradient is a background-image, so a hover background-color can
     sit underneath it without disturbing the bar */
  background: linear-gradient(90deg, rgba(26, 115, 232, 0.08) var(--w, 0%), transparent var(--w, 0%));
  transition: background-color var(--ease);
}

.score-row:hover {
  background-color: rgba(17, 17, 17, 0.04);
}

.score-rank {
  width: 15px;
  flex: none;
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--ink-ghost);
  font-variant-numeric: tabular-nums;
}

.score-word {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-row.is-top1 .score-word {
  font-weight: 700;
}

.score-val {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.score-delta {
  flex: none;
  width: 24px;
  text-align: right;
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.score-delta.up { color: var(--up); }
.score-delta.down { color: var(--down); }
.score-delta.same { color: var(--ink-ghost); }

.score-empty {
  font-size: 12px;
  color: var(--ink-faint);
  padding: 6px 2px;
}

body.score-panel-hidden .score-panel {
  display: none;
}

@media (max-width: 1150px) {
  .display-stage {
    flex-direction: column;
  }
  .score-panel {
    flex: none;
    align-self: stretch;
    max-height: none;
  }
}

/* Mobile touchpad settings: gear + cursor-speed slider */
.gear-btn {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 70;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--hairline-strong);
  background: rgba(255, 255, 255, 0.85);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink-soft);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--ease), color var(--ease), box-shadow var(--ease);
}

.gear-btn:hover {
  background: #ffffff;
  color: var(--ink-strong);
  box-shadow: var(--shadow-md);
}

.gear-btn:active {
  background: rgba(17, 17, 17, 0.06);
  color: var(--ink-strong);
}

.display-body .gear-btn,
.display-body .speed-panel {
  display: none; /* phone-only controls */
}

.speed-panel {
  position: fixed;
  top: 58px;
  right: 10px;
  z-index: 70;
  width: min(78vw, 280px);
  padding: 14px 16px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
}

.speed-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
}

.speed-panel input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.speed-hint {
  margin-top: 8px;
  font-size: 11px;
  letter-spacing: 0.01em;
  color: rgba(17, 17, 17, 0.5);
}

.speed-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.score-param-input {
  width: 72px;
  height: 22px;
  border: 1px solid var(--hairline-strong);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--ink);
  background: rgba(17, 17, 17, 0.02);
  transition: border-color var(--ease), box-shadow var(--ease), background-color var(--ease);
}

.score-param-input:hover {
  border-color: rgba(17, 17, 17, 0.3);
}

.score-param-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #ffffff;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

/* hide number-input spinners: they crowd the narrow param fields */
.score-param-input::-webkit-outer-spin-button,
.score-param-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.score-param-input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Parameter stepper buttons flanking each runtime input */
.score-param-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.score-param-step {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hairline, rgba(17, 17, 17, 0.16));
  border-radius: 5px;
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  color: var(--ink-soft, rgba(17, 17, 17, 0.55));
  transition: background-color 140ms ease, color 140ms ease;
}

.score-param-step:hover {
  background: rgba(17, 17, 17, 0.06);
  color: var(--ink-strong, rgba(17, 17, 17, 0.85));
}

.score-param-step:active {
  transform: translateY(0.5px);
}

/* Bottom action zone: Clear/Undo pill, bottom-LEFT under the Z key */
.action-strip {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  margin-top: 10px;
}

.action-pill {
  min-width: 84px;
  padding: 6px 18px;
  text-align: center;
  border: 1px solid var(--hairline, rgba(17, 17, 17, 0.16));
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft, rgba(17, 17, 17, 0.55));
  background: rgba(255, 255, 255, 0.7);
  transition: background-color 140ms ease, color 140ms ease;
}

.action-pill.is-hover {
  background: #d93025;
  border-color: #d93025;
  color: #ffffff;
}
