@font-face {
  font-family: "Akashi";
  src: url("public/original/Fonts/Akashi.ttf") format("truetype");
  font-display: block;
}

@font-face {
  font-family: "Munro Small";
  src: url("public/original/Fonts/munroSmall.ttf") format("truetype");
  font-display: block;
}

:root {
  color-scheme: dark;
  --chainary-vw: 100vw;
  --chainary-vh: 100vh;
  --chainary-vv-left: 0px;
  --chainary-vv-top: 0px;
  --stage-ratio: 1.5;
  --stage-scale: 1;
  --stage-width: 480px;
  --stage-height: 320px;
  --game-background-image: none;
  --game-background-physical-tile-size: 10px;
  --viewport-stage-left: 0px;
  --viewport-stage-top: 0px;
  --viewport-stage-bottom: 320px;
  --viewport-stage-center-y: 160px;
  --title-binary-width: 480px;
  --viewport-stage-width: 480px;
  --binary-horizontal-overscan: 20px;
  --viewport-overlay-bleed: 1px;
  --breakable-block-backing-bleed: 0px;
  --mobile-input-backdrop-bottom: 1px;
  --game-block-image: none;
  --stage-bg: #030303;
  --text: #ffffff;
  --red: #e3131b;
  --panel-shadow: rgba(0, 0, 0, 0.72);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --rounded: "Arial Rounded MT Bold", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  --system: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@supports (height: 100svh) {
  :root {
    --chainary-vh: 100svh;
  }
}

* {
  box-sizing: border-box;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #050506;
  color: var(--text);
  font-family: "Munro Small", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0;
  -webkit-text-size-adjust: 100%;
  touch-action: none;
}

button {
  appearance: none;
  border: 0;
  border-radius: 0;
  margin: 0;
  padding: 0;
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: default;
  opacity: 0.42;
}

.optical-label {
  display: block;
  width: max-content;
  line-height: 1;
  pointer-events: none;
  transform: translate(var(--optical-label-x, 0), var(--optical-label-y, 0));
}

.app-shell {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--chainary-vw);
  height: var(--chainary-vh);
  min-height: var(--chainary-vh);
  display: grid;
  place-items: center;
  padding: 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));
  background: #050506;
  overflow: clip;
  touch-action: none;
  transform: translate3d(var(--chainary-vv-left), var(--chainary-vv-top), 0);
  transform-origin: top left;
}

.app-shell.is-game-screen {
  background-color: #f2f2f2;
  background-image: var(--game-background-image);
  background-position: center top;
  background-repeat: repeat;
  background-size: var(--game-background-physical-tile-size) var(--game-background-physical-tile-size);
  image-rendering: pixelated;
}

.app-shell.is-level-screen {
  align-items: start;
}

html.chainary-installed,
html.chainary-installed body {
  /* Keep 100vh authoritative throughout the installed-app session. */
  height: 100vh;
  min-height: 100vh;
}

html.chainary-installed .app-shell {
  right: 0;
  bottom: 0;
  width: auto;
  height: auto;
  min-height: 0;
  transform: none;
}

.app-shell:fullscreen,
.app-shell:-webkit-full-screen {
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  background-color: #050506;
}

.debug-hud {
  position: absolute;
  right: max(8px, env(safe-area-inset-right));
  top: max(8px, env(safe-area-inset-top));
  z-index: 100;
  width: min(540px, calc(100% - 16px));
  padding: 8px 10px 9px;
  border: 1px solid rgba(70, 255, 139, 0.9);
  background: rgba(0, 10, 4, 0.9);
  color: #71ff9f;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.65);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.35;
  letter-spacing: 0;
  text-align: left;
  image-rendering: auto;
  pointer-events: none;
}

html.chainary-ios .debug-hud {
  box-shadow: none;
}

.debug-hud-header {
  min-height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 5px;
  color: #d9ffe5;
  font-size: 12px;
  font-weight: 700;
}

.debug-hud-controls {
  display: flex;
  align-items: stretch;
  gap: 6px;
  margin-bottom: 5px;
}

