:root {
  --bg: hsl(210, 25%, 97%);
  --surface: #ffffff;
  --surface-subtle: hsl(210, 20%, 94%);
  --text: hsl(220, 25%, 14%);
  --text-muted: hsl(215, 15%, 45%);
  --primary: hsl(215, 85%, 48%);
  --primary-active: hsl(215, 85%, 38%);
  --primary-light: hsl(215, 90%, 95%);
  --primary-border: hsl(215, 80%, 82%);
  --right: hsl(145, 65%, 35%);
  --right-bg: hsl(145, 70%, 94%);
  --wrong: hsl(355, 78%, 52%);
  --wrong-bg: hsl(355, 85%, 96%);
  --wrong-border: hsl(355, 70%, 84%);
  --border: hsl(214, 20%, 88%);
  --radius: 14px;
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.06);
  --map-ocean: #d8eaf8;
  --map-neighbor: #f1f5f9;
  --map-neighbor-stroke: #94a3b8;
  --map-target: #ea580c;
  --map-target-stroke: #7c2d12;
  --map-pin: #dc2626;
}

:root[data-theme="dark"] {
  --bg: hsl(222, 32%, 9%);
  --surface: hsl(222, 28%, 13%);
  --surface-subtle: hsl(222, 24%, 18%);
  --text: hsl(214, 32%, 94%);
  --text-muted: hsl(215, 18%, 65%);
  --primary: hsl(215, 92%, 62%);
  --primary-active: hsl(215, 92%, 54%);
  --primary-light: hsla(215, 90%, 62%, 0.16);
  --primary-border: hsla(215, 85%, 62%, 0.38);
  --right: hsl(145, 72%, 52%);
  --right-bg: hsla(145, 70%, 48%, 0.16);
  --wrong: hsl(355, 88%, 66%);
  --wrong-bg: hsla(355, 85%, 58%, 0.16);
  --wrong-border: hsla(355, 80%, 62%, 0.38);
  --border: hsl(220, 22%, 23%);
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  --map-ocean: #0f2238;
  --map-neighbor: #273549;
  --map-neighbor-stroke: #556984;
  --map-target: #fb923c;
  --map-target-stroke: #fff7ed;
  --map-pin: #f87171;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  user-select: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.app {
  max-width: 440px;
  min-height: 100dvh;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Header & Username */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.logo {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.install-pill-btn {
  border: 1px solid var(--primary-border);
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.06s ease, background 0.12s ease;
}

.install-pill-btn:active {
  transform: scale(0.96);
  background: var(--surface-subtle);
}

.install-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--primary-light);
  border: 1px solid var(--primary-border);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 11px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.install-hint a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

.install-hint-close {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-box {
  position: relative;
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px 4px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.username-input {
  border: none;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  width: clamp(84px, 26vw, 112px);
  text-align: right;
  padding-right: 4px;
  outline: none;
  user-select: text;
}

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

.edit-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.06s ease, background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.icon-btn:active {
  transform: scale(0.93);
}

.theme-btn,
.sound-btn {
  font-size: 0.86rem;
}

.sound-btn.muted {
  opacity: 0.58;
  background: var(--surface-subtle);
}

.danger-btn:active,
.danger-btn:hover {
  color: var(--wrong);
  border-color: var(--wrong);
  background: var(--wrong-bg);
}

/* Switcher Rows (Users & Game Configs) */
.switcher-row {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.switcher-row::-webkit-scrollbar {
  display: none;
}

.switcher-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  flex-shrink: 0;
  min-width: 36px;
}

.pill-list {
  display: flex;
  align-items: center;
  gap: 6px;
}

.game-switcher-row {
  overflow-x: visible;
  align-items: flex-start;
}

.game-switcher-row .switcher-label {
  padding-top: 6px;
}

.game-switcher-row .pill-list {
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.game-switcher-row .pill-list::-webkit-scrollbar {
  display: none;
}

.game-switcher-row.expanded {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
}

.game-switcher-row.expanded .pill-list {
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  overflow-x: visible;
  width: 100%;
}

.game-switcher-row.expanded .switcher-actions {
  grid-column: 3;
  grid-row: 1;
}

.game-switcher-row.expanded .pill-btn {
  padding: 6px 8px;
  font-size: 0.76rem;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.switcher-actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}

.expand-pill-btn {
  border-style: solid;
  background: var(--surface);
}

.pill-meta {
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.82;
  margin-left: 3px;
}

.overview-list {
  max-height: 290px;
  overflow-y: auto;
}

.overview-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--surface-subtle);
  font-size: 0.81rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.overview-row:hover {
  border-color: var(--primary-border);
}

.overview-row.is-active {
  background: var(--primary-light);
  border-color: var(--primary-border);
}

.overview-game-name {
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.overview-rank-info {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.overview-rank-info .rank-leader {
  color: #d97706;
}

[data-theme="dark"] .overview-rank-info .rank-leader {
  color: #fbbf24;
}

.overview-rank-info .rank-up-hint {
  color: var(--primary);
  background: var(--primary-light);
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 0.7rem;
}

.overview-right-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.overview-score {
  font-weight: 800;
  color: var(--text);
  min-width: 22px;
  text-align: right;
}

.pill-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.pill-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.add-pill-btn {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--primary);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}

.add-pill-btn:active {
  background: var(--surface-subtle);
}

/* Game Configuration Card */
.config-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.config-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ops-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.op-toggle {
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 6px 0;
  font-size: 1.15rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.1s ease, color 0.1s ease, border-color 0.1s ease;
}

.op-toggle.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.ranges-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.range-col {
  background: var(--surface-subtle);
  border-radius: 10px;
  padding: 6px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.range-title {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.range-inputs {
  display: flex;
  align-items: center;
  gap: 3px;
  width: 100%;
  justify-content: center;
}

.range-inputs input {
  width: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 6px;
  padding: 4px 2px;
  font-size: 0.82rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  outline: none;
  user-select: text;
  -moz-appearance: textfield;
}

.range-inputs input::-webkit-outer-spin-button,
.range-inputs input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.range-inputs input:focus {
  border-color: var(--primary);
}

.range-sep {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.config-error {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--wrong);
  background: var(--wrong-bg);
  padding: 6px 10px;
  border-radius: 8px;
  text-align: center;
}

.config-form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.small-btn {
  padding: 9px 14px;
  font-size: 0.9rem;
  border-radius: 10px;
}

/* Views */
.view {
  display: none;
  flex: 1;
  flex-direction: column;
  gap: 10px;
}

.view.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* Last Result Banner */
.result-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  text-align: center;
  box-shadow: var(--shadow);
}

.result-banner.celebrate-pop {
  animation: resultPop 0.55s cubic-bezier(0.22, 1.28, 0.36, 1);
}

.result-banner.celebrate-pop .result-score-value {
  animation: scorePop 0.65s cubic-bezier(0.22, 1.35, 0.36, 1);
}

@keyframes resultPop {
  0% {
    opacity: 0;
    transform: translateY(-8px) scale(0.92);
  }
  60% {
    opacity: 1;
    transform: translateY(0) scale(1.03);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes scorePop {
  0% {
    transform: scale(0.6);
  }
  65% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

.celebration-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 999;
}

.result-banner.new-high-score {
  background: var(--right-bg);
  border: 2px solid var(--right);
}

.result-score-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.result-banner.new-high-score .result-score-label,
.result-banner.new-high-score .result-score-value {
  color: var(--right);
}

.result-score-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.15;
}

.result-score-detail {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.mini-action-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  border-radius: 999px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.06s ease, background 0.12s ease;
}

.mini-action-btn:active {
  transform: scale(0.96);
  background: var(--surface-subtle);
}

/* Buttons */
.play-actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.play-actions > button {
  flex: 1;
}

.play-actions > .primary-btn,
.play-actions > .secondary-btn {
  padding-left: 10px;
  padding-right: 10px;
}

.play-actions > .orientation-toggle-btn {
  flex: 0 0 auto;
}

.orientation-toggle-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  padding: 6px 10px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.1;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.orientation-toggle-btn:active {
  transform: scale(0.96);
  background: var(--surface-subtle);
}

.orientation-toggle-btn.active {
  background: var(--primary-light);
  border: 2px solid var(--primary);
  color: var(--primary);
  padding: 5px 9px;
}

.orientation-icon {
  display: block;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.orientation-toggle-btn.active .orientation-icon {
  transform: rotate(-90deg);
}

.game-bottom-actions {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.game-bottom-actions > #quit-btn {
  flex: 1;
}

.game-orientation-btn {
  flex-direction: row;
  gap: 6px;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 0.84rem;
}

.game-orientation-btn.active {
  padding: 8px 11px;
}

.primary-btn {
  width: 100%;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-size: 1.02rem;
  font-weight: 700;
  padding: 13px 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(18, 100, 225, 0.25);
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}

.primary-btn:active {
  transform: scale(0.98);
  background: var(--primary-active);
}

.primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.primary-btn.small-btn {
  padding: 9px 14px;
  font-size: 0.9rem;
  border-radius: 10px;
}

.secondary-btn {
  flex: 1;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.96rem;
  font-weight: 700;
  padding: 11px 14px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}

.secondary-btn:active {
  transform: scale(0.98);
  background: var(--surface-subtle);
}

.secondary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
}

/* Leaderboard */
.leaderboard-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-card {
  flex: 0 0 auto;
}

.leaderboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.collapsible-header {
  width: 100%;
  border: none;
  background: transparent;
  padding: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.collapsible-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chevron-icon {
  font-size: 0.82rem;
  color: var(--text-muted);
  width: 12px;
  display: inline-block;
  text-align: center;
}

.review-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leaderboard-header h2 {
  font-size: 0.96rem;
  font-weight: 700;
}

.leaderboard-header-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.my-rank-left-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-light);
  padding: 3px 8px;
  border-radius: 999px;
}

.my-rank-bar {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--surface-subtle);
  padding: 7px 11px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.my-rank-main {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.my-rank-jump.clickable {
  cursor: pointer;
}

.my-rank-jump.clickable:hover strong {
  color: var(--primary);
  text-decoration: underline;
}

.next-rank-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.next-rank-text strong {
  color: var(--text);
  font-weight: 700;
}

.my-best-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.inline-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.inline-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.inline-btn:active {
  background: var(--surface-subtle);
}

.leaderboard-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: minmax(36px, auto) 1fr auto;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 0.9rem;
}

.leaderboard-row.is-me {
  background: var(--primary-light);
  font-weight: 700;
  color: var(--primary);
}

.rank-num {
  font-weight: 700;
  color: var(--text-muted);
}

.leaderboard-row.is-me .rank-num {
  color: var(--primary);
}

.player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-name.clickable {
  cursor: pointer;
}

.player-name.clickable:hover {
  color: var(--primary);
  text-decoration: underline;
}

.user-page-name {
  font-size: 1.75rem;
}

.review-list.user-page-list {
  flex: 1;
  max-height: none;
  overflow-y: visible;
}

.user-page-list .overview-row {
  grid-template-columns: 1fr auto;
  padding: 7px 10px;
}

.user-row-left {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.player-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.player-right-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.empty-row {
  text-align: center;
  padding: 16px 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.leaderboard-pinned-me {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.leaderboard-pinned-sep {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1;
  padding: 1px 0;
  user-select: none;
}

.leaderboard-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.page-nav-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.page-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  min-width: 28px;
  height: 26px;
  padding: 0 8px;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.page-btn:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
}

.page-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.page-ellipsis {
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0 2px;
}

/* Review Section */
.chart-section {
  background: var(--surface-subtle);
  border-radius: 10px;
  padding: 8px 10px 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-score {
  background: hsl(217, 91%, 53%);
}

.dot-right {
  background: hsl(152, 76%, 36%);
}

.dot-my-best {
  background: hsl(36, 95%, 46%);
}

.dot-delta {
  background: linear-gradient(135deg, var(--right) 50%, var(--wrong) 50%);
}

.history-chart {
  width: 100%;
  height: 155px;
  display: block;
  overflow: visible;
}

.review-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.review-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 260px;
  overflow-y: auto;
}

.review-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-subtle);
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.review-row.has-wrong {
  background: var(--wrong-bg);
}

.review-eq {
  font-weight: 700;
}

.review-q-slot {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 5px;
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 800;
}

.review-row.has-wrong .review-q-slot {
  background: var(--surface);
  color: var(--wrong);
}

.review-answers {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  font-weight: 700;
}

.review-wrong-ans {
  color: var(--wrong);
  text-decoration: line-through;
}

.review-right-ans {
  color: var(--right);
}

.review-duration {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 42px;
  text-align: right;
}

/* Game View */
#game-view {
  justify-content: space-between;
}

.game-hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  text-align: center;
  box-shadow: var(--shadow);
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.hud-value {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hud-subvalue {
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.text-right {
  color: var(--right);
}

.text-wrong {
  color: var(--wrong);
}

.race-hud-bar {
  display: flex;
  flex-direction: column;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 0.84rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow);
}

.race-hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}

.race-vs-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.race-diff-badge {
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.76rem;
  font-weight: 800;
  flex-shrink: 0;
}

.race-diff-badge.ahead {
  background: var(--right-bg);
  color: var(--right);
}

.race-diff-badge.behind {
  background: var(--wrong-bg);
  color: var(--wrong);
}

.race-diff-badge.tied {
  background: var(--surface-subtle);
  color: var(--text-muted);
}

.race-opp-eq {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding-top: 5px;
  border-top: 1px dashed var(--border);
  font-size: 0.82rem;
}

.race-opp-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.race-opp-step {
  font-size: 0.71rem;
  font-weight: 700;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 6px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.race-opp-math {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
  flex-shrink: 0;
}

.race-opp-op {
  color: var(--text-muted);
  font-weight: 700;
}

.race-opp-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 1px 6px;
  border-radius: 6px;
  border: 1.5px solid var(--primary);
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 800;
  transition: background 0.1s, border-color 0.1s, color 0.1s;
}

.race-opp-slot.empty {
  color: var(--text-muted);
}

.race-opp-slot.wrong {
  border-color: var(--wrong);
  background: var(--wrong-bg);
  color: var(--wrong);
}

.race-opp-slot.right {
  border-color: var(--right);
  background: var(--right-bg);
  color: var(--right);
}

.race-opp-quiz {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Equation Card */
.equation-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.question-last-perf {
  align-self: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-variant-numeric: tabular-nums;
}

.question-last-perf.had-wrong {
  color: var(--wrong);
  background: var(--wrong-bg);
  border-color: var(--wrong-border);
}

.equation-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: clamp(1.9rem, 7.5vw, 2.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  box-shadow: var(--shadow);
  min-height: 108px;
}

.equation-card.has-map-prompt {
  padding: 10px 12px 12px;
}

.equation-card.has-map-prompt.is-replay-card {
  padding: 8px 10px;
  min-height: 0;
}

.math-eq-group {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.quiz-prompt-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  width: 100%;
}

.quiz-prompt-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.quiz-prompt-text {
  font-size: clamp(1.55rem, 6vw, 2.15rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--text);
  word-break: break-word;
}

.quiz-prompt-text.is-flag {
  font-size: clamp(3.1rem, 12vw, 4rem);
  line-height: 1.1;
}

.quiz-prompt-text.is-map {
  width: 100%;
  display: flex;
  justify-content: center;
  margin-top: 2px;
}

/* Country Context Map SVGs */
.geo-map-svg {
  display: block;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--map-ocean);
}

.geo-map-prompt {
  width: 100%;
  max-width: 292px;
  height: auto;
  max-height: 172px;
}

.is-replay-card .geo-map-prompt {
  max-width: 185px;
  max-height: 108px;
}

.geo-map-choice {
  width: 100%;
  height: auto;
  max-height: 152px;
}

.quiz-choices.replay-compact .geo-map-choice {
  max-width: 136px;
  max-height: 78px;
}

.geo-map-mini {
  width: 52px;
  height: 35px;
  border-radius: 6px;
  flex-shrink: 0;
}

.geo-map-ocean {
  fill: var(--map-ocean);
}

.geo-map-neighbor {
  fill: var(--map-neighbor);
  stroke: var(--map-neighbor-stroke);
  stroke-width: 0.85px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.geo-map-target {
  fill: var(--map-target);
  stroke: var(--map-target-stroke);
  stroke-width: 1.4px;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.geo-map-mini .geo-map-neighbor {
  stroke-width: 0.55px;
}

.geo-map-mini .geo-map-target {
  stroke-width: 0.95px;
}

.geo-map-pin-ring {
  fill: rgba(234, 88, 12, 0.2);
  stroke: var(--map-pin);
  stroke-width: 2px;
  vector-effect: non-scaling-stroke;
}

.geo-map-mini .geo-map-pin-ring {
  stroke-width: 1.35px;
}

.geo-map-pin-dot {
  fill: var(--map-target);
  stroke: #ffffff;
  stroke-width: 1px;
  vector-effect: non-scaling-stroke;
}

.review-inline-map,
.race-opp-mini-map {
  display: inline-flex;
  vertical-align: middle;
}

.review-q-slot.review-slot-map {
  padding: 2px;
  display: inline-flex;
  vertical-align: middle;
}

.eq-item {
  min-width: 64px;
  height: 64px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  padding: 0 10px;
}

.eq-item.question-slot {
  background: var(--surface-subtle);
  border: 2px solid var(--primary);
  color: var(--primary);
}

.eq-item.question-slot.empty {
  color: var(--text-muted);
}

.eq-item.question-slot.wrong {
  background: var(--wrong-bg);
  border-color: var(--wrong);
  color: var(--wrong);
  animation: shake 0.22s ease;
}

.eq-op {
  color: var(--text-muted);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* 3-Digits-Per-Row Mobile Keypad */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  flex: 1;
  max-height: 340px;
}

.key-btn {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 1.65rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 58px;
  transition: transform 0.05s ease, background 0.1s ease;
}

.key-btn:active {
  transform: scale(0.96);
  background: var(--surface-subtle);
}

.key-zero {
  grid-column: 2;
}

/* 2-Choice Quiz Buttons */
.quiz-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  flex: 1;
  max-height: 220px;
}

.quiz-choices.replay-compact {
  flex: 0 0 auto;
  max-height: none;
}

.choice-btn {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: clamp(1.1rem, 4.3vw, 1.35rem);
  font-weight: 700;
  padding: 16px 12px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 88px;
  line-height: 1.25;
  word-break: break-word;
  transition: transform 0.05s ease, background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}

.quiz-choices.replay-compact .choice-btn {
  min-height: 52px;
  padding: 8px 10px;
  font-size: 0.98rem;
  cursor: default;
}

.choice-btn.is-flag {
  font-size: clamp(2.6rem, 10vw, 3.3rem);
}

.quiz-choices.replay-compact .choice-btn.is-flag {
  font-size: 1.8rem;
}

.choice-btn.is-map {
  padding: 8px;
}

.quiz-choices.replay-compact .choice-btn.is-map {
  padding: 5px;
  min-height: 64px;
}

.choice-btn:active:not(:disabled) {
  transform: scale(0.97);
  background: var(--surface-subtle);
}

.choice-btn.wrong {
  background: var(--wrong-bg);
  border-color: var(--wrong);
  color: var(--wrong);
  animation: shake 0.22s ease;
}

.choice-btn.right {
  background: var(--right-bg);
  border-color: var(--right);
  color: var(--right);
}

/* Replay Panel */
.replay-panel {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.replay-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.replay-title {
  font-size: 0.92rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.replay-timeline {
  position: relative;
  padding: 6px 0;
  cursor: pointer;
  touch-action: none;
  outline: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.replay-race-chart-wrap {
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.replay-race-chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.replay-race-chart-legend {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

.replay-chart-live {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  flex-shrink: 0;
}

.replay-race-chart {
  width: 100%;
  height: 68px;
  display: block;
  overflow: visible;
}

.replay-timeline-track {
  position: relative;
  height: 12px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: visible;
}

.replay-timeline-segments {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  overflow: hidden;
}

.replay-seg-block {
  position: absolute;
  top: 0;
  bottom: 0;
  border-right: 1px solid rgba(15, 23, 42, 0.08);
}

.replay-seg-block.seg-right {
  background: hsla(145, 65%, 42%, 0.14);
}

.replay-seg-block.seg-wrong {
  background: hsla(355, 78%, 52%, 0.22);
}

.replay-timeline-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 0%;
  background: hsla(215, 85%, 48%, 0.22);
  border-radius: 999px 0 0 999px;
  pointer-events: none;
}

.replay-timeline-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.replay-marker {
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  border-radius: 999px;
  box-shadow: 0 0 0 1.5px var(--surface);
}

.replay-marker.marker-right {
  background: var(--right);
}

.replay-marker.marker-wrong {
  width: 7px;
  height: 10px;
  border-radius: 3px;
  background: var(--wrong);
  z-index: 2;
}

.replay-timeline-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: 2.5px solid var(--surface);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28);
  pointer-events: none;
  z-index: 3;
}

.replay-timeline:focus-visible .replay-timeline-thumb {
  box-shadow: 0 0 0 3px hsla(215, 85%, 48%, 0.35);
}

.replay-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.replay-log-list {
  flex: 1;
  max-height: 220px;
}

.replay-log-list .review-row {
  cursor: pointer;
}

.replay-log-list .review-row:active {
  opacity: 0.8;
}

.app-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
  padding: 4px 0 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

#game-view.active ~ .app-footer,
body.game-landscape .app-footer {
  display: none !important;
}

.footer-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.footer-android-links {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.footer-sep {
  color: var(--text-muted);
  opacity: 0.6;
}

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .footer-android-links,
  .install-pill-btn,
  .install-hint {
    display: none !important;
  }
}

.app-footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.app-footer .footer-credit a {
  font-weight: 600;
}

.app-footer a:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Gameplay-Only Landscape Mode (active solely during play for opted-in games) */
html.game-landscape-lock,
body.game-landscape {
  overflow: hidden;
  height: 100%;
}

body.game-landscape {
  display: flex;
  align-items: center;
  justify-content: center;
}

body.game-landscape .topbar,
body.game-landscape .install-hint {
  display: none !important;
}

body.game-landscape .app {
  max-width: 960px;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  max-height: 520px;
  margin: auto;
  padding:
    calc(6px + env(safe-area-inset-top, 0px))
    calc(14px + env(safe-area-inset-right, 0px))
    calc(8px + env(safe-area-inset-bottom, 0px))
    calc(14px + env(safe-area-inset-left, 0px));
  gap: 6px;
  overflow: hidden;
}

/* CSS 90° viewport rotation fallback when OS portrait lock keeps the viewport portrait (e.g. iOS) */
@media (orientation: portrait) {
  body.game-landscape.game-css-rotated .app {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100vh;
    width: 100dvh;
    height: 100vw;
    height: 100dvw;
    max-width: none;
    max-height: none;
    margin: 0;
    padding:
      6px
      calc(14px + env(safe-area-inset-bottom, 0px))
      8px
      calc(14px + env(safe-area-inset-top, 0px));
    transform: translate(-50%, -50%) rotate(90deg);
    z-index: 50;
  }
}

body.game-landscape .game-hud {
  padding: 5px 10px;
  border-radius: 10px;
  gap: 6px;
  align-items: center;
}

body.game-landscape .hud-label {
  font-size: 0.62rem;
}

body.game-landscape .hud-value {
  font-size: 1.12rem;
  line-height: 1.1;
}

body.game-landscape .hud-subvalue {
  font-size: 0.98rem;
  line-height: 1.1;
}

body.game-landscape .race-hud-bar {
  padding: 4px 10px;
  font-size: 0.78rem;
}

body.game-landscape .question-last-perf {
  font-size: 0.7rem;
  padding: 1px 8px;
}

body.game-landscape .game-bottom-actions {
  gap: 6px;
}

body.game-landscape .game-bottom-actions > #quit-btn {
  padding: 6px 12px;
  font-size: 0.8rem;
  white-space: nowrap;
}

body.game-landscape .game-orientation-btn {
  padding: 6px 10px;
  font-size: 0.78rem;
}

body.game-landscape .game-orientation-btn.active {
  padding: 5px 9px;
}

/* Landscape 2-Choice Quiz Layout: Header row + full-width prompt + 2 wide thumb buttons */
body.game-landscape #game-view.is-quiz-mode {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr);
  gap: 6px 8px;
  flex: 1;
  min-height: 0;
}

body.game-landscape #game-view.is-quiz-mode.is-race-mode {
  grid-template-rows: auto auto minmax(0, 1fr) minmax(0, 1fr);
}

body.game-landscape #game-view.is-quiz-mode .game-hud {
  grid-column: 1;
  grid-row: 1;
}

body.game-landscape #game-view.is-quiz-mode .game-bottom-actions {
  grid-column: 2;
  grid-row: 1;
}

body.game-landscape #game-view.is-quiz-mode .game-bottom-actions > .game-orientation-btn {
  order: -1;
}

body.game-landscape #game-view.is-quiz-mode #race-hud-bar {
  grid-column: 1 / -1;
}

body.game-landscape #game-view.is-quiz-mode .equation-wrap {
  grid-column: 1 / -1;
  min-height: 0;
  gap: 3px;
}

