@font-face {
  font-family: Cinzel;
  src: url("assets/ui/cinzel.woff2") format("woff2");
  font-weight: 900;
  font-display: swap;
}
:root {
  color-scheme: dark;
  --ink: #151717;
  --gold: #ddbd7a;
  --rule: #9b804d69;
  --ivory: #f5ead3;
  --muted: #bdb5a5;
  --serif: "Songti TC", "PMingLiU", "MingLiU", "Noto Serif CJK TC", serif;
  font-family: "Microsoft JhengHei", system-ui, sans-serif;
  background: var(--ink);
  color: var(--ivory);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input {
  font: inherit;
}
button {
  color: inherit;
  cursor: pointer;
}
button:focus-visible,
input:focus-visible {
  outline: 2px solid #ffe3a5;
  outline-offset: 4px;
}
button:disabled {
  cursor: wait;
  opacity: 0.62;
}
[hidden] {
  display: none !important;
}
.lobby {
  min-height: 100vh;
  min-height: 100svh;
  position: relative;
  display: flex;
  flex-direction: column;
  isolation: isolate;
  background: #1b1b19;
}
.lobby:before,
.lobby:after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.lobby:before {
  background: url("assets/ui/cover.jpg") left 28% center/cover no-repeat;
}
.lobby:after {
  background:
    linear-gradient(
      90deg,
      rgba(17, 18, 18, 0.03) 17%,
      rgba(18, 18, 17, 0.09) 36%,
      rgba(16, 19, 19, 0.84) 63%,
      #111617 100%
    ),
    linear-gradient(
      0deg,
      #101515aa,
      transparent 24%,
      transparent 77%,
      #15171763
    );
}
.masthead,
.lobby-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 clamp(24px, 5vw, 85px);
}
.masthead {
  height: 82px;
  border-bottom: 1px solid #d1b37b4d;
}
.wordmark {
  font:
    900 22px/1 Cinzel,
    Georgia,
    serif;
  letter-spacing: 0.2em;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f9e6bc;
  text-shadow: 0 1px 5px #070906;
}
.wordmark img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  image-rendering: pixelated;
}
.masthead nav {
  display: flex;
  align-items: center;
  gap: clamp(11px, 2vw, 26px);
}
.character-portrait {
  display: block;
  width: 46px;
  height: 46px;
  image-rendering: pixelated;
  background: radial-gradient(ellipse at 50% 38%, #626756, #252d2a 76%);
  border: 1px solid #aa9266;
  border-radius: 50%;
  flex: none;
}
.masthead nav button {
  border: none;
  background: transparent;
  color: #e2d8c3;
  font-size: 14px;
  letter-spacing: 0.14em;
  padding: 10px 1px;
}
.masthead nav button:hover {
  color: white;
  text-decoration: underline;
  text-underline-offset: 7px;
}
.entry {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: clamp(32px, 5vh, 72px) clamp(36px, 8vw, 150px);
}
.entry-content {
  width: clamp(340px, 31vw, 510px);
}
.eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 14px;
  color: #e2bc74;
  font:
    900 12px/1.2 Cinzel,
    Georgia,
    serif;
  letter-spacing: 0.28em;
}
.eyebrow:before {
  content: "";
  width: 37px;
  height: 1px;
  background: #c6a063;
}
h1 {
  font: 700 clamp(53px, 4.9vw, 87px) / 1.18 var(--serif);
  letter-spacing: 0.09em;
  margin: 0 -0.09em 13px 0;
  color: #f8edd8;
  text-shadow: 0 3px 22px #181812;
}
.mission {
  margin: 0 0 clamp(24px, 4.5vh, 54px);
  font-size: 15px;
  line-height: 1.9;
  color: #e1dacb;
  letter-spacing: 0.045em;
}
.professions {
  border: 0;
  padding: 0;
  margin: 0;
}
.professions legend {
  display: flex;
  align-items: center;
  float: left;
  width: 100%;
  gap: 12px;
  color: #dfcfab;
  font-size: 12px;
  letter-spacing: 0.2em;
  margin: 0 0 12px;
}
.professions legend:after {
  content: "";
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, var(--rule), transparent);
}
.hero-options {
  clear: both;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.hero-options button {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  color: #c7c1b3;
  background: #1e2221bb;
  border: 1px solid #80796378;
  transition:
    border-color 0.16s,
    background 0.16s;
}
.hero-options button img {
  width: 38px;
  height: 36px;
  object-fit: cover;
  border-radius: 50%;
}
.hero-options button span {
  font: 700 17px var(--serif);
  letter-spacing: 0.07em;
}
.hero-options button:hover {
  border-color: #c4a365;
}
.hero-options button[aria-pressed="true"] {
  color: #fff0c8;
  border-color: #d3af6a;
  background: linear-gradient(130deg, #594934cc, #322c20e8);
  box-shadow: inset 0 -2px #bd995c;
}
.hero-detail {
  margin: 12px 0 24px;
  color: #ccc4b4;
  font-size: 13px;
  line-height: 1.65;
  min-height: 1.65em;
}
.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  position: relative;
  width: 100%;
  min-height: 53px;
  border: 1px solid #efcc89;
  background: linear-gradient(105deg, #e2c28a, #c49b59);
  color: #2e2518;
  font: 700 20px var(--serif);
  letter-spacing: 0.18em;
  box-shadow: inset 0 0 0 3px #99743e66;
}
.primary:hover:not(:disabled) {
  filter: brightness(1.11);
}
.primary i {
  font:
    normal 23px Georgia,
    serif;
  position: absolute;
  right: 18px;
}
.load-error {
  color: #ffbea3;
  font-size: 13px;
}
.lobby-footer {
  min-height: 65px;
  border-top: 1px solid #c8b18452;
  font-size: 12px;
  letter-spacing: 0.07em;
  color: #ded5c3;
}
.location {
  display: flex;
  gap: 10px;
  align-items: center;
  text-shadow: 0 1px 4px #000;
}
.location i {
  width: 8px;
  height: 8px;
  border: 1px solid #e6ce94;
  transform: rotate(45deg);
}
kbd {
  display: inline-block;
  font:
    11px Georgia,
    serif;
  padding: 3px 4px;
  border: 1px solid #b7a68580;
  border-radius: 2px;
  margin-right: 2px;
}
.sep {
  padding: 0 9px;
  color: #b39c74;
}
.touch-hint {
  display: none;
}
#battle {
  position: fixed;
  inset: 0;
  background: #171c18;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}
#arena {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.hud {
  position: absolute;
  inset: max(14px, env(safe-area-inset-top)) 18px auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  gap: 10px;
  pointer-events: none;
  text-shadow: 0 1px 3px #000;
}
.vitals,
.clock,
.hud-right,
.xp {
  background: #161b19ee;
  border: 1px solid #998252ad;
  box-shadow: 0 3px 12px #0005;
}
.vitals {
  width: min(165px, 100%);
  padding: 9px 11px;
}
#hud-skill {
  display: block;
  font-size: 11px;
  color: #ebcf95;
}
.vitals-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 14px;
}
.vitals-title b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.vitals-title span,
#kills {
  flex: none;
  white-space: nowrap;
}
.vitals-title span,
.hp-number {
  font-size: 10px;
  color: #e4dbc5;
}
.meter {
  height: 6px;
  background: #49423a;
  overflow: hidden;
  margin: 5px 0 1px;
}
.meter i,
.xp i {
  display: block;
  height: 100%;
  transform-origin: left center;
  background: #c45540;
}
.clock {
  text-align: center;
  padding: 7px 18px;
}
.clock span {
  display: block;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--gold);
}
.clock strong {
  font:
    900 23px/1.35 Cinzel,
    Georgia,
    serif;
  font-variant-numeric: tabular-nums;
}
.hud-right {
  justify-self: end;
  display: flex;
  align-items: center;
  font-size: 13px;
  gap: 13px;
  padding: 6px 6px 6px 12px;
}
.hud-right button {
  pointer-events: auto;
  width: 35px;
  height: 33px;
  border: 1px solid var(--rule);
  background: #534832;
}
.xp {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  width: min(520px, 65vw);
  font-size: 10px;
  color: #e3d8bb;
}
.xp > div {
  height: 5px;
  flex: 1;
  background: #343a35;
}
.xp i {
  background: #7ebcb0;
}
#bossbar {
  position: absolute;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  width: min(55%, 380px);
  text-align: center;
  text-shadow: 0 1px 3px #000;
  color: #fff1d3;
  font-size: 13px;
}
#bossbar .meter {
  border: 1px solid #b99260;
  height: 9px;
}
#bossbar i {
  background: #b34436;
}
#announcement {
  position: absolute;
  top: 26%;
  width: 100%;
  text-align: center;
  color: #fff0c7;
  font: 700 clamp(20px, 3vw, 37px) var(--serif);
  letter-spacing: 0.12em;
  text-shadow:
    0 2px 5px #100c08,
    0 0 12px #100c08;
  pointer-events: none;
}
#joystick {
  position: absolute;
  width: 94px;
  height: 94px;
  border-radius: 50%;
  border: 1px solid #eedcb388;
  background: #1b211c60;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
