:root {
  color-scheme: dark;
  --bg: #10171b;
  --panel: #182329;
  --ink: #e6e1ce;
  --muted: #a6b2ae;
  --red: #b5555d;
  --line: #36434a;
  --accent: #c5aa78;
  font-family: Consolas, 'Courier New', monospace;
  background: var(--bg);
  color: var(--ink);
}
* {
  box-sizing: border-box;
  scrollbar-width: auto;
  scrollbar-color: #697a78 #151f25;
}
::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: #151f25;
}
::-webkit-scrollbar-thumb {
  background: #697a78;
  border: 3px solid #151f25;
  border-radius: 7px;
}
::-webkit-scrollbar-thumb:hover {
  background: #8d9b91;
}
::-webkit-scrollbar-thumb:active {
  background: #b3baaa;
}
::-webkit-scrollbar-thumb:disabled {
  background: #38474c;
}
body {
  margin: 0;
  padding: max(12px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  min-height: 100svh;
}
button,
select,
a,
input {
  font: inherit;
}
button,
select {
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 3px;
  min-height: 44px;
  padding: 10px 16px;
  cursor: pointer;
}
button:hover,
select:hover {
  border-color: #a8b3a5;
  background: #27333a;
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 2px solid #dac995;
  outline-offset: 4px;
}
a {
  color: var(--muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}
a:hover {
  color: var(--ink);
}
[hidden] {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}
#game-app {
  width: min(1120px, 100%);
  margin: auto;
}
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  flex-wrap: wrap;
}
.wordmark {
  font-size: 16px;
  letter-spacing: 2px;
}
.wordmark span {
  color: #c5aa78;
}
.toolbar-controls {
  display: flex;
  gap: 8px;
}
select {
  max-width: 160px;
}
#back::before {
  content: '←';
  margin-right: 10px;
}
.game-shell {
  border: 1px solid var(--line);
  box-shadow: 0 20px 70px #0004;
  margin-top: 18px;
  background: #111a20;
}
.hud {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 12px 20px;
  min-height: 70px;
  background: #151f25;
  border-bottom: 1px solid var(--line);
}
.hud span {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.hud small {
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--muted);
  text-transform: uppercase;
}
.hud b {
  font-size: 19px;
  font-weight: 700;
}
.hud button {
  margin-left: auto;
}
#health-value {
  color: #cb7a79;
  font-size: 15px;
  letter-spacing: 2px;
}
.arena {
  position: relative;
  isolation: isolate;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16/9;
  image-rendering: pixelated;
  touch-action: none;
  cursor: crosshair;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: #0b1419ba;
  backdrop-filter: blur(1px);
  overflow: auto;
  text-align: center;
}
.menu-panel {
  max-width: 560px;
}
.eyebrow {
  color: #adb7aa;
  font-size: 11px;
  letter-spacing: 4px;
}
h1 {
  margin: 12px 0;
  font-family: Impact, 'Arial Black', sans-serif;
  font-size: clamp(32px, 6vw, 78px);
  line-height: 0.95;
  letter-spacing: 1px;
  text-shadow: 3px 3px #080d12;
}
h1 span {
  color: #c5aa78;
}
#overlay-detail {
  color: #c5c9ba;
  font-size: 14px;
  line-height: 1.5;
}
.record {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 20px 0;
}
.record b {
  color: #e4d2a5;
}
.menu-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}
.primary {
  background: #405a76;
  border-color: #8b9eab;
  color: #fff0de;
  box-shadow: 0 3px 0 #1c2e43;
}
.primary:hover {
  background: #526f8d;
}
.boss-hud {
  position: absolute;
  top: 12px;
  left: 25%;
  right: 25%;
  background: #10191eeb;
  border: 1px solid #735252;
  padding: 8px 12px;
}
.boss-hud div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 10px;
  margin-bottom: 5px;
}
.boss-hud progress {
  appearance: none;
  display: block;
  width: 100%;
  height: 6px;
  border: 0;
  background: #313b37;
  accent-color: #ba6c6a;
}
.boss-hud progress::-webkit-progress-bar {
  background: #313b37;
}
.boss-hud progress::-webkit-progress-value {
  background: #ba6c6a;
}
.boss-hud progress::-moz-progress-bar {
  background: #ba6c6a;
}
#infection-value {
  color: #b3c19c;
}
.game-footer {
  padding: 18px 2px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.8;
}
.game-footer p {
  margin: 0 0 12px;
}
.options {
  display: flex;
  gap: 12px 24px;
  align-items: center;
  flex-wrap: wrap;
}
.options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  cursor: pointer;
}
.options input {
  width: 18px;
  height: 18px;
  accent-color: #ba6c6a;
}
.options #save-status {
  max-width: 460px;
  color: #889a94;
  font-size: 11px;
}
#boss-help {
  margin-top: 8px;
  color: #b9b69e;
}
.touch-controls {
  display: none;
  padding: 12px 18px;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #151f25;
  border-top: 1px solid var(--line);
}
.touch-pad {
  width: 96px;
  height: 96px;
  border: 1px solid #52615d;
  background: #213139;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  touch-action: none;
  user-select: none;
}
.touch-pad span {
  font-size: 29px;
}
.touch-pad small {
  font-size: 10px;
  max-width: 84px;
  text-align: center;
}
.touch-pad.active {
  background: #38504e;
  border-color: #b4b99f;
}
.intro {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  padding: max(20px, env(safe-area-inset-top)) 20px
    max(20px, env(safe-area-inset-bottom));
  background: #0b1016;
  overflow: auto;
  text-align: center;
}
.intro > img {
  width: min(40vh, 330px);
  height: auto;
  object-fit: contain;
}
.intro .partner-logo {
  width: 90px;
  height: 90px;
}
.intro p {
  color: #b8c0b2;
  font-size: 13px;
  margin: 0;
}
.intro small {
  color: #8f9e99;
  font-size: 12px;
}
.intro strong {
  letter-spacing: 3px;
  font-size: clamp(18px, 4vw, 30px);
  color: #d8b9aa;
}
.intro .intro-close {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  font-size: 26px;
  padding: 0;
  width: 44px;
  height: 44px;
  z-index: 21;
}
.intro #intro-play {
  margin-top: 4px;
  font-size: 12px;
}
@media (pointer: coarse) {
  .touch-controls {
    display: flex;
  }
  #controls {
    font-size: 10px;
  }
  #fullscreen {
    display: none;
  }
}
@media (max-width: 600px) {
  body {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
  .toolbar {
    gap: 6px;
  }
  .toolbar .wordmark {
    display: none;
  }
  .toolbar-controls {
    gap: 4px;
  }
  .toolbar button {
    padding: 8px;
    font-size: 11px;
  }
  .toolbar select {
    max-width: 125px;
    font-size: 12px;
  }
  .hud {
    gap: 14px;
    padding: 8px 10px;
    min-height: 64px;
  }
  .hud b {
    font-size: 15px;
  }
  #health-value {
    font-size: 11px;
    letter-spacing: 0;
  }
  .hud button {
    font-size: 11px;
    padding: 6px;
  }
  .overlay {
    padding: 12px;
  }
  h1 {
    font-size: 32px;
    margin: 7px 0;
  }
  .eyebrow {
    font-size: 9px;
    margin: 0;
    letter-spacing: 2px;
  }
  #overlay-detail {
    font-size: 11px;
    margin: 8px 0;
  }
  .record {
    margin: 8px 0;
    font-size: 10px;
  }
  .menu-actions {
    gap: 6px;
  }
  .menu-actions button {
    padding: 6px 9px;
    font-size: 11px;
    min-height: 40px;
  }
  .boss-hud {
    left: 15%;
    right: 15%;
    top: 6px;
  }
  .boss-hud div {
    font-size: 8px;
  }
  .intro > img {
    width: min(36vh, 260px);
  }
  .intro .partner-logo {
    width: 60px;
    height: 60px;
  }
}
@media (max-height: 550px) and (orientation: landscape) {
  .intro {
    gap: 4px;
    justify-content: flex-start;
    padding-top: 12px;
  }
  .intro > img {
    width: 140px;
  }
  .intro .partner-logo {
    width: 40px;
    height: 40px;
  }
  .intro p {
    font-size: 11px;
  }
  .game-shell {
    margin-top: 6px;
  }
  .toolbar {
    min-height: 44px;
  }
  .hud {
    min-height: 48px;
    padding: 4px 12px;
  }
  .game-footer {
    padding: 8px 0;
  }
  .touch-pad {
    width: 72px;
    height: 72px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
@media (forced-colors: active) {
  * {
    scrollbar-color: auto;
  }
  button,
  select,
  progress {
    forced-color-adjust: auto;
  }
  .game-shell,
  .touch-pad {
    border: 1px solid CanvasText;
  }
}

/* Wrapping keeps controls reachable with compact viewports and browser zoom. */
.toolbar-controls {
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}
.hud {
  flex-wrap: wrap;
}
.overlay {
  align-items: safe center;
  justify-content: safe center;
}
.menu-panel {
  margin: auto;
  flex-shrink: 0;
  max-width: 100%;
}
/* Language direction mirrors chrome, never world coordinates or aiming. */
.game-shell,
.wordmark,
#wave-value,
#score-value,
#best-value {
  direction: ltr;
  unicode-bidi: isolate;
}
[dir='rtl'] .hud-stats,
[dir='rtl'] .special-hud > div,
[dir='rtl'] .overlay,
[dir='rtl'] .boss-hud,
[dir='rtl'] .touch-pad small {
  direction: rtl;
}
#translation-notice {
  color: var(--muted);
  font-size: 0.9em;
  overflow-wrap: anywhere;
}
.hud button {
  margin-left: 0;
  margin-inline-start: auto;
}
#back::before {
  margin-right: 0;
  margin-inline-end: 10px;
}
[dir='rtl'] #back::before {
  content: '→';
}
button,
label,
strong,
.record,
#boss-status {
  min-width: 0;
  overflow-wrap: anywhere;
}
.toolbar-controls select {
  max-width: min(220px, 70vw);
}
.touch-controls > button {
  max-width: 104px;
  min-width: 44px;
  font-size: 11px;
}
.touch-pad {
  flex-shrink: 0;
}
.touch-pad small {
  overflow-wrap: anywhere;
}
.boss-hud {
  position: static;
  inset: auto;
  padding: 9px 14px;
  border: 0;
  border-bottom: 1px solid #735252;
  background: #172229;
}
.boss-hud > div {
  flex-wrap: wrap;
  gap: 5px 15px;
}
.boss-hud #boss-phase {
  margin-inline-start: auto;
}
.boss-hud #boss-status {
  margin: 6px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: #d8c499;
}
.boss-hud[data-mode='weak'] #boss-status {
  color: #e4a38e;
}
.boss-hud[data-mode='latched'] progress {
  accent-color: #c57273;
}
.boss-hud[data-mode='latched'] progress::-webkit-progress-value {
  background: #c57273;
}
.boss-hud[data-mode='latched'] progress::-moz-progress-bar {
  background: #c57273;
}
#suck[aria-pressed='true'] {
  background: #743e48;
  border-color: #d3918d;
}
.hud b,
.record b,
#boss-phase,
#infection-value {
  unicode-bidi: isolate;
}
.record,
#overlay-detail,
#boss-status {
  unicode-bidi: plaintext;
}
.translation-notice {
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
  padding: 12px 0;
  border-top: 1px solid var(--line);
  overflow-wrap: anywhere;
}
.wordmark {
  max-width: 300px;
  line-height: 1.3;
  font-size: 13px;
}
.special-hud {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  padding: 12px 20px;
  background: #1b2a3b;
  border-bottom: 1px solid var(--line);
}
.special-hud > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12px;
  align-items: center;
}
.special-hud progress {
  grid-column: 1;
  appearance: none;
  width: 100%;
  height: 10px;
  border: 0;
  background: #303e4b;
  accent-color: #aa936a;
}
.special-hud progress::-webkit-progress-bar {
  background: #303e4b;
}
.special-hud progress::-webkit-progress-value {
  background: #aa936a;
}
.special-hud progress::-moz-progress-bar {
  background: #aa936a;
}
.special-hud button {
  grid-column: 2;
  grid-row: 1/3;
  font-size: 12px;
}
.special-hud[data-ready='true'] {
  border-bottom-color: #aa936a;
}
.special-hud[data-ready='true'] #special-status {
  color: #e6d2a9;
}
h1 {
  font-size: clamp(28px, 5vw, 64px);
  line-height: 1.04;
}
.intro > img {
  width: min(46vh, 360px);
}
.intro strong {
  max-width: 620px;
}
.intro p {
  letter-spacing: 3px;
}
.touch-controls {
  gap: 8px;
}
.menu-panel {
  padding-block: 8px;
}
@media (max-width: 600px) {
  .special-hud {
    padding: 10px;
    gap: 7px 10px;
  }
  .special-hud > div {
    font-size: 10px;
    flex-wrap: wrap;
    gap: 4px;
  }
  .special-hud button {
    font-size: 10px;
    padding: 8px;
    max-width: 115px;
  }
  h1 {
    font-size: 28px;
  }
  .arena {
    min-height: 230px;
  }
  .intro > img {
    width: min(44vh, 290px);
  }
}
@media (max-height: 550px) and (orientation: landscape) {
  .intro > img {
    width: 150px;
  }
  .intro {
    justify-content: center;
  }
  .touch-controls {
    padding: 8px;
  }
  .special-hud {
    padding: 7px 12px;
  }
}

