:root {
  color-scheme: light;
  --sheet: oklch(0.99 0.004 245);
  --sheet-blue: oklch(0.965 0.018 245);
  --desk: oklch(0.91 0.025 245);
  --desk-deep: oklch(0.83 0.035 245);
  --ink: oklch(0.25 0.035 250);
  --ink-soft: oklch(0.46 0.035 250);
  --line: oklch(0.78 0.04 245);
  --pencil-blue: oklch(0.49 0.12 250);
  --pencil-blue-dark: oklch(0.39 0.12 250);
  --pencil-blue-soft: oklch(0.92 0.035 250);
  --mark-red: oklch(0.58 0.19 28);
  --mark-red-soft: oklch(0.94 0.035 28);
  --correct-green: oklch(0.51 0.11 155);
  --correct-green-soft: oklch(0.94 0.035 155);
  --mixed-amber: oklch(0.55 0.14 76);
  --mixed-amber-soft: oklch(0.95 0.04 76);
  --focus: oklch(0.64 0.17 76);
  --shadow-ink: oklch(0.25 0.035 250 / 0.16);
  --font-ui: "BIZ UDPGothic", "Yu Gothic UI", "Noto Sans TC", system-ui, sans-serif;
  --font-equation: "Arial Rounded MT Bold", "Avenir Next", "Trebuchet MS", var(--font-ui);
  --z-sticky: 20;
  --z-overlay: 30;
  --z-dialog: 40;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--desk);
}

body {
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  background: var(--desk);
  font-family: var(--font-ui);
  line-height: 1.5;
}

button,
select {
  min-height: 44px;
  font: inherit;
}

button,
summary,
select,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:not(:disabled),
summary,
select {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: var(--z-dialog);
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: var(--sheet);
  background: var(--ink);
  transform: translateY(-160%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 52px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) auto minmax(150px, 1fr);
  align-items: center;
  min-height: 64px;
  margin-bottom: 14px;
}

.back-link,
.settings summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: max-content;
  min-height: 44px;
  padding: 8px 12px;
  color: var(--pencil-blue-dark);
  background: var(--sheet);
  border: 2px solid var(--pencil-blue);
  border-radius: 8px;
  font-weight: 800;
  text-decoration: none;
}

.back-link:hover,
.settings summary:hover {
  color: var(--sheet);
  background: var(--pencil-blue-dark);
}

.title-lockup {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: left;
}

.equal-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--sheet);
  background: var(--mark-red);
  border-radius: 50%;
  font-family: var(--font-equation);
  font-size: 1.75rem;
  font-weight: 900;
  transform: rotate(-7deg);
}

.title-kicker {
  display: block;
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 800;
}

.title-lockup h1 {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.08;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.settings {
  position: relative;
  justify-self: end;
}

.settings summary {
  list-style: none;
}

.settings summary::-webkit-details-marker {
  display: none;
}

.settings-panel {
  position: absolute;
  z-index: var(--z-sticky);
  top: calc(100% + 8px);
  right: 0;
  width: min(260px, calc(100vw - 32px));
  padding: 16px;
  background: var(--sheet);
  border: 2px solid var(--ink);
  border-radius: 10px;
  box-shadow: 4px 4px 0 var(--shadow-ink);
}

.settings-panel label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 800;
}

.settings-panel select {
  width: 100%;
  padding: 8px 10px;
  color: var(--ink);
  background: var(--sheet);
  border: 2px solid var(--line);
  border-radius: 6px;
  font-size: 1rem;
}

.settings-version {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  font-size: 0.82rem;
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
  align-items: start;
}

.play-panel,
.control-panel {
  min-width: 0;
}

.score-strip {
  display: flex;
  min-height: 62px;
  background: var(--ink);
  color: var(--sheet);
  border-radius: 12px 12px 0 0;
  overflow: hidden;
}

