:root {
  color-scheme: light;
  --ranger: #173c56;
  --ranger-deep: #0c293a;
  --ranger-soft: #2b5870;
  --fog: #dfe9eb;
  --field-white: #f7faf9;
  --ink: #0d2838;
  --muted-ink: #536d78;
  --signal: #e46b3c;
  --signal-dark: #8b351f;
  --lichen: #4f8069;
  --lichen-light: #d6e7dc;
  --brass: #d5aa45;
  --danger: #b94934;
  --line: rgba(13, 40, 56, 0.22);
  --topbar-height: max(68px, calc(58px + env(safe-area-inset-top)));
  --focus-inner: #ffffff;
  --focus-outer: #0c293a;
  font-family: Aptos, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
  touch-action: manipulation;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  color: var(--ink);
  background: var(--ranger);
  -webkit-tap-highlight-color: transparent;
}

button,
select {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-inner);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--focus-outer);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.app-shell {
  width: 100%;
  height: 100dvh;
  min-height: 320px;
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  width: 100%;
  height: var(--topbar-height);
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding:
    env(safe-area-inset-top)
    max(16px, env(safe-area-inset-right))
    0
    max(16px, env(safe-area-inset-left));
  color: var(--field-white);
  background: var(--ranger);
  box-shadow: inset 0 -4px 0 var(--signal);
}

.home-link,
.icon-button,
.dialog-close {
  display: inline-flex;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
}

.home-link {
  width: max-content;
  gap: 9px;
  padding: 0 13px;
  color: var(--field-white);
  border: 1px solid rgba(247, 250, 249, 0.5);
  text-decoration: none;
  font-weight: 750;
  transition: color 180ms ease, background-color 180ms ease;
}

.home-link:hover {
  color: var(--ranger-deep);
  background: var(--field-white);
}

.brand-lockup {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: left;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  grid-template-columns: repeat(2, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 3px;
  padding: 5px;
  border: 2px solid var(--brass);
  border-radius: 50%;
}

.brand-mark i {
  display: block;
  background: var(--field-white);
}

.brand-mark i:nth-child(1) {
  border-radius: 8px 2px 2px;
}

.brand-mark i:nth-child(2) {
  border-radius: 2px 8px 2px 2px;
  background: var(--signal);
}

.brand-mark i:nth-child(3) {
  grid-column: 1 / -1;
  border-radius: 2px 2px 7px 7px;
  background: var(--lichen-light);
}

.brand-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  line-height: 1.05;
}

.brand-copy strong {
  overflow: hidden;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 1rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.brand-copy small {
  margin-top: 5px;
  color: #c8d9dd;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.top-actions {
  display: flex;
  justify-self: end;
  gap: 8px;
}

.icon-button,
.dialog-close {
  cursor: pointer;
  color: var(--field-white);
  border: 1px solid rgba(247, 250, 249, 0.5);
  background: transparent;
  transition: color 180ms ease, background-color 180ms ease;
}

.icon-button:hover,
.dialog-close:hover {
  color: var(--ranger-deep);
  background: var(--field-white);
}

.sound-icon {
  position: relative;
  width: 22px;
  height: 18px;
}

.sound-icon::before {
  position: absolute;
  top: 5px;
  left: 1px;
  width: 6px;
  height: 8px;
  content: "";
  background: currentColor;
}

.sound-icon::after {
  position: absolute;
  top: 2px;
  left: 5px;
  width: 12px;
  height: 14px;
  border: 2px solid currentColor;
  border-left: 0;
  border-radius: 0 12px 12px 0;
  content: "";
}

#sound-toggle[aria-pressed="false"] .sound-icon::after {
  top: 8px;
  left: 2px;
  width: 20px;
  height: 2px;
  border: 0;
  border-radius: 0;
  background: currentColor;
  transform: rotate(-42deg);
}

.settings-icon {
  display: flex;
  width: 23px;
  height: 20px;
  flex-direction: column;
  justify-content: space-between;
}

.settings-icon i {
  position: relative;
  display: block;
  width: 100%;
  height: 2px;
  background: currentColor;
}

.settings-icon i::after {
  position: absolute;
  top: -3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  content: "";
  background: currentColor;
}