body.game-landscape #game-view.is-quiz-mode .equation-card {
  flex: 1;
  min-height: 0;
  padding: 6px 14px;
  overflow: hidden;
}

body.game-landscape #game-view.is-quiz-mode .quiz-prompt-group {
  height: 100%;
  min-height: 0;
  gap: 2px;
}

body.game-landscape #game-view.is-quiz-mode .quiz-prompt-label {
  font-size: 0.66rem;
  flex-shrink: 0;
}

body.game-landscape #game-view.is-quiz-mode .quiz-prompt-text {
  font-size: clamp(1.2rem, 3.4vw, 1.8rem);
}

body.game-landscape #game-view.is-quiz-mode .quiz-prompt-text.is-flag {
  font-size: clamp(2.3rem, 6.8vw, 3.3rem);
}

body.game-landscape #game-view.is-quiz-mode .quiz-prompt-text.is-map {
  flex: 1;
  min-height: 0;
  align-items: center;
  margin-top: 0;
}

body.game-landscape .geo-map-prompt {
  aspect-ratio: 260 / 168;
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
}

body.game-landscape #game-view.is-quiz-mode #quiz-choices {
  grid-column: 1 / -1;
  max-height: none;
  min-height: 0;
  gap: 10px;
}

body.game-landscape #game-view.is-quiz-mode .choice-btn {
  min-height: 0;
  height: 100%;
  padding: 8px 14px;
  font-size: clamp(1.05rem, 2.8vw, 1.35rem);
  overflow: hidden;
}