.score-item {
  display: flex;
  flex: 1;
  align-items: baseline;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  border-inline-start: 1px solid oklch(1 0 0 / 0.18);
}

.score-item:first-child {
  border-inline-start: 0;
}

.score-item span {
  color: oklch(0.84 0.02 245);
  font-size: 0.78rem;
  font-weight: 700;
}

.score-item output {
  font-family: var(--font-equation);
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.score-item--score output {
  min-width: 3ch;
  color: oklch(0.87 0.12 80);
}

.score-item--lives output {
  color: oklch(0.75 0.16 25);
  font-size: 1rem;
  letter-spacing: 0.1em;
}

.worksheet {
  padding: 12px;
  background: var(--sheet);
  border: 2px solid var(--ink);
  border-top: 0;
  border-radius: 0 0 12px 12px;
}

.worksheet-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 4px 5px 10px;
}

.worksheet-heading span {
  color: var(--ink-soft);
  font-size: 0.75rem;
  font-weight: 700;
}

.worksheet-heading h2 {
  margin: 1px 0 0;
  font-size: 1.15rem;
  line-height: 1.2;
}

.worksheet-heading .live-speed {
  color: var(--pencil-blue-dark);
  font-family: var(--font-equation);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.fall-zone {
  position: relative;
  height: min(62vh, 650px);
  min-height: 480px;
  overflow: hidden;
  background-color: var(--sheet);
  background-image:
    linear-gradient(oklch(0.84 0.04 245 / 0.55) 1px, transparent 1px),
    linear-gradient(90deg, oklch(0.84 0.04 245 / 0.55) 1px, transparent 1px);
  background-size: 24px 24px;
  border: 2px solid var(--line);
  border-radius: 8px;
  isolation: isolate;
  touch-action: manipulation;
}

.fall-zone:focus-visible {
  outline-offset: 2px;
}

.lane-divider {
  position: absolute;
  inset-block: 0;
  left: 50%;
  width: 1px;
  background: oklch(0.7 0.04 245 / 0.5);
}

.spawn-label {
  position: absolute;
  z-index: 2;
  top: 7px;
  left: 50%;
  padding: 1px 7px;
  color: var(--ink-soft);
  background: var(--sheet);
  font-size: 0.68rem;
  font-weight: 800;
  transform: translateX(-50%);
}

.equation-layer {
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
}

.equation-card {
  position: absolute;
  top: 0;
  left: 25%;
  display: flex;
  width: clamp(118px, 34%, 166px);
  min-height: 62px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  color: var(--ink);
  background: var(--sheet);
  border: 2px solid var(--pencil-blue);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--shadow-ink);
  font-family: var(--font-equation);
  font-size: clamp(1.45rem, 4vw, 2.15rem);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  letter-spacing: 0.02em;
  white-space: nowrap;
  transform: translate3d(-50%, -80px, 0);
  will-change: transform;
}

.equation-card[data-lane="1"] {
  left: 75%;
}

.equation-card[data-mode="mul-div"] {
  border-color: var(--correct-green);
}

.equation-card[data-mode="mixed"] {
  width: clamp(145px, 42%, 190px);
  border-color: var(--mixed-amber);
  font-size: clamp(1.15rem, 3.3vw, 1.8rem);
}

.equation-card::after {
  position: absolute;
  right: 7px;
  bottom: 4px;
  color: var(--ink-soft);
  content: "=?";
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 800;
}

.equation-card[data-state="correct"] {
  color: var(--correct-green);
  background: var(--correct-green-soft);
  border-color: var(--correct-green);
  opacity: 0;
  transition: opacity 180ms ease-out, scale 180ms ease-out;
  scale: 0.88;
}

.equation-card[data-state="missed"] {
  color: var(--mark-red);
  background: var(--mark-red-soft);
  border-color: var(--mark-red);
  opacity: 0;
  transition: opacity 180ms ease-out;
}

