:root {
  color-scheme: dark;
  --bench: #1d292e;
  --bench-deep: #10191d;
  --bench-line: #33464d;
  --silver: #bfc2bd;
  --silver-light: #d8dad5;
  --silver-mid: #a9ada9;
  --silver-dark: #777d7c;
  --bezel: #242a29;
  --key-black: #252827;
  --key-edge: #0e1110;
  --key-face: #363a38;
  --ink: #171d1d;
  --muted: #505958;
  --lcd: #adb88b;
  --lcd-shadow: #738064;
  --lcd-ink: #172113;
  --orange: #d85822;
  --orange-dark: #8d3213;
  --blue: #355f91;
  --blue-dark: #1d3b63;
  --ochre: #9b896b;
  --service: #e1b641;
  --paper: #d9d8cb;
  --focus: #f7dc62;
  --danger: #b83a27;
  --font-industrial: "Arial Narrow", "Bahnschrift Condensed", "Noto Sans TC",
    sans-serif;
  --font-ui: "Bahnschrift", "Noto Sans TC", "Segoe UI", sans-serif;
  --font-lcd: "Cascadia Mono", "Consolas", "Noto Sans Mono", monospace;
  --mg880-vh: 100dvh;
}

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

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bench-deep);
  text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  padding: 0 18px 92px;
  overflow-x: hidden;
  color: #f3f5f2;
  background-color: var(--bench);
  background-image: repeating-linear-gradient(
    93deg,
    rgb(255 255 255 / 2%) 0,
    rgb(255 255 255 / 2%) 1px,
    transparent 1px,
    transparent 7px
  );
  font-family: var(--font-ui);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
select,
input {
  font: inherit;
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

button,
a,
select,
input,
[tabindex]:not([tabindex="-1"]) {
  outline: 3px solid transparent;
  outline-offset: 3px;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
  outline-color: var(--focus);
}

a {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: var(--ink);
  background: var(--focus);
  border: 2px solid var(--ink);
  border-radius: 2px;
  transform: translateY(-160%);
}

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

.site-bar {
  width: min(1040px, 100%);
  min-height: 64px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--bench-line);
}

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

.brand-copy {
  min-width: 0;
}

.brand-eyebrow,
.panel-kicker,
.setting-label {
  margin: 0;
  color: #b8c3c4;
  font-family: var(--font-industrial);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  line-height: 1.1;
  text-transform: uppercase;
}

.brand-title {
  margin: 2px 0 0;
  overflow: hidden;
  color: #f7f8f5;
  font-family: var(--font-industrial);
  font-size: clamp(1rem, 2.2vw, 1.28rem);
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.1;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.home-link {
  min-height: 44px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #edf1ef;
  background: transparent;
  border: 1px solid #63767b;
  border-radius: 2px;
  font-family: var(--font-industrial);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-decoration: none;
  text-transform: uppercase;
}

.home-link:hover {
  color: #fff;
  border-color: var(--service);
  background: #26363c;
}

.site-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 8px;
}

.icon-button {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #eef2ef;
  background: #172429;
  border: 1px solid #62747a;
  border-radius: 2px;
  cursor: pointer;
}

.icon-button:hover {
  color: var(--focus);
  border-color: var(--service);
}

.icon-button[aria-pressed="false"] .sound-on,
.icon-button[aria-pressed="true"] .sound-off {
  display: none;
}

.workbench {
  width: min(1040px, 100%);
  margin: 22px auto 0;
  display: grid;
  grid-template-columns: minmax(430px, 500px) minmax(270px, 310px);
  align-items: start;
  justify-content: center;
  gap: clamp(22px, 4vw, 46px);
}

/*
 * MG-880 body: a narrow, brushed-silver slab. The proportions, shallow
 * corners and hard lower edge follow the photographed calculator rather than
 * a modern rounded app panel.
 */
.calculator-shell {
  position: relative;
  width: min(470px, 100%);
  min-width: 0;
  min-height: 0;
  aspect-ratio: 0.7 / 1;
  padding: 17px 18px 18px;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background-color: var(--silver);
  background-image: repeating-linear-gradient(
    0deg,
    rgb(255 255 255 / 8%) 0,
    rgb(255 255 255 / 8%) 1px,
    rgb(65 72 71 / 4%) 1px,
    rgb(65 72 71 / 4%) 2px,
    transparent 2px,
    transparent 5px
  );
  border: 2px solid var(--silver-light);
  border-right-color: #6d7372;
  border-bottom-color: #5d6362;
  border-radius: 7px;
  box-shadow:
    0 8px 0 #4b5150,
    0 16px 28px rgb(0 0 0 / 34%);
  isolation: isolate;
}