.debug-collapse,
.debug-toggle {
  min-height: 28px;
  pointer-events: auto;
}

.debug-collapse {
  min-width: 44px;
  padding: 2px 7px;
  border: 1px solid rgba(113, 255, 159, 0.72);
  background: rgba(113, 255, 159, 0.12);
  color: #d9ffe5;
  font: inherit;
  line-height: 1;
}

.debug-toggle {
  flex: 1 1 0;
  min-width: 0;
  padding: 2px 7px;
  border: 1px solid #71ff9f;
  background: rgba(44, 162, 83, 0.42);
  color: #fff;
  font: inherit;
  line-height: 1;
  pointer-events: auto;
}

.debug-hud.is-collapsed {
  width: auto;
  padding: 5px 7px;
}

.debug-hud.is-collapsed .debug-hud-header {
  min-height: 28px;
  margin-bottom: 0;
}

.debug-hud.is-collapsed .debug-hud-controls,
.debug-hud.is-collapsed .debug-metrics {
  display: none;
}

.debug-toggle.is-off {
  border-color: #ff7575;
  background: rgba(162, 44, 44, 0.42);
  color: #ffd4d4;
}

.debug-metrics {
  min-height: 0;
  margin: 0;
  overflow: hidden;
  color: inherit;
  font: inherit;
  white-space: pre;
}

.stage.is-debug-invincible .player {
  filter: drop-shadow(0 0 2px #24ff70) drop-shadow(0 0 1px #fff);
}

.stage-wrap {
  position: relative;
  width: var(--stage-width);
  height: var(--stage-height);
  display: block;
  overflow: visible;
}

.stage {
  position: absolute;
  left: 0;
  top: 0;
  width: 480px;
  height: 320px;
  overflow: visible;
  background-color: var(--stage-bg);
  image-rendering: pixelated;
  touch-action: none;
  isolation: isolate;
  transform: scale(var(--stage-scale));
  transform-origin: top left;
}

.stage[data-screen="game"] {
  background-color: transparent;
  background-image: none;
  overflow: visible;
}

.stage[data-screen="game"]::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  z-index: 1;
  width: calc(var(--title-binary-width) + 50px);
  height: 100%;
  background-image: var(--game-block-image), var(--game-block-image);
  background-position: calc(50% + 10px) 80px, calc(50% + 10px) 120px;
  background-repeat: repeat-x;
  background-size: 20px 20px;
  pointer-events: none;
  transform: translateX(-50%) translateZ(0);
}

.stage[data-screen="game"].is-boss-level::after {
  background-image: var(--game-block-image);
  background-position: calc(50% + 10px) 120px;
}

.screen,
.game-layer,
.sprite-layer,
.binary-background,
.modal-root,
.tutorial-overlay {
  position: absolute;
  inset: 0;
}

.screen,
.game-layer {
  z-index: 2;
}

.game-layer {
  overflow: visible;
}

.binary-background,
.modal-binary {
  color: var(--red);
  opacity: 0.88;
  font-family: "Munro Small", monospace;
  font-size: 20px;
  line-height: 0.9;
  white-space: normal;
  overflow-wrap: anywhere;
  overflow: hidden;
  text-align: left;
  pointer-events: none;
}

.binary-background {
  inset: auto;
  left: calc(var(--viewport-stage-left) - var(--binary-horizontal-overscan));
  top: var(--viewport-stage-center-y);
  width: calc(
    var(--viewport-stage-width) +
    var(--binary-horizontal-overscan) +
    var(--binary-horizontal-overscan)
  );
  max-height: calc(var(--viewport-stage-bottom) - var(--viewport-stage-top));
  z-index: 0;
  transform: translateY(-50%) translateZ(0);
}

.text-button {
  color: #fff;
  text-shadow: 0 2px 0 #000;
}

.title-screen,
.credits-screen {
  background: transparent;
}

.title-lockup {
  position: absolute;
  top: 31px;
  left: 50%;
  width: max-content;
  transform: translateX(-50%);
}