.danger-zone {
  position: absolute;
  z-index: 3;
  right: 0;
  bottom: 0;
  left: 0;
  height: 66px;
  background: oklch(0.96 0.025 28 / 0.82);
  border-top: 3px solid var(--mark-red);
}

.danger-label {
  position: absolute;
  top: -15px;
  right: 14px;
  padding: 2px 8px;
  color: var(--sheet);
  background: var(--mark-red);
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 900;
}

.feedback-stamp {
  position: absolute;
  z-index: 7;
  top: 43%;
  left: 50%;
  min-width: 100px;
  padding: 5px 12px;
  color: var(--correct-green);
  background: var(--sheet);
  border: 3px solid currentColor;
  border-radius: 6px;
  font-size: 1.2rem;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, -50%) rotate(-5deg) scale(0.9);
}

.feedback-stamp.is-visible {
  animation: stamp-in 520ms cubic-bezier(0.16, 1, 0.3, 1);
}

.feedback-stamp[data-tone="miss"] {
  color: var(--mark-red);
  transform: translate(-50%, -50%) rotate(4deg) scale(0.9);
}

@keyframes stamp-in {
  0% { opacity: 0; scale: 1.35; }
  18%, 72% { opacity: 1; scale: 1; }
  100% { opacity: 0; scale: 0.96; }
}

.game-overlay {
  position: absolute;
  z-index: var(--z-overlay);
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: oklch(0.99 0.004 245 / 0.94);
}

.game-overlay[hidden] {
  display: none;
}

.overlay-copy {
  max-width: 420px;
  text-align: center;
}

.overlay-symbol {
  display: inline-block;
  margin-bottom: 14px;
  padding: 5px 12px;
  color: var(--pencil-blue-dark);
  border-block: 2px solid var(--pencil-blue);
  font-family: var(--font-equation);
  font-size: 1.65rem;
  font-weight: 900;
  transform: rotate(-2deg);
}

.overlay-copy h3 {
  margin: 0;
  font-size: 1.5rem;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.overlay-copy p {
  max-width: 34ch;
  margin: 8px auto 18px;
  color: var(--ink-soft);
  text-wrap: pretty;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 10px 18px;
  border-radius: 7px;
  font-weight: 900;
}

.primary-button {
  color: var(--sheet);
  background: var(--pencil-blue-dark);
  border: 2px solid var(--pencil-blue-dark);
}

.primary-button:hover {
  background: var(--pencil-blue);
  border-color: var(--pencil-blue);
}

.secondary-button {
  color: var(--pencil-blue-dark);
  background: var(--sheet);
  border: 2px solid var(--pencil-blue);
}

.secondary-button:not(:disabled):hover {
  background: var(--pencil-blue-soft);
}

.answer-console {
  display: flex;
  align-items: center;
  min-height: 70px;
  margin-top: 10px;
  padding: 8px 14px;
  background: var(--ink);
  border-radius: 8px;
}

.answer-label {
  margin-right: auto;
  color: oklch(0.84 0.02 245);
  font-size: 0.8rem;
  font-weight: 800;
}

.answer-console output {
  min-width: 2.4ch;
  color: var(--sheet);
  font-family: var(--font-equation);
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  line-height: 1;
  text-align: right;
}

.answer-caret {
  width: 3px;
  height: 30px;
  margin-left: 5px;
  background: var(--focus);
  animation: caret-blink 900ms steps(1, end) infinite;
}

.answer-console[data-state="invalid"] {
  background: var(--mark-red);
  animation: console-nudge 180ms ease-out;
}

.answer-console[data-state="correct"] {
  background: var(--correct-green);
}

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

@keyframes console-nudge {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-5px); }
  70% { transform: translateX(4px); }
}

.control-panel {
  padding: 18px;
  background: var(--sheet);
  border: 2px solid var(--ink);
  border-radius: 12px;
}

.mode-section,
.speed-ruler,
.keypad-section {
  padding-bottom: 17px;
  border-bottom: 1px solid var(--line);
}

