:root {
  color-scheme: dark;
  --nd-ink: #07090c;
  --nd-panel: #11171d;
  --nd-bone: #e9dfbd;
  --nd-cyan: #60f0db;
  --nd-gold: #e5b94e;
  --nd-red: #c94b42;
  --nd-line: #3b5258;
  --nd-focus: #fff17a;
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

.game-shell {
  box-sizing: border-box;
  position: relative;
  width: calc(100% - 24px);
  max-width: 1180px;
  margin: 0 auto;
  padding-bottom: 48px;
}

.nd-site-header img {
  max-width: min(520px, 90vw);
}

.back-link {
  display: block;
  width: fit-content;
  margin: 0 auto 16px;
}

.mobile-only-notice {
  display: none;
  box-sizing: border-box;
  width: min(560px, 100%);
  margin: 20px auto;
  padding: 18px;
  color: #e8f3ee;
  text-align: center;
  background: rgba(4, 10, 13, 0.94);
  border: 1px solid #00cccc;
  border-radius: 8px;
  box-shadow: 0 0 14px rgba(0, 204, 204, 0.22);
}

.game-info {
  width: min(820px, 100%);
  margin: 0 auto 18px;
  padding: 12px 18px;
  text-align: center;
  color: #d9e4df;
  background: rgba(4, 10, 13, 0.9);
  border: 1px solid #00cccc;
  border-radius: 8px;
  box-shadow: 0 0 14px rgba(0, 204, 204, 0.22);
}

.game-info h2 {
  margin: 0 0 5px;
  color: #00cccc;
  font-size: 1.15rem;
}

.game-info p {
  margin: 0;
  line-height: 1.55;
}

.play-guide {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  margin-top: 12px;
  text-align: left;
}

.play-guide article {
  padding: 10px 12px;
  background: rgba(20, 36, 39, 0.56);
  border-left: 3px solid #00cccc;
}

.play-guide h3 {
  margin: 0 0 4px;
  color: #8ff6e9;
  font-size: 0.87rem;
  letter-spacing: 0.04em;
}

.play-guide article p {
  font-family: system-ui, sans-serif;
  font-size: 0.82rem;
}

.control-line {
  padding-top: 9px;
  border-top: 1px solid rgba(0, 204, 204, 0.34);
}

#nd-shell {
  position: relative;
  width: min(1040px, 100%);
  margin: 0 auto;
  overflow: hidden;
  color: var(--nd-bone);
  font-family: "Courier New", monospace;
  background: #030507;
  border: 2px solid #00cccc;
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(0, 204, 204, 0.24);
  cursor:
    url("/images/cursors/pointer.cur") 6 0,
    url("/images/cursors/pointer.png") 6 0,
    auto;
}

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

#nd-shell button,
#nd-shell a,
#nd-shell input,
#nd-shell select {
  font: inherit;
}

#nd-shell button,
#nd-shell a,
#nd-shell label,
#nd-shell input,
#nd-shell select {
  cursor:
    url("/images/cursors/hover.cur") 11 0,
    url("/images/cursors/hover.png") 11 0,
    pointer;
}

#nd-shell button {
  padding: 0.62rem 0.9rem;
  color: #eaf7ed;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  background: #162128;
  border: 2px solid #5c7478;
  box-shadow: inset -3px -3px #071014, inset 3px 3px #2d4148;
}

#nd-shell button:hover:not(:disabled),
#nd-shell button:focus-visible {
  color: #071014;
  background: var(--nd-cyan);
  border-color: #d8fff8;
}

#nd-shell button:focus-visible,
#nd-shell a:focus-visible,
#nd-shell input:focus-visible {
  outline: 3px solid var(--nd-focus);
  outline-offset: 3px;
}

#nd-shell button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nd-screen {
  display: none;
  width: 100%;
}

.nd-screen.is-active {
  display: flex;
}

#landing {
  position: relative;
  min-height: 0;
  height: clamp(470px, 72vh, 590px);
  align-items: center;
  justify-content: center;
}

.landing-art,
.landing-vignette {
  position: absolute;
  inset: 0;
}

.landing-art {
  background: url("../assets/ui/title-screen.png?v=2.2.0") center / cover no-repeat;
  image-rendering: pixelated;
}

.landing-vignette {
  background:
    radial-gradient(circle at center, rgba(1, 2, 3, 0.48), rgba(1, 2, 3, 0.88) 68%),
    linear-gradient(0deg, rgba(3, 5, 8, 0.95), transparent 48%);
}

.landing-content {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  width: min(590px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 28px;
  text-align: center;
  background: rgba(2, 5, 8, 0.72);
  border: 1px solid rgba(96, 240, 219, 0.32);
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.62);
}