.calculator-shell::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 5px;
  border: 1px solid rgb(58 64 63 / 30%);
  border-radius: 3px;
  pointer-events: none;
}

.calculator-shell::after {
  content: "";
  position: absolute;
  z-index: 8;
  right: 11px;
  bottom: 7px;
  left: 11px;
  height: 1px;
  background: rgb(255 255 255 / 45%);
  pointer-events: none;
}

.device-top {
  position: relative;
  flex: 0 0 auto;
  padding: 7px 7px 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.lcd-frame {
  position: relative;
  min-width: 0;
  padding: 9px;
  overflow: hidden;
  background: var(--bezel);
  border: 2px solid #5e6562;
  border-top-color: #141817;
  border-left-color: #141817;
  border-radius: 4px;
  box-shadow:
    inset 0 3px 6px rgb(0 0 0 / 62%),
    0 1px 0 rgb(255 255 255 / 42%);
}

.lcd-glass {
  position: relative;
  min-height: 130px;
  padding: 14px 15px 10px;
  overflow: hidden;
  color: var(--lcd-ink);
  background-color: var(--lcd);
  background-image: repeating-linear-gradient(
    0deg,
    rgb(28 40 22 / 3%) 0,
    rgb(28 40 22 / 3%) 1px,
    transparent 1px,
    transparent 4px
  );
  border: 2px solid #69745b;
  border-top-color: #4f5845;
  border-left-color: #4f5845;
  border-radius: 2px;
  box-shadow: inset 0 0 8px rgb(35 48 28 / 28%);
}

.calc-readout {
  min-height: 69px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  overflow: hidden;
  font-family: var(--font-lcd);
  font-size: clamp(2.1rem, 7.4vw, 4rem);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.025em;
  line-height: 1;
  text-align: right;
  text-overflow: clip;
  white-space: nowrap;
  text-shadow: 1px 1px 0 rgb(255 255 255 / 12%);
}

.game-readout {
  position: relative;
  min-height: 69px;
  display: grid;
  grid-template-columns: minmax(39px, 0.78fr) minmax(0, 7fr);
  align-items: stretch;
  gap: 5px;
}

.aim-cell,
.invader-cell {
  min-width: 0;
  display: grid;
  place-items: center;
  color: var(--lcd-ink);
  border: 1px solid rgb(27 39 20 / 25%);
  font-family: var(--font-lcd);
  font-size: clamp(1.35rem, 4.4vw, 2.35rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.aim-cell {
  position: relative;
  border-width: 2px;
  background: rgb(23 33 18 / 8%);
}

.aim-cell::after {
  content: "AIM";
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-family: var(--font-ui);
  font-size: 0.43rem;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.invader-rail {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 2px;
}

.invader-cell.is-target {
  border-color: var(--lcd-ink);
  box-shadow: inset 0 -3px 0 var(--lcd-ink);
}

.invader-cell.is-danger {
  color: #2a190d;
  background: rgb(184 58 39 / 18%);
}

.invader-cell.is-hit {
  color: var(--lcd);
  background: var(--lcd-ink);
}

.shot-beam {
  position: absolute;
  z-index: 3;
  top: 50%;
  right: 2px;
  left: 43px;
  height: 3px;
  background: var(--lcd-ink);
  opacity: 0;
  transform: scaleX(0);
  transform-origin: left center;
  pointer-events: none;
}

.shot-beam.is-firing,
.lcd-glass.is-firing .shot-beam {
  animation: beam-fire 180ms steps(3, end);
}

.screen-status {
  min-width: 0;
  min-height: 25px;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #2e3d26;
  font-family: var(--font-industrial);
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.1;
  text-transform: uppercase;
}

.screen-message {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-meta {
  flex: 0 0 auto;
  color: #425039;
  font-size: 0.58rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.game-banner {
  position: absolute;
  z-index: 4;
  inset: 50% auto auto 50%;
  width: max-content;
  max-width: calc(100% - 20px);
  padding: 5px 8px;
  color: var(--lcd);
  background: var(--lcd-ink);
  border: 1px solid #0d140a;
  font-family: var(--font-industrial);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  transform: translate(-50%, -50%);
}

.identity-strip {
  min-height: 61px;
  margin-top: 10px;
  padding: 8px 3px 9px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-top: 1px solid rgb(255 255 255 / 58%);
  border-bottom: 5px solid #82775c;
}

.identity-copy {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 5px;
  white-space: nowrap;
}

.casio-wordmark {
  color: #171b1b;
  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(1.04rem, 3vw, 1.35rem);
  font-weight: 950;
  letter-spacing: -0.04em;
  line-height: 1;
  text-transform: uppercase;
}

.identity-copy > span {
  color: #424948;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.49rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.identity-copy > strong:not(.casio-wordmark) {
  color: #252b2a;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.61rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.game-mark {
  position: relative;
  width: 49px;
  min-width: 49px;
  height: 39px;
  padding: 18px 3px 2px;
  display: grid;
  place-items: center;
  color: #f2f1e8;
  background: var(--blue);
  border: 1px solid #697372;
  box-shadow: inset 0 0 0 2px var(--silver-light);
  font-family: var(--font-industrial);
  font-size: 0.49rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  line-height: 1;
  text-transform: uppercase;
}

.game-notes {
  position: absolute;
  top: 2px;
  left: 5px;
  color: var(--orange);
  font-family: Arial, sans-serif;
  font-size: 0.98rem;
  font-weight: 900;
  letter-spacing: -0.12em;
  line-height: 1;
}

.mode-deck {
  position: relative;
  min-height: 86px;
  padding: 10px 3px 6px;
  flex: 0 0 auto;
}

.mode-labels {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 7px;
}

.mode-dot {
  position: relative;
  width: 52px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  color: #f4f4ed;
  background: var(--ochre);
  border: 1px solid rgb(47 51 49 / 30%);
  border-radius: 50%;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

button.mode-dot {
  cursor: pointer;
}

.mode-dot.mode-off {
  background: #958d7a;
}

.mode-dot.mode-music {
  background: var(--orange);
  font-size: 1.1rem;
}

.mode-dot.mode-calc-label {
  background: #728cad;
}

.mode-game-label {
  min-height: 44px;
  padding: 0 2px;
  display: grid;
  place-items: center;
  color: #424847;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.56rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.mode-dot[aria-pressed="true"]::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: -13px;
  width: 7px;
  height: 7px;
  background: #171b1a;
  border: 1px solid var(--silver-light);
}

.mode-switch {
  width: 160px;
  min-height: 44px;
  margin-top: 7px;
  padding: 0 9px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  align-items: end;
  gap: 5px;
  background: transparent;
  border: 0;
  border-top: 2px solid #383e3d;
  border-right: 2px solid #383e3d;
  border-left: 2px solid #383e3d;
  border-radius: 0;
}

.mode-button {
  position: relative;
  min-height: 44px;
  padding: 0 2px;
  color: #333a39;
  background: transparent;
  border: 0;
  border-radius: 0;
  font-family: var(--font-industrial);
  font-size: 0.56rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-transform: uppercase;
}

.mode-button::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  width: 7px;
  height: 7px;
  background: #555d5b;
  border: 1px solid #242a29;
  transform: translateX(-50%);
}

.mode-button[aria-pressed="true"] {
  color: #111615;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.mode-button[aria-pressed="true"]::before {
  background: #111615;
}

.mode-slider {
  position: absolute;
  bottom: 7px;
  left: 17px;
  width: 45px;
  height: 35px;
  background: var(--key-black);
  border: 1px solid var(--key-edge);
  border-bottom: 4px solid #0a0c0c;
  border-radius: 4px;
  box-shadow: 0 1px 0 rgb(255 255 255 / 28%);
  transition: transform 160ms steps(2, end);
}

.mode-deck:has(#mode-game[aria-pressed="true"]) .mode-slider {
  transform: translateX(76px);
}

.mode-slider::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 10px;
  width: 23px;
  height: 15px;
  border-top: 2px solid #5a605e;
  border-bottom: 2px solid #111514;
}

.auto-power {
  position: absolute;
  top: 19px;
  right: 2px;
  color: #3b4241;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.55rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.memory-row {
  min-width: 0;
  margin-top: 2px;
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  gap: 7px;
  align-items: end;
}

.memory-spacer {
  min-width: 0;
  min-height: 44px;
  grid-column: span 2;
}

.keypad {
  min-width: 0;
  margin-top: 20px;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: repeat(5, minmax(44px, 1fr));
  grid-template-rows: repeat(4, minmax(54px, 1fr));
  gap: 10px 7px;
}

.key {
  position: relative;
  min-width: 0;
  min-height: 54px;
  padding: 5px;
  color: #d9dad6;
  background-color: var(--key-face);
  background-image: linear-gradient(
    105deg,
    rgb(255 255 255 / 8%) 0,
    transparent 35%,
    rgb(0 0 0 / 10%) 100%
  );
  border: 2px solid var(--key-edge);
  border-top-color: #535856;
  border-left-color: #535856;
  border-bottom-width: 5px;
  border-radius: 5px;
  box-shadow:
    inset 0 0 0 2px rgb(255 255 255 / 4%),
    0 1px 0 rgb(255 255 255 / 28%);
  font-family: var(--font-industrial);
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
}

.key:hover {
  color: #fff;
  background-color: #414644;
}

.key:active,
.key.is-pressed {
  top: 2px;
  border-bottom-width: 3px;
}

.key-memory {
  min-height: 48px;
  font-size: 0.95rem;
}

.key-game {
  color: #eef2f4;
  background-color: var(--blue);
  border-color: #102849;
  border-top-color: #547dae;
  border-left-color: #547dae;
}

.key-game-icon {
  display: inline-grid;
  width: 1.15em;
  height: 1.15em;
  place-items: center;
  border: 2px solid currentColor;
  font-family: var(--font-lcd);
  font-size: 0.86em;
  line-height: 1;
}

.key-percent,
.key-clear,
.key-ac {
  color: #f2f1eb;
}

.key-aim,
.key-fire-real {
  box-shadow:
    inset 0 0 0 2px rgb(255 255 255 / 4%),
    0 0 0 2px rgb(51 58 57 / 32%);
}

.key-fire-real {
  border-color: #131817;
}

.key-op,
.key-equals {
  color: #ecece7;
}

.key-label {
  position: relative;
  z-index: 2;
}

.physical-caption {
  position: absolute;
  z-index: 3;
  right: 1px;
  left: 1px;
  bottom: -18px;
  overflow: hidden;
  color: #383f3e;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.48rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
  pointer-events: none;
}

.physical-caption.caption-top {
  top: -16px;
  bottom: auto;
}

.operator-panel {
  min-width: 0;
  margin-top: 28px;
  padding: 18px 17px 16px;
  color: var(--ink);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    0deg,
    rgb(0 0 0 / 2%) 0,
    rgb(0 0 0 / 2%) 1px,
    transparent 1px,
    transparent 4px
  );
  border: 1px solid #8b8d84;
  border-top: 8px solid var(--blue);
  border-radius: 2px;
  box-shadow:
    7px 8px 0 rgb(7 14 17 / 32%),
    0 15px 24px rgb(0 0 0 / 18%);
}

.mission-header {
  margin: 0 0 14px;
  padding-bottom: 11px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 3px solid #8a7d62;
}

.panel-kicker {
  color: var(--blue-dark);
  font-size: 0.61rem;
}

.mission-title {
  margin: 3px 0 0;
  color: #171d1d;
  font-family: var(--font-industrial);
  font-size: 1.28rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  line-height: 1;
  text-transform: uppercase;
}

.phase-badge {
  min-width: 62px;
  min-height: 28px;
  padding: 5px 7px;
  display: grid;
  place-items: center;
  color: #f7f6ef;
  background: var(--blue);
  border: 1px solid var(--blue-dark);
  font-family: var(--font-industrial);
  font-size: 0.63rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.phase-badge[data-phase="running"],
.phase-badge.is-running {
  background: #37694f;
  border-color: #1d4734;
}

.phase-badge[data-phase="gameover"],
.phase-badge.is-gameover {
  background: var(--danger);
  border-color: #762116;
}

.stat-grid {
  margin: 0 0 14px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid #888b84;
  border-left: 1px solid #888b84;
}

.stat {
  min-width: 0;
  min-height: 58px;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid #888b84;
  border-bottom: 1px solid #888b84;
}

.stat-label {
  color: #596160;
  font-family: var(--font-industrial);
  font-size: 0.58rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  line-height: 1;
  text-transform: uppercase;
}

.stat-value {
  overflow: hidden;
  color: #171d1d;
  font-family: var(--font-lcd);
  font-size: 1.15rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-button {
  width: 100%;
  min-height: 48px;
  padding: 8px 14px;
  color: #fff;
  background: var(--orange);
  border: 1px solid var(--orange-dark);
  border-bottom: 4px solid #70240d;
  border-radius: 2px;
  font-family: var(--font-industrial);
  font-weight: 900;
  letter-spacing: 0.1em;
  cursor: pointer;
  text-transform: uppercase;
}

.action-button:hover {
  background: #e7652e;
}

.action-button:active {
  border-bottom-width: 2px;
  transform: translateY(2px);
}

.instructions {
  margin-top: 15px;
  padding-top: 12px;
  border-top: 1px solid #96978f;
}

.instruction-title {
  margin: 0 0 8px;
  color: var(--blue-dark);
  font-family: var(--font-industrial);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.instruction-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  color: #3e4544;
  font-size: 0.75rem;
  list-style: none;
}

.instruction-list li {
  position: relative;
  min-width: 0;
  padding-left: 19px;
}

.instruction-list li::before {
  content: attr(data-step);
  position: absolute;
  top: 1px;
  left: 0;
  width: 14px;
  height: 14px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  font-family: var(--font-industrial);
  font-size: 0.53rem;
  font-weight: 900;
}

kbd,
.instruction-list kbd {
  padding: 1px 4px;
  color: #f1f2ed;
  background: #343a38;
  border: 1px solid #161a19;
  border-bottom-width: 2px;
  border-radius: 2px;
  font-family: var(--font-lcd);
  font-size: 0.68rem;
  white-space: nowrap;
}

.feedback-pulse {
  animation: feedback-pulse 220ms steps(2, end);
}

.calculator-shell.is-hit {
  animation: device-hit 190ms ease-out;
}

.calculator-shell.is-damaged {
  animation: device-damage 260ms ease-out;
}

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

dialog.settings-dialog,
.settings-dialog {
  width: min(420px, calc(100vw - 28px));
  max-height: min(620px, calc(100dvh - 28px));
  margin: auto;
  padding: 0;
  overflow: auto;
  color: var(--ink);
  background: var(--silver);
  border: 2px solid var(--silver-light);
  border-right-color: #666d6b;
  border-bottom-color: #666d6b;
  border-radius: 4px;
  box-shadow: 0 10px 0 rgb(8 16 19 / 42%);
}

dialog.settings-dialog::backdrop,
.settings-dialog::backdrop {
  background: rgb(8 15 18 / 76%);
}

.dialog-header {
  min-height: 61px;
  padding: 9px 10px 9px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  background: var(--blue);
  border-bottom: 4px solid #8a7d62;
}

.dialog-title {
  margin: 0;
  font-family: var(--font-industrial);
  font-size: 1.16rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dialog-close {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue-dark);
  border: 1px solid #9db2c9;
  border-radius: 2px;
  cursor: pointer;
}

.dialog-body {
  padding: 17px;
  display: grid;
  gap: 17px;
}

.setting-row {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.setting-label {
  color: #313938;
}

.setting-row select {
  width: 100%;
  padding: 8px 34px 8px 10px;
  color: var(--ink);
  background: #f0f0e9;
  border: 2px solid #747b79;
  border-radius: 2px;
}

.setting-toggle {
  width: 100%;
  min-height: 48px;
  padding: 8px 11px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #fff;
  background: #555d5b;
  border: 1px solid #272d2c;
  border-radius: 2px;
  cursor: pointer;
}

.setting-toggle[aria-pressed="true"] {
  background: var(--blue);
}

.version-stamp {
  margin: 0;
  color: #4c5553;
  font-family: var(--font-lcd);
  font-size: 0.7rem;
}

@keyframes beam-fire {
  0% {
    opacity: 1;
    transform: scaleX(0);
  }

  55% {
    opacity: 1;
    transform: scaleX(1);
  }

  100% {
    opacity: 0;
    transform: scaleX(1);
  }
}

@keyframes feedback-pulse {
  50% {
    background-color: #cbd6a4;
  }
}

@keyframes device-hit {
  50% {
    transform: translateX(2px);
  }
}

@keyframes device-damage {
  35% {
    transform: translateX(-3px);
  }

  70% {
    transform: translateX(3px);
  }
}

@media (max-width: 800px) {
  body {
    padding-inline: 12px;
  }

  .site-bar,
  .workbench {
    width: 100%;
  }

  .workbench {
    grid-template-columns: minmax(0, 470px);
    gap: 20px;
  }

  .calculator-shell {
    justify-self: center;
  }

  .operator-panel {
    width: min(470px, 100%);
    margin-top: 0;
    justify-self: center;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(190px, 0.72fr);
    grid-template-areas:
      "head stats"
      "notes action";
    gap: 12px 16px;
  }

  .mission-header {
    grid-area: head;
    margin: 0;
  }

  .stat-grid {
    grid-area: stats;
    margin: 0;
  }

  .instructions {
    grid-area: notes;
    margin: 0;
  }

  .action-button {
    grid-area: action;
    align-self: end;
  }
}

@media (max-width: 480px) {
  body {
    padding: 0 9px 96px;
  }

  .site-bar {
    min-height: 58px;
    gap: 8px;
  }

  .brand-eyebrow {
    display: none;
  }

  .home-link {
    width: 44px;
    padding: 0;
    overflow: hidden;
    font-size: 0;
  }

  .home-link::before {
    content: "←";
    font-size: 1.2rem;
  }

  .workbench {
    margin-top: 12px;
  }

  .calculator-shell {
    width: min(365px, 100%);
    padding: 12px 13px 15px;
    aspect-ratio: auto;
    min-height: 590px;
    border-radius: 5px;
    box-shadow:
      0 6px 0 #4b5150,
      0 12px 20px rgb(0 0 0 / 30%);
  }

  .device-top {
    padding: 6px;
  }

  .lcd-frame {
    padding: 7px;
  }

  .lcd-glass {
    min-height: 112px;
    padding: 11px 9px 8px;
  }

  .calc-readout,
  .game-readout {
    min-height: 61px;
  }

  .calc-readout {
    font-size: clamp(2rem, 13vw, 3.2rem);
  }

  .game-readout {
    grid-template-columns: minmax(34px, 0.78fr) minmax(0, 7fr);
    gap: 3px;
  }

  .aim-cell,
  .invader-cell {
    font-size: clamp(1rem, 6.8vw, 1.65rem);
  }

  .identity-strip {
    min-height: 54px;
    margin-top: 8px;
    padding-block: 7px;
  }

  .casio-wordmark {
    font-size: 1rem;
  }

  .identity-copy > span {
    font-size: 0.42rem;
  }

  .game-mark {
    width: 45px;
    min-width: 45px;
    height: 36px;
  }

  .mode-deck {
    min-height: 78px;
    padding-top: 8px;
  }

  .mode-dot {
    width: 47px;
  }

  .auto-power {
    font-size: 0.48rem;
  }

  .memory-row {
    gap: 5px;
  }

  .keypad {
    margin-top: 19px;
    gap: 9px 5px;
  }

  .key,
  .keypad .key {
    min-height: 52px;
    border-bottom-width: 4px;
    font-size: 1rem;
  }

  .key-memory {
    min-height: 46px;
    font-size: 0.82rem;
  }

  .physical-caption {
    font-size: 0.42rem;
  }

  .operator-panel {
    padding: 15px 13px;
    display: block;
  }

  .mission-header,
  .stat-grid {
    margin-bottom: 13px;
  }

  .instructions {
    margin-top: 14px;
  }
}

/*
 * Card-sized landscape keeps the photographed upright silhouette intact.
 * The complete 470px chassis is optically scaled as one object so the preview
 * shows the LCD, mode deck and every key without reshaping the calculator.
 */
@media (orientation: landscape) and (min-width: 760px) and (min-height: 501px) and (max-height: 560px) {
  body {
    min-height: 100dvh;
    padding: 0 18px 10px;
    overflow: hidden;
  }

  .workbench {
    width: min(900px, 100%);
    min-height: 0;
    margin: 8px auto 0;
    grid-template-columns: 330px minmax(280px, 330px);
    justify-content: center;
    align-items: start;
    gap: 28px;
  }

  .calculator-shell {
    width: 470px;
    max-width: none;
    transform: scale(0.66);
    transform-origin: top left;
  }

  .operator-panel {
    width: 100%;
    max-height: calc(100dvh - 78px);
    margin-top: 0;
    overflow: hidden;
  }
}

/*
 * Short landscape reflows the same physical controls into an open service
 * position: display and mode deck left, five-column keypad right. No control
 * is scaled below its 44px touch target.
 */
@media (orientation: landscape) and (max-height: 500px) {
  html,
  body {
    min-height: 100%;
  }

  body {
    height: var(--mg880-vh);
    min-height: 0;
    padding: 0 70px 7px 7px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .site-bar {
    width: 100%;
    min-height: 48px;
    flex: 0 0 48px;
  }

  .brand-eyebrow {
    display: none;
  }

  .brand-title {
    font-size: 0.86rem;
  }

  .home-link,
  .icon-button {
    min-height: 44px;
    height: 44px;
  }

  .workbench {
    width: 100%;
    min-height: 0;
    margin: 5px 0 0;
    flex: 1 1 auto;
    grid-template-columns: minmax(390px, 1fr) clamp(158px, 25vw, 228px);
    gap: 7px;
  }

  .calculator-shell {
    width: 100%;
    height: calc(var(--mg880-vh) - 60px);
    min-height: 0;
    aspect-ratio: auto;
    padding: 7px 8px;
    display: grid;
    grid-template-columns: minmax(136px, 0.72fr) minmax(236px, 1.28fr);
    grid-template-rows: 44px minmax(0, 1fr);
    grid-template-areas:
      "top memory"
      "top keypad";
    column-gap: 8px;
    row-gap: 4px;
    overflow: hidden;
    border-radius: 4px;
    box-shadow:
      0 4px 0 #4b5150,
      0 7px 12px rgb(0 0 0 / 27%);
  }

  .calculator-shell::before {
    inset: 3px;
  }

  .device-top {
    grid-area: top;
    min-height: 0;
    height: 100%;
    padding: 4px;
    display: grid;
    grid-template-rows: minmax(99px, 1fr) auto auto;
    gap: 4px;
  }

  .lcd-frame {
    min-height: 0;
    height: auto;
    padding: 4px;
  }

  .lcd-glass {
    min-height: 87px;
    height: 100%;
    padding: 6px 6px 4px;
  }

  .calc-readout,
  .game-readout {
    min-height: 48px;
  }

  .calc-readout {
    font-size: clamp(1.45rem, 4.8vw, 2.6rem);
  }

  .game-readout {
    grid-template-columns: minmax(26px, 0.78fr) minmax(0, 7fr);
    gap: 2px;
  }

  .aim-cell,
  .invader-cell {
    font-size: clamp(0.76rem, 2.35vw, 1.28rem);
  }

  .aim-cell::after {
    display: none;
  }

  .invader-rail {
    gap: 1px;
  }

  .shot-beam {
    left: 29px;
  }

  .screen-status {
    min-height: 19px;
    margin-top: 2px;
    gap: 3px;
    font-size: 0.48rem;
  }

  .screen-meta {
    font-size: 0.43rem;
  }

  .game-banner {
    padding: 4px 5px;
    font-size: 0.54rem;
  }

  .identity-strip {
    min-height: 35px;
    margin: 0;
    padding: 3px 1px;
    border-bottom-width: 3px;
  }

  .casio-wordmark {
    font-size: 0.76rem;
  }

  .identity-copy > span {
    display: none;
  }

  .identity-copy > strong:not(.casio-wordmark) {
    font-size: 0.46rem;
  }

  .game-mark {
    width: 34px;
    min-width: 34px;
    height: 28px;
    padding-top: 13px;
    font-size: 0.37rem;
  }

  .game-notes {
    top: 1px;
    left: 3px;
    font-size: 0.7rem;
  }

  .mode-deck {
    min-height: 0;
    padding: 4px 1px 2px;
    align-self: stretch;
  }

  .mode-labels {
    gap: 3px;
  }

  .mode-dot {
    width: 44px;
    height: 44px;
    padding: 0 2px;
    font-size: 0.46rem;
  }

  .mode-dot.mode-music {
    font-size: 0.85rem;
  }

  .mode-switch {
    width: 134px;
    min-height: 44px;
    margin-top: 5px;
    padding-inline: 5px;
  }

  .mode-button {
    min-height: 44px;
    font-size: 0.48rem;
  }

  .mode-slider {
    bottom: 3px;
    left: 8px;
    width: 40px;
    height: 31px;
  }

  .auto-power {
    right: 0;
    bottom: 2px;
    top: auto;
    max-width: 70px;
    font-size: 0.42rem;
    text-align: right;
  }

  .memory-row {
    grid-area: memory;
    min-height: 44px;
    margin: 0;
    gap: 4px;
  }

  .memory-spacer,
  .key-memory {
    min-height: 44px;
    height: 44px;
  }

  .key-memory {
    font-size: 0.72rem;
  }

  .keypad {
    grid-area: keypad;
    min-height: 0;
    height: 100%;
    margin: 0;
    grid-template-rows: repeat(4, minmax(44px, 1fr));
    gap: 4px;
  }

  .key,
  .keypad .key {
    min-height: 44px;
    height: 100%;
    padding: 2px;
    border-bottom-width: 3px;
    border-radius: 3px;
    font-size: 0.83rem;
  }

  .memory-row .key {
    height: 44px;
  }

  .physical-caption {
    right: 0;
    left: 0;
    bottom: -9px;
    font-size: 0.34rem;
  }

  .operator-panel {
    width: 100%;
    min-height: 0;
    height: calc(var(--mg880-vh) - 60px);
    margin: 0;
    padding: 7px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-top-width: 5px;
    box-shadow: 4px 4px 0 rgb(7 14 17 / 30%);
  }

  .mission-header {
    min-height: 34px;
    margin: 0 0 5px;
    padding-bottom: 4px;
    gap: 4px;
    border-bottom-width: 2px;
  }

  .panel-kicker {
    display: none;
  }

  .mission-title {
    margin: 0;
    font-size: 0.82rem;
  }

  .phase-badge {
    min-width: 46px;
    min-height: 23px;
    padding: 3px;
    font-size: 0.47rem;
  }

  .stat-grid {
    margin: 0 0 5px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stat {
    min-height: 40px;
    padding: 3px 4px;
  }

  .stat-label {
    font-size: 0.44rem;
  }

  .stat-value {
    font-size: 0.82rem;
  }

  .instructions {
    margin: 4px 0 5px;
    padding-top: 4px;
    overflow: hidden;
  }

  .instruction-title {
    display: none;
  }

  .instruction-list {
    gap: 2px;
    font-size: 0.53rem;
    line-height: 1.12;
  }

  .instruction-list li {
    padding-left: 13px;
  }

  .instruction-list li::before {
    top: 0;
    width: 10px;
    height: 10px;
    font-size: 0.4rem;
  }

  .instruction-list li:nth-child(n + 3) {
    display: none;
  }

  kbd,
  .instruction-list kbd {
    padding: 0 2px;
    font-size: 0.49rem;
  }

  .action-button {
    min-height: 44px;
    margin-top: auto;
    padding: 5px 7px;
    border-bottom-width: 2px;
    font-size: 0.64rem;
  }
}

@media (orientation: landscape) and (max-height: 380px) {
  body {
    padding-right: 62px;
  }

  .site-bar {
    min-height: 44px;
    flex-basis: 44px;
  }

  .workbench {
    margin-top: 4px;
    grid-template-columns: minmax(384px, 1fr) clamp(150px, 25vw, 200px);
    gap: 6px;
  }

  .calculator-shell,
  .operator-panel {
    height: calc(var(--mg880-vh) - 54px);
  }

  .calculator-shell {
    grid-template-columns: minmax(133px, 0.7fr) minmax(236px, 1.3fr);
    padding: 5px 7px;
    row-gap: 3px;
  }

  .lcd-glass {
    min-height: 80px;
    padding-block: 4px;
  }

  .calc-readout,
  .game-readout {
    min-height: 45px;
  }

  .identity-strip {
    min-height: 31px;
  }

  .mode-deck {
    padding-top: 2px;
  }

  .mode-dot {
    width: 44px;
  }

  .memory-row,
  .keypad {
    gap: 3px;
  }

  .instructions {
    display: none;
  }
}

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

  .key:active,
  .key.is-pressed,
  .action-button:active {
    transform: none;
  }
}

@media (forced-colors: active) {
  .calculator-shell,
  .lcd-frame,
  .lcd-glass,
  .key,
  .mode-dot,
  .mode-button,
  .operator-panel,
  .stat,
  .action-button {
    border: 2px solid CanvasText;
  }

  .mode-button[aria-pressed="true"],
  .mode-dot[aria-pressed="true"],
  .setting-toggle[aria-pressed="true"] {
    outline: 3px solid Highlight;
    outline-offset: -4px;
  }
}