.speed-ruler,
.keypad-section {
  padding-top: 17px;
}

.section-heading,
.ruler-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-heading h2,
.ruler-heading h2 {
  margin: 0;
  font-size: 1rem;
}

.section-heading > span,
.ruler-heading > span {
  color: var(--ink-soft);
  font-size: 0.7rem;
  font-weight: 700;
}

.mode-switch {
  display: grid;
  gap: 8px;
}

.mode-button {
  display: grid;
  grid-template-columns: 68px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  width: 100%;
  min-height: 72px;
  padding: 10px;
  color: var(--ink);
  background: var(--sheet);
  border: 2px solid var(--line);
  border-radius: 8px;
  text-align: left;
}

.mode-button:hover {
  background: var(--pencil-blue-soft);
  border-color: var(--pencil-blue);
}

.mode-button.is-selected {
  background: var(--pencil-blue-soft);
  border-color: var(--pencil-blue-dark);
}

.mode-button[data-mode="mul-div"].is-selected {
  background: var(--correct-green-soft);
  border-color: var(--correct-green);
}

.mode-button[data-mode="mixed"].is-selected {
  background: var(--mixed-amber-soft);
  border-color: var(--mixed-amber);
}

.mode-equation {
  grid-row: 1 / span 2;
  align-self: stretch;
  display: grid;
  place-items: center;
  color: var(--sheet);
  background: var(--pencil-blue-dark);
  border-radius: 5px;
  font-family: var(--font-equation);
  font-size: 1.08rem;
  font-weight: 900;
}

.mode-button[data-mode="mul-div"] .mode-equation {
  background: var(--correct-green);
}

.mode-button[data-mode="mixed"] .mode-equation {
  background: var(--mixed-amber);
  font-size: 0.9rem;
}

.mode-button strong {
  align-self: end;
  font-size: 0.9rem;
}

.mode-button small {
  align-self: start;
  color: var(--ink-soft);
  font-size: 0.7rem;
  line-height: 1.35;
}

.speed-ruler ol {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 3px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.speed-ruler li {
  position: relative;
  height: 32px;
  color: var(--ink-soft);
  background: var(--desk);
  border-bottom: 3px solid var(--line);
  font-size: 0.68rem;
  font-weight: 900;
  text-align: center;
}

.speed-ruler li::before {
  position: absolute;
  right: 50%;
  bottom: -3px;
  width: 2px;
  height: 8px;
  background: var(--line);
  content: "";
}

.speed-ruler li.is-active {
  color: var(--sheet);
  background: var(--pencil-blue-dark);
  border-bottom-color: var(--pencil-blue-dark);
}

.speed-ruler li span {
  display: inline-block;
  padding-top: 7px;
}

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

.keypad button {
  min-height: 48px;
  color: var(--ink);
  background: var(--sheet);
  border: 2px solid var(--line);
  border-radius: 7px;
  font-family: var(--font-equation);
  font-size: 1.05rem;
  font-weight: 900;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.keypad button:hover,
.keypad button:active {
  background: var(--pencil-blue-soft);
  border-color: var(--pencil-blue);
}

.keypad .keypad-function {
  color: var(--pencil-blue-dark);
  background: var(--desk);
}

.game-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 17px;
}

.game-actions .secondary-button {
  min-width: 0;
  padding-inline: 9px;
  font-size: 0.82rem;
}

.how-to {
  max-width: 820px;
  margin: 30px auto 0;
  padding: 0 8px;
}

.how-to h2 {
  margin: 0 0 10px;
  font-size: 1.15rem;
}

.how-to ol {
  display: flex;
  gap: 28px;
  margin: 0;
  padding-left: 22px;
}

.how-to li {
  flex: 1;
  max-width: 28ch;
  padding-left: 2px;
  color: var(--ink-soft);
  font-size: 0.86rem;
}

.how-to li::marker {
  color: var(--mark-red);
  font-weight: 900;
}

.how-to p {
  margin: 14px 0 0;
  color: var(--ink-soft);
  font-size: 0.75rem;
}

.game-over-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--sheet);
  border: 3px solid var(--ink);
  border-radius: 12px;
}