body.game-landscape #game-view.is-quiz-mode .choice-btn.is-flag {
  font-size: clamp(2.1rem, 6.2vw, 3rem);
}

body.game-landscape #game-view.is-quiz-mode .choice-btn.is-map {
  padding: 6px;
}

body.game-landscape .geo-map-choice {
  aspect-ratio: 200 / 138;
  height: 100%;
  width: auto;
  max-width: 100%;
  max-height: 100%;
}

/* Landscape Math Layout: Left column (HUD + Equation + Actions) + Right column (Keypad) */
body.game-landscape #game-view.is-math-mode {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 46%);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 6px 10px;
  flex: 1;
  min-height: 0;
}

body.game-landscape #game-view.is-math-mode.is-race-mode {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

body.game-landscape #game-view.is-math-mode .game-hud,
body.game-landscape #game-view.is-math-mode #race-hud-bar,
body.game-landscape #game-view.is-math-mode .equation-wrap,
body.game-landscape #game-view.is-math-mode .game-bottom-actions {
  grid-column: 1;
}

body.game-landscape #game-view.is-math-mode .equation-wrap {
  min-height: 0;
  gap: 3px;
}

body.game-landscape #game-view.is-math-mode .equation-card {
  flex: 1;
  min-height: 0;
  padding: 10px;
  font-size: clamp(1.6rem, 4.2vw, 2.25rem);
}

body.game-landscape #game-view.is-math-mode .eq-item {
  min-width: 52px;
  height: 52px;
  padding: 0 8px;
}

body.game-landscape #game-view.is-math-mode #keypad {
  grid-column: 2;
  grid-row: 1 / -1;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  max-height: none;
  height: 100%;
  min-height: 0;
  gap: 7px;
}

body.game-landscape #game-view.is-math-mode .key-btn {
  min-height: 0;
  font-size: 1.45rem;
}