/* One stage scales by both dimensions; world and pointer coordinates stay 16:9. */
.hud-stats {
  display: flex;
  gap: 32px;
  min-width: 0;
  flex-wrap: wrap;
}
.hud-stats > span {
  min-width: 0;
}
.stage {
  min-width: 0;
}
.game-settings {
  margin-top: 8px;
  min-width: 0;
}
.game-settings > summary {
  min-height: 44px;
  padding: 10px 2px;
  cursor: pointer;
  color: var(--muted);
}
.game-settings > summary:focus-visible {
  outline: 2px solid #dac995;
  outline-offset: 2px;
}
.game-settings[open] > summary {
  color: var(--ink);
}
.rotate-notice {
  display: none;
  position: fixed;
  z-index: 30;
  inset: 0;
  flex-direction: column;
  justify-content: safe center;
  align-items: center;
  gap: 16px;
  padding: max(24px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
  overflow: auto;
  background: var(--bg);
  text-align: center;
}
.rotate-icon {
  width: 96px;
  height: 96px;
  flex-shrink: 0;
  color: #bda57d;
}
.rotate-notice h2 {
  font-size: clamp(24px, 7vw, 36px);
  margin: 0;
}
.rotate-notice p {
  margin: 0;
  line-height: 1.65;
  max-width: 30em;
}
.rotate-notice .eyebrow {
  letter-spacing: 2px;
  font-size: 11px;
}
.rotate-notice > a {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-top: 8px;
}
@media (max-width: 600px) {
  .hud-stats {
    gap: 14px;
  }
  .arena {
    min-height: 0;
  }
}
@media (any-pointer: coarse) {
  .touch-controls {
    display: flex;
  }
  #fullscreen {
    display: none;
  }
}
@media (any-pointer: coarse) and (orientation: portrait) {
  .rotate-notice {
    display: flex;
  }
  #game-content {
    visibility: hidden;
  }
  body {
    overflow: hidden;
  }
}
@media (any-pointer: coarse) and (orientation: landscape) {
  body {
    height: 100dvh;
    min-height: 0;
    padding: max(6px, env(safe-area-inset-top))
      max(6px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom))
      max(6px, env(safe-area-inset-left));
  }
  #game-app {
    width: 100%;
    height: 100%;
  }
  #game-content {
    display: grid;
    height: 100%;
    min-height: 0;
    grid-template-rows: 44px minmax(0, 1fr) 32px;
    gap: 4px;
  }
  .toolbar {
    min-height: 44px;
    gap: 8px;
    flex-wrap: nowrap;
  }
  .toolbar .wordmark {
    display: none;
  }
  .toolbar-controls {
    flex-wrap: nowrap;
    max-width: 45%;
  }
  .toolbar select {
    min-height: 44px;
    max-width: min(180px, 40vw);
    padding: 6px;
    font-size: 12px;
  }
  #back {
    font-size: 12px;
    max-width: 52%;
    line-height: 1.25;
  }
  .game-shell {
    display: grid;
    grid-template-columns: 100px minmax(0, 1fr) 100px;
    grid-template-rows: auto minmax(44px, 1fr) 44px;
    gap: 4px;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 4px;
    box-shadow: none;
  }
  .hud,
  .special-hud,
  .touch-controls {
    display: contents;
  }
  .hud-stats {
    grid-column: 1;
    grid-row: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-content: start;
    gap: 3px 6px;
    padding: 4px;
  }
  .hud-stats > span {
    gap: 2px;
  }
  .hud-stats > span:last-child {
    grid-column: 1/-1;
  }
  .hud small {
    font-size: 9px;
    letter-spacing: 0;
  }
  .hud b {
    font-size: 12px;
    overflow-wrap: anywhere;
  }
  #health-value {
    font-size: 11px;
    letter-spacing: 0;
  }
  .stage {
    grid-column: 2;
    grid-row: 1/4;
    min-height: 0;
    min-width: 0;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    background: #101a28;
  }
  .boss-hud {
    padding: 3px 6px;
    min-width: 0;
  }
  .boss-hud > div {
    margin-bottom: 3px;
    font-size: 10px;
  }
  .boss-hud #boss-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    margin: 0;
  }
  .arena {
    display: grid;
    place-items: center;
    min-height: 0;
    min-width: 0;
    container-type: size;
  }
  canvas {
    width: min(100cqw, 177.7777778cqh);
    height: auto;
    max-width: 100%;
    aspect-ratio: 16/9;
  }
  .overlay {
    padding: 8px;
  }
  .menu-panel {
    padding: 4px;
  }
  h1 {
    font-size: clamp(18px, 3vw, 32px);
    margin: 6px 0;
  }
  .eyebrow {
    font-size: 9px;
    margin: 0;
    letter-spacing: 1px;
  }
  #overlay-detail {
    font-size: 11px;
    margin: 6px 0;
  }
  .record {
    margin: 6px 0;
    font-size: 10px;
  }
  .menu-actions {
    gap: 5px;
  }
  .menu-actions button {
    font-size: 11px;
    padding: 5px 8px;
    min-height: 44px;
  }
  #move-pad {
    grid-column: 1;
    grid-row: 2;
    justify-self: center;
    align-self: center;
  }
  #aim-pad {
    grid-column: 3;
    grid-row: 2;
    justify-self: center;
    align-self: center;
  }
  .touch-pad {
    width: 76px;
    height: 76px;
    max-height: 100%;
    min-height: 44px;
  }
  .touch-pad span {
    font-size: 24px;
  }
  .touch-pad small {
    font-size: 10px;
  }
  #pause,
  #dash {
    grid-column: 1;
    grid-row: 3;
    width: 48%;
    min-height: 44px;
    max-width: none;
    padding: 4px;
    font-size: 9px;
    margin: 0;
  }
  #pause {
    justify-self: start;
  }
  #dash {
    justify-self: end;
  }
  .special-hud > div {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    flex-direction: column;
    text-align: center;
    gap: 4px;
    font-size: 10px;
    padding: 4px 2px 16px;
  }
  #special-health {
    grid-column: 3;
    grid-row: 1;
    align-self: end;
    height: 8px;
  }
  #special-button {
    grid-column: 3;
    grid-row: 3;
    width: 100%;
    max-width: none;
    min-height: 44px;
    padding: 4px;
    font-size: 10px;
  }
  .game-settings {
    margin: 0;
    min-width: 0;
  }
  .game-settings > summary {
    display: flex;
    align-items: center;
    min-height: 32px;
    padding: 4px 8px;
    font-size: 12px;
    border: 1px solid var(--line);
    border-radius: 3px;
  }
  .game-settings > summary::before {
    content: '▸';
    margin-inline-end: 8px;
  }
  .game-settings[open] > summary::before {
    content: '▾';
  }
  .game-settings[open] {
    position: fixed;
    bottom: max(6px, env(safe-area-inset-bottom));
    left: max(6px, env(safe-area-inset-left));
    right: max(6px, env(safe-area-inset-right));
    z-index: 16;
    max-height: calc(
      100dvh - max(6px, env(safe-area-inset-top)) -
        max(6px, env(safe-area-inset-bottom)) - 48px
    );
    overflow: auto;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 3px;
  }
  .game-settings[open] > summary {
    position: sticky;
    top: 0;
    min-height: 44px;
    z-index: 1;
    background: var(--panel);
    color: var(--ink);
  }
  .game-footer {
    padding: 12px;
    font-size: 12px;
  }
  .game-footer .options {
    gap: 8px 20px;
    font-size: 13px;
  }
  .intro {
    gap: 5px;
  }
  .intro > img {
    width: min(32dvh, 160px);
  }
}
@media (any-pointer: coarse) and (orientation: landscape) and (max-height: 330px) {
  .game-shell {
    grid-template-columns: 92px minmax(0, 1fr) 92px;
    gap: 3px;
    padding: 3px;
  }
  .touch-pad {
    width: 60px;
    height: 60px;
  }
  .hud-stats {
    gap: 2px 4px;
    padding: 2px;
  }
  .special-hud > div {
    font-size: 9px;
    gap: 2px;
  }
}
@media (any-pointer: coarse) and (orientation: landscape) {
  .stage > .arena {
    grid-row: 2;
  }
}