.game-over-dialog::backdrop {
  background: oklch(0.18 0.025 250 / 0.68);
}

.game-over-dialog form {
  padding: 24px;
  text-align: center;
}

.result-mark {
  display: grid;
  width: 52px;
  height: 52px;
  margin: 0 auto 10px;
  place-items: center;
  color: var(--sheet);
  background: var(--mark-red);
  border-radius: 50%;
  font-size: 1.6rem;
  font-weight: 900;
  transform: rotate(-8deg);
}

.game-over-dialog h2 {
  margin: 0;
  font-size: 1.5rem;
}

.game-over-dialog dl {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 20px 0;
  border-block: 1px solid var(--line);
}

.game-over-dialog dl div {
  padding: 12px 5px;
}

.game-over-dialog dt {
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.game-over-dialog dd {
  margin: 2px 0 0;
  font-family: var(--font-equation);
  font-size: 1.15rem;
  font-weight: 900;
}

.version-info {
  position: fixed;
  right: 8px;
  bottom: 6px;
  z-index: var(--z-sticky);
  color: oklch(0.32 0.03 250 / 0.65);
  font-size: 0.65rem;
  pointer-events: none;
}

.visually-hidden {
  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;
}

@media (max-width: 900px) {
  .page-shell {
    width: min(760px, calc(100% - 24px));
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .control-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
  }

  .mode-section,
  .speed-ruler,
  .keypad-section,
  .game-actions {
    min-width: 0;
  }

  .mode-section {
    grid-row: 1 / span 2;
    padding-right: 18px;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }

  .speed-ruler {
    padding-top: 0;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 16px, 520px);
    padding-top: 8px;
  }

  .topbar {
    grid-template-columns: 48px 1fr 48px;
    min-height: 58px;
    margin-bottom: 8px;
  }

  .back-link,
  .settings summary {
    width: 44px;
    height: 44px;
    justify-content: center;
    padding: 0;
  }

  .back-link span:last-child,
  .settings summary span:last-child,
  .title-kicker {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .equal-mark {
    width: 34px;
    height: 34px;
    font-size: 1.35rem;
  }

  .title-lockup {
    gap: 7px;
  }

  .title-lockup h1 {
    font-size: 1.38rem;
  }

  .score-strip {
    min-height: 54px;
  }

  .score-item {
    display: grid;
    gap: 0;
    padding: 7px 6px;
    text-align: center;
  }

  .score-item span {
    font-size: 0.66rem;
  }

  .score-item output {
    font-size: 1.18rem;
  }

  .score-item--lives output {
    font-size: 0.78rem;
  }

  .worksheet {
    padding: 8px;
  }

  .fall-zone {
    height: clamp(350px, 52svh, 500px);
    min-height: 350px;
  }

  .equation-card {
    width: clamp(112px, 40%, 150px);
    min-height: 56px;
    font-size: 1.55rem;
  }

  .answer-console {
    min-height: 60px;
  }

  .control-panel {
    display: block;
    padding: 14px;
  }

  .mode-section {
    padding-right: 0;
    padding-bottom: 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .mode-button {
    display: flex;
    min-height: 68px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }

  .mode-equation {
    min-height: 30px;
    font-size: 0.95rem;
  }

  .mode-button small {
    display: none;
  }

  .speed-ruler {
    padding-top: 14px;
  }

  .keypad-section {
    padding-top: 14px;
  }

  .keypad button {
    min-height: 52px;
    font-size: 1.15rem;
  }

  body[data-game-phase="running"] .page-shell {
    padding-bottom: 292px;
  }

  body[data-game-phase="running"] .fall-zone {
    height: min(40svh, 330px);
    min-height: 300px;
  }

  body[data-game-phase="running"] .keypad-section {
    position: fixed;
    z-index: var(--z-sticky);
    right: 8px;
    bottom: 8px;
    left: 8px;
    max-width: 374px;
    margin-inline: auto;
    padding: 10px;
    background: var(--sheet);
    border: 2px solid var(--ink);
    border-radius: 10px;
    box-shadow: 3px 3px 0 var(--shadow-ink);
  }

  body[data-game-phase="running"] .keypad-section .section-heading {
    margin-bottom: 7px;
  }

  body[data-game-phase="running"] .keypad button {
    min-height: 45px;
  }

  body[data-game-phase="running"] .game-actions {
    position: fixed;
    z-index: calc(var(--z-sticky) + 1);
    right: max(16px, calc((100vw - 358px) / 2));
    bottom: 240px;
    display: block;
    padding: 0;
  }

  body[data-game-phase="running"] .game-actions #pause-button {
    width: 46px;
    min-width: 46px;
    padding: 0;
    color: var(--sheet);
    background: var(--pencil-blue-dark);
    border-color: var(--pencil-blue-dark);
  }

  body[data-game-phase="running"] .game-actions #pause-button [data-control-label] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  body[data-game-phase="running"] .game-actions #restart-button {
    display: none;
  }

  .how-to {
    margin-top: 24px;
  }

  .how-to ol {
    display: grid;
    gap: 8px;
  }
}