#joystick i {
  display: block;
  position: absolute;
  left: 30px;
  top: 30px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid #eedcb3;
  background: #bca57c88;
}
dialog {
  background: #1b211f;
  color: var(--ivory);
  width: min(440px, calc(100vw - 32px));
  max-height: 85svh;
  padding: 0;
  border: 1px solid #aa8a55;
  box-shadow: 0 18px 90px #000c;
}
dialog::backdrop {
  background: #080c0bba;
}
/* Phones: no window may be taller than the screen between the status bar /
   notch and the home indicator. The account and character windows, which hold
   text fields, hang from the top so the keyboard never pushes their title and
   first field out of view; in-battle choices stay centred under the thumbs. */
@media (max-width: 700px) {
  dialog[open] {
    max-height: calc(100svh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 64px) !important;
  }
  dialog.net-dialog[open],
  dialog.pf-dialog[open] {
    margin: calc(env(safe-area-inset-top, 0px) + 44px) auto auto;
  }
}
.dialog-inner {
  padding: 24px;
}
/* Pinned title bar: the padding-top/negative margin pair makes the bar cover
   the window's top padding, so it looks unchanged at rest and keeps the ×
   in reach once the content below has scrolled. */
.dialog-inner header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #1b211f;
  margin-top: -24px;
  padding-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--rule);
  padding-bottom: 13px;
  margin-bottom: 16px;
}
.dialog-inner h2 {
  font: 700 25px var(--serif);
  letter-spacing: 0.1em;
  margin: 0;
}
.dialog-inner header button {
  font-size: 25px;
  background: none;
  border: 0;
  color: var(--muted);
}
.dialog-inner p {
  font-size: 14px;
  line-height: 1.6;
  color: #dbd5c7;
}
.dialog-actions {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.secondary,
.choice {
  border: 1px solid var(--rule);
  background: #292d27;
  color: var(--ivory);
  padding: 11px 14px;
  font-size: 15px;
}
.secondary:hover,
.choice:hover {
  background: #413d2e;
  border-color: var(--gold);
}
.choice {
  width: 100%;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 12px;
  margin-top: 8px;
}
.choice img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  image-rendering: pixelated;
}
.choice b,
.choice small {
  display: block;
}
.choice small {
  color: var(--muted);
  margin-top: 4px;
}
.result,
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid #9b804d38;
  font-size: 14px;
}
.result b {
  color: #efd4a2;
}
.setting-row input {
  accent-color: #d9b478;
  width: 120px;
}
#career-action {position:absolute;bottom:max(52px,env(safe-area-inset-bottom));left:14px;padding:6px 10px;background:#241e16e8;color:#ffe3a2;border:1px solid #b28a4d;z-index:3}
#career-action:disabled {color:#d0c5ad}
#ult-bar {position:absolute;left:14px;bottom:calc(max(52px,env(safe-area-inset-bottom)) + 40px);display:flex;flex-wrap:wrap;gap:5px;max-width:min(92vw,430px);z-index:3}
#ult-bar[hidden] {display:none}
#ult-bar button {padding:6px 8px;font-size:13px;line-height:1.2;background:#182330e8;color:#d6ebff;border:1px solid #6f9fd0;border-radius:3px}
#ult-bar button:disabled {color:#8f9aa6;border-color:#465361}
#potion {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 8px;
  border: 1px solid var(--rule);
  background: #171d19ed;
  color: var(--ivory);
}
#potion img {
  width: 23px;
  height: 23px;
  image-rendering: pixelated;
}
#potion kbd {
  margin: 0;
  color: var(--muted);
}
#potion:disabled {
  cursor: default;
  opacity: 0.65;
}
.victory-town {
  width: 100%;
  max-height: 145px;
  object-fit: cover;
  object-position: center 52%;
  border: 1px solid var(--rule);
}
@media (pointer: coarse) {
  .desktop-hint,
  #potion kbd {
    display: none;
  }
  .touch-hint {
    display: inline;
  }
}
@media (max-width: 740px) {
  .masthead {
    height: 62px;
  }
  .entry {
    padding: 26px 25px 34px;
  }
  .entry-content {
    width: min(360px, 75vw);
  }
  .lobby:after {
    background:
      linear-gradient(
        90deg,
        #15191718,
        #14181754 24%,
        #121616da 65%,
        #121617f0
      ),
      linear-gradient(0deg, #15191988, transparent 55%);
  }
  .hero-options button {
    gap: 5px;
  }
  .lobby-footer {
    min-height: 52px;
  }
  .hud {
    inset: max(8px, env(safe-area-inset-top)) 8px auto;
    gap: 4px;
  }
  .vitals {
    width: min(120px, 100%);
    padding: 5px 6px;
  }
  .clock {
    padding: 4px 7px;
  }
  .hud-right {
    gap: 5px;
    padding: 3px 3px 3px 6px;
  }
  .hud-right button {
    width: 29px;
    height: 29px;
  }
  .character-portrait {
    width: 34px;
    height: 34px;
  }
  .clock strong {
    font-size: 18px;
  }
}
@media (max-width: 520px) and (orientation: portrait) {
  .hud {
    grid-template-columns: minmax(0, 1fr) auto minmax(min-content, 1fr);
  }
  .lobby:before {
    inset: 0 0 auto;
    height: 55svh;
    background-position: 36% 34%;
  }
  .lobby:after {
    background: linear-gradient(
      0deg,
      #151a19 0%,
      #151a19 37%,
      #151a19cc 52%,
      transparent 74%,
      #12161255 100%
    );
  }
  .masthead {
    margin: 0 20px;
  }
  .entry {
    align-items: flex-end;
    justify-content: center;
    padding: clamp(130px, 21vh, 230px) 23px 25px;
  }
  .entry-content {
    width: 100%;
  }
  .eyebrow {
    font-size: 10px;
  }
  .mission {
    margin-bottom: 19px;
    font-size: 14px;
  }
  .wide {
    display: none;
  }
  .hero-options button {
    min-height: 47px;
  }
  .hero-detail {
    margin: 10px 0 15px;
  }
  .lobby-footer {
    margin: 0 23px;
  }
  .wordmark {
    font-size: 19px;
  }
  .hud-right {
    font-size: 11px;
  }
  .clock {
    padding: 4px 6px;
  }
  .vitals-title {
    font-size: 12px;
  }
  .hp-number {
    font-size: 9px;
  }
}
@media (max-height: 600px) and (orientation: landscape) {
  .masthead {
    height: 42px;
  }
  .entry {
    padding: 12px 7vw;
  }
  .entry-content {
    width: 310px;
  }
  .eyebrow {
    margin-bottom: 5px;
    font-size: 9px;
  }
  h1 {
    font-size: 41px;
    margin-bottom: 4px;
  }
  .mission {
    font-size: 11px;
    margin: 0 0 9px;
  }
  .wide {
    display: none;
  }
  .hero-options button {
    min-height: 37px;
  }
  .hero-options button img {
    width: 28px;
    height: 27px;
  }
  .hero-detail {
    margin: 4px 0 9px;
    font-size: 11px;
  }
  .professions legend {
    margin-bottom: 5px;
    font-size: 10px;
  }
  .primary {
    min-height: 39px;
  }
  .lobby-footer {
    min-height: 29px;
  }
}

/* Battle controls. Everything hangs from two base lines, so a phone's notch and
   home-indicator insets move each group as a whole and nothing ends up on top
   of anything else: at the bottom the experience bar, above it potion / career
   skill / supply chest in one row, above that the ultimates in a grid. */
:root {
  --hud-top: max(14px, env(safe-area-inset-top));
  --hud-base: max(14px, env(safe-area-inset-bottom));
  --hud-left: max(14px, env(safe-area-inset-left));
  --hud-right: max(14px, env(safe-area-inset-right));
}
#battle .xp {
  bottom: var(--hud-base);
}
#battle #potion,
#battle #career-action,
#battle #run-chest {
  bottom: calc(var(--hud-base) + 36px);
  height: 38px;
  box-sizing: border-box;
}
#battle #potion {
  left: var(--hud-left);
  min-width: 58px;
  justify-content: center;
}
#battle #career-action {
  left: calc(var(--hud-left) + 64px);
  padding: 0 12px;
  font-size: 13px;
}
#battle #run-chest {
  right: var(--hud-right);
  padding: 0 10px;
  font-size: 12px;
}
#battle #ult-bar {
  left: var(--hud-left);
  right: var(--hud-right);
  bottom: calc(var(--hud-base) + 82px);
  max-width: 560px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(98px, 1fr));
  gap: 6px;
}
#battle #ult-bar[hidden] {
  display: none;
}
#battle #ult-bar button {
  height: 34px;
  padding: 0 6px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#battle #bossbar {
  top: calc(var(--hud-top) + 72px);
}
#battle #chain {
  top: calc(var(--hud-top) + 48px);
}
@media (max-width: 740px) {
  #battle .xp {
    left: var(--hud-left);
    right: var(--hud-right);
    width: auto;
    transform: none;
  }
}

