@font-face {
  font-family: "Liberation Mono";
  src: url("/static/fonts/LiberationMono-Regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Liberation Mono";
  src: url("/static/fonts/LiberationMono-Bold.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Top inset for every screen's top edge: the safe area, plus 2% of the
     viewport on touch devices (below). Mirrors Ekhart dev-0.2. */
  --top-inset: env(safe-area-inset-top, 0px);
  color-scheme: light;
  --bg: #ffffff;
  --fg: #141414;
  --muted: #5e6368;
  --ink: #2c333a;
  --tile: #f3f4f6;
  --key: #ffffff;
  --key-border: #2c333a;
  --key-down: #2c333a;
  --key-down-fg: #ffffff;
  --key-mute: #e4e4e4;
  --dot: #ee6b57;
  --dot-down: #c44734;
  --captured: #0077cc;
  --danger: #b42318;
  --on-accent: #1a120f;
  --gap: 3px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #10110f;
    --fg: #e7e4d8;
    --muted: #9b988c;
    --ink: #d9d6c8;
    --tile: #1a1c18;
    --key: #171814;
    --key-border: #d0cdb8;
    --key-down: #e7e4d8;
    --key-down-fg: #10110f;
    --key-mute: #2a2d27;
    --dot: #ff7a5c;
    --dot-down: #d4553c;
    --captured: #79d2e6;
    --danger: #ff9b8a;
    --on-accent: #1a120f;
  }
}

/* Touch devices: iOS 26 "Liquid Glass" frosts a band below the status
   bar, so push every screen ~2% further down to keep the UI out of it.
   The app still fits the viewport (100dvh), so nothing scrolls or
   bounces. */
@media (pointer: coarse) {
  :root { --top-inset: calc(env(safe-area-inset-top, 0px) + 2dvh); }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: "Liberation Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.3;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  border-radius: 0;
  appearance: none;
  -webkit-appearance: none;
}

#app {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg);
}

.screen-host {
  height: 100%;
  min-height: 0;
}

.boot {
  margin: 0;
  padding: calc(var(--top-inset) + 1.4rem) 1.15rem;
  letter-spacing: 0.08em;
}

.block {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: 1.5rem;
  text-align: center;
  background: var(--bg);
  color: var(--fg);
}

.block[hidden] { display: none !important; }

.block h1 { margin: 0; }

.block-msg {
  margin: 0;
  max-width: 16rem;
  font-size: 1.15rem;
  line-height: 1.35;
}

.screen {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.screen.start { position: relative; }

/* The Profile button: a person silhouette in the top-right corner of the
   title screen, keyed like the other buttons. A check badge appears once
   this device is logged in with Raven. 46px square, so the tap target is
   comfortably over 44px. */
.profile-icon {
  position: absolute;
  z-index: 3;
  top: calc(var(--top-inset) + 0.45rem);
  right: calc(env(safe-area-inset-right) + 0.55rem);
  width: 2.875rem;
  height: 2.875rem;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--key-border);
  border-radius: 0.65rem;
  background: var(--key);
  color: var(--ink);
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.profile-icon .profile-glyph {
  display: block;
  width: 1.6rem;
  height: 1.6rem;
}

.profile-icon.down {
  background: var(--key-down);
  border-color: var(--key-down);
  color: var(--key-down-fg);
}

.profile-icon:focus { outline: none; }

.profile-icon:focus-visible {
  outline: 3px solid var(--captured);
  outline-offset: 3px;
}

.profile-icon[hidden] { display: none; }

.profile-badge {
  position: absolute;
  top: -0.42rem;
  right: -0.42rem;
  width: 1.15rem;
  height: 1.15rem;
  display: none;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--captured);
  color: var(--bg);
}

.profile-badge svg {
  display: block;
  width: 0.72rem;
  height: 0.72rem;
}

.profile-icon.linked .profile-badge { display: flex; }

/* The title with the "beta" stamp tucked under its end. */
.title-row {
  align-self: flex-start;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: calc(100% - 2.6rem);
  margin: 0.15rem 0 0.55rem;
}

.title-row h1 { margin: 0; }

/* The red rubber stamp it wore up to 1.10, now under the title. */
.beta {
  margin: 0.3rem 0.15rem 0 0;
  padding: 0.2rem 0.42rem 0.16rem;
  background: #d01212;
  color: #fff;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  line-height: 1;
  text-transform: lowercase;
  transform: rotate(8deg);
  pointer-events: none;
}