@media (orientation: landscape) and (max-height: 560px) {
  .page-shell {
    width: min(980px, calc(100% - 16px));
    padding-block: 6px 20px;
  }

  .topbar {
    min-height: 46px;
    margin-bottom: 5px;
  }

  .equal-mark {
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
  }

  .title-lockup h1 {
    font-size: 1.2rem;
  }

  .game-grid {
    grid-template-columns: minmax(0, 1fr) 284px;
    gap: 10px;
  }

  .score-strip {
    min-height: 40px;
  }

  .score-item {
    padding-block: 3px;
  }

  .worksheet {
    padding: 6px;
  }

  .worksheet-heading {
    min-height: 29px;
    padding: 1px 4px 4px;
  }

  .worksheet-heading > div > span {
    display: none;
  }

  .worksheet-heading h2 {
    font-size: 0.95rem;
  }

  .fall-zone {
    height: 190px;
    min-height: 190px;
  }

  .answer-console {
    min-height: 44px;
    margin-top: 5px;
  }

  .answer-console output {
    font-size: 1.5rem;
  }

  .overlay-symbol {
    margin-bottom: 5px;
    padding-block: 2px;
    font-size: 1.15rem;
  }

  .overlay-copy h3 {
    font-size: 1.1rem;
  }

  .overlay-copy p {
    margin-block: 3px 7px;
    font-size: 0.78rem;
  }

  .control-panel {
    display: block;
    max-height: calc(100svh - 60px);
    padding: 10px;
    overflow-y: auto;
  }

  .mode-section {
    padding: 0 0 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .mode-button {
    display: block;
    min-height: 52px;
    padding: 5px;
    text-align: center;
  }

  .mode-equation {
    min-height: 26px;
    margin-bottom: 2px;
  }

  .mode-button small,
  .speed-ruler,
  .section-heading--compact {
    display: none;
  }

  .keypad-section {
    padding-block: 8px;
  }

  .keypad button {
    min-height: 38px;
  }

  .game-actions {
    padding-top: 8px;
  }

  .how-to {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .answer-caret {
    opacity: 1;
  }
}

@media (forced-colors: active) {
  .fall-zone,
  .mode-button,
  .keypad button,
  .answer-console,
  .score-strip {
    forced-color-adjust: none;
  }

  .equation-card,
  .primary-button,
  .secondary-button,
  .back-link,
  .settings summary {
    border-color: CanvasText;
  }
}