/* Level-up choices: a gold bar under the boss bar. The fight does not stop for
   it, so it stays out of the middle of the screen and each choice is one tap. */
#upgrade-bar {
  position: absolute;
  top: calc(var(--hud-top) + 106px);
  left: var(--hud-left);
  right: var(--hud-right);
  max-width: 560px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  gap: 4px 5px;
  padding: 5px 6px 6px;
  background: #2b2412f2;
  border: 1px solid #e3bd5d;
  box-shadow: 0 0 12px #e3bd5d66;
  z-index: 4;
  animation: upgrade-bar 0.9s ease-in-out infinite alternate;
}
#upgrade-bar[hidden] {
  display: none;
}
#upgrade-bar strong {
  grid-column: 1 / -1;
  color: #ffdf8c;
  font-size: 11px;
  letter-spacing: 0.08em;
}
#upgrade-bar .choice {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  min-width: 0;
  padding: 5px 5px 6px;
  background: #1c1f1ae6;
  border: 1px solid #b79a55;
  color: var(--ivory);
  text-align: left;
}
#upgrade-bar .choice img {
  width: 20px;
  height: 20px;
  flex: none;
  image-rendering: pixelated;
}
#upgrade-bar .choice span {
  min-width: 0;
}
#upgrade-bar .choice b {
  display: block;
  font-size: 13px;
  color: #ffe9b0;
}
#upgrade-bar .choice small {
  display: block;
  font-size: 10.5px;
  line-height: 1.3;
  color: #d5ccb4;
}
#upgrade-bar .reroll {
  grid-column: 1 / -1;
  justify-self: end;
  padding: 3px 8px;
  font-size: 11px;
  background: #1c1f1ae6;
  border: 1px solid #8d7a4a;
  color: #e9d7a6;
}
@keyframes upgrade-bar {
  from { box-shadow: 0 0 6px #e3bd5d55; }
  to { box-shadow: 0 0 16px #e3bd5dcc; }
}

/* The lobby header on a phone: four short buttons on one line. */
.professions[hidden],
.hero-detail[hidden] {
  display: none;
}
@media (max-width: 740px) {
  .masthead nav {
    gap: 4px;
  }
  .masthead nav button {
    padding: 5px 7px;
    font-size: 12px;
    white-space: nowrap;
  }
}
