/* Understood: high contrast, large targets, adult. No thin type, no flash. */

:root {
  color-scheme: light;
  --ink: #111111;
  --bg: #ffffff;
  --blue: #0b3a82;
  --blue-press: #072456;
  --line: #111111;
  --track: #d9e2f2;
  --gap: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 600;
  font-size: 22px;
  line-height: 1.25;
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
}

button, input, select {
  font: inherit;
  font-weight: 800;
  color: var(--ink);
}

button {
  border: 3px solid var(--line);
  background: var(--bg);
  border-radius: 10px;
  padding: 10px 12px;
  min-height: 64px;
  min-width: 64px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

button:active, button.is-pressed {
  background: var(--blue-press);
  color: #fff;
  border-color: var(--line);
}

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 4px solid var(--ink);
  outline-offset: 2px;
}

button:disabled {
  opacity: 1;
  color: var(--ink);
  background: var(--bg);
  border-style: dashed;
}

input, select {
  display: block;
  width: 100%;
  min-height: 64px;
  border: 3px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff;
  font-size: 22px;
}

h1, h2, h3, p { margin: 0; }

h1 { font-size: 32px; font-weight: 800; }
h2 { font-size: 28px; font-weight: 800; margin: 8px 0; }
h3 { font-size: 22px; font-weight: 800; margin: 16px 0 8px; }

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

.boot {
  font-size: 40px;
  font-weight: 800;
  padding: 24px;
}

.app-shell, .ryan, .helper, .gate {
  min-height: 100vh;
  min-height: 100dvh;
}

.ryan {
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
}

.ryan, .helper, .gate {
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.top-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  min-height: 44px;
  padding: calc(4px + env(safe-area-inset-top)) 8px 0;
  position: relative;
}

.gear {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 4px;
  border-width: 2px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gear svg { display: block; }

.hold-label {
  position: absolute;
  top: calc(44px + env(safe-area-inset-top));
  right: 8px;
  margin: 0;
  background: var(--ink);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  padding: 6px 10px;
  z-index: 6;
}

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

.screen:has(.board) { overflow: hidden; }

.talk {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 8px 12px 12px;
  min-height: 0;
}

.hint, .banner, .lead, .note, .meta, .when, .status, .card-hint {
  font-size: 22px;
  font-weight: 700;
}

.hint { text-align: center; font-size: 24px; }

.banner {
  border: 3px solid var(--line);
  padding: 10px 12px;
}

.mic {
  flex: 1 1 42vh;
  min-height: 42vh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--blue);
  color: #fff;
  border-color: var(--line);
  border-radius: 16px;
  padding: 16px;
}

.mic:active, .mic.is-pressed {
  background: var(--blue-press);
  color: #fff;
}

.mic-icon { font-size: 160px; line-height: 1; }
.mic-label {
  align-self: stretch;
  text-align: center;
  font-size: 56px;
  font-weight: 800;
  line-height: 1.05;
  color: #fff;
}
.mic-sub { font-size: 22px; font-weight: 700; color: #fff; min-height: 1.2em; }

.talk.has-result .mic,
.talk.has-retry .mic {
  flex: 0 0 auto;
  min-height: 88px;
}

.talk.has-result .mic-icon,
.talk.has-retry .mic-icon { font-size: 32px; }
.talk.has-result .mic-label,
.talk.has-retry .mic-label { font-size: 28px; }

.mic.is-listening {
  animation: listen 1.8s ease-in-out infinite;
}

@keyframes listen {
  0%, 100% { box-shadow: inset 0 0 0 4px #ffffff; }
  50% { box-shadow: inset 0 0 0 14px #c5d4ef; }
}

.meter-track {
  display: block;
  width: min(80%, 420px);
  height: 22px;
  border: 3px solid var(--line);
  background: var(--track);
  margin-top: 8px;
}

.mic .meter-track { border-color: #fff; }

.meter {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--blue);
}

.card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  width: 100%;
  border: 3px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  padding: 12px;
}

button.card:active, button.card.is-pressed {
  background: var(--blue);
  color: #fff;
}

.card-emoji {
  font-size: 96px;
  line-height: 1;
}

.card-text {
  font-size: 40px;
  font-weight: 800;
  line-height: 1.15;
  color: inherit;
}

.card-hint { color: inherit; }

.or-label {
  font-size: 28px;
  font-weight: 800;
  margin: 0;
}

.alts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
}

.alt {
  min-height: 96px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
}

.alt-emoji { font-size: 40px; line-height: 1; }
.alt-label { font-size: 22px; font-weight: 800; line-height: 1.1; }

.big-btn {
  width: 100%;
  min-height: 80px;
  font-size: 28px;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.big-btn:active, .big-btn.is-pressed {
  background: var(--blue-press);
  color: #fff;
}

.big-emoji { font-size: 40px; line-height: 1; }

.tabs {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  padding: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border-top: 3px solid var(--line);
  background: #fff;
}

.tabs button {
  min-height: 80px;
  font-size: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}

.tabs button[aria-current="page"] {
  background: var(--blue);
  color: #fff;
}

.tab-icon { font-size: 28px; line-height: 1; }

.board {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  padding: 8px;
  overflow: hidden;
}

.board-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  padding-bottom: 4px;
}

.nav-btn {
  min-width: 120px;
  min-height: 64px;
  font-size: 24px;
  background: var(--blue);
  color: #fff;
}

.nav-btn:active, .nav-btn.is-pressed {
  background: var(--blue-press);
  color: #fff;
}

.nav-btn[aria-disabled="true"] {
  background: #fff;
  color: var(--ink);
}

.grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: var(--gap);
  min-height: 0;
}

.tile {
  min-height: 0;
  min-width: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  text-align: center;
}

.tile:active, .tile.is-pressed {
  background: var(--blue);
  color: #fff;
}

.tile-emoji {
  /* 72px on an 800x1280 tablet; shrink with the viewport, never under 44px. */
  font-size: clamp(44px, min(9vw, 5.625vh), 72px);
  line-height: 1;
}
.tile-label {
  font-size: clamp(20px, min(3.5vw, 2.1875vh), 28px);
  font-weight: 800;
  line-height: 1.1;
  max-width: 100%;
}

.empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
}

.helper-bar, .gate-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  border-bottom: 3px solid var(--line);
}

.helper-main, .gate-main {
  flex: 1;
  overflow: auto;
  padding: 12px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.field { font-weight: 800; display: block; margin-top: 8px; }

.stepper {
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  gap: 8px;
  align-items: center;
}

.stepper span {
  text-align: center;
  font-weight: 800;
  font-size: 22px;
}

.h-card, .prow, .score-row {
  border: 3px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.h-phrase { font-size: 28px; font-weight: 800; }
.h-emoji { font-size: 40px; line-height: 1; }

.act-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.act-row button, .emoji-btn {
  min-height: 64px;
  font-size: 20px;
}

.prow-main {
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  width: 100%;
  font-size: 22px;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.emoji-btn { font-size: 32px; padding: 4px; }
.emoji-btn.is-on { background: var(--blue); }

.score-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
}

.score-name { font-weight: 800; }
.score-num { font-variant-numeric: tabular-nums; font-weight: 800; }

.gate-main .card-text { margin-bottom: 8px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

@media (forced-colors: active) {
  button, input, select, .card, .tile, .h-card {
    border: 2px solid ButtonText;
  }
}