.eyebrow {
  margin: 0;
  color: var(--nd-cyan);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.landing-content h1,
.screen-heading h2 {
  margin: 0.22rem 0;
  color: #fff2c7;
  font-family: Georgia, serif;
  line-height: 0.88;
  text-transform: uppercase;
  text-shadow: 4px 4px #591f25, 0 0 24px rgba(227, 176, 71, 0.5);
}

.landing-content h1 {
  max-width: none;
  font-size: clamp(2.8rem, 6vw, 4.8rem);
}

.landing-content h1 span {
  display: block;
  color: var(--nd-gold);
  font-size: 0.46em;
  letter-spacing: 0.15em;
}

.tagline {
  max-width: 46ch;
  margin: 0.65rem auto;
  color: #d8d4c4;
  font-size: 0.95rem;
  line-height: 1.55;
}

.player-name-row {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr);
  align-items: center;
  gap: 10px;
  width: min(470px, 100%);
  margin: 0 auto;
  color: var(--nd-cyan);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.player-name-row input {
  min-width: 0;
  padding: 0.52rem 0.68rem;
  color: #f4f0dc;
  background: rgba(4, 10, 13, 0.94);
  border: 2px solid #557579;
}

.title-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 0.5rem;
  width: min(470px, 100%);
  margin: 0.75rem auto 0;
}

.title-actions button:first-child {
  grid-column: 1 / -1;
  background: #71302f;
  border-color: #e8ac4f;
}

.return-link {
  display: inline-block;
  margin-top: 0.8rem;
  color: #8fdad0;
}

.interaction-note {
  position: absolute;
  right: 0.7rem;
  bottom: 0.45rem;
  z-index: 3;
  margin: 0;
  color: #a6afa9;
  font-size: 0.64rem;
}

#hero-select {
  min-height: 0;
  padding: 16px 18px;
  align-items: stretch;
  flex-direction: column;
  background: radial-gradient(circle, #1c2a2f, #06090d 75%);
}

.screen-heading {
  max-width: 850px;
  margin: 0 auto;
  padding: 0;
  text-align: center;
}

.screen-heading h2 {
  font-size: clamp(1.8rem, 3.2vw, 2.8rem);
  line-height: 0.95;
}

.screen-heading > p:last-child {
  margin: 0.3rem 0;
  font-size: 0.76rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  width: 100%;
  margin: 0.55rem auto;
}

.hero-card {
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr;
  gap: 0.38rem;
  min-width: 0;
  min-height: 0;
  height: 241px;
  box-sizing: border-box;
  padding: 0.62rem;
  text-align: left;
  background: #10171b;
  border: 2px solid #3d595d;
}

.hero-card:hover {
  border-color: var(--nd-cyan);
}

.hero-card-head {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 0.6rem;
  align-items: center;
}

.hero-card img {
  width: 50px;
  height: 50px;
  object-fit: contain;
  background: #071014;
  border: 2px solid #536e70;
  image-rendering: pixelated;
}

.hero-card h3 {
  margin: 0;
  color: var(--nd-gold);
  font-size: clamp(0.88rem, 1.4vw, 1.08rem);
  line-height: 1.1;
}

.hero-card p {
  margin: 0;
  font-size: 0.65rem;
  line-height: 1.3;
}

.hero-title {
  display: block;
  margin-top: 0.12rem;
  color: #c6c0aa;
  font-size: 0.62rem;
  line-height: 1.2;
}

.hero-bio {
  min-height: 2.6em;
  color: #d6d1bd;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.hero-stats > span {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.32rem;
  align-items: center;
  min-width: 0;
}

.hero-stats small {
  color: #9be9dc;
  font-size: 0.55rem;
  text-transform: uppercase;
}

.stat-line {
  display: flex;
  gap: 2px;
}

.stat-line i {
  width: 7px;
  height: 5px;
  background: #26363a;
  border: 1px solid #496064;
}

.stat-line i.on {
  background: var(--nd-cyan);
  border-color: #cafff7;
}

.hero-ability {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.4rem;
  padding-top: 0.35rem;
  font-size: 0.61rem;
  line-height: 1.25;
  border-top: 1px solid #2d4246;
}

.hero-ability b {
  color: var(--nd-gold);
}

.hero-tradeoff {
  display: grid;
  gap: 0.08rem;
  color: #bcc9c3;
  font-size: 0.59rem;
  line-height: 1.2;
}

.hero-card button {
  align-self: end;
  width: 100%;
  padding: 0.32rem 0.35rem;
  font-size: 0.62rem;
}

#hero-select > .panel-actions {
  margin-top: 0.25rem;
}

#game-screen {
  min-height: 0;
  padding: 14px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: radial-gradient(circle at 50% 45%, #132126, #030507 72%);
}