.settings-icon i:nth-child(1)::after,
.settings-icon i:nth-child(3)::after {
  right: 3px;
}

.settings-icon i:nth-child(2)::after {
  left: 3px;
}

.mission-layout {
  display: grid;
  width: min(1320px, 100%);
  height: calc(100dvh - var(--topbar-height));
  min-height: 0;
  grid-template-columns: minmax(220px, 0.72fr) minmax(390px, 1.55fr) minmax(210px, 0.68fr);
  gap: clamp(10px, 1.3vw, 18px);
  margin: 0 auto;
  padding: clamp(10px, 1.8vh, 18px) clamp(10px, 1.5vw, 20px) max(10px, env(safe-area-inset-bottom));
}

.brief-panel,
.board-panel,
.log-panel {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.brief-panel {
  display: flex;
  flex-direction: column;
  padding: clamp(17px, 2vw, 26px);
  color: var(--ink);
  border: 1px solid rgba(247, 250, 249, 0.56);
  border-radius: 7px;
  background: var(--field-white);
}

.edition-chip {
  display: inline-flex;
  width: max-content;
  min-height: 28px;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--field-white);
  background: var(--ranger-soft);
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 0.68rem;
  font-weight: 720;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brief-heading h1 {
  max-width: 13ch;
  margin: 18px 0 10px;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: clamp(1.75rem, 2.55vw, 2.65rem);
  font-weight: 760;
  letter-spacing: -0.025em;
  line-height: 0.98;
  text-wrap: balance;
}

.brief-heading p {
  max-width: 37ch;
  margin: 0;
  color: var(--muted-ink);
  font-size: 0.88rem;
  line-height: 1.58;
  text-wrap: pretty;
}

.run-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: clamp(18px, 3vh, 34px);
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.status-beacon {
  position: relative;
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  border: 2px solid var(--ranger);
  border-radius: 50%;
}

.status-beacon::after {
  position: absolute;
  inset: 2px;
  border-radius: inherit;
  content: "";
  background: var(--brass);
}

.run-status[data-state="playing"] .status-beacon::after {
  background: var(--lichen);
  animation: beacon 1.3s ease-in-out infinite alternate;
}

.run-status[data-state="complete"] .status-beacon::after {
  background: var(--signal);
}

.run-status > span:last-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.run-status small,
.stats dt,
.board-code,
.log-header > div > span,
.dialog-code,
.settings-head span {
  color: var(--muted-ink);
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 0.64rem;
  font-weight: 720;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.run-status strong {
  margin-top: 2px;
  overflow: hidden;
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 14px 0 0;
  padding: 0;
}

.stats > div {
  min-width: 0;
  padding: 5px 10px;
  border-right: 1px solid var(--line);
}

.stats > div:first-child {
  padding-left: 0;
}

.stats > div:last-child {
  padding-right: 0;
  border-right: 0;
}

.stats dt,
.stats dd {
  margin: 0;
}

.stats dd {
  margin-top: 4px;
  overflow: hidden;
  color: var(--ranger-deep);
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  font-weight: 720;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stats dd small {
  color: var(--muted-ink);
  font-size: 0.66em;
}

.primary-action,
.secondary-action {
  min-height: 52px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 750;
  transition: transform 170ms ease, filter 170ms ease, background-color 170ms ease;
}

.primary-action {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: auto;
  padding: 11px 15px;
  color: var(--ranger-deep);
  background: var(--signal);
  box-shadow: 0 4px 0 var(--signal-dark);
}

.primary-action > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}

.primary-action small {
  font-size: 0.62rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  opacity: 1;
  text-transform: uppercase;
}

.primary-action strong {
  font-size: 1rem;
}

.primary-action > span:last-child {
  font-size: 1.45rem;
}

.primary-action:hover,
.secondary-action:hover {
  filter: brightness(1.08);
}

.primary-action:active,
.secondary-action:active {
  transform: translateY(2px);
}

.board-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 1px solid rgba(247, 250, 249, 0.56);
  border-radius: 7px;
  background: var(--fog);
}

.board-header,
.board-footer {
  display: flex;
  width: 100%;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 clamp(12px, 1.7vw, 22px);
}

.board-header {
  min-height: 58px;
  border-bottom: 1px solid var(--line);
  background: var(--field-white);
}

.board-header > div {
  display: flex;
  min-width: 0;
  align-items: baseline;
  gap: 10px;
}

.board-header h2,
.log-header h2 {
  margin: 0;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.board-header p {
  max-width: 28ch;
  margin: 0;
  overflow: hidden;
  color: var(--muted-ink);
  font-size: 0.75rem;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-board {
  position: relative;
  display: grid;
  width: min(calc(100% - 24px), calc(100dvh - var(--topbar-height) - 128px));
  max-width: 620px;
  min-width: 0;
  min-height: 0;
  aspect-ratio: 1;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: clamp(6px, 1.1vw, 11px);
  margin: auto;
  padding: clamp(8px, 1.25vw, 14px);
  isolation: isolate;
}

.game-board::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  border: 1px solid rgba(13, 40, 56, 0.22);
  content: "";
  background: #cbdadd;
}

.memory-card {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  aspect-ratio: 1;
  padding: 0;
  border-radius: 7px;
  cursor: pointer;
  background: transparent;
  perspective: 900px;
}

.memory-card[aria-disabled="true"] {
  cursor: not-allowed;
}

.memory-card.is-matched {
  z-index: 3;
  cursor: default;
}

.card-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 430ms cubic-bezier(0.22, 1, 0.36, 1);
}

.memory-card.is-flipped .card-inner,
.memory-card.is-matched .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  clip-path: polygon(0 0, calc(100% - 13px) 0, 100% 13px, 100% 100%, 0 100%);
}