.scroll {
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.start-body, .end-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: calc(var(--top-inset) + 1.4rem) 1.35rem 0.75rem;
}

.dock {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  padding: 0.75rem 0.6rem calc(env(safe-area-inset-bottom) + 0.95rem);
}

.dock .go {
  width: min(16rem, 78%);
  height: 3.5rem;
}

.credit {
  margin: 0.85rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.01em;
}

.credit .heart {
  color: var(--dot);
  font-size: 1.45em;
}

h1 {
  margin: 0.15rem 0 0.55rem;
  font-size: clamp(2.2rem, 12vw, 3.3rem);
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 0.95;
}

.kicker {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.04em;
  font-size: 0.92rem;
}

.rule {
  margin: 0.35rem 0;
  max-width: 22rem;
  line-height: 1.35;
}

.example { margin-top: 1.4rem; }

.screen.start .start-body {
  display: flex;
  flex-direction: column;
}

.screen.start .example {
  margin-top: auto;
  margin-bottom: auto;
}

.ex-label {
  margin: 0.85rem 0 0.35rem;
  color: var(--muted);
  letter-spacing: 0.16em;
  font-size: 0.72rem;
}

.found-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.found-count {
  margin: 0.85rem 0 0.35rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  font-size: 0.72rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.9rem;
}

.chip {
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.chip .lit { color: var(--dot); }
.chip .captured { color: var(--captured); }
.chip.no { color: var(--muted); text-decoration: line-through; }
.muted { color: var(--muted); }

.result-score {
  margin: 0.15rem 0 0;
  font-size: clamp(4rem, 22vw, 6rem);
  font-weight: 700;
  line-height: 0.85;
  font-variant-numeric: tabular-nums;
}

.rank {
  margin: 0.55rem 0 0.35rem;
  color: var(--muted);
}

.end-body .combo { margin: 1.15rem 0 0.35rem; }

.stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: calc(var(--top-inset) + 0.7rem) 1.1rem 0.2rem;
  min-height: 4.2rem;
}

.score-slot {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  min-width: 2.5rem;
}

.live-score {
  margin: 0;
  font-weight: 700;
  font-size: clamp(2rem, 11vw, 3rem);
  line-height: 0.85;
  font-variant-numeric: tabular-nums;
}

.end-score {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
}

.update-overlay {
  z-index: 28;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.update-card {
  position: relative;
  z-index: 1;
  width: min(18rem, 100%);
  padding: 1.35rem 1.2rem 1.2rem;
  background: var(--bg);
  color: var(--fg);
  border: 3px solid var(--ink);
  text-align: center;
}

.update-msg {
  margin: 0 0 1.15rem;
  font-weight: 700;
  line-height: 1.35;
}

.update-card .go {
  width: 100%;
  height: 3.5rem;
}

.audio-overlay {
  z-index: 27;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.audio-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: var(--bg);
}

.audio-card {
  position: relative;
  z-index: 1;
  width: min(18rem, 100%);
  padding: 1.35rem 1.2rem 1.2rem;
  background: var(--bg);
  color: var(--fg);
  border: 3px solid var(--ink);
  text-align: center;
}

.audio-title {
  margin: 0 0 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.audio-card .go {
  width: 100%;
  height: 3.5rem;
}

.audio-card .player {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.wave {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  height: 4.4rem;
  margin: 0 0 1.15rem;
}

.wave span {
  --peak: 0.72;
  display: block;
  width: 0.38rem;
  height: 3.3rem;
  background: var(--dot);
  transform: scaleY(0.28);
  transform-origin: center;
  animation: wave 0.95s ease-in-out infinite;
  animation-play-state: paused;
}

.wave.play span { animation-play-state: running; }

.wave span:nth-child(odd) { background: var(--dot); }
.wave span:nth-child(even) { background: var(--captured); }
.wave span:nth-child(1) { --peak: 0.38; animation-delay: -0.15s; }
.wave span:nth-child(2) { --peak: 0.62; animation-delay: -0.4s; }
.wave span:nth-child(3) { --peak: 0.9; animation-delay: -0.7s; }
.wave span:nth-child(4) { --peak: 0.55; animation-delay: -0.25s; }
.wave span:nth-child(5) { --peak: 1; animation-delay: -0.85s; }
.wave span:nth-child(6) { --peak: 0.7; animation-delay: -0.5s; }
.wave span:nth-child(7) { --peak: 0.95; animation-delay: -0.1s; }
.wave span:nth-child(8) { --peak: 0.48; animation-delay: -0.6s; }
.wave span:nth-child(9) { --peak: 0.82; animation-delay: -0.35s; }
.wave span:nth-child(10) { --peak: 0.58; animation-delay: -0.75s; }
.wave span:nth-child(11) { --peak: 0.88; animation-delay: -0.2s; }
.wave span:nth-child(12) { --peak: 0.42; animation-delay: -0.55s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.28); }
  50% { transform: scaleY(var(--peak)); }
}

.overlay-back {
  position: absolute;
  inset: 0;
  background: rgba(16, 17, 15, 0.45);
}

.sheet {
  position: absolute;
  left: 0.95rem;
  right: 0.95rem;
  top: calc(var(--top-inset) + 0.95rem);
  bottom: calc(env(safe-area-inset-bottom) + 0.95rem);
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg);
  color: var(--fg);
  border: 3px solid var(--ink);
}