#canvas-wrap {
  position: relative;
  width: min(1000px, 100%);
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #000;
  border: 4px solid #33474c;
  box-shadow: 0 0 0 2px #10171a, 0 0 25px #000;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor:
    url("/images/cursors/pointer.cur") 6 0,
    url("/images/cursors/pointer.png") 6 0,
    crosshair;
}

.game-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.38rem;
  margin-top: 0.62rem;
}

.game-actions button {
  padding: 0.42rem 0.65rem;
  font-size: 0.68rem;
}

#nd-shell:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 0;
  background: #020405;
}

#nd-shell:fullscreen #game-screen {
  width: 100%;
  height: 100%;
  padding: 10px;
}

#nd-shell:fullscreen #canvas-wrap {
  width: min(calc(100vw - 24px), calc((100vh - 82px) * 16 / 9));
}

#hud {
  position: absolute;
  inset: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  align-items: start;
  min-height: 30px;
  padding: 5px 7px;
  font-size: clamp(7px, 1vw, 10px);
  text-shadow: 2px 2px #000;
  pointer-events: none;
  background: linear-gradient(#06090eef, #06090e99, transparent);
}

.hud-left,
.hud-right {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-right {
  justify-content: flex-end;
}

.hud-center {
  display: flex;
  flex-direction: column;
  text-align: center;
}

.hud-center strong {
  color: #f0d178;
}

.heart {
  margin-right: 1px;
  color: #e45550;
}

.heart.empty {
  color: #3c3335;
}

.soul-icon {
  color: #62efc8;
}

#boss-hud {
  position: absolute;
  right: 17%;
  bottom: 8px;
  left: 17%;
  font-size: 8px;
  text-align: center;
  text-shadow: 2px 2px #000;
  text-transform: uppercase;
}

#boss-hud > div {
  height: 6px;
  background: #16090c;
  border: 1px solid #e4b84b;
}

#boss-bar {
  display: block;
  width: 100%;
  height: 100%;
  background: #d14642;
}

#boss-hud small {
  color: #ffd978;
}

.is-hidden {
  display: none !important;
}

#toast {
  position: absolute;
  top: 38px;
  left: 50%;
  padding: 5px 9px;
  color: #f5edcf;
  font-size: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  background: #091114e8;
  border: 1px solid #6de4d1;
  transform: translateX(-50%);
  transition: opacity 0.15s;
}

#toast.show {
  opacity: 1;
}

#objective {
  position: absolute;
  bottom: 8px;
  left: 8px;
  color: #dce7d9;
  font-size: 7px;
  text-shadow: 2px 2px #000;
  pointer-events: none;
}

.modal-backdrop {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: none;
  place-items: center;
  padding: 1rem;
  background: #010305e8;
}

.modal-backdrop.is-open {
  display: grid;
}

.modal-card {
  position: relative;
  width: min(820px, 95vw);
  max-height: 88vh;
  padding: 1.5rem;
  overflow: auto;
  background: linear-gradient(135deg, #18242aef, #090e12f5);
  border: 3px solid #4b6b6b;
  box-shadow: 0 0 0 3px #06090b, 0 18px 60px #000;
}

.modal-card h2 {
  margin: 0.2rem 0 1rem;
  color: #edcf7c;
  font-family: Georgia, serif;
  text-transform: uppercase;
}

.modal-close {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.3rem;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem;
  margin-top: 1rem;
}

.dialogue-box {
  position: fixed;
  z-index: 40;
  bottom: 2.5vh;
  left: 50%;
  display: none;
  grid-template-columns: 92px 1fr;
  gap: 1rem;
  width: min(860px, 94vw);
  padding: 1rem;
  background: #080e12f5;
  border: 3px solid #b38b43;
  box-shadow: 0 0 0 3px #070707;
  transform: translateX(-50%);
}

.dialogue-box.is-open {
  display: grid;
}

.dialogue-box img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: #101820;
  border: 2px solid #4c6b69;
  image-rendering: pixelated;
}

.dialogue-box h2 {
  margin: 0;
  color: #5ee9d0;
  font-family: Georgia, serif;
}

.dialogue-box p {
  margin: 0.45rem 0;
  line-height: 1.5;
}

.dialogue-box small {
  color: #999;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
}

.settings-grid input[type="range"] {
  width: min(260px, 48vw);
}

.settings-grid select,
.save-code {
  padding: 0.5rem;
  color: #fff;
  background: #0d151a;
  border: 2px solid #52676c;
}

.realm-grid,
.shop-grid,
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.65rem;
}

.realm-card,
.shop-item,
.inventory-item {
  padding: 0.8rem;
  background: #0b1115;
  border: 2px solid #364d52;
}

.inventory-item {
  position: relative;
  padding-left: 2.7rem;
}

