@font-face {
  font-family: "NinjaPixel";
  src: url("./assets/ui/font.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --ink: #10131b;
  --deep: #191b29;
  --panel: #30263a;
  --cream: #fff1d2;
  --muted: #c9b7b0;
  --red: #f05b65;
  --red-dark: #9e334d;
  --gold: #f6be68;
  --cyan: #77d8d0;
  --violet: #8778df;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 20%, #31304b 0, #171923 42%, #0b0e14 100%);
  color: var(--cream);
  font-family: "NinjaPixel", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

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

button {
  font: inherit;
}

.page-shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.game-shell {
  position: relative;
  width: min(96vw, calc(90dvh * 16 / 9), 1440px);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  isolation: isolate;
  border: 3px solid #77506b;
  border-radius: 4px;
  background: #1b2230;
  box-shadow:
    0 0 0 3px #241928,
    0 18px 70px #000a,
    inset 0 0 50px #0008;
  touch-action: none;
  overscroll-behavior: none;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
  background:
    linear-gradient(#0c0e1824, transparent 16%, transparent 78%, #0c0e1866),
    radial-gradient(ellipse at center, transparent 52%, #090b13a8 100%);
  mix-blend-mode: multiply;
}

.hidden {
  display: none !important;
}

.pixel-panel {
  border: 12px solid transparent;
  border-image: url("./assets/ui/panel.png") 6 fill / 16px / 0 stretch;
  image-rendering: pixelated;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  text-shadow: 2px 2px #201622;
}

.hud-top {
  position: absolute;
  inset: 14px 14px auto;
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  align-items: start;
  gap: 16px;
}

.player-panel,
.stat-panel {
  min-height: 62px;
  display: flex;
  align-items: center;
  padding: 3px 7px;
  background: #211c2ddb;
}

.player-panel {
  width: min(310px, 30vw);
  justify-self: start;
}

.portrait {
  width: 44px;
  height: 44px;
  margin-right: 9px;
  image-rendering: pixelated;
}

.player-bars {
  min-width: 0;
  flex: 1;
}

.tiny-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin: 0 2px 5px;
  color: #ffe6b9;
  font-size: clamp(10px, 1.1vw, 15px);
  letter-spacing: 0.04em;
}

.bar {
  position: relative;
  height: 15px;
  overflow: hidden;
  border: 2px solid #fff0c9;
  background: #16151e;
  box-shadow: inset 0 0 0 2px #342537;
}

.bar-fill {
  width: 100%;
  height: 100%;
  transform-origin: left center;
  transition: transform 120ms linear;
}

.bar span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #fff8e9;
  font-family: "NinjaPixel", monospace;
  font-size: 9px;
  line-height: 1;
  text-shadow: 1px 1px #3b1521;
}

.hp-bar .bar-fill {
  background: linear-gradient(#ff7f77 0 45%, #d83f59 46% 100%);
}

.clock-panel {
  min-width: 150px;
  text-align: center;
}

.clock {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 5px;
  color: #fff4d6;
  font-family: "NinjaPixel", monospace;
  font-size: clamp(22px, 2.5vw, 38px);
  letter-spacing: 0.08em;
  filter: drop-shadow(0 3px 0 #352037);
}

.clock small {
  color: #c9bcae;
  font-size: clamp(8px, 0.82vw, 11px);
  letter-spacing: 0.04em;
}

.run-progress {
  position: relative;
  width: min(178px, 22vw);
  height: 7px;
  margin: 4px auto 14px;
  border: 1px solid #e6d7b2;
  background: #16151ed9;
  box-shadow: inset 0 0 0 1px #342537, 0 2px 0 #201622;
}

.run-progress-fill {
  position: absolute;
  inset: 1px;
  background: linear-gradient(90deg, #8376bd, #e4b867 72%, #d84a62);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 120ms linear;
}

.run-marker {
  position: absolute;
  top: -3px;
  width: 3px;
  height: 11px;
  border: 1px solid #2b1b2a;
  transform: translateX(-50%);
  background: #dda75b;
  box-shadow: 0 0 0 1px #f8dfad66;
}

.run-marker.final {
  background: #e95368;
  box-shadow: 0 0 0 1px #ffb7b766;
}

.run-marker.completed {
  background: #fff0b0;
  box-shadow: 0 0 6px #fff0b0;
}

.run-marker span {
  position: absolute;
  top: 11px;
  left: 50%;
  color: #d9c59e;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 7px;
  font-style: normal;
  line-height: 1;
  letter-spacing: 0.02em;
  transform: translateX(-50%);
  white-space: nowrap;
}

.wave-label,
.boss-name {
  margin-top: 3px;
  color: #f3c37d;
  font-size: clamp(9px, 1vw, 13px);
  letter-spacing: 0.12em;
}

.stat-panel {
  width: fit-content;
  min-width: 205px;
  justify-self: end;
  justify-content: flex-end;
  gap: 10px;
  color: #fbe6c7;
  font-size: clamp(10px, 1.1vw, 14px);
  pointer-events: auto;
}

.stat-panel strong {
  color: #ffcd72;
}

.seal-tracker {
  position: absolute;
  top: 84px;
  left: 17px;
  min-width: 178px;
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 6px;
  border-image-width: 13px;
  background: #211c2dcf;
  color: #d9c8b5;
  pointer-events: none;
}

.seal-label {
  font-size: 9px;
  letter-spacing: 0.08em;
}

.seal-pips {
  display: flex;
  gap: 4px;
}

.seal-pip {
  position: relative;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid #65566f;
  border-radius: 50%;
  background: #15141d;
  opacity: 0.42;
}

.seal-pip img {
  width: 17px;
  height: 17px;
  image-rendering: pixelated;
}

.seal-pip i {
  position: absolute;
  inset: -3px;
  border: 1px solid transparent;
  border-radius: 50%;
}

.seal-pip.current {
  opacity: 0.9;
}

.seal-pip.current i {
  border-color: #f6be68;
  animation: seal-pulse 900ms steps(2) infinite;
}

.seal-pip.active {
  border-color: #ffe5a1;
  background: #71404f;
  opacity: 1;
  box-shadow: 0 0 9px #f7c46c99;
}

.seal-pip.active img {
  filter: brightness(1.45) sepia(0.35);
}

.seal-tracker strong {
  color: #ffd985;
  font-size: 9px;
}

@keyframes seal-pulse {
  50% { transform: scale(1.12); opacity: 0.45; }
}

.engraving-rack {
  position: absolute;
  top: 139px;
  left: 17px;
  min-width: 178px;
  min-height: 47px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 6px;
  border-image-width: 13px;
  background: #211c2dcf;
  pointer-events: auto;
}

.engraving-label {
  color: #cfc0c8;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.engraving-slots {
  display: flex;
  gap: 4px;
}

.engraving-slot {
  position: relative;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border: 2px solid #5b4a63;
  background: #12131cbd;
  color: #786b7e;
  font-size: 14px;
  opacity: 0.68;
}

.engraving-slot.filled {
  border-color: #d9aa72;
  background: linear-gradient(145deg, #673d50, #211b2b);
  opacity: 1;
  box-shadow: 0 0 8px #efbb7566;
}

.engraving-slot img {
  width: 20px;
  height: 20px;
  image-rendering: pixelated;
}

.engraving-slot small {
  position: absolute;
  right: -3px;
  bottom: -4px;
  width: 10px;
  height: 10px;
  display: grid;
  place-items: center;
  border: 1px solid #ba8b69;
  border-radius: 50%;
  background: #271b2c;
  color: #f1cf98;
  font-size: 6px;
}

.icon-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 2px solid #d19b70;
  border-radius: 2px;
  background: #3a283c;
  color: #fff0cf;
  cursor: pointer;
  box-shadow: inset 0 -3px #1d1824;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: #ffe2a2;
  background: #55334a;
  outline: 2px solid #f2c476;
}

.boss-wrap {
  position: absolute;
  top: 79px;
  left: 50%;
  width: min(520px, 56vw);
  transform: translateX(-50%);
  text-align: center;
}

.boss-name {
  margin: 0 0 6px;
  color: #ff9b83;
}

.boss-meta {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 6px;
}

.boss-meta .boss-name {
  margin: 0;
}

.boss-tier-badge {
  padding: 2px 5px;
  border: 1px solid #ffd78e;
  color: #ffe9b5;
  background: #65412dcc;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: clamp(7px, 0.74vw, 10px);
  line-height: 1;
  letter-spacing: 0.06em;
  text-shadow: 1px 1px #321a22;
}

.boss-pattern {
  min-height: 13px;
  margin: -4px 0 4px;
  color: #fff0b0;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: clamp(8px, 0.82vw, 11px);
  letter-spacing: 0.08em;
  opacity: 0;
  transition: opacity 120ms ease;
}

.boss-pattern.visible {
  opacity: 1;
}

#bossShieldText {
  color: #ffe08d;
  font-size: clamp(8px, 0.8vw, 11px);
}

.boss-bar {
  height: 13px;
  border-color: #ffb78f;
  box-shadow: 0 2px 8px #0009;
}

.boss-bar .bar-fill {
  background: linear-gradient(90deg, #9d294b, #f15d64, #ff9a68);
}

.boss-wrap[data-encounter="mid"] .boss-tier-badge {
  border-color: #ffe0a0;
  color: #fff0bd;
  background: #6f4c2ee8;
}

.boss-wrap[data-encounter="mid"] .boss-name {
  color: #ffc877;
}

.boss-wrap[data-encounter="mid"] .boss-bar {
  border-color: #ffd78d;
}

.boss-wrap[data-encounter="mid"] .boss-bar .bar-fill {
  background: linear-gradient(90deg, #9a552d, #e39546, #ffd17c);
}

.boss-wrap[data-encounter="final"] .boss-tier-badge {
  border-color: #ff9eaa;
  color: #ffe0dc;
  background: #711f3ee8;
}

.boss-wrap[data-encounter="final"] .boss-name {
  color: #ff8c82;
}

.boss-wrap[data-encounter="final"] .boss-bar {
  border-color: #ff9f91;
  box-shadow: 0 2px 8px #0009, 0 0 10px #c2295355;
}

.hud-bottom {
  position: absolute;
  inset: auto 20px 14px;
}

.xp-bar {
  height: 14px;
  border-color: #c7bbff;
}

.xp-bar .bar-fill {
  background: linear-gradient(#a19aff 0 45%, #6158c7 46% 100%);
}

.weapon-rack {
  display: flex;
  justify-content: center;
  gap: 8px;
  min-height: 45px;
  margin-bottom: 7px;
}

.weapon-slot {
  position: relative;
  width: 43px;
  height: 43px;
  display: grid;
  place-items: center;
  border: 3px solid #d8a46d;
  background: #221c2ecf;
  box-shadow: 0 3px 0 #15121c;
}

.weapon-slot img {
  width: 31px;
  height: 31px;
  image-rendering: pixelated;
}

.weapon-slot small {
  position: absolute;
  right: -4px;
  bottom: -5px;
  min-width: 18px;
  padding: 2px;
  border: 1px solid #f7d089;
  border-radius: 50%;
  background: #50334d;
  color: white;
  font-family: "NinjaPixel", monospace;
  font-size: 8px;
  text-align: center;
}

.weapon-slot.evolved {
  border-color: #ffe49a;
  background: linear-gradient(145deg, #6d3d4d, #241d31);
  box-shadow: 0 0 13px #f6be6873, inset 0 0 12px #f6be6833;
}

.weapon-slot.evolved small {
  border-radius: 3px;
  background: #a35a4d;
  color: #fff0a9;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 26px;
  overflow: auto;
  background: #0b0d16d9;
  backdrop-filter: blur(2px);
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.loading-overlay {
  z-index: 50;
  background: #11141c;
}

.compact-modal {
  width: min(360px, 80%);
  min-height: 130px;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: #dfcfae;
  text-align: center;
}

.moon-spinner {
  width: 34px;
  height: 34px;
  border: 5px solid #f6cf81;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 900ms steps(8) infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#titleOverlay {
  place-items: center end;
  overflow: hidden;
  background:
    linear-gradient(90deg, #0b1011a8 0%, #0b101175 40%, #17111fe8 72%),
    radial-gradient(circle at 22% 42%, #d9936870, transparent 28%),
    #111723;
}

.title-moon {
  position: absolute;
  left: 8%;
  top: 12%;
  width: 35%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #f9d69d;
  box-shadow: 0 0 40px #f4ae7188, 0 0 120px #ba61764f;
}

.title-moon::before {
  content: "";
  position: absolute;
  inset: -4% -11% 7% 20%;
  border-radius: 50%;
  background: #1a1724;
}

.title-moon::after {
  content: "";
  position: absolute;
  left: 41%;
  bottom: -39%;
  width: 110px;
  height: 150px;
  background: url("./assets/actors/player.png") 0 0 / 440px 770px no-repeat;
  image-rendering: pixelated;
  transform: scale(1.2);
  transform-origin: bottom center;
  filter: drop-shadow(0 10px 5px #0008);
}

.title-card {
  position: relative;
  z-index: 1;
  width: min(480px, 50%);
  padding: 24px 28px;
  text-align: center;
}

.eyebrow {
  margin: 0 0 8px;
  color: #e3aa76;
  font-size: 11px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 15px;
}

h1 span {
  display: block;
  white-space: nowrap;
  color: #fff2d4;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: clamp(52px, 7vw, 90px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.08em;
  text-shadow: 4px 4px #7a3049, 7px 7px #231625;
}

h1 small {
  display: block;
  margin-top: 16px;
  color: #f3be78;
  font-size: clamp(14px, 1.6vw, 22px);
  font-weight: 500;
  letter-spacing: 0.45em;
}

.title-copy {
  margin-bottom: 17px;
  color: #e5d6c4;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: clamp(13px, 1.4vw, 18px);
  line-height: 1.7;
}

.controls-copy {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px 14px;
  margin: 0 auto 20px;
  color: #bdafaa;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 12px;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 2px 5px;
  border: 1px solid #c28b72;
  border-bottom-width: 3px;
  border-radius: 3px;
  background: #2d2231;
  color: #ffe9c6;
  font-family: "NinjaPixel", monospace;
  font-size: 10px;
  line-height: 1.2;
}

.pixel-button {
  min-width: 210px;
  padding: 13px 24px 11px;
  border: 8px solid transparent;
  border-image: url("./assets/ui/button.png") 3 fill / 10px / 0 stretch;
  background: #65404a;
  color: #fff0ce;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-shadow: 1px 2px #402134;
  cursor: pointer;
  image-rendering: pixelated;
}

.pixel-button:hover,
.pixel-button:focus-visible {
  border-image-source: url("./assets/ui/button-hover.png");
  color: white;
  filter: brightness(1.12);
  outline: 2px solid #ffe59e;
  outline-offset: 2px;
}

.pixel-button:active {
  transform: translateY(2px);
}

.pixel-button.primary {
  background: #8e3e55;
}

.record {
  margin: 13px 0 8px;
  color: #bda8a2;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 11px;
}

.credit-link {
  color: #968b92;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 10px;
  text-decoration: none;
}

.credit-link:hover {
  color: #f1c58e;
}

.level-heading {
  text-align: center;
}

.level-heading p {
  margin-bottom: 5px;
  color: #d5aa75;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 12px;
}

.level-heading h2 {
  margin-bottom: 17px;
  color: #fff1ca;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: clamp(26px, 3.5vw, 42px);
  text-shadow: 3px 3px #6b334d;
}

#levelOverlay {
  align-content: center;
}

.upgrade-grid {
  width: min(900px, 94%);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
}

.upgrade-card {
  position: relative;
  min-height: 205px;
  padding: 20px 17px 17px;
  border: 12px solid transparent;
  border-image: url("./assets/ui/panel.png") 6 fill / 17px / 0 stretch;
  background: #2c2439;
  color: var(--cream);
  text-align: left;
  cursor: pointer;
  image-rendering: pixelated;
  transition: transform 100ms ease, filter 100ms ease;
}

.upgrade-card:hover,
.upgrade-card:focus-visible {
  transform: translateY(-5px);
  filter: brightness(1.16);
  outline: 3px solid #f3ce84;
  outline-offset: 1px;
}

.upgrade-card.evolution {
  border-image-source: url("./assets/ui/button-hover.png");
  background: linear-gradient(145deg, #5f3a40, #2a2135 65%);
  box-shadow: inset 0 0 24px #f6be6829, 0 0 18px #f6be6838;
}

.upgrade-card.evolution::after {
  content: "EVOLUTION";
  position: absolute;
  left: 14px;
  top: 8px;
  color: #ffe5a2;
  font-size: 8px;
  letter-spacing: 0.15em;
}

.upgrade-card.evolution img {
  border-color: #ffe2a0;
  box-shadow: 0 0 12px #f6be6866;
}

.upgrade-card::before {
  content: attr(data-key);
  position: absolute;
  top: 8px;
  right: 10px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 2px solid #a77d72;
  background: #211a27;
  color: #e9c895;
  font-family: "NinjaPixel", monospace;
  font-size: 10px;
}

.upgrade-card img {
  width: 52px;
  height: 52px;
  padding: 5px;
  border: 3px solid #c5936e;
  background: #17151fc4;
  image-rendering: pixelated;
}

.upgrade-type {
  display: block;
  margin: 10px 0 4px;
  color: #e8ad6f;
  font-size: 9px;
  letter-spacing: 0.12em;
}

.upgrade-card h3 {
  margin: 0 0 8px;
  color: #fff0ce;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 18px;
}

.upgrade-card p {
  margin: 0;
  color: #cdbfba;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 12px;
  line-height: 1.55;
}

.choice-help {
  margin: 14px 0 0;
  color: #a99a9d;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 11px;
  text-align: center;
}

.reroll-button {
  display: block;
  margin: 10px auto -4px;
  color: #d8c9ff;
  border-color: #8778ae;
}

.engraving-overlay {
  background:
    radial-gradient(circle at 50% 24%, #815c7561, transparent 35%),
    #090b15ed;
}

.engraving-heading {
  margin-bottom: 4px;
}

.engraving-heading h2 {
  margin-bottom: 6px;
  color: #ffe5a2;
  text-shadow: 3px 3px #6b334d, 0 0 18px #d8a26370;
}

.engraving-heading span {
  display: block;
  margin-bottom: 13px;
  color: #bcaeb8;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 11px;
}

.engraving-card {
  min-height: 220px;
  background: linear-gradient(155deg, #392c42, #211b2c 72%);
  box-shadow: inset 0 0 24px #e7bd7221;
}

.engraving-card img {
  width: 58px;
  height: 58px;
  border-color: #e0b675;
  background: #17151f;
  box-shadow: 0 0 12px #e7bd7247;
}

.engraving-card.tier-2 {
  background: linear-gradient(155deg, #4f2941, #211928 72%);
}

.engraving-card.tier-2 img {
  border-color: #e9787d;
  box-shadow: 0 0 13px #d8566a59;
}

.engraving-card.tier-3 {
  background: linear-gradient(155deg, #403a65, #201a2c 72%);
}

.engraving-card.tier-3 img {
  border-color: #c9b9ff;
  box-shadow: 0 0 14px #a590ff66;
}

.modal {
  width: min(440px, 90%);
  padding: 30px 34px;
  background: #241d2dcf;
  text-align: center;
}

.modal h2 {
  margin-bottom: 24px;
  color: #fff1cf;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 35px;
  text-shadow: 3px 3px #603248;
}

.modal .pixel-button {
  display: block;
  width: min(280px, 100%);
  margin: 10px auto;
}

.settings-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: -8px 0 16px;
}

.setting-toggle {
  min-height: 48px;
  padding: 7px 9px;
  border: 2px solid #70576d;
  background: #17151f99;
  color: #c6b5bc;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 10px;
  cursor: pointer;
}

.setting-toggle span,
.setting-toggle strong {
  display: block;
}

.setting-toggle strong {
  margin-top: 3px;
  color: #8b7e88;
}

.setting-toggle[aria-pressed="true"] {
  border-color: #c89169;
  background: #3a293b;
}

.setting-toggle[aria-pressed="true"] strong {
  color: #ffd18c;
}

.setting-toggle:hover,
.setting-toggle:focus-visible {
  border-color: #ffe0a2;
  outline: 2px solid #7d5c69;
}

.text-button {
  margin-top: 8px;
  border: 0;
  background: none;
  color: #bda9aa;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
}

.text-button:hover,
.text-button:focus-visible {
  color: #ffe2aa;
  outline: none;
}

.result-modal {
  width: min(530px, 92%);
  padding-top: 25px;
}

.result-modal h2 {
  margin-bottom: 8px;
}

.result-copy {
  margin-bottom: 17px;
  color: #493c46;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 13px;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 15px;
}

.result-stats div {
  padding: 10px 6px;
  border: 2px solid #745366;
  background: #17151f9e;
}

.result-stats span,
.result-stats strong {
  display: block;
}

.result-stats span {
  margin-bottom: 4px;
  color: #ad9ba1;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 10px;
}

.result-stats strong {
  color: #ffd28a;
  font-size: 18px;
}

.result-engravings {
  min-height: 39px;
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: -3px 0 10px;
  color: #4c4149;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 10px;
}

.result-engraving {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid #886474;
  background: #17151fbd;
  color: #e4cad0;
}

.result-engraving img {
  width: 25px;
  height: 25px;
  image-rendering: pixelated;
}

.result-engraving i {
  position: absolute;
  right: 2px;
  bottom: -5px;
  padding: 1px 3px;
  background: #80506b;
  color: #fff0b4;
  font-size: 7px;
  font-style: normal;
}

.damage-list {
  margin: 0 auto 13px;
  padding: 8px 12px;
  border-top: 1px solid #67505e;
  border-bottom: 1px solid #67505e;
  color: #463b44;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 11px;
  text-align: left;
}

.damage-row {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}

.toast {
  position: absolute;
  z-index: 20;
  top: 27%;
  left: 50%;
  min-width: 250px;
  padding: 8px 16px;
  transform: translate(-50%, -10px);
  opacity: 0;
  color: #ffe4a5;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: clamp(15px, 2vw, 24px);
  font-weight: 800;
  text-align: center;
  text-shadow: 3px 3px #562d49;
  pointer-events: none;
  transition: opacity 180ms, transform 180ms;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.joystick,
.dash-button {
  display: none;
  position: absolute;
  z-index: 18;
}

.joystick {
  left: 30px;
  bottom: 48px;
  width: 116px;
  height: 116px;
  border: 4px solid #ecd9b666;
  border-radius: 50%;
  background: #19182466;
  box-shadow: inset 0 0 25px #0007;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 48px;
  border: 3px solid #f3d9a9aa;
  border-radius: 50%;
  background: #72435bbf;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 8px #0008;
}

.dash-button {
  right: 34px;
  bottom: 54px;
  width: 82px;
  height: 82px;
  border: 4px solid #f2d49a99;
  border-radius: 50%;
  background: #8c3c58b8;
  color: white;
  text-shadow: 1px 2px #472338;
  box-shadow: inset 0 -8px #3a2138aa, 0 4px 10px #0007;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
}

.dash-button span,
.dash-button small {
  display: block;
}

.dash-button small {
  margin-top: 2px;
  color: #e5cab3;
  font-size: 9px;
}

.dash-button.cooling {
  filter: grayscale(0.7) brightness(0.65);
}

.rotate-notice {
  display: none;
}

.outside-help {
  margin: 0;
  color: #796f78;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-align: center;
}

.stage-effect {
  min-height: 12px;
  margin-top: 2px;
  color: #8de2df;
  font-size: clamp(7px, 0.75vw, 10px);
  letter-spacing: 0.08em;
}

.difficulty-badge {
  padding: 3px 5px;
  border: 1px solid #9d5463;
  background: #4a2538;
  color: #ffbd8d;
  font-size: 9px;
}

.title-meta-row {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 11px 0 8px;
}

.moon-wallet {
  min-height: 29px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border: 2px solid #796174;
  background: #181620bd;
  color: #bcaab3;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 10px;
}

.moon-wallet img {
  width: 19px;
  height: 19px;
  image-rendering: pixelated;
}

.moon-wallet strong {
  color: #ffe19a;
  font-family: "NinjaPixel", monospace;
  font-size: 13px;
}

.seal-star-wallet {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 9px;
  border: 2px solid #796174;
  background: #181620bd;
  color: #cbb9b8;
  font-size: 10px;
}

.seal-star-wallet strong {
  color: #ffe19a;
  font-family: "NinjaPixel", monospace;
  font-size: 17px;
}

.mini-button {
  min-height: 29px;
  padding: 4px 9px;
  border: 2px solid #75586d;
  background: #302337;
  color: #d8c0be;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 10px;
  cursor: pointer;
}

.mini-button:hover,
.mini-button:focus-visible {
  border-color: #f0c47e;
  color: #fff1cf;
  outline: 2px solid #7e5265;
}

.meta-modal {
  width: min(920px, 96%);
  max-height: min(510px, 94%);
  padding: 20px 24px;
  overflow: auto;
  background: #241d2de8;
  color: #f7e7c9;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  text-align: left;
  touch-action: pan-y;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.mastery-grid,
.contract-grid,
.oath-grid {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
}

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

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

.oath-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.mastery-card,
.contract-card,
.oath-card {
  min-width: 0;
  padding: 8px;
  border: 2px solid #655066;
  background: #17151fa8;
  color: #d5c4c0;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
}

.mastery-card {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  align-items: center;
}

.mastery-card img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  image-rendering: pixelated;
}

.mastery-card strong,
.contract-card strong,
.oath-card strong {
  display: block;
  margin-bottom: 3px;
  color: #ffe2ad;
  font-size: 11px;
}

.mastery-card span,
.contract-card p,
.oath-card p {
  margin: 0;
  color: #b9a9ad;
  font-size: 9px;
  line-height: 1.4;
}

.progression-card-title {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 6px;
  align-items: center;
}

.progression-card-title img {
  width: 24px;
  height: 24px;
  object-fit: contain;
  image-rendering: pixelated;
}

.progression-card-title strong {
  margin-bottom: 0;
}

.mastery-bar {
  height: 6px;
  margin-top: 5px;
  border: 1px solid #74566c;
  background: #11121a;
}

.mastery-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #7a5fce, #f2bd72);
}

.contract-card.complete {
  border-color: #d5b06e;
  background: #493448b8;
}

.contract-card small,
.oath-card small {
  display: block;
  margin-top: 5px;
  color: #e0b978;
  font-size: 8px;
}

.oath-card {
  cursor: pointer;
  text-align: left;
}

.oath-card.selected {
  border-color: #ffe09a;
  background: linear-gradient(145deg, #65384e, #221b2b);
  box-shadow: 0 0 9px #f2bd7255;
}

.oath-card:disabled {
  filter: grayscale(0.8);
  opacity: 0.48;
  cursor: not-allowed;
}

.result-progression {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 0 0 9px;
  color: #4b3e47;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 10px;
}

.result-progression strong {
  color: #713c4f;
  font-size: 13px;
}

.game-shell.low-power .vignette {
  display: none;
}

.game-shell.low-power .toast,
.game-shell.low-power .boss-pattern,
.game-shell.low-power .run-progress-fill {
  transition: none;
}

.meta-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.meta-heading .eyebrow {
  margin-bottom: 3px;
}

.meta-heading h2 {
  margin: 0;
  color: #fff0ca;
  font-size: clamp(24px, 3vw, 36px);
  text-shadow: 3px 3px #603248;
}

.meta-copy,
.loadout-summary {
  color: #cbbab7;
  font-size: 11px;
  line-height: 1.55;
}

.loadout-section {
  margin-bottom: 10px;
}

.loadout-section h3,
.history-title {
  margin: 0 0 6px;
  color: #e6b979;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.selection-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

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

.selection-card {
  position: relative;
  min-height: 78px;
  display: grid;
  grid-template-columns: 58px 1fr;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border: 2px solid #655066;
  background: #17151fa6;
  color: #d7c7c2;
  text-align: left;
  cursor: pointer;
}

.selection-card:hover:not(:disabled),
.selection-card:focus-visible:not(:disabled) {
  border-color: #f0c37c;
  outline: 2px solid #705066;
}

.selection-card.selected {
  border-color: #ffe198;
  background: linear-gradient(145deg, #5a3549, #211b2b);
  box-shadow: inset 0 0 14px #eeb86b24, 0 0 10px #eeb86b38;
}

.selection-card:disabled,
.selection-card.locked {
  filter: grayscale(0.9);
  opacity: 0.48;
  cursor: not-allowed;
}

.selection-card > img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  image-rendering: pixelated;
}

.selection-card strong,
.selection-card span,
.selection-card small {
  display: block;
}

.selection-card strong {
  margin-bottom: 3px;
  color: #fff0d1;
  font-size: 14px;
}

.selection-card span {
  color: #d9aa72;
  font-size: 9px;
}

.selection-card small {
  margin-top: 3px;
  color: #b8aaad;
  font-size: 9px;
  line-height: 1.35;
}

.selection-lock {
  position: absolute;
  right: 7px;
  top: 6px;
  width: 18px !important;
  height: 18px !important;
}

.compact-loadout {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr 1fr;
  gap: 14px;
}

.difficulty-grid,
.weapon-choice-grid {
  display: flex;
  gap: 5px;
}

.difficulty-choice,
.weapon-choice {
  min-width: 37px;
  min-height: 37px;
  display: grid;
  place-items: center;
  padding: 3px;
  border: 2px solid #644e63;
  background: #17151f;
  color: #c8b7b5;
  cursor: pointer;
}

.difficulty-choice.selected,
.weapon-choice.selected {
  border-color: #f1c378;
  background: #633449;
  color: #ffe5a1;
}

.difficulty-choice:disabled,
.weapon-choice:disabled {
  filter: grayscale(1);
  opacity: 0.38;
  cursor: not-allowed;
}

.weapon-choice img {
  width: 28px;
  height: 28px;
  image-rendering: pixelated;
}

.loadout-summary {
  min-height: 34px;
  margin: 6px 0 9px;
  padding: 7px 9px;
  border-left: 3px solid #c28b68;
  background: #16141e99;
}

.modal-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.modal-actions .pixel-button,
.meta-modal > .pixel-button {
  display: block;
  margin: 8px auto 0;
}

.unlock-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
}

.unlock-card {
  min-height: 120px;
  display: grid;
  align-content: start;
  justify-items: start;
  padding: 9px;
  border: 2px solid #674f65;
  background: #17151fa8;
  color: #d4c2bd;
  text-align: left;
}

.unlock-card img {
  width: 33px;
  height: 33px;
  margin-bottom: 5px;
  image-rendering: pixelated;
}

.unlock-card strong {
  color: #f4dfbc;
  font-size: 11px;
}

.unlock-card p {
  min-height: 32px;
  margin: 4px 0 7px;
  color: #ad9fa4;
  font-size: 9px;
  line-height: 1.4;
}

.unlock-card button {
  width: 100%;
  margin-top: auto;
  padding: 5px;
  border: 1px solid #9a6b68;
  background: #673449;
  color: #ffe1a1;
  font: inherit;
  font-size: 9px;
  cursor: pointer;
}

.unlock-card.unlocked {
  border-color: #756c70;
  opacity: 0.66;
}

.unlock-card.unlocked button,
.unlock-card button:disabled {
  background: #2b2630;
  color: #857a80;
  cursor: default;
}

.codex-total {
  color: #ffe09a;
  font-size: 22px;
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.codex-section {
  min-height: 72px;
  padding: 8px;
  border: 1px solid #654f63;
  background: #16141e94;
}

.codex-section h3 {
  margin: 0 0 6px;
  color: #e3b779;
  font-size: 10px;
}

.codex-items {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.codex-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 5px;
  border: 1px solid #635365;
  background: #29202d;
  color: #d9c6c0;
  font-size: 8px;
}

.codex-chip.locked {
  color: #675f68;
  filter: grayscale(1);
}

.codex-chip img {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
}

.history-list {
  min-height: 34px;
  display: grid;
  gap: 4px;
}

.history-row {
  display: grid;
  grid-template-columns: 70px 1fr auto auto;
  gap: 8px;
  padding: 5px 7px;
  border-bottom: 1px solid #493b4d;
  color: #b9a9ad;
  font-size: 9px;
}

.history-row strong {
  color: #e8ca96;
}

.result-reward {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin: -2px auto 8px;
  color: #4c4048;
  font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  font-size: 10px;
}

.result-reward img {
  width: 23px;
  height: 23px;
  image-rendering: pixelated;
}

.result-reward strong {
  color: #703d4e;
  font-size: 15px;
}

.result-reward small {
  color: #5e5159;
}

.meta-modal > .text-button,
.result-modal > .text-button {
  color: #51434d;
}

.meta-modal > .text-button:hover,
.meta-modal > .text-button:focus-visible,
.result-modal > .text-button:hover,
.result-modal > .text-button:focus-visible {
  color: #281f2a;
}

@media (pointer: coarse), (max-width: 820px) {
  .game-shell[data-phase="running"] .joystick,
  .game-shell[data-phase="running"] .dash-button {
    display: block;
  }

  .outside-help {
    display: none;
  }

  .page-shell {
    padding: 0;
  }

  .game-shell {
    width: min(100vw, calc(100dvh * 16 / 9));
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }

  .hud-top {
    top: max(6px, env(safe-area-inset-top));
    right: max(7px, env(safe-area-inset-right));
    bottom: auto;
    left: max(7px, env(safe-area-inset-left));
    grid-template-columns: 1fr auto 1fr;
    gap: 5px;
  }

  .joystick {
    left: max(18px, env(safe-area-inset-left));
    bottom: max(34px, env(safe-area-inset-bottom));
  }

  .dash-button {
    right: max(22px, env(safe-area-inset-right));
    bottom: max(40px, env(safe-area-inset-bottom));
  }

  .player-panel,
  .stat-panel {
    min-height: 48px;
    border-width: 9px;
    border-image-width: 12px;
  }

  .portrait {
    width: 32px;
    height: 32px;
    margin-right: 5px;
  }

  .stat-panel {
    min-width: 138px;
    gap: 5px;
  }

  .clock-panel {
    min-width: 118px;
  }

  .clock {
    gap: 3px;
  }

  .run-progress {
    width: min(130px, 25vw);
    margin-top: 2px;
    margin-bottom: 4px;
  }

  .run-marker span {
    display: none;
  }

  .icon-button {
    width: 29px;
    height: 29px;
  }

  .hud-bottom {
    inset: auto 10px 6px;
  }

  .seal-tracker {
    top: 59px;
    left: 7px;
    min-width: 126px;
    min-height: 38px;
    gap: 4px;
    border-width: 9px;
    border-image-width: 11px;
  }

  .seal-label {
    display: none;
  }

  .seal-pip {
    width: 19px;
    height: 19px;
  }

  .engraving-rack {
    top: 101px;
    left: 7px;
    min-width: 126px;
    min-height: 35px;
    gap: 4px;
    border-width: 9px;
    border-image-width: 11px;
  }

  .engraving-label {
    display: none;
  }

  .engraving-slot {
    width: 21px;
    height: 21px;
  }

  .engraving-slot img {
    width: 17px;
    height: 17px;
  }

  .boss-wrap {
    top: 58px;
    width: min(620px, 68vw);
  }

  .boss-meta {
    gap: 5px;
  }

  .boss-tier-badge {
    padding: 2px 4px;
  }

  .weapon-rack {
    display: none;
  }

  .upgrade-grid {
    gap: 7px;
  }

  .upgrade-card {
    min-height: 170px;
    padding: 12px 10px;
  }

  .upgrade-card img {
    width: 39px;
    height: 39px;
  }

  .upgrade-card h3 {
    font-size: 14px;
  }

  .upgrade-card p {
    font-size: 10px;
  }

  .engraving-card {
    min-height: 178px;
  }

  .engraving-heading span {
    display: none;
  }

  .result-engraving span {
    display: none;
  }

  .difficulty-badge,
  .stage-effect {
    display: none;
  }

  .meta-modal {
    width: 97%;
    max-height: 96%;
    padding: 11px 13px;
  }

  .progression-modal {
    max-height: 98%;
  }

  .meta-heading {
    margin-bottom: 7px;
  }

  .meta-heading h2 {
    font-size: 23px;
  }

  .selection-card {
    min-height: 62px;
    grid-template-columns: 43px 1fr;
    padding: 5px 7px;
  }

  .character-grid,
  .stage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .selection-card > img {
    width: 40px;
    height: 40px;
  }

  .selection-card small {
    display: none;
  }

  .compact-loadout {
    gap: 8px;
  }

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

  .unlock-card {
    min-height: 90px;
  }

  .unlock-card p {
    display: none;
  }

  .codex-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mastery-grid,
  .contract-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .mastery-card {
    grid-template-columns: 34px 1fr;
    padding: 5px;
  }

  .mastery-card img {
    width: 32px;
    height: 32px;
  }

  .history-row {
    grid-template-columns: 58px 1fr auto;
  }

  .history-row span:last-child {
    display: none;
  }
}

@media (orientation: portrait) and (max-width: 700px) {
  .game-shell {
    width: 100vw;
    height: auto;
    margin-top: -10vh;
    overflow: visible;
  }

  .overlay {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
  }

  .game-shell[data-phase="running"] .rotate-notice,
  .game-shell[data-phase="paused"] .rotate-notice {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 80;
    display: block;
    width: 85vw;
    padding: 9px 12px;
    transform: translateX(-50%);
    border-radius: 5px;
    background: #1b1723e8;
    color: #ddc9ba;
    font-family: "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
    font-size: 11px;
    text-align: center;
  }

  .title-card {
    width: min(82%, 400px);
    padding: 10px;
  }

  .title-meta-row .moon-wallet {
    display: none;
  }

  .title-meta-row {
    gap: 4px;
    margin: 6px 0 0;
  }

  .title-meta-row .mini-button {
    min-height: 26px;
    padding: 3px 6px;
    font-size: 8px;
  }

  .title-copy,
  .controls-copy,
  .record,
  .credit-link {
    display: none;
  }

  h1 span {
    font-size: 46px;
  }

  .pixel-button {
    min-width: 180px;
    padding: 9px 14px;
  }

  .mastery-grid,
  .contract-grid,
  .oath-grid {
    grid-template-columns: 1fr 1fr;
  }
}

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

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  transition-duration: 0.01ms !important;
}