.sheet-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.8rem 0.95rem;
  border-bottom: 2px solid var(--ink);
}

.sheet-title {
  margin: 0;
  letter-spacing: 0.16em;
  font-weight: 700;
}

.sheet-close {
  border: 2px solid var(--ink);
  padding: 0.28rem 0.6rem;
  font-weight: 700;
}

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.35rem 1rem 1.15rem;
}

.term-name {
  margin: 0.75rem 0 0.1rem;
  font-weight: 700;
}

.term-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.score-empty { margin-top: 1rem; }

/* Profile sheet */
.profile-banner {
  margin: 0.85rem 0 0.2rem;
  padding: 0.55rem 0.7rem;
  border: 2px solid var(--captured);
  font-size: 0.86rem;
  font-weight: 700;
}

.profile-kicker {
  margin: 0.95rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

/* The username, big, where the number used to be. Up to 20 characters. */
.profile-name {
  margin: 0 0 0.2rem;
  font-weight: 700;
  font-size: clamp(1.7rem, 9vw, 2.5rem);
  line-height: 1.1;
  color: var(--dot);
  overflow-wrap: anywhere;
}

/* The only place a player number shows. */
.profile-early {
  display: inline-block;
  margin: 0.2rem 0 0.35rem;
  padding: 0.12rem 0.45rem;
  border: 2px solid var(--captured);
  color: var(--captured);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* Where the number goes before there is one. */
.profile-claim {
  margin: 0.95rem 0 0.35rem;
  font-weight: 700;
  font-size: 1.12rem;
  line-height: 1.35;
  color: var(--dot);
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem 0.9rem;
  margin-top: 0.5rem;
}

.stat {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stat-val {
  font-weight: 700;
  font-size: 1.2rem;
}

.stat-name {
  color: var(--muted);
  font-size: 0.74rem;
}

.profile-best {
  margin: 0.2rem 0 0;
  padding-left: 1.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.profile-best li { margin: 0.12rem 0; }

.profile-daily-note { margin-top: 0.85rem; }

.profile-linked { color: var(--captured); }

.profile-privacy { margin-top: 0.15rem; }

.profile-switch {
  display: block;
  margin: 0.55rem auto 0.35rem;
  padding: 0.35rem 0.5rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  text-decoration: underline;
  cursor: pointer;
}

.profile-switch[disabled] { opacity: 0.6; }

/* "Change username": the same quiet link, left-aligned under the name. */
.profile-switch.profile-rename {
  margin: 0 0 0.3rem;
  padding: 0.25rem 0;
}

.profile-rename-note { margin: 0.1rem 0 0.3rem; }

/* Pick a username */
.username-label {
  display: block;
  margin: 0.95rem 0 0.3rem;
  font-weight: 700;
  font-size: 0.86rem;
}

.username-input {
  display: block;
  width: 100%;
  height: 3.2rem;
  margin: 0;
  padding: 0 0.75rem;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--key);
  color: var(--fg);
  font: inherit;
  font-size: 1.1rem; /* 16px or more: iOS doesn't zoom into the field */
  font-weight: 700;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.username-input:focus { border-color: var(--captured); }

.username-input[aria-invalid="true"] { border-color: var(--danger); }

.username-msg { margin-top: 0.45rem; min-height: 1.1em; }

.username-msg.error { color: var(--danger); font-weight: 700; }

.username-msg.ok { color: var(--captured); font-weight: 700; }

.username-note { margin-top: 0.2rem; }

.profile-link {
  color: inherit;
  font-weight: 700;
  overflow-wrap: anywhere;
}

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

.profile-status { margin-top: 0.6rem; }

.go.listen[disabled] { opacity: 0.6; }

/* "Your login expired, log in again": the first thing on the title screen
   until it's dismissed or the player logs in. It stops short of the
   Profile button (top right). */
.expired-note {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 0.35rem;
  margin: -0.85rem 3.2rem 0.9rem 0;
  border: 2px solid var(--dot);
  background: var(--bg);
  animation: note-in 0.22s ease-out;
}

@keyframes note-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.expired-text {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.5rem 0 0.5rem 0.65rem;
  text-align: left;
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.3;
  cursor: pointer;
}

.expired-go {
  flex: 0 0 auto;
  align-self: center;
  padding: 0.3rem 0.5rem;
  border: 2px solid var(--ink);
  border-radius: 0.45rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.expired-x {
  flex: 0 0 auto;
  width: 2.5rem;
  border-left: 2px solid var(--dot);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.expired-text.down, .expired-x.down { background: var(--tile); }

.expired-go.down {
  background: var(--key-down);
  color: var(--key-down-fg);
}

@media (prefers-reduced-motion: reduce) {
  .expired-note { animation: none; }
}

/* Email login, inside the Profile sheet. One step at a time; each fits a
   360 x 740 screen and the body scrolls when the keyboard is up. */
.login-step { animation: step-in 0.18s ease-out; }

@keyframes step-in {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: none; }
}

.profile-switch.login-back {
  margin: 0.45rem 0 0;
  padding: 0.3rem 0;
  text-decoration: none;
  font-weight: 700;
}

.login-title { margin-top: 0.55rem; }

.login-primary {
  display: block;
  width: 100%;
  margin-top: 0.55rem;
}

.login-primary[hidden],
.profile-switch[hidden] { display: none; }

.login-lead { overflow-wrap: anywhere; }

.login-check:empty { display: none; }

.login-check { margin-top: 0.5rem; }

/* The small reference under a verification failure ("Ref 600010"). */
.login-check.login-ref {
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
}

.login-privacy { margin-top: 0.9rem; }

/* The Turnstile widget: usually invisible (interaction-only). It borrows
   the body's side padding so the 300 px "flexible" widget fits a 360 px
   screen; narrower than 300 falls back to "compact". */
.ts-host {
  display: flex;
  justify-content: center;
  margin: 0 -0.75rem;
}

.ts-host > * { margin-top: 0.4rem; }

/* Six boxes over one real input. The input covers the boxes, invisible, so
   a tap anywhere focuses it and the OS code autofill and paste just work. */
.code-wrap {
  position: relative;
  margin: 0.9rem 0 0;
  max-width: 24rem;
}

.code-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.4rem;
}

.code-box {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 3.3rem;
  border: 2px solid var(--ink);
  background: var(--key);
  color: var(--fg);
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.code-box.filled { animation: pop 0.12s ease-out; }

.code-box.active {
  border-color: var(--captured);
  box-shadow: inset 0 0 0 1px var(--captured);
}

.code-box.active::after {
  content: "";
  width: 2px;
  height: 1.5rem;
  background: var(--captured);
  animation: caret 1s steps(1) infinite;
}

@keyframes caret {
  50% { opacity: 0; }
}

.code-wrap.bad .code-box { border-color: var(--danger); }

.code-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  -webkit-text-fill-color: transparent;
  font-size: 16px; /* iOS doesn't zoom into the field */
  /* Invisible by colour, not opacity: iOS offers no long-press Paste or
     one-time-code suggestion on an opacity: 0 field. */
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.code-input::selection { background: transparent; color: transparent; }

/* Autofill must not paint a tinted box over the code boxes. */
/* Two rules: a browser that doesn't know one pseudo-class drops only
   that rule. The long transition is what keeps the tint away. */
.code-input:autofill { transition: background-color 9999s step-end; }
.code-input:-webkit-autofill { transition: background-color 9999s step-end; }

.code-wrap:has(.code-input:disabled) .code-row { opacity: 0.6; }

.login-resend { margin-top: 0.7rem; }

/* The login code keypad (1.13): the in-game keyboard's keys (.key, .go,
   .mute, .back, .down and the light/dark key colours), laid out as a
   full-width Paste key over a 3x4 ten-key grid. Keys are a fixed share of
   the screen height so the code boxes, the pad and its toggle fit a
   360 x 740 screen with nothing scrolled. Same side inset as .kb. */
.kb-pad {
  --pad-key: clamp(2.5rem, 6.4vh, 3.4rem);
  display: flex;
  flex-direction: column;
  gap: calc(var(--gap) * 2);
  max-width: 24rem;
  margin: 0.55rem 0 0;
  padding: 0 max(0px, env(safe-area-inset-right)) 0 max(0px, env(safe-area-inset-left));
  touch-action: manipulation;
}

.kb-pad[hidden] { display: none; }

.kb-pad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: calc(var(--gap) * 2);
}

.kb-pad .key,
.kb-pad .go {
  height: var(--pad-key);
  width: 100%;
}

.kb-pad .pad-paste {
  font-size: clamp(1rem, 4.4vw, 1.2rem);
  letter-spacing: 0.01em;
}

.kb-pad .pad-enter { border-color: var(--captured); }

/* Keyboard focus on pad keys (Tab, switch access): a ring in the accent
   colour, outside the key so it never hides the pressed look. */
.kb-pad .key:focus-visible,
.kb-pad .go:focus-visible {
  outline: 3px solid var(--captured);
  outline-offset: 2px;
}

.profile-switch.login-keyboard { margin-top: 0.55rem; }

.login-resend[disabled] {
  text-decoration: none;
  opacity: 0.75;
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .login-step, .code-box.filled, .code-box.active::after { animation: none; }
}

.score-word {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.score-letters .trix,
h1 .trix { color: var(--dot); }

.score-letters .captured,
h1 .captured { color: var(--captured); }

.how-lead {
  margin: 0.85rem 0 0.35rem;
}

.how-score {
  margin: 1.2rem 0 0.2rem;
  font-weight: 700;
  font-size: 1.35rem;
}

.combo.mini {
  justify-content: center;
  gap: 0.65rem;
  padding: 0.95rem 0 0.15rem;
}

.combo.mini .tile {
  width: 2.85rem;
  border-width: 2px;
  border-radius: 0.5rem;
  font-size: 1.85rem;
}

.how-word {
  margin: 0.85rem 0;
  font-weight: 700;
  letter-spacing: 0.08em;
  font-size: 1.6rem;
}

.score-part {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.time {
  margin: 0;
  font-weight: 700;
  font-size: clamp(3.4rem, 20vw, 5.6rem);
  line-height: 0.8;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.05em;
}

.time.urgent { color: var(--dot); }

.combo {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: min(5vw, 1.2rem);
  padding: 0 1.15rem;
}

.stage .combo { margin-top: 1.5rem; }

.tile {
  width: min(22vw, 24vh, 6.5rem);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  border-radius: 0.85rem;
  background: var(--tile);
  color: var(--fg);
  font-weight: 700;
  font-size: calc(min(22vw, 24vh, 6.5rem) * 0.72);
  line-height: 1;
}

.combo.wait { opacity: 0.35; }

.tile.on {
  background: var(--dot);
  border-color: var(--dot);
  color: var(--on-accent);
}

.word-row {
  flex: 1 1 auto;
  min-height: 4.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 1.1rem;
}

.word {
  margin: 0;
  min-height: 1.15em;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1;
  max-width: 100%;
  white-space: nowrap;
}

.note {
  margin: 0.25rem 0 0;
  min-height: 1.15em;
  font-size: 0.82rem;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.note.miss { color: var(--danger); }

.dots {
  flex: 0 0 1.7rem;
  height: 1.7rem;
  margin-bottom: 0.55rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0 1.1rem;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  touch-action: pan-x;
  overscroll-behavior: contain;
}

.dots::-webkit-scrollbar { display: none; }

.dot {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: var(--dot);
  flex: 0 0 auto;
  animation: pop 0.16s ease-out;
}

/* Keyboard: four rows (Trixle Go, then three letter rows) of equal height.
   Row 2 is 10 equal keys.
   Row 3 is those same keys, centered (half a key of inset).
   Row 4 is a 10-column grid: a blank, seven letters, and a backspace
   that spans two columns so the letters stay aligned with row 2.
   Padding on row 3 is (width + key gap) / 20 per side. Do not "simplify" it.

   Height (1.9.1): the rows used to share 40% of the screen. They are now
   75% of that height, so keys are squarer and Trixle Go is shorter, and
   the keyboard sits --kb-lift higher for an easier reach. --kb-fixed is
   everything in the box that is not a row: top and bottom padding
   (including the safe-area inset), the three row gaps, and the Go row's
   bottom padding. The rows get 0.75 of what they had, the fixed parts stay
   as they were, and the lift is added on top of the safe-area inset. Keep
   --kb-fixed in step with the padding below and .kb-go's padding.

   Width (1.9.1): keys sit --kb-hgap apart (1px, was the shared 3px --gap)
   and the keyboard keeps --kb-side clear of each screen edge (3px, was
   8px; a larger left/right safe-area inset still wins via max()). That
   gives each of the ten top-row keys 2.8px more width than 1.9. Only the
   horizontal spacing changed; the rows are still --gap apart vertically,
   so the heights above are untouched. Both are at their floor. Do not
   take --kb-hgap to 0: the 2px borders of neighbouring keys then fuse
   into one 4px bar and the keys stop reading as separate keys. Do not
   take --kb-side below about 3px, or the row sits against the screen
   edge. */
.kb {
  --kb-scale: 0.75;
  --kb-lift: 1.5rem;
  --kb-hgap: 1px;
  --kb-side: 3px;
  --kb-fixed: calc(2px + 6px + env(safe-area-inset-bottom) + 3 * var(--gap) + 0.7rem);
  flex: 0 0 calc(var(--kb-scale) * (40% - var(--kb-fixed)) + var(--kb-fixed) + var(--kb-lift));
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 2px max(var(--kb-side), env(safe-area-inset-right)) calc(env(safe-area-inset-bottom) + 6px + var(--kb-lift)) max(var(--kb-side), env(safe-area-inset-left));
  touch-action: none;
}

.kb-row {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
}

.kb-go {
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding-bottom: 0.7rem;
}

.kb-10, .kb-9 {
  display: flex;
  gap: var(--kb-hgap);
}

.kb-10 > .key,
.kb-9 > .key {
  flex: 1 1 0;
  min-width: 0;
}

.kb-9 {
  padding-inline: calc((100% + var(--kb-hgap)) / 20);
}

.kb-4 {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: var(--kb-hgap);
}

.kb-4 .back { grid-column: span 2; }

.key, .go {
  height: 100%;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--key-border);
  border-radius: 0.65rem;
  background: var(--key);
  color: var(--fg);
  font-weight: 700;
  line-height: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}

.key { font-size: clamp(1.15rem, 6.4vw, 1.6rem); }

.go {
  font-size: clamp(1rem, 4.4vw, 1.28rem);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.go.listen {
  width: 100%;
  height: 3.5rem;
  margin: 0.85rem 0 0.35rem;
  flex: 0 0 auto;
}

.kb-go .go {
  width: 50%;
  height: 100%;
  border-width: 4px;
  border-color: var(--captured);
}

.key.mute { background: var(--key-mute); }

.key.down, .go.down, .key.mute.down {
  background: var(--key-down);
  color: var(--key-down-fg);
  border-color: var(--key-down);
}

.go.ready {
  background: var(--dot);
  border-color: var(--dot);
  color: var(--on-accent);
}

.go.ready.down {
  background: var(--dot-down);
  border-color: var(--dot-down);
  color: var(--on-accent);
}

.kb-go .go.down,
.kb-go .go.ready,
.kb-go .go.ready.down {
  border-color: var(--captured);
}

.go.prefer,
.go.prefer.down {
  border-color: var(--captured);
}

.key:focus, .go:focus { outline: none; }

.key svg {
  width: 1.7rem;
  height: 1.25rem;
  display: block;
}

.back svg {
  width: 2rem;
  height: 1.45rem;
}

@keyframes pop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake { animation: shake 0.42s linear; }

@media (prefers-reduced-motion: reduce) {
  .shake, .dot { animation: none; }
}

/* Mode select (Play opens it). Each mode is a tall button with a caption.
   A disabled mode (Daily, for now) is dimmed and ignores taps. */
.mode-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin: 1.2rem 0 0;
  max-width: 22rem;
}

.mode {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 0.2rem;
  width: 100%;
  min-height: 4.4rem;
  padding: 0.6rem 1rem;
  text-align: left;
  white-space: normal;
}

.mode-label {
  font-size: clamp(1.1rem, 5vw, 1.35rem);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.mode-caption {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
}

.mode.go.down .mode-caption { color: inherit; }

.mode.off,
.mode.off:disabled {
  border: 2px dashed var(--key-mute);
  border-radius: 0.65rem;
  background: transparent;
  color: var(--muted);
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}