.title-word {
  margin: 0;
  color: #fff;
  font-family: "Akashi", serif;
  font-size: 40px;
  font-weight: 400;
  line-height: 1;
  text-align: center;
}

.title-chai {
  position: absolute;
  width: 8px;
  height: 13px;
  left: 78px;
  top: -6px;
  image-rendering: pixelated;
}

.title-nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 75px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 58px;
}

.title-button {
  min-width: 72px;
  min-height: 46px;
  font-size: 30px;
  line-height: 1;
}

.level-screen {
  overflow: visible;
}

.level-grid {
  position: absolute;
  left: 24px;
  top: 40px;
  width: 432px;
  height: calc(var(--viewport-stage-bottom) - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 16px;
  display: grid;
  grid-template-columns: repeat(8, 42px);
  grid-auto-rows: 42px;
  gap: 13px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.level-grid::-webkit-scrollbar {
  display: none;
}

.level-button {
  --level-content-opacity: 1;
  position: relative;
  width: 42px;
  height: 42px;
  color: #fff;
  background-repeat: no-repeat;
  background-size: 42px 42px;
  image-rendering: pixelated;
}

.level-button:disabled {
  opacity: 1;
}

.level-content {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: var(--level-content-opacity);
  pointer-events: none;
}

.level-art {
  position: absolute;
  inset: 0;
  z-index: 1;
  background-repeat: no-repeat;
  background-size: 42px 42px;
  image-rendering: pixelated;
  pointer-events: none;
}

.level-button:not(:disabled):active .level-art {
  filter: brightness(0.65);
}

.level-button.is-boss .level-number {
  color: #050505;
}

.level-number {
  position: absolute;
  left: 50%;
  top: 13px;
  width: max-content;
  font-size: 25px;
  line-height: 1;
  color: #fff;
  text-align: center;
  z-index: 2;
  pointer-events: none;
  transform: translate(-50%, -50%) translate(1px, -2px);
}

.medal {
  position: absolute;
  z-index: 2;
  width: 8px;
  height: 11px;
  top: 26px;
  image-rendering: pixelated;
}

.medal.easy {
  left: 5px;
}

.medal.normal {
  left: 17px;
}

.medal.hard {
  left: 29px;
}

.screen-icons {
  position: absolute;
  right: 0;
  top: 0;
  height: 40px;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
}

.screen-icons > .icon-button + .icon-button,
.modal-icons > .icon-button + .icon-button {
  margin-left: -10px;
}

.icon-button,
.pause-icon-button {
  width: 40px;
  height: 40px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: 40px 40px;
  image-rendering: pixelated;
}

.icon-button.is-highlighted,
.pause-icon-button.is-highlighted {
  filter: brightness(0.65);
}

.pause-icon-button {
  position: absolute;
  left: calc((480px - var(--viewport-stage-width)) / 2 - 4px);
  top: calc(var(--viewport-stage-top) - var(--viewport-overlay-bleed));
  width: 33px;
  height: calc(37px + var(--viewport-overlay-bleed));
  z-index: 15;
  background-color: rgba(0, 0, 0, 0.7);
  box-shadow: -1px 0 0 rgba(0, 0, 0, 0.7);
  background-position: center bottom;
  background-size: 33px 37px;
}

html.chainary-desktop .pause-icon-button {
  top: calc(var(--viewport-stage-top) - var(--viewport-overlay-bleed));
}

html.chainary-ios .pause-icon-button {
  left: calc((480px - var(--title-binary-width)) / 2 - 4px);
  top: calc(var(--viewport-stage-top) - var(--viewport-overlay-bleed));
  width: 36px;
  box-shadow: none;
  background-position: left bottom;
}

/* iOS standalone safe-area padding shifts the scaled stage inward. Project
   full-screen art back to the real viewport edges without changing desktop. */
html.chainary-ios .stage[data-screen="game"]::after {
  left: var(--viewport-stage-left);
  width: var(--viewport-stage-width);
  transform: translateZ(0);
}

html.chainary-ios .stage[data-screen="game"]::after {
  background-position:
    calc(240px - var(--viewport-stage-left)) 80px,
    calc(240px - var(--viewport-stage-left)) 120px;
}

html.chainary-ios .stage[data-screen="game"].is-boss-level::after {
  background-position: calc(240px - var(--viewport-stage-left)) 120px;
}

html.chainary-ios .bit-controls {
  bottom: calc(var(--mobile-input-backdrop-bottom) + 17px);
}

html.chainary-ios .bit-guides {
  bottom: calc(var(--mobile-input-backdrop-bottom) + 5px);
}

html.chainary-ios .bit-guide-backdrop {
  bottom: var(--mobile-input-backdrop-bottom);
}

.sprite-layer {
  z-index: 3;
  overflow: visible;
}

.sprite,
.block,
.crack,
.boss,
.player,
.spike {
  position: absolute;
  display: block;
  image-rendering: pixelated;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.block {
  width: 20px;
  height: 20px;
}

.breakable-block-backing {
  position: absolute;
  display: none;
  width: calc(20px + var(--breakable-block-backing-bleed) + var(--breakable-block-backing-bleed));
  height: calc(20px + var(--breakable-block-backing-bleed) + var(--breakable-block-backing-bleed));
  image-rendering: pixelated;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  pointer-events: none;
  transform: translate3d(
    calc(0px - var(--breakable-block-backing-bleed)),
    calc(0px - var(--breakable-block-backing-bleed)),
    0
  );
}

html.chainary-desktop.chainary-large-stage .breakable-block-backing {
  display: block;
}

.block .crack {
  right: auto;
  bottom: auto;
  width: 20px;
  height: 20px;
}

.crack {
  inset: 0;
}

.player {
  width: 8px;
  height: 11px;
  z-index: 7;
  will-change: left, top, opacity, background-image;
}

.boss {
  width: 60px;
  height: 80px;
  z-index: 5;
}

.boss-health-message {
  position: absolute;
  left: 43px;
  top: 7px;
  z-index: 13;
  padding: 1px 4px 3px 8px;
  color: #fff;
  background: rgba(0, 0, 0, 0.7);
  font-size: 20px;
  line-height: 20px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}

.boss-health-message.is-visible {
  animation: boss-health-message 4.75s linear both;
}

@keyframes boss-health-message {
  0% {
    opacity: 0;
  }

  16% {
    opacity: 1;
  }

  84% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.spike {
  width: 20px;
  height: 20px;
  z-index: 6;
  will-change: transform, opacity;
}

.number-tag {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 12;
  width: 46px;
  height: 21px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  text-align: center;
  display: grid;
  place-items: center;
  --optical-label-x: 2px;
  --optical-label-y: -2.5px;
  pointer-events: none;
  will-change: transform;
}

.number-tag .optical-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) translate(var(--optical-label-x), var(--optical-label-y));
}

.total-value {
  position: absolute;
  z-index: 11;
  left: 0;
  right: 0;
  top: 187px;
  height: auto;
  color: #000;
  font-family: "Akashi", serif;
  font-size: 50px;
  line-height: 1;
  text-align: center;
  pointer-events: none;
  text-shadow: none;
  transform: translate(3px, -50%);
}

.bit-controls {
  position: absolute;
  z-index: 10;
  left: 6px;
  bottom: 25px;
  width: 474px;
  height: 100px;
  display: grid;
  grid-template-columns: repeat(8, 50px);
  column-gap: 10px;
  padding-left: 4px;
}

.bit-controls::before {
  content: "";
  position: absolute;
  left: 0;
  top: 29px;
  width: 469px;
  height: 58px;
  background: rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.bit-guide-backdrop:not([hidden]) + .bit-controls::before {
  display: none;
}

.bit-button {
  width: 50px;
  height: 100px;
  /* Number shortcuts can reveal focus left by a pointer click. */
  outline: none;
  color: #fff;
  font-family: "Munro Small", monospace;
  font-size: 90px;
  line-height: 1;
  text-align: center;
  display: grid;
  place-items: center;
  --optical-label-x: -4px;
  --optical-label-y: 8px;
  text-shadow: none;
}

.bit-button .optical-label {
  width: 36px;
  height: 45px;
  color: transparent;
  font-size: 0;
  line-height: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5' shape-rendering='crispEdges'%3E%3Cpath fill='%23fff' d='M1 0h2v1H1zM0 1h1v3H0zM3 1h1v3H3zM1 4h2v1H1z'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 36px 45px;
  image-rendering: pixelated;
}

.bit-button.is-on .optical-label {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5' shape-rendering='crispEdges'%3E%3Cpath fill='%23fff' d='M2 0h1v5H2zM1 1h1v1H1z'/%3E%3C/svg%3E");
}

.bit-button:disabled,
.pause-icon-button:disabled {
  opacity: 1;
}

.bit-guides {
  position: absolute;
  z-index: 10;
  left: 3px;
  bottom: 13px;
  width: 469px;
  height: 24px;
  display: grid;
  grid-template-columns: repeat(8, 50px);
  column-gap: 10px;
  padding-left: 4px;
  pointer-events: none;
}

.bit-guide-backdrop {
  position: absolute;
  z-index: 9;
  left: 6px;
  bottom: 8px;
  width: 469px;
  height: 88px;
  background: rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.bit-guide {
  width: 50px;
  height: 24px;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  text-align: center;
  display: grid;
  place-items: center;
  --optical-label-y: 0;
  text-shadow: none;
}

.tutorial-overlay {
  inset: auto;
  left: calc(var(--viewport-stage-left) - var(--viewport-overlay-bleed));
  top: calc(var(--viewport-stage-top) - var(--viewport-overlay-bleed));
  z-index: 30;
  width: calc(var(--viewport-stage-width) + var(--viewport-overlay-bleed) + var(--viewport-overlay-bleed));
  height: calc(
    var(--viewport-stage-bottom) - var(--viewport-stage-top) +
    var(--viewport-overlay-bleed) + var(--viewport-overlay-bleed)
  );
  background: rgba(0, 0, 0, 0.7);
  display: grid;
  place-items: center;
  padding: 40px 36px;
  transform: translateZ(0);
}

.stage.is-tutorial-guides-revealed .bit-guides {
  z-index: 31;
}

.tutorial-text {
  position: absolute;
  top: 48px;
  left: 36px;
  right: 36px;
  color: #fff;
  font-size: 30px;
  line-height: 1.04;
  text-align: center;
  white-space: pre-line;
  text-shadow: none;
}

.tutorial-next {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 104px;
  margin: auto;
  width: 120px;
  min-height: 36px;
  font-size: 30px;
  text-shadow: none;
}

.modal-root {
  z-index: 40;
}

.stage.is-outcome-overlay .number-tag,
.stage.is-outcome-overlay .total-value,
.stage.is-outcome-overlay .bit-controls,
.stage.is-outcome-overlay .bit-guides,
.stage.is-outcome-overlay .bit-guide-backdrop,
.stage.is-outcome-overlay .pause-icon-button {
  visibility: hidden;
}

.modal-fade {
  position: absolute;
  left: calc(var(--viewport-stage-left) - var(--viewport-overlay-bleed));
  top: calc(var(--viewport-stage-top) - var(--viewport-overlay-bleed));
  width: calc(var(--viewport-stage-width) + var(--viewport-overlay-bleed) + var(--viewport-overlay-bleed));
  height: calc(
    var(--viewport-stage-bottom) - var(--viewport-stage-top) +
    var(--viewport-overlay-bleed) + var(--viewport-overlay-bleed)
  );
  overflow: hidden;
  background: rgba(0, 0, 0, 0.92);
  transform: translateZ(0);
}

.modal-fade.is-game-fade {
  background: #000;
  opacity: 0.1;
  animation: chainary-game-fade 450ms steps(9, end) forwards;
}

.modal-binary {
  position: absolute;
  inset: auto;
  left: 50%;
  top: 50%;
  width: calc(100% + var(--binary-horizontal-overscan) + var(--binary-horizontal-overscan));
  max-height: 100%;
  transform: translate(-50%, -50%) translateZ(0);
}

.modal-icons {
  position: absolute;
  right: 0;
  top: 0;
  z-index: 2;
  height: 40px;
  display: flex;
  align-items: flex-start;
}

.modal-panel,
.spec-panel {
  position: absolute;
  left: 50%;
  top: var(--viewport-stage-center-y);
  background-repeat: no-repeat;
  background-size: 100% 100%;
  image-rendering: pixelated;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 10px 18px var(--panel-shadow));
}

.modal-panel {
  width: 370px;
  height: 192px;
}

.spec-panel {
  width: 250px;
  height: 207px;
  color: #fff;
}

.spec-panel.is-boss {
  color: #050505;
}

.spec-line {
  position: absolute;
  left: 15px;
  width: 220px;
  height: 20px;
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
}

.spec-title {
  top: 10px;
  height: 32px;
  font-size: 40px;
  line-height: 32px;
}

.spec-wall {
  top: 45px;
}

.spec-shield {
  top: 63px;
}

.spec-speed {
  top: 81px;
}

.spec-frequency {
  top: 99px;
}

.spec-max {
  top: 117px;
}

.spec-line:not(.spec-title) {
  font-size: 20px;
}

.spec-buttons {
  position: absolute;
  left: 17px;
  right: 17px;
  bottom: 19px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.difficulty-button {
  position: relative;
  height: 42px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: auto 100%;
  color: inherit;
}

.difficulty-button:disabled {
  pointer-events: none;
}

.difficulty-label {
  position: absolute;
  top: 4px;
  height: 20px;
  font-size: 20px;
  line-height: 20px;
  text-align: left;
  pointer-events: none;
  transform: translateY(-2px);
}

.difficulty-button.easy,
.difficulty-button.hard {
  width: 58px;
}

.difficulty-button.normal {
  width: 72px;
}

.difficulty-button.easy .difficulty-label {
  left: 12px;
  width: 50px;
}

.difficulty-button.normal .difficulty-label {
  left: 7px;
  width: 65px;
}

.difficulty-button.hard .difficulty-label {
  left: 10px;
  width: 50px;
}

.difficulty-button img {
  position: absolute;
  left: 50%;
  top: 26px;
  width: 8px;
  height: 11px;
  transform: translateX(-50%);
  image-rendering: pixelated;
}

.modal-title {
  position: absolute;
  left: 0;
  right: 0;
  top: 30px;
  height: auto;
  font-size: 60px;
  line-height: 1;
  text-align: center;
  transform: translateY(-50%);
}

.modal-subtitle {
  position: absolute;
  left: 0;
  right: 0;
  top: 88px;
  height: auto;
  font-size: 30px;
  line-height: 1;
  text-align: center;
  transform: translateY(-50%);
}

.modal-actions {
  position: absolute;
  left: 20px;
  right: 20px;
  bottom: 20px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
}

.modal-action {
  flex: 0 0 100px;
  width: 100px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  color: #fff;
  background-repeat: no-repeat;
  background-size: 100% 100%;
  font-size: 27px;
  line-height: 1;
  --optical-label-x: 1px;
  --optical-label-y: -2px;
}

.modal-level-strip {
  position: absolute;
  left: 40px;
  right: 40px;
  top: 73px;
  height: 42px;
  display: flex;
  gap: 13px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}

.modal-level-strip::before,
.modal-level-strip::after {
  content: "";
  flex: 0 0 calc((100% - 42px) / 2);
}

.modal-level-strip::-webkit-scrollbar {
  display: none;
}

.modal-level-strip .level-button {
  flex: 0 0 42px;
}

.modal-level-strip.is-edge-faded .level-content {
  will-change: opacity;
}

@keyframes chainary-game-fade {
  from {
    opacity: 0.1;
  }

  to {
    opacity: 1;
  }
}

/* Portrait phones and unusually shaped desktop browser windows are gated:
   gameplay and its original control spacing need a landscape-sized surface. */
.rotate-overlay,
.resize-overlay {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: none;
  padding: max(24px, var(--safe-top)) max(24px, var(--safe-right)) max(24px, var(--safe-bottom)) max(24px, var(--safe-left));
  place-content: center;
  place-items: center;
  gap: 13px;
  color: #fff;
  background:
    radial-gradient(circle at 50% 28%, rgba(153, 28, 39, 0.5), transparent 42%),
    #050506;
  font-family: var(--rounded);
  text-align: center;
}

.resize-overlay {
  z-index: 1001;
}

.rotate-overlay > img,
.resize-overlay > img {
  width: min(24vw, 96px);
  height: auto;
  border-radius: 22%;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.5);
}

.rotate-overlay strong,
.resize-overlay strong {
  margin-top: 2px;
  font-size: clamp(22px, 8vw, 38px);
}

.rotate-overlay > span {
  color: #d3d3d8;
  font-family: var(--system);
  font-size: clamp(14px, 4.6vw, 19px);
  line-height: 1.4;
}

.browser-resize {
  display: none;
  grid-template: 50px 54px 50px / 48px 82px 48px;
  width: 178px;
  height: 154px;
  place-items: center;
  color: #ff8b94;
}

.browser-resize i {
  position: relative;
  grid-area: 2 / 2;
  display: block;
  width: 74px;
  height: 48px;
  border: 3px solid #fff;
  border-radius: 6px;
  box-shadow: inset 0 8px 0 -5px #fff;
}

.browser-resize i::before {
  position: absolute;
  top: 4px;
  left: 5px;
  width: 3px;
  height: 3px;
  content: "";
  background: #ff8b94;
  border-radius: 50%;
  box-shadow: 6px 0 #ff8b94, 12px 0 #ff8b94;
}

.resize-arrow {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  animation: resize-arrow-left 1.55s ease-in-out infinite;
}

.resize-arrow svg {
  display: block;
  width: 40px;
  height: 40px;
  overflow: visible;
}

.resize-arrow path {
  fill: none;
  stroke: currentColor;
  stroke-width: 5.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.resize-arrow-point-left svg {
  transform: rotate(180deg);
}

.resize-arrow-point-up svg {
  transform: rotate(-90deg);
}

.resize-arrow-point-down svg {
  transform: rotate(90deg);
}

.resize-arrow-left {
  grid-area: 2 / 1;
  animation-name: resize-arrow-right;
}

.resize-arrow-top {
  grid-area: 1 / 2;
  animation-name: resize-arrow-down;
}

.resize-arrow-right {
  grid-area: 2 / 3;
  animation-name: resize-arrow-left;
}

.resize-arrow-bottom {
  grid-area: 3 / 2;
  animation-name: resize-arrow-up;
}

.resize-copy {
  display: none;
  max-width: min(92vw, 760px);
  place-items: center;
}

.resize-copy > strong {
  display: block;
  text-wrap: balance;
}

/* Keep the resize guard fully visible when a desktop window is exceptionally
   short or narrow. Above this breakpoint the artwork retains its native
   dimensions; below it every part follows the limiting viewport edge. */
@media (max-height: 360px), (max-width: 360px) {
  .resize-overlay {
    padding:
      max(clamp(8px, 4vmin, 24px), var(--safe-top))
      max(clamp(8px, 4vmin, 24px), var(--safe-right))
      max(clamp(8px, 4vmin, 24px), var(--safe-bottom))
      max(clamp(8px, 4vmin, 24px), var(--safe-left));
    gap: clamp(5px, 3vmin, 13px);
  }

  .resize-overlay > img {
    width: min(24vw, 24vmin, 96px);
  }

  .resize-overlay strong {
    font-size: clamp(16px, 8vmin, 38px);
    line-height: 1.1;
  }

  .browser-resize {
    grid-template:
      min(12vmin, 50px) min(13vmin, 54px) min(12vmin, 50px) /
      min(11.5vmin, 48px) min(19.7vmin, 82px) min(11.5vmin, 48px);
    width: min(42.7vmin, 178px);
    height: min(37vmin, 154px);
  }

  .browser-resize i {
    width: min(17.8vmin, 74px);
    height: min(11.5vmin, 48px);
    border-width: min(0.72vmin, 3px);
    border-radius: min(1.45vmin, 6px);
    box-shadow: inset 0 min(1.92vmin, 8px) 0 max(-5px, -1.2vmin) #fff;
  }

  .browser-resize i::before {
    top: min(0.96vmin, 4px);
    left: min(1.2vmin, 5px);
    width: min(0.72vmin, 3px);
    height: min(0.72vmin, 3px);
    box-shadow:
      min(1.45vmin, 6px) 0 #ff8b94,
      min(2.9vmin, 12px) 0 #ff8b94;
  }

  .resize-arrow {
    width: min(11.5vmin, 48px);
    height: min(11.5vmin, 48px);
  }

  .resize-arrow svg {
    width: min(9.6vmin, 40px);
    height: min(9.6vmin, 40px);
  }
}

@keyframes resize-arrow-left {
  0%,
  100% {
    transform: translateX(5px);
  }

  50% {
    transform: translateX(-5px);
  }
}

@keyframes resize-arrow-right {
  0%,
  100% {
    transform: translateX(-5px);
  }

  50% {
    transform: translateX(5px);
  }
}

@keyframes resize-arrow-up {
  0%,
  100% {
    transform: translateY(5px);
  }

  50% {
    transform: translateY(-5px);
  }
}

@keyframes resize-arrow-down {
  0%,
  100% {
    transform: translateY(-5px);
  }

  50% {
    transform: translateY(5px);
  }
}

.install-hint {
  max-width: min(90vw, 360px);
  margin: 3px 0 0;
  color: #aeb0b8;
  font-family: var(--system);
  font-size: clamp(12px, 3.45vw, 14px);
  line-height: 1.4;
}

.install-lead {
  display: block;
  text-wrap: balance;
}

.install-hint > span[aria-label="More"] {
  color: #fff;
  letter-spacing: 0.04em;
}

.phone-rotate {
  position: relative;
  width: 66px;
  height: 52px;
}

.phone-rotate span {
  position: absolute;
  inset: 0;
  display: block;
  width: 28px;
  height: 43px;
  margin: auto;
  border: 3px solid #fff;
  border-radius: 6px;
  animation: turn-phone 1.8s ease-in-out infinite;
}

.phone-rotate::after {
  position: absolute;
  inset: 0;
  width: 52px;
  height: 52px;
  margin: auto;
  box-sizing: border-box;
  content: "";
  border-top: 3px solid #ff8b94;
  border-right: 3px solid #ff8b94;
  border-radius: 50%;
  transform: rotate(28deg);
}

@keyframes turn-phone {
  0%,
  28% {
    transform: rotate(0deg);
  }

  60%,
  100% {
    transform: rotate(90deg);
  }
}

@media (orientation: portrait) and (max-aspect-ratio: 1 / 1) {
  .rotate-overlay {
    display: grid;
  }

  .stage-wrap,
  .debug-hud {
    visibility: hidden;
    pointer-events: none;
  }
}

html[data-browser-window-fit="too-wide"] .resize-overlay,
html[data-browser-window-fit="too-wide"] .browser-resize-narrower,
html[data-browser-window-fit="too-tall"] .resize-overlay,
html[data-browser-window-fit="too-tall"] .browser-resize-wider,
html[data-browser-window-fit] .resize-copy {
  display: grid;
}

html[data-browser-window-fit] .rotate-overlay {
  display: none;
}

html[data-browser-window-fit] .stage-wrap,
html[data-browser-window-fit] .debug-hud {
  visibility: hidden;
  pointer-events: none;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
  :root {
    /* WebKit can exclude the safe area from svh/visualViewport in installed apps. */
    --chainary-vh: 100vh;
  }

  html,
  body {
    height: 100vh;
    min-height: 100vh;
  }

  .app-shell {
    right: 0;
    bottom: 0;
    width: auto;
    height: auto;
    min-height: 0;
    transform: none;
  }

  .install-hint {
    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;
  }
}

@media (max-aspect-ratio: 3 / 2) {
  .app-shell {
    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));
  }
}
