:root {
  color-scheme: dark;
  --ink: #141d23;
  --gold: #e8b75c;
  --paper: #f9ead0;
  --muted: #c4b698;
  --line: #e8b75c38;
  --ruby: #df6161;
  --mint: #45d8bc;
  font-family: Tahoma, Arial, sans-serif;
  color: var(--paper);
  background: var(--ink);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  overflow: hidden;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
button {
  font: inherit;
  cursor: pointer;
}
button:disabled {
  cursor: wait;
  opacity: 0.55;
}
button:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 2px solid #fff2c4;
  outline-offset: 5px;
}
button {
  color: inherit;
}
button,
a {
  touch-action: manipulation;
}
button[hidden],
[hidden] {
  display: none !important;
}
#game {
  width: 100%;
  height: 100svh;
  min-height: 480px;
  position: relative;
  overflow: hidden;
}
#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  outline: none;
}
.screen-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    #111a20b0,
    transparent 25%,
    transparent 76%,
    #111a2080
  );
}
.topbar {
  position: absolute;
  top: max(22px, env(safe-area-inset-top));
  right: 4%;
  left: 4%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  z-index: 12;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--paper);
  direction: ltr;
}
.brand img {
  width: 30px;
  height: 43px;
  object-fit: contain;
}
.brand > span {
  font-family: Georgia, serif;
  font-size: 22px;
  letter-spacing: 3px;
}
.brand small {
  display: block;
  font-family: Arial, sans-serif;
  letter-spacing: 3px;
  font-size: 8px;
  margin-top: 3px;
  color: var(--gold);
}
.tools {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #111a2090;
  font-size: 22px;
}
.icon-button:hover {
  border-color: var(--gold);
  background: #29302b;
}
.quiet {
  border: 0;
  background: transparent;
  font-size: 12px;
  color: var(--muted);
  padding: 12px;
  text-decoration: underline;
  text-underline-offset: 5px;
}
.quiet:hover {
  color: var(--paper);
}
.home {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    270deg,
    #111a20 0%,
    #111a20f7 36%,
    #111a20c9 65%,
    #111a2080 100%
  );
  overflow: auto;
  padding: 100px 6% 28px;
  display: flex;
  align-items: center;
}
.hero-art {
  position: absolute;
  left: 5%;
  bottom: 0;
  height: 100%;
  max-width: 62%;
  object-fit: contain;
  object-position: bottom;
  mask-image: linear-gradient(
    0deg,
    transparent 0%,
    #000 15%,
    #000 84%,
    transparent 100%
  );
  filter: saturate(0.95);
  opacity: 0.95;
}
.home-content {
  position: relative;
  width: 510px;
  max-width: 47%;
  z-index: 2;
  padding-bottom: 12px;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: 0.8px;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 15px;
}
.eyebrow > span:empty {
  width: 30px;
  height: 1px;
  background: var(--gold);
}
h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(58px, 5.6vw, 89px);
  line-height: 1.08;
  letter-spacing: -2px;
  margin: 0 0 20px;
  font-weight: 700;
}
h1 > span {
  display: block;
  font-size: 0.38em;
  color: var(--gold);
  letter-spacing: 0;
  margin: 10px 1px 0;
  font-weight: 400;
}
.intro-copy {
  font-size: 14px;
  line-height: 1.95;
  color: #dfd4c3;
  margin: 0 0 24px;
}
.unit-select {
  margin: 0;
  padding: 0;
  border: 0;
}
.unit-select legend {
  font-size: 12px;
  color: var(--paper);
  margin-bottom: 12px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.unit-select legend span {
  font: 11px monospace;
  color: var(--gold);
  direction: ltr;
}
.unit-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 7px;
}
.unit {
  position: relative;
  display: block;
  padding: 0 0 8px;
  overflow: hidden;
  border: 1px solid #ead1a125;
  border-radius: 5px;
  background: #202522;
  min-width: 0;
  transition:
    border-color 0.2s,
    transform 0.2s;
}
.unit:hover {
  transform: translateY(-3px);
  border-color: #e8b75c88;
}
.unit[aria-pressed="true"] {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px #e8b75c33;
}
.unit img {
  width: 100%;
  aspect-ratio: 0.82;
  object-fit: cover;
  object-position: 50% 10%;
  display: block;
  mask-image: linear-gradient(#000 78%, transparent);
  margin-bottom: -5px;
}
.unit > span {
  display: block;
  font-size: 10px;
  white-space: nowrap;
  padding: 5px 0 0;
}
.unit[aria-pressed="true"]:after {
  content: "◆";
  position: absolute;
  top: 4px;
  right: 5px;
  color: var(--gold);
  font-size: 11px;
}
.unit-description {
  min-height: 30px;
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
  margin: 10px 0 16px;
}
.campaign-heading {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 10px;
  color: var(--muted);
}
.levels {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.level {
  position: relative;
  text-align: right;
  min-height: 53px;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 8px;
  background: #152027;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}
.level b {
  display: block;
  font-family: Georgia, serif;
  font-size: 17px;
  color: var(--gold);
  font-weight: 400;
  float: left;
  margin-right: 4px;
}
.level[aria-pressed="true"] {
  background: #e8b75c16;
  border-color: #e8b75c99;
  color: var(--paper);
}
.level:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.start-row {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 22px;
}
.primary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  position: relative;
  isolation: isolate;
  min-height: 54px;
  min-width: 230px;
  padding: 14px 24px;
  border: 1px solid #f9d787;
  border-radius: 4px;
  background: linear-gradient(105deg, #eac178, #c99643);
  color: #261f15;
  font-weight: bold;
  box-shadow: 0 7px 28px #0003;
  transition:
    filter 0.2s,
    transform 0.2s;
  overflow: hidden;
}
.primary:not(:disabled):hover {
  filter: brightness(1.09);
  transform: translateY(-2px);
}
.primary:not(:disabled):active {
  transform: translateY(1px);
}
.primary:before {
  content: "";
  position: absolute;
  inset: 0;
  border: 1px solid #fbe2a9;
  pointer-events: none;
  animation: buttonRipple 3s cubic-bezier(0, 0.2, 0.8, 1) infinite;
  z-index: -1;
}
.best {
  font-size: 10px;
  line-height: 1.7;
  color: var(--muted);
}
.best b {
  font-size: 16px;
  color: var(--gold);
  display: block;
  font-family: monospace;
}
.load-status {
  font-size: 10px;
  color: var(--muted);
  margin: 9px 0;
  min-height: 15px;
}
.load-status.error {
  color: #ffb9a3;
}
.control-note {
  font-size: 10px;
  color: #a9a796;
  margin: 10px 0 0;
  line-height: 1.7;
}
.control-note kbd {
  border: 1px solid #e8b75c55;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
  margin: 0 1px;
}
.mobile-note {
  display: none;
}
.hero-caption {
  position: absolute;
  left: 8%;
  bottom: 4%;
  display: flex;
  gap: 13px;
  align-items: center;
  direction: rtl;
}
.hero-caption > span {
  font-size: 38px;
  color: var(--gold);
}
.hero-caption p {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.8;
}
.hero-caption strong {
  font-size: 15px;
  font-weight: normal;
  color: var(--paper);
}
.hud {
  position: absolute;
  top: 96px;
  right: 4%;
  left: 4%;
  pointer-events: none;
  z-index: 5;
}
.stage-readout {
  position: absolute;
  right: 0;
  top: 8px;
  text-shadow: 0 2px 8px #000a;
}
.stage-readout span {
  display: block;
  font-size: 10px;
  letter-spacing: 1px;
  color: #fff0d6;
}
.stage-readout strong {
  display: block;
  font-size: 18px;
  margin-top: 7px;
}
.army-readout {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  margin: auto;
  width: max-content;
  min-width: 205px;
  border: 1px solid #e8b75c66;
  border-radius: 8px;
  background: #14242be6;
  padding: 8px 13px;
  box-shadow: 0 8px 28px #0003;
}
.army-readout img {
  width: 42px;
  height: 55px;
  object-fit: cover;
  object-position: top;
  border-radius: 4px;
}
.army-readout span {
  font-size: 9px;
  color: var(--muted);
  display: block;
}
.army-readout strong {
  font-family: Georgia, serif;
  font-size: 38px;
  line-height: 1.1;
  color: #ffdc92;
  font-variant-numeric: tabular-nums;
}
.army-readout.bump {
  animation: countBump 0.32s ease-out;
}
.power-readout {
  border-right: 1px solid var(--line);
  padding-right: 11px;
  margin-right: 8px;
}
.power-readout b {
  display: block;
  font-size: 16px;
  margin-top: 5px;
  color: var(--mint);
  font-family: monospace;
}
.progress-track {
  position: relative;
  height: 4px;
  width: 230px;
  margin: 16px auto;
  background: #14242ba8;
  direction: ltr;
  border-radius: 4px;
}
.progress-track > div {
  height: 100%;
  width: 0;
  background: #f4cc84;
  border-radius: 4px;
}
.progress-track > span:first-of-type {
  position: absolute;
  top: 8px;
  left: 0;
  font-size: 9px;
  color: #fff0d9;
  text-shadow: 0 1px 4px #000;
}
.boss-mark {
  position: absolute;
  right: -5px;
  top: -10px;
  color: #ffe2a6;
  font-size: 20px;
}
.battle {
  position: absolute;
  left: 50%;
  top: 238px;
  transform: translateX(-50%);
  width: min(380px, 86vw);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 14px;
  background: #211d23ed;
  border: 1px solid #e4816955;
  border-radius: 6px;
  z-index: 6;
  box-shadow: 0 12px 35px #0003;
}
.battle img {
  width: 47px;
  height: 64px;
  object-fit: cover;
  object-position: top;
  border-radius: 3px;
}
.battle-copy {
  flex: 1;
}
.battle-copy > span {
  display: block;
  color: #df9f8b;
  font-size: 9px;
}
.battle-copy strong {
  display: block;
  font-size: 15px;
  margin: 4px 0 8px;
}
.enemy-health {
  height: 5px;
  background: #593235;
  border-radius: 4px;
  overflow: hidden;
}
.enemy-health > div {
  height: 100%;
  background: #ef8771;
  width: 100%;
  transition: width 0.06s linear;
}
.battle-copy small {
  display: block;
  margin-top: 5px;
  font: 9px monospace;
  color: #ccaaa0;
}
.battle-swords {
  color: #e5947c;
  font-size: 28px;
}
.toast {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, 10px);
  padding: 10px 22px;
  background: #14242be6;
  border: 1px solid #e8b75c55;
  border-radius: 5px;
  color: #fcdf9f;
  text-align: center;
  font-size: 17px;
  font-weight: bold;
  opacity: 0;
  pointer-events: none;
  z-index: 8;
  transition:
    opacity 0.18s,
    transform 0.18s;
  white-space: nowrap;
}
.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.toast.negative {
  color: #ffb5a9;
  border-color: #c97067;
}
.combo {
  position: absolute;
  right: 4%;
  top: 220px;
  font-size: 11px;
  color: #fff0cb;
  background: #273337c9;
  padding: 8px 11px;
  border-radius: 4px;
  border-right: 2px solid var(--gold);
}
.guidance {
  position: absolute;
  bottom: max(34px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #17252bd9;
  border: 1px solid var(--line);
  padding: 10px 18px;
  border-radius: 30px;
  display: flex;
  align-items: center;
  gap: 24px;
  font-size: 11px;
  color: #ebd7b9;
  pointer-events: none;
  white-space: nowrap;
}
.guidance b {
  font-size: 20px;
}
.support {
  position: absolute;
  bottom: 30px;
  right: 4%;
  font-size: 10px;
  color: #eee0c6;
  background: #17252bcc;
  border-radius: 4px;
  padding: 10px;
}
.result-backdrop {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: #121c24b5;
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 24px;
}
.result-card {
  width: min(440px, 100%);
  padding: 30px 36px;
  text-align: center;
  background: linear-gradient(135deg, #243038, #151f25);
  border: 1px solid #cbaa6655;
  border-radius: 10px;
  box-shadow: 0 22px 90px #0007;
}
.result-symbol {
  display: block;
  font-size: 46px;
  color: var(--gold);
  line-height: 1;
}
.result-card .eyebrow {
  justify-content: center;
  margin: 13px 0;
  font-size: 10px;
}
.result-card h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 36px;
  margin: 10px 0 12px;
}
.result-card > p:not(.eyebrow) {
  font-size: 12px;
  line-height: 1.9;
  color: var(--muted);
}
.result-card .primary {
  width: 100%;
  justify-content: center;
  margin: 22px 0 8px;
}
.secondary {
  width: 100%;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  font-size: 12px;
  color: var(--paper);
}
.secondary:hover {
  background: #e8b75c0f;
}
.result-card > .quiet {
  margin-top: 7px;
}
.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 22px 0;
}
.result-stats span {
  font-size: 10px;
  color: var(--muted);
}
.result-stats b {
  display: block;
  color: var(--gold);
  font:
    24px Georgia,
    serif;
  margin: 8px 0;
}
.save-status {
  min-height: 16px;
  margin: 6px 0 !important;
  font-size: 9px !important;
}
.codex {
  width: min(1000px, 94vw);
  max-height: 88svh;
  padding: 25px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #152028;
  color: var(--paper);
}
.codex::backdrop {
  background: #081016d9;
  backdrop-filter: blur(12px);
}
.codex-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.codex-heading h2 {
  font:
    32px Georgia,
    serif;
  margin: 0;
}
.codex-heading .eyebrow {
  margin-bottom: 8px;
}
.codex-intro {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.8;
}
.codex-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-top: 24px;
}
.lore-card {
  margin: 0;
  background: #202628;
  border: 1px solid #e8b75c25;
  border-radius: 4px;
  overflow: hidden;
}
.lore-card img {
  width: 100%;
  aspect-ratio: 0.7;
  object-fit: cover;
  display: block;
  object-position: top;
}
.lore-card figcaption {
  padding: 12px 9px;
  font-size: 11px;
  line-height: 1.7;
}
.lore-card small {
  display: block;
  font-size: 9px;
  color: var(--muted);
  margin-top: 4px;
}
.fatal {
  position: absolute;
  inset: 20%;
  padding: 30px;
  background: #14232a;
  color: var(--paper);
  z-index: 100;
}
.save-status:empty {
  display: none;
}
#game[data-mode="running"] .brand,
#game[data-mode="battle"] .brand {
  opacity: 0.7;
}
@keyframes buttonRipple {
  from {
    transform: scale(0.8);
    opacity: 0.8;
  }
  to {
    transform: scale(2.4);
    opacity: 0;
  }
}
@keyframes countBump {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}
@media (min-width: 1400px) {
  .home-content {
    width: 570px;
  }
  .unit img {
    aspect-ratio: 0.9;
  }
  .home {
    padding-right: 9%;
  }
  .hero-art {
    left: 8%;
  }
}
@media (max-height: 760px) and (min-width: 701px) {
  .home {
    padding-top: 85px;
  }
  .home-content {
    width: 470px;
  }
  h1 {
    font-size: 58px;
    margin-bottom: 12px;
  }
  .intro-copy {
    margin-bottom: 14px;
  }
  .unit img {
    aspect-ratio: 1;
  }
  .unit-description {
    margin-bottom: 8px;
    min-height: 20px;
  }
  .start-row {
    margin-top: 14px;
  }
  .hero-art {
    height: 94%;
  }
}
@media (max-width: 700px) {
  #game {
    min-height: 420px;
  }
  .topbar {
    top: max(14px, env(safe-area-inset-top));
    left: 18px;
    right: 18px;
    gap: 10px;
  }
  .brand > span {
    font-size: 16px;
    letter-spacing: 2px;
  }
  .brand small {
    font-size: 6px;
    letter-spacing: 2px;
  }
  .brand img {
    width: 24px;
    height: 36px;
  }
  .tools {
    gap: 5px;
  }
  .icon-button {
    width: 34px;
    height: 34px;
    font-size: 19px;
  }
  .tools .quiet {
    font-size: 10px;
    padding: 8px;
  }
  .home {
    padding: 94px 22px 22px;
    align-items: flex-end;
    background: linear-gradient(
      0deg,
      #111a20 8%,
      #111a20ee 51%,
      #111a20a0 83%,
      #111a20b5
    );
  }
  .hero-art {
    height: 62%;
    max-width: 80%;
    left: -8%;
    bottom: auto;
    top: 36px;
    opacity: 0.57;
    mask-image: linear-gradient(#000 30%, transparent 95%);
  }
  .home-content {
    max-width: 100%;
    width: 100%;
    padding: 0;
  }
  .eyebrow {
    font-size: 9px;
    margin-bottom: 12px;
  }
  h1 {
    font-size: 65px;
    margin-bottom: 15px;
  }
  h1 > span {
    font-size: 27px;
    margin-top: 6px;
  }
  .intro-copy {
    font-size: 12px;
    line-height: 1.85;
    margin-bottom: 23px;
    max-width: 290px;
  }
  .unit-select legend {
    font-size: 11px;
  }
  .unit-grid {
    gap: 5px;
  }
  .unit img {
    aspect-ratio: 0.78;
  }
  .unit > span {
    font-size: 9px;
  }
  .unit-description {
    font-size: 10px;
    min-height: 30px;
    margin: 10px 0 13px;
  }
  .levels {
    gap: 5px;
  }
  .level {
    font-size: 9px;
    padding: 7px;
    min-height: 53px;
  }
  .level b {
    font-size: 14px;
  }
  .start-row {
    gap: 12px;
    margin-top: 20px;
  }
  .primary {
    min-width: 0;
    flex: 1;
    min-height: 51px;
    font-size: 14px;
    padding: 13px 18px;
  }
  .best {
    font-size: 9px;
    min-width: 62px;
  }
  .best b {
    font-size: 14px;
  }
  .hero-caption {
    display: none;
  }
  .control-note {
    font-size: 9px;
  }
  .desktop-note {
    display: none;
  }
  .mobile-note {
    display: inline;
  }
  .hud {
    top: 74px;
    right: 16px;
    left: 16px;
  }
  .stage-readout {
    top: 4px;
    max-width: 100px;
  }
  .stage-readout span {
    font-size: 8px;
  }
  .stage-readout strong {
    font-size: 12px;
    margin-top: 4px;
  }
  .army-readout {
    min-width: 163px;
    padding: 7px 9px;
    gap: 8px;
    margin: 0 0 0 auto;
    position: absolute;
    left: 0;
    top: 0;
  }
  .army-readout img {
    width: 30px;
    height: 42px;
  }
  .army-readout strong {
    font-size: 29px;
  }
  .army-readout span {
    font-size: 8px;
  }
  .power-readout {
    padding-right: 9px;
    margin-right: 2px;
  }
  .power-readout b {
    font-size: 13px;
  }
  .progress-track {
    width: calc(100% - 6px);
    margin-top: 79px;
  }
  .battle {
    top: 204px;
    max-width: 320px;
    padding: 8px 12px;
  }
  .battle img {
    height: 51px;
    width: 38px;
  }
  .battle-copy strong {
    font-size: 13px;
  }
  .toast {
    font-size: 14px;
    top: 38%;
    padding: 10px 14px;
    max-width: 92%;
  }
  .combo {
    top: 180px;
    font-size: 9px;
    padding: 5px 9px;
  }
  .guidance {
    bottom: 25px;
    font-size: 10px;
    padding: 8px 14px;
    gap: 15px;
  }
  .guidance b {
    font-size: 18px;
  }
  .support {
    bottom: 78px;
    right: 16px;
    font-size: 9px;
  }
  .result-card {
    padding: 25px 22px;
  }
  .result-card h2 {
    font-size: 31px;
  }
  .codex {
    padding: 20px;
  }
  .codex-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .lore-card figcaption {
    font-size: 10px;
    padding: 8px;
  }
  .codex-heading h2 {
    font-size: 26px;
  }
}
@media (max-width: 700px) and (max-height: 760px) {
  .home {
    padding-top: 77px;
  }
  h1 {
    font-size: 48px;
  }
  .intro-copy {
    margin-bottom: 15px;
    font-size: 11px;
  }
  .eyebrow {
    margin-bottom: 9px;
  }
  .unit img {
    aspect-ratio: 1.15;
  }
  .unit-description {
    margin-bottom: 8px;
    min-height: 25px;
  }
  .start-row {
    margin-top: 12px;
  }
  .unit-select legend {
    margin-bottom: 9px;
  }
  .home-content {
    padding-top: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