.inventory-item::before {
  position: absolute;
  top: 0.7rem;
  left: 0.55rem;
  width: 24px;
  height: 24px;
  content: "";
  background: url("../assets/ui/icons.png?v=2.2.0") 0 0 / 192px 48px;
  image-rendering: pixelated;
}

.realm-card h3,
.shop-item h3 {
  margin: 0.1rem 0;
  color: #e8c86f;
}

.realm-card p,
.shop-item p {
  font-size: 0.78rem;
  line-height: 1.4;
}

.realm-card.locked {
  opacity: 0.45;
}

.map-list {
  display: grid;
  gap: 0.4rem;
  padding: 0;
  list-style: none;
}

.map-list li {
  padding: 0.55rem;
  background: #0b1115;
  border-left: 5px solid #465f63;
}

.map-list li.done {
  border-color: #69ddb9;
}

.credits-list {
  color: #d7dbc9;
  line-height: 2;
  text-align: center;
}

.credits-list strong {
  display: block;
  color: #edc768;
  font-family: Georgia, serif;
  font-size: 1.4rem;
}

.controls-table {
  width: 100%;
  border-collapse: collapse;
}

.controls-table td {
  padding: 0.55rem;
  border-bottom: 1px solid #2b3d41;
}

.controls-table td:first-child {
  color: #7fe9d8;
  font-weight: bold;
}

.save-code {
  width: 100%;
  min-height: 100px;
}

.loading-art,
.realm-map-art,
.ending-art {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  margin: 0 auto 1rem;
  background: #05090b;
  border: 2px solid #4d6b6b;
  image-rendering: pixelated;
}

.shopkeeper {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1rem;
}

.shopkeeper img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  background: #071014;
  border: 2px solid #557071;
  image-rendering: pixelated;
}

#touch-controls {
  display: none;
}

.scoreboard-section {
  width: min(900px, 100%);
  margin: 28px auto 0;
  padding: 20px;
  color: #dfe9e5;
  text-align: center;
  background: rgba(4, 10, 13, 0.9);
  border: 1px solid #00cccc;
  border-radius: 9px;
  box-shadow: 0 0 18px rgba(0, 204, 204, 0.2);
}

.scoreboard-section h2 {
  margin: 0 0 5px;
  color: #00cccc;
  font-family: "Cinzel", serif;
  text-shadow: 0 0 6px #00cccc;
}

.scoreboard-section p {
  margin: 0 0 14px;
  color: #a9c7c7;
}

.scoreboard-scroll {
  overflow-x: auto;
}

#scoreboard-table {
  width: 100%;
  border-collapse: collapse;
  background: rgba(0, 0, 0, 0.68);
}

#scoreboard-table th,
#scoreboard-table td {
  padding: 9px 10px;
  border: 1px solid #174a4d;
}

#scoreboard-table th {
  color: #041011;
  background: #00cccc;
}

#scoreboard-table tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 900px) {
  .mobile-only-notice {
    display: block;
  }

  .desktop-game {
    display: none;
  }
}

@media (max-width: 820px) {
  .hero-grid {
    grid-template-columns: repeat(2, minmax(190px, 1fr));
  }

  #game-screen {
    min-height: auto;
    padding: 10px;
  }
}

@media (max-width: 620px) {
  .game-shell {
    width: calc(100% - 12px);
  }

  .game-info {
    box-sizing: border-box;
    width: calc(100% - 16px);
    font-size: 0.78rem;
  }

  .play-guide {
    grid-template-columns: 1fr;
  }

  #landing {
    min-height: 610px;
    align-items: flex-end;
  }

  .landing-vignette {
    background: linear-gradient(0deg, #030508 18%, rgba(3, 5, 8, 0.88) 67%, rgba(3, 5, 8, 0.38));
  }

  .landing-content {
    width: calc(100% - 28px);
    margin: 0 auto;
    padding: 22px 0;
    text-align: center;
  }

  .landing-content h1 {
    max-width: none;
    font-size: clamp(2.7rem, 15vw, 4rem);
  }

  .tagline {
    margin-right: auto;
    margin-left: auto;
  }

  .player-name-row {
    grid-template-columns: 1fr;
    margin: 0 auto;
    text-align: left;
  }

  .title-actions {
    grid-template-columns: 1fr;
  }

  .title-actions button:first-child {
    grid-column: auto;
  }

  .return-link {
    margin-bottom: 18px;
  }

  .interaction-note {
    display: none;
  }

  #hero-select {
    padding: 18px 12px;
  }

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

  #hud {
    grid-template-columns: 1fr 1fr;
  }

  .hud-center {
    display: none;
  }

  .dialogue-box {
    grid-template-columns: 64px 1fr;
  }

  .dialogue-box img {
    width: 60px;
    height: 60px;
  }

  #objective,
  #boss-hud {
    bottom: 50px;
  }

  .scoreboard-section {
    padding: 14px 8px;
  }
}