@media (any-pointer: coarse) and (orientation: landscape) {
  #pause,
  #dash {
    min-width: 44px;
  }
}

.library-panel {
  position: fixed;
  z-index: 40;
  inset: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  width: min(
    900px,
    calc(
      100% - max(8px, env(safe-area-inset-left)) -
        max(8px, env(safe-area-inset-right))
    )
  );
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 0 0 100vmax #080f14e8;
}
.library-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  min-width: 0;
}
.library-header h2 {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: clamp(15px, 3vw, 24px);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.library-header button {
  flex-shrink: 0;
  min-width: 44px;
  min-height: 44px;
  max-width: 35%;
  font-size: 12px;
}
.library-header #library-close {
  font-size: 24px;
  padding: 4px;
  width: 44px;
  max-width: 44px;
}
.library-body {
  flex: 1;
  min-height: 0;
  padding: clamp(14px, 4vw, 32px);
  overflow: auto;
  overscroll-behavior: contain;
  text-align: center;
}
.library-prose {
  max-width: 680px;
  margin: 0 auto 20px;
  text-align: start;
  font-size: 14px;
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.library-action {
  margin: 6px;
  min-height: 48px;
  max-width: 100%;
  overflow-wrap: anywhere;
}
.enemy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 12px;
}
.enemy-grid button {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: start;
}
.enemy-marker {
  font-size: 24px;
  color: var(--accent);
}
.enemy-picture {
  width: min(300px, 100%);
  height: auto;
  image-rendering: pixelated;
  margin: 0 auto 24px;
  border: 1px solid var(--line);
  touch-action: pan-y;
}
.library-stat {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  max-width: 600px;
  margin: 14px auto;
  font-size: 13px;
  line-height: 1.6;
  text-align: start;
  overflow-wrap: anywhere;
}
.library-stat > * {
  min-width: 0;
}
.library-stat b {
  unicode-bidi: isolate;
  text-align: end;
  color: var(--accent);
}
.credit-logo {
  width: min(180px, 40vw);
  height: 180px;
  object-fit: contain;
  margin: 16px;
}
.library-body > strong {
  display: block;
  margin: 16px 0 24px;
  letter-spacing: 3px;
  overflow-wrap: anywhere;
}
.library-body .game-footer {
  padding: 0;
  margin: 0;
  text-align: start;
}
.library-body .options {
  display: grid;
  gap: 20px;
  font-size: 16px;
}
.library-body .options label {
  display: flex;
  align-items: center;
  min-height: 44px;
  gap: 12px;
}
.library-body .options input {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.intro {
  padding: max(64px, calc(env(safe-area-inset-top) + 56px))
    max(20px, env(safe-area-inset-right))
    max(84px, calc(env(safe-area-inset-bottom) + 76px))
    max(20px, env(safe-area-inset-left));
}
.intro-scene {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 0;
  max-width: 100%;
  animation: intro-scene-in 420ms ease-out both;
}
.intro-scene img {
  width: min(36dvh, 240px);
  height: auto;
  max-height: 50dvh;
  object-fit: contain;
}
.intro-scene strong {
  font-size: clamp(16px, 3vw, 30px);
  text-align: center;
  overflow-wrap: anywhere;
}
.intro-close {
  z-index: 2;
}
.intro #intro-play {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(
    100% - max(32px, env(safe-area-inset-left)) -
      max(32px, env(safe-area-inset-right))
  );
  min-height: 44px;
  margin: 0;
}
@keyframes intro-scene-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@media (max-height: 430px) {
  .library-header {
    padding: 4px 8px;
  }
  .library-body {
    padding: 12px;
  }
  .library-prose {
    margin-bottom: 14px;
    font-size: 13px;
  }
  .credit-logo {
    width: 90px;
    height: 90px;
  }
  .enemy-picture {
    width: min(200px, 100%);
    margin-bottom: 16px;
  }
  .intro-scene {
    gap: 4px;
  }
  .intro-scene img {
    width: min(28dvh, 120px);
  }
}
@media (forced-colors: active) {
  .library-panel,
  .enemy-picture {
    border-color: CanvasText;
  }
  .enemy-marker,
  .library-stat b {
    color: CanvasText;
  }
}
@media (any-pointer: coarse) and (orientation: landscape) {
  #pause,
  #dash,
  #special-button {
    font-size: 0;
  }
  #pause::before {
    content: 'Ⅱ';
    font-size: 22px;
    line-height: 1;
  }
  #pause[data-paused='true']::before {
    content: '▶';
    font-size: 18px;
  }
  #dash::before {
    content: '»';
    font-size: 28px;
    line-height: 1;
  }
  #special-button::before {
    content: '🎩';
    font-size: 24px;
    line-height: 1;
  }
}
@media (any-pointer: coarse) and (orientation: landscape) {
  .game-shell {
    grid-template-rows: clamp(64px, 22dvh, 96px) minmax(44px, 1fr) 44px;
  }
  .hud-stats,
  .special-hud > div {
    min-height: 0;
    max-height: 100%;
    overflow: auto;
  }
  .hud-stats small {
    overflow-wrap: anywhere;
  }
}