.card-back {
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: clamp(7px, 1.1vw, 12px);
  color: var(--field-white);
  border: 1px solid rgba(247, 250, 249, 0.34);
  background: var(--ranger-soft);
  box-shadow: inset 0 -4px 0 rgba(12, 41, 58, 0.42);
  transition: color 160ms ease, background-color 160ms ease, transform 160ms ease;
}

.memory-card:hover:not([aria-disabled="true"]) .card-back {
  color: var(--ranger-deep);
  background: var(--signal);
}

.memory-card[aria-disabled="true"] .card-back {
  filter: saturate(0.45);
  opacity: 0.74;
}

.tag-number {
  font-family: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  font-size: clamp(0.68rem, 1.2vw, 0.86rem);
  font-weight: 700;
}

.tag-mark {
  position: relative;
  display: grid;
  width: clamp(26px, 37%, 52px);
  aspect-ratio: 1;
  place-items: center;
  align-self: center;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.tag-mark::before,
.tag-mark::after {
  position: absolute;
  content: "";
  background: currentColor;
}

.tag-mark::before {
  width: 58%;
  height: 2px;
}

.tag-mark::after {
  width: 2px;
  height: 58%;
}

.tag-series {
  align-self: flex-end;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: clamp(0.5rem, 0.85vw, 0.63rem);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.card-front {
  flex-direction: column;
  gap: clamp(1px, 0.5vw, 6px);
  color: var(--ink);
  border: 1px solid rgba(13, 40, 56, 0.28);
  background: var(--field-white);
  transform: rotateY(180deg);
  box-shadow: inset 0 -4px 0 rgba(13, 40, 56, 0.12);
}

.animal-glyph {
  font-size: clamp(1.75rem, 5.2vw, 4rem);
  line-height: 1;
  filter: saturate(0.88);
}

.animal-code {
  color: var(--muted-ink);
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: clamp(0.48rem, 0.82vw, 0.66rem);
  font-weight: 700;
  letter-spacing: 0.08em;
}

.memory-card.is-matched .card-front {
  color: var(--ranger-deep);
  border: 3px solid var(--lichen);
  background: var(--lichen-light);
  box-shadow: inset 0 0 0 3px var(--field-white);
}

.memory-card.is-matched::after {
  position: absolute;
  right: -4px;
  bottom: -4px;
  z-index: 4;
  display: grid;
  width: clamp(22px, 27%, 36px);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  color: var(--field-white);
  content: "✓";
  background: var(--lichen);
  font-weight: 900;
  transform: rotate(-8deg);
  animation: stamp-in 260ms cubic-bezier(0.22, 1, 0.36, 1);
}

.memory-card.is-miss .card-inner {
  animation: misread 320ms ease-out;
}

.memory-card.is-miss .card-front {
  border-color: var(--danger);
  background: #f7ded8;
}

.trail-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.trail-halo,
.trail-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trail-halo {
  stroke: rgba(247, 250, 249, 0.9);
  stroke-width: 7;
}

.trail-path {
  stroke: var(--lichen);
  stroke-width: 3;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw-trail 520ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.trail-node {
  fill: var(--signal);
  stroke: var(--field-white);
  stroke-width: 2;
}

.board-footer {
  min-height: 42px;
  border-top: 1px solid var(--line);
  color: var(--muted-ink);
  background: var(--field-white);
}

.board-footer p {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
  margin: 0;
  overflow: hidden;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

kbd {
  display: inline-flex;
  min-height: 23px;
  align-items: center;
  padding: 2px 7px;
  border: 1px solid rgba(13, 40, 56, 0.35);
  border-radius: 3px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 2px 0 rgba(13, 40, 56, 0.2);
  font: 700 0.64rem "Cascadia Mono", monospace;
}

.grid-coordinate {
  flex: 0 0 auto;
  font-family: "Cascadia Mono", monospace;
  font-size: 0.6rem;
}

.log-panel {
  display: flex;
  flex-direction: column;
  padding: clamp(15px, 1.8vw, 22px);
  color: var(--field-white);
  border: 1px solid rgba(247, 250, 249, 0.34);
  border-radius: 7px;
  background: var(--ranger-deep);
}

.log-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(247, 250, 249, 0.22);
}

.log-header > div > span {
  color: #a9c1c8;
}

.log-header h2 {
  margin-top: 4px;
}

.log-header > strong {
  color: var(--brass);
  font-family: "Cascadia Mono", monospace;
  font-size: 1.15rem;
}

.pair-log {
  display: grid;
  min-height: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.pair-log li {
  display: grid;
  min-width: 0;
  min-height: 54px;
  grid-template-columns: 23px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  padding: 6px 7px;
  border: 1px solid rgba(247, 250, 249, 0.23);
  border-radius: 4px;
  color: #9fb9c1;
  background: rgba(247, 250, 249, 0.04);
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.pair-log li.is-logged {
  color: var(--ranger-deep);
  border-color: var(--lichen-light);
  background: var(--lichen-light);
}

.log-index {
  font-family: "Cascadia Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
}

.log-animal {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
}

.log-animal span {
  font-size: 1.18rem;
}

.log-animal small {
  overflow: hidden;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-note {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid rgba(247, 250, 249, 0.22);
  color: #bdd0d5;
}

.log-note > span {
  color: var(--signal);
  font-size: 1.05rem;
}

.log-note p {
  margin: 0;
  font-size: 0.68rem;
  line-height: 1.45;
}

.secondary-action {
  width: calc(100% - 52px);
  margin-top: auto;
  padding: 9px 12px;
  color: var(--ranger-deep);
  background: var(--brass);
  box-shadow: 0 4px 0 #83651f;
}

.version {
  margin: 12px 0 0;
  color: #83a2ab;
  font-family: "Cascadia Mono", monospace;
  font-size: 0.52rem;
  letter-spacing: 0.07em;
}

.version span {
  color: var(--signal);
}

dialog {
  color: var(--ink);
  border: 0;
  border-radius: 8px;
  background: var(--field-white);
  box-shadow: 0 8px 0 rgba(12, 41, 58, 0.34);
}

dialog::backdrop {
  background: rgba(6, 24, 34, 0.76);
}

.win-dialog {
  width: min(410px, calc(100vw - 24px));
  padding: 28px;
  text-align: center;
}

.win-dialog[open] {
  animation: dialog-enter 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.dialog-flag {
  display: grid;
  width: 56px;
  aspect-ratio: 1;
  place-items: center;
  margin: 0 auto 15px;
  border-radius: 50%;
  color: var(--field-white);
  background: var(--lichen);
  font-size: 1.65rem;
  font-weight: 900;
}

.dialog-code {
  margin: 0;
  color: var(--signal-dark);
}

.win-dialog h2 {
  margin: 8px 0 7px;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 1.65rem;
  line-height: 1.05;
  text-wrap: balance;
}

.win-dialog > p:not(.dialog-code) {
  margin: 0;
  color: var(--muted-ink);
  font-size: 0.86rem;
}

.win-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  margin: 22px 0;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.win-stats > div + div {
  border-left: 1px solid var(--line);
}

.win-stats dt {
  color: var(--muted-ink);
  font-size: 0.7rem;
}

.win-stats dd {
  margin: 5px 0 0;
  font-family: "Cascadia Mono", monospace;
  font-size: 1.5rem;
  font-weight: 750;
}

.dialog-action {
  justify-content: center;
  margin-top: 0;
}

.settings-dialog {
  width: min(450px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  overflow: auto;
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 19px 20px;
  color: var(--field-white);
  background: var(--ranger);
}

.settings-head span {
  color: #bdd0d5;
}

.settings-head h2 {
  margin: 3px 0 0;
  font-family: Bahnschrift, "Arial Narrow", sans-serif;
  font-size: 1.35rem;
}

.settings-body {
  padding: 8px 20px;
}

.setting-row {
  display: flex;
  min-height: 76px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.setting-row > span:first-child {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.setting-row strong {
  font-size: 0.9rem;
}

.setting-row small {
  margin-top: 3px;
  color: var(--muted-ink);
  font-size: 0.68rem;
}

select {
  max-width: 170px;
  min-height: 44px;
  padding: 6px 32px 6px 10px;
  border: 1px solid rgba(13, 40, 56, 0.42);
  border-radius: 5px;
  background: #ffffff;
  font-size: 1rem;
}

.switch {
  display: inline-flex;
  min-width: 92px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 5px 9px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--field-white);
  background: var(--lichen);
}

.switch[aria-checked="false"] {
  color: var(--ink);
  background: #c4ced0;
}

.switch > span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
}

.switch b {
  font-size: 0.72rem;
}

.settings-version {
  margin: 0;
  padding: 13px 20px;
  color: var(--muted-ink);
  font-family: "Cascadia Mono", monospace;
  font-size: 0.58rem;
  text-align: center;
}

body .fa-help-btn {
  right: max(10px, env(safe-area-inset-right)) !important;
  bottom: max(8px, env(safe-area-inset-bottom)) !important;
  width: 40px !important;
  height: 40px !important;
}

@keyframes beacon {
  to {
    transform: scale(0.62);
    opacity: 0.65;
  }
}

@keyframes stamp-in {
  from {
    transform: scale(0.65) rotate(-18deg);
    opacity: 0;
  }
}

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

@keyframes draw-trail {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes dialog-enter {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

@media (max-width: 1040px) {
  .mission-layout {
    grid-template-columns: minmax(200px, 0.68fr) minmax(370px, 1.45fr) minmax(190px, 0.64fr);
    gap: 9px;
    padding-inline: 9px;
  }

  .brief-panel,
  .log-panel {
    padding: 15px;
  }

  .brief-heading h1 {
    font-size: 1.75rem;
  }

  .brief-heading p {
    font-size: 0.8rem;
  }

  .pair-log li {
    grid-template-columns: 19px minmax(0, 1fr);
    padding-inline: 5px;
  }
}

@media (max-height: 620px) and (min-width: 761px) {
  :root {
    --topbar-height: max(56px, calc(48px + env(safe-area-inset-top)));
  }

  .mission-layout {
    gap: 8px;
    padding: 8px;
  }

  .brief-panel,
  .log-panel {
    padding: 13px;
  }

  .edition-chip {
    min-height: 24px;
    font-size: 0.58rem;
  }

  .brief-heading h1 {
    margin: 11px 0 7px;
    font-size: 1.5rem;
  }

  .brief-heading p,
  .log-note {
    display: none;
  }

  .run-status {
    margin-top: 12px;
    padding-block: 8px;
  }

  .stats {
    margin-top: 9px;
  }

  .stats > div {
    padding-inline: 7px;
  }

  .primary-action,
  .secondary-action {
    min-height: 46px;
  }

  .board-header {
    min-height: 46px;
  }

  .board-footer {
    min-height: 34px;
  }

  .game-board {
    width: min(calc(100% - 18px), calc(100dvh - var(--topbar-height) - 96px));
    padding: 7px;
  }

  .pair-log {
    gap: 5px;
    margin-top: 8px;
  }

  .pair-log li {
    min-height: 42px;
    padding-block: 4px;
  }

  .log-header {
    padding-bottom: 9px;
  }

  .version {
    display: none;
  }
}

@media (max-width: 820px) and (min-height: 521px) {
  :root {
    --topbar-height: max(58px, calc(50px + env(safe-area-inset-top)));
  }

  .topbar {
    padding-inline: max(8px, env(safe-area-inset-left)) max(8px, env(safe-area-inset-right));
  }

  .home-link {
    min-width: 44px;
    padding-inline: 10px;
  }

  .home-link > span:last-child {
    display: none;
  }

  .brand-lockup {
    gap: 7px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .brand-copy strong {
    font-size: 0.88rem;
  }

  .brand-copy small {
    display: none;
  }

  .top-actions {
    gap: 5px;
  }

  .icon-button {
    min-width: 44px;
    min-height: 44px;
  }

  .mission-layout {
    display: grid;
    height: calc(100dvh - var(--topbar-height));
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 7px;
    padding: 7px 7px max(7px, env(safe-area-inset-bottom));
  }

  .brief-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(122px, 0.62fr);
    grid-template-areas:
      "status action"
      "stats stats";
    gap: 7px 10px;
    padding: 9px 10px;
  }

  .brief-panel.is-running {
    grid-template-columns: 1fr;
    grid-template-areas:
      "status"
      "stats";
  }

  .brief-heading {
    display: none;
  }

  .run-status {
    grid-area: status;
    margin: 0;
    padding: 5px 0;
    border: 0;
  }

  .run-status small {
    font-size: 0.55rem;
  }

  .run-status strong {
    font-size: 0.79rem;
  }

  .stats {
    grid-area: stats;
    margin: 0;
    padding-top: 6px;
    border-top: 1px solid var(--line);
  }

  .stats dt {
    font-size: 0.56rem;
  }

  .stats dd {
    margin-top: 1px;
    font-size: 1.1rem;
  }

  .primary-action {
    grid-area: action;
    min-height: 44px;
    margin: 0;
    padding: 6px 10px;
  }

  .primary-action small {
    display: none;
  }

  .primary-action strong {
    font-size: 0.82rem;
  }

  .primary-action > span:last-child {
    font-size: 1.1rem;
  }

  .board-header {
    min-height: 36px;
    padding-inline: 10px;
  }

  .board-header > div {
    gap: 7px;
  }

  .board-header h2 {
    font-size: 0.88rem;
  }

  .board-code {
    font-size: 0.54rem;
  }

  .board-header p {
    max-width: 18ch;
    font-size: 0.62rem;
  }

  .game-board {
    width: min(calc(100vw - 28px), 47dvh);
    gap: 6px;
    padding: 7px;
  }

  .card-back {
    padding: 7px;
  }

  .animal-glyph {
    font-size: clamp(1.75rem, 11vw, 3rem);
  }

  .board-footer {
    min-height: 27px;
    padding-inline: 9px;
  }

  .board-footer p {
    font-size: 0.58rem;
  }

  .board-footer kbd,
  .grid-coordinate {
    display: none;
  }

  .log-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(122px, 0.62fr);
    grid-template-areas:
      "header action"
      "pairs pairs";
    gap: 7px 10px;
    padding: 9px 10px;
  }

  .log-header {
    grid-area: header;
    align-items: center;
    padding: 0;
    border: 0;
  }

  .log-header > div > span {
    display: none;
  }

  .log-header h2 {
    margin: 0;
    font-size: 0.86rem;
  }

  .log-header > strong {
    font-size: 0.92rem;
  }

  .pair-log {
    grid-area: pairs;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 4px;
    margin: 0;
    padding-right: 50px;
  }

  .pair-log li {
    display: grid;
    min-height: 42px;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 3px 2px;
  }

  .log-index {
    font-size: 0.5rem;
  }

  .log-animal small {
    display: none;
  }

  .log-animal span {
    font-size: 1rem;
  }

  .log-note,
  .version {
    display: none;
  }

  .secondary-action {
    grid-area: action;
    width: calc(100% - 50px);
    min-height: 44px;
    margin: 0;
    padding: 6px 8px;
    font-size: 0.78rem;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  :root {
    --topbar-height: max(52px, calc(44px + env(safe-area-inset-top)));
  }

  .topbar {
    padding-inline: max(7px, env(safe-area-inset-left)) max(7px, env(safe-area-inset-right));
  }

  .home-link {
    min-width: 44px;
    min-height: 44px;
    padding-inline: 9px;
    font-size: 0.76rem;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }

  .brand-copy strong {
    font-size: 0.78rem;
  }

  .brand-copy small {
    display: none;
  }

  .icon-button {
    min-width: 44px;
    min-height: 44px;
  }

  .mission-layout {
    grid-template-columns: minmax(142px, 0.62fr) minmax(260px, 1.3fr) minmax(155px, 0.7fr);
    gap: 6px;
    padding: 6px max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
  }

  .brief-panel,
  .log-panel {
    padding: 8px 9px;
  }

  .edition-chip {
    display: none;
  }

  .brief-heading h1 {
    max-width: 15ch;
    margin: 0 0 5px;
    font-size: 1.08rem;
    line-height: 1.02;
  }

  .brief-heading p {
    display: none;
  }

  .run-status {
    margin-top: 7px;
    padding-block: 6px;
  }

  .status-beacon {
    width: 11px;
    height: 11px;
  }

  .run-status small {
    font-size: 0.5rem;
  }

  .run-status strong {
    font-size: 0.7rem;
  }

  .stats {
    margin-top: 6px;
  }

  .stats > div {
    padding-inline: 4px;
  }

  .stats dt {
    font-size: 0.48rem;
  }

  .stats dd {
    margin-top: 1px;
    font-size: 0.88rem;
  }

  .primary-action {
    min-height: 44px;
    padding: 4px 8px;
  }

  .primary-action small {
    display: none;
  }

  .primary-action strong {
    font-size: 0.75rem;
  }

  .primary-action > span:last-child {
    font-size: 1rem;
  }

  .board-header {
    min-height: 32px;
    padding-inline: 8px;
  }

  .board-header h2 {
    font-size: 0.8rem;
  }

  .board-code {
    display: none;
  }

  .board-header p {
    max-width: 19ch;
    font-size: 0.54rem;
  }

  .game-board {
    width: min(calc(100% - 10px), calc(100dvh - var(--topbar-height) - 44px));
    gap: 4px;
    padding: 5px;
  }

  .card-face {
    border-radius: 4px;
  }

  .card-back {
    padding: 5px;
  }

  .tag-mark {
    max-width: 36px;
  }

  .animal-glyph {
    font-size: clamp(1.45rem, 7.5vh, 2.4rem);
  }

  .board-footer {
    display: none;
  }

  .log-header {
    padding-bottom: 6px;
  }

  .log-header > div > span {
    display: none;
  }

  .log-header h2 {
    font-size: 0.78rem;
  }

  .log-header > strong {
    font-size: 0.83rem;
  }

  .pair-log {
    gap: 3px;
    margin-top: 5px;
  }

  .pair-log li {
    min-height: 33px;
    grid-template-columns: 15px minmax(0, 1fr);
    gap: 3px;
    padding: 2px 3px;
  }

  .log-index {
    font-size: 0.46rem;
  }

  .log-animal span {
    font-size: 0.9rem;
  }

  .log-animal small {
    display: none;
  }

  .log-note,
  .version {
    display: none;
  }

  .secondary-action {
    width: calc(100% - 48px);
    min-height: 44px;
    padding: 4px 7px;
    font-size: 0.68rem;
  }
}

@media (max-height: 520px) and (orientation: landscape) and (max-width: 700px) {
  .home-link > span:last-child {
    display: none;
  }

  .mission-layout {
    grid-template-columns: minmax(130px, 0.58fr) minmax(248px, 1.28fr) minmax(145px, 0.68fr);
  }

  .brief-heading h1 {
    font-size: 0.96rem;
  }

  .stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }

  .home-link,
  .icon-button,
  .dialog-close,
  .primary-action,
  .secondary-action,
  .card-inner,
  .card-back,
  .pair-log li {
    transition-duration: 0.001ms !important;
  }

  .run-status[data-state="playing"] .status-beacon::after,
  .memory-card.is-matched::after,
  .memory-card.is-miss .card-inner,
  .trail-path,
  .win-dialog[open] {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
  }

  .card-inner {
    transition: none !important;
  }
}
