@font-face {
  font-family: 'Cinzel';
  src: url('assets/fonts/cinzel-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Cinzel';
  src: url('assets/fonts/cinzel-latin-700-normal.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('assets/fonts/cormorant-garamond-latin-500-normal.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('assets/fonts/cormorant-garamond-latin-600-normal.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant Garamond';
  src: url('assets/fonts/cormorant-garamond-latin-500-italic.woff2') format('woff2');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
}

:root {
  --ink: #f3e8cf;
  --ink-dim: #b9aec8;
  --gold: #e9c982;
  --gold-deep: #b8893e;
  --panel: rgba(20, 15, 36, 0.74);
  --panel-edge: rgba(233, 201, 130, 0.38);
  --player: #62d6b0;
  --enemy: #ff6a5a;
  --hp: linear-gradient(90deg, #3fb88e, #7ff0bf);
  --mp: linear-gradient(90deg, #4f7de0, #9cc2ff);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --display: 'Cinzel', 'Trajan Pro', Georgia, serif;
  --serif: 'Cormorant Garamond', Georgia, serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #120e24;
  color: var(--ink);
  font-family: var(--serif);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  /* Menus scroll but never pinch-zoom (the game canvas handles its own pinch). */
  touch-action: pan-x pan-y;
}

#app {
  position: fixed;
  inset: 0;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

#grade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(90, 60, 170, 0.35), rgba(255, 150, 100, 0.12) 55%, rgba(20, 10, 50, 0.4));
  mix-blend-mode: soft-light;
}
#app[data-weather='rain'] #grade {
  background: linear-gradient(180deg, rgba(40, 60, 140, 0.5), rgba(60, 80, 140, 0.25) 55%, rgba(10, 10, 40, 0.5));
}
#app[data-weather='snow'] #grade {
  background: linear-gradient(180deg, rgba(150, 170, 255, 0.35), rgba(220, 230, 255, 0.15) 55%, rgba(40, 40, 90, 0.35));
}
#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 50%, rgba(8, 4, 20, 0.7) 100%);
}

.hidden {
  display: none !important;
}

/* ---------- Panels & buttons ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.04), inset 0 1px 0 rgba(255, 240, 200, 0.12);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  backdrop-filter: blur(10px) saturate(1.2);
}

.btn {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.08em;
  color: var(--ink);
  min-height: 46px;
  padding: 0 18px;
  border-radius: 11px;
  border: 1px solid rgba(233, 201, 130, 0.45);
  background: linear-gradient(180deg, rgba(70, 52, 104, 0.92), rgba(34, 25, 58, 0.94));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 240, 210, 0.18);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, opacity 0.15s;
}
.btn:active {
  transform: scale(0.96);
  filter: brightness(1.25);
}
.btn:disabled {
  opacity: 0.38;
  pointer-events: none;
}
.btn.primary {
  color: #2a1a08;
  background: linear-gradient(180deg, #f6dea0, #cf9f4f);
  border-color: #fff1c4;
  box-shadow: 0 6px 22px rgba(233, 180, 90, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.btn.ghost {
  background: rgba(20, 15, 36, 0.5);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--panel-edge);
  background: var(--panel);
  color: var(--gold);
  font-size: 18px;
  display: grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
#hud > * {
  pointer-events: auto;
}
#hud > #callout,
#hud > #hint,
#hud > #objective {
  pointer-events: none;
}

#topbar {
  position: absolute;
  top: calc(var(--safe-t) + 10px);
  left: calc(var(--safe-l) + 12px);
  right: calc(var(--safe-r) + 12px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
#turnorder {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  overflow: hidden;
  max-width: calc(100% - 56px);
  pointer-events: auto;
}
.chip {
  position: relative;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--player);
  background: radial-gradient(circle at 50% 30%, #3b2d5c, #17122a);
  transition: transform 0.25s ease;
}
.chip.enemy {
  border-color: var(--enemy);
}
.chip.now {
  width: 46px;
  height: 46px;
  box-shadow: 0 0 0 2px rgba(255, 211, 107, 0.6), 0 0 18px rgba(255, 211, 107, 0.55);
  border-color: #ffd36b;
}
.chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}
.chip-sep {
  width: 1px;
  height: 26px;
  background: var(--panel-edge);
  margin: 0 2px;
}

#objective {
  position: absolute;
  top: calc(var(--safe-t) + 68px);
  left: calc(var(--safe-l) + 16px);
  font-style: italic;
  font-size: 15px;
  color: var(--ink-dim);
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.8);
}
#objective .label {
  font-family: var(--display);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--gold);
  margin-right: 6px;
  text-transform: uppercase;
}

#callout {
  position: absolute;
  top: calc(var(--safe-t) + 74px);
  left: 50%;
  transform: translate(-50%, -8px);
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.14em;
  padding: 5px 30px;
  opacity: 0;
  white-space: nowrap;
  background: linear-gradient(90deg, transparent, rgba(20, 14, 36, 0.85) 20%, rgba(20, 14, 36, 0.85) 80%, transparent);
  border-top: 1px solid rgba(233, 201, 130, 0.5);
  border-bottom: 1px solid rgba(233, 201, 130, 0.5);
  transition: opacity 0.2s ease, transform 0.2s ease;
  color: var(--gold);
}
#callout.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
#callout.enemy {
  color: #ff9d8f;
}

#hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-b) + 170px);
  font-style: italic;
  font-size: 16px;
  color: var(--ink);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
  opacity: 0;
  transition: opacity 0.25s;
  white-space: nowrap;
}
#hint.show {
  opacity: 1;
}

#bottom {
  position: absolute;
  left: calc(var(--safe-l) + 10px);
  right: calc(var(--safe-r) + 10px);
  bottom: calc(var(--safe-b) + 10px);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}
#bottom > * {
  pointer-events: auto;
}

/* Unit card */
#unitcard {
  width: min(300px, 100%) !important;
}
#unitcard,
#inspect {
  display: flex;
  gap: 12px;
  padding: 10px 14px 10px 10px;
  width: min(360px, 100%);
  align-items: center;
}
.portrait {
  flex: 0 0 auto;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--panel-edge);
  background: radial-gradient(circle at 50% 35%, #4a3a70, #17122a 75%);
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}
.portrait.enemy {
  background: radial-gradient(circle at 50% 35%, #5a2a3a, #17122a 75%);
}
.u-info {
  flex: 1;
  min-width: 0;
}
.u-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.05em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.u-name .lv {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.12em;
}
.u-class {
  font-style: italic;
  color: var(--ink-dim);
  font-size: 14px;
  margin-top: -2px;
}
.bar {
  position: relative;
  height: 12px;
  margin-top: 5px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.bar > i {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 6px;
  transition: width 0.35s ease;
}
.bar > i.ghost {
  background: rgba(255, 90, 80, 0.75) !important;
  animation: blink 0.9s infinite;
}
.bar.hp > i {
  background: var(--hp);
}
.bar.mp > i {
  background: var(--mp);
}
.bar.enemy.hp > i:not(.ghost) {
  background: linear-gradient(90deg, #d8453a, #ff8f6b);
}
.bar span {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.08em;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}
.bar b {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.15em;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 1px 2px #000;
}
@keyframes blink {
  50% {
    opacity: 0.35;
  }
}
.u-status {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
  min-height: 0;
}
.st {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.1em;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid currentColor;
  background: rgba(0, 0, 0, 0.35);
}
.u-stats {
  display: grid;
  grid-template-columns: repeat(4, auto);
  gap: 1px 10px;
  margin-top: 6px;
  font-family: var(--display);
  font-size: 10px;
  color: var(--ink-dim);
  letter-spacing: 0.06em;
}
.u-stats em {
  font-style: normal;
  color: var(--ink);
}
.u-gear {
  margin-top: 5px;
  font-size: 13px;
  font-style: italic;
  color: var(--ink-dim);
}
.u-weak {
  margin-top: 4px;
  font-size: 13px;
  color: #ffcf8a;
  font-style: italic;
}

#inspect {
  position: absolute;
  top: calc(var(--safe-t) + 96px);
  right: calc(var(--safe-r) + 12px);
  width: min(320px, calc(100% - 24px));
  animation: slideIn 0.2s ease;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* Commands */
#commands {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 210px;
}
#commands .row {
  display: flex;
  gap: 8px;
}
#commands .row .btn {
  flex: 1;
}
.cmd-title {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.22em;
  color: var(--gold);
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 1px 6px #000;
}
.skill-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 8px;
}
.skill {
  text-align: left;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0 8px;
  padding: 8px 12px;
  height: auto;
  min-height: 52px;
}
.skill .nm {
  font-size: 14px;
}
.skill .mp {
  font-size: 11px;
  color: #9cc2ff;
  align-self: center;
}
.skill .ds {
  grid-column: 1 / -1;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  letter-spacing: 0;
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.2;
  margin-top: 2px;
}

.preview {
  padding: 12px 14px;
}
.pv-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--gold);
  text-transform: uppercase;
}
.pv-target {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  margin-top: 8px;
}
.pv-target + .pv-target {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(233, 201, 130, 0.15);
}
.pv-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
}
.pv-num {
  font-family: var(--display);
  font-weight: 700;
  font-size: 22px;
  text-align: right;
  line-height: 1;
}
.pv-num.dmg {
  color: #fff;
}
.pv-num.heal {
  color: #8dffc0;
}
.pv-num small {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-dim);
  letter-spacing: 0.08em;
  margin-top: 3px;
}
.pv-target .bar {
  grid-column: 1 / -1;
}
.pv-notes {
  grid-column: 1 / -1;
  font-style: italic;
  font-size: 13px;
  color: #ffcf8a;
}

/* ---------- Banner ---------- */
#banner {
  position: absolute;
  top: 40%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
}
#banner.show {
  opacity: 1;
}
#banner .text {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(28px, 7vw, 54px);
  letter-spacing: 0.18em;
  background: linear-gradient(180deg, #fff6dc, #e9c982 55%, #b8893e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 12px rgba(255, 190, 110, 0.45));
  text-align: center;
  padding: 0 16px;
}
#banner .sub {
  font-style: italic;
  font-size: 18px;
  color: var(--ink);
  text-shadow: 0 1px 8px #000;
  margin-top: 4px;
}
#banner .line {
  width: min(520px, 80vw);
  height: 1px;
  margin: 10px 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

/* ---------- Dialogue ---------- */
#dialogue {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 calc(var(--safe-r) + 12px) calc(var(--safe-b) + 14px) calc(var(--safe-l) + 12px);
  background: linear-gradient(180deg, transparent 45%, rgba(8, 5, 18, 0.65));
  cursor: pointer;
}
.dlg-box {
  position: relative;
  display: flex;
  gap: 14px;
  width: min(760px, 100%);
  padding: 14px 18px 18px 14px;
  background: linear-gradient(180deg, rgba(28, 20, 48, 0.92), rgba(14, 10, 26, 0.95));
  border: 1px solid var(--panel-edge);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 240, 200, 0.12);
  animation: slideIn 0.25s ease;
}
.dlg-portrait {
  flex: 0 0 auto;
  width: 84px;
  height: 84px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--panel-edge);
  background: radial-gradient(circle at 50% 35%, #4a3a70, #17122a 75%);
}
.dlg-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: auto;
}
.dlg-box.narration .dlg-portrait {
  display: none;
}
.dlg-box.narration .dlg-text {
  font-style: italic;
  text-align: center;
}
.dlg-body {
  flex: 1;
  min-width: 0;
}
.dlg-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.dlg-text {
  font-size: 20px;
  line-height: 1.35;
  font-weight: 500;
  min-height: 54px;
}
.dlg-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.dlg-choices:empty {
  display: none;
}
.dlg-choice {
  min-height: 44px;
  letter-spacing: normal;
  text-align: left;
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.25;
  padding: 8px 14px;
}
.dlg-box.choosing {
  cursor: default;
}
.dlg-box.choosing .dlg-next {
  display: none;
}
.dlg-box.choosing .dlg-text {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.12em;
  color: var(--gold);
  min-height: 0;
}
.dlg-next {
  position: absolute;
  right: 16px;
  bottom: 8px;
  color: var(--gold);
  font-size: 14px;
  animation: bob 1s ease-in-out infinite;
}
@keyframes bob {
  50% {
    transform: translateY(3px);
  }
}
.dlg-skip {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  right: calc(var(--safe-r) + 12px);
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 8px 14px;
  cursor: pointer;
}

/* ---------- Title & results ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 16px);
  background: radial-gradient(ellipse at 50% 45%, rgba(10, 6, 24, 0.15), rgba(10, 6, 24, 0.75));
  transition: opacity 0.6s ease;
}
.screen.fade {
  opacity: 0;
  pointer-events: none;
}
.title-inner {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.crest {
  width: 30px;
  height: 30px;
  transform: rotate(45deg);
  border: 1px solid var(--gold);
  margin-bottom: 18px;
  box-shadow: 0 0 24px rgba(255, 200, 120, 0.6), inset 0 0 12px rgba(255, 200, 120, 0.8);
  background: radial-gradient(circle, #fff3c4 0 20%, #ffb45a 45%, transparent 70%);
  animation: glow 3s ease-in-out infinite;
}
@keyframes glow {
  50% {
    box-shadow: 0 0 40px rgba(255, 200, 120, 0.9), inset 0 0 16px rgba(255, 220, 150, 1);
  }
}
h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(40px, 11vw, 86px);
  letter-spacing: 0.14em;
  background: linear-gradient(180deg, #fff8e4, #f0d08c 50%, #b8893e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 4px 24px rgba(255, 170, 90, 0.4));
  padding-left: 0.14em;
}
.subtitle {
  font-style: italic;
  font-size: clamp(17px, 4vw, 22px);
  color: var(--ink);
  margin: 6px 0 30px;
  text-shadow: 0 1px 10px #000;
}
#btn-begin {
  min-width: 200px;
  font-size: 16px;
  min-height: 52px;
}
.title-hint {
  margin-top: 18px;
  font-size: 14px;
  color: var(--ink-dim);
  font-style: italic;
}

.results-card {
  width: min(560px, 100%);
  padding: 22px 22px 18px;
  max-height: 100%;
  overflow-y: auto;
}
.results-card h2 {
  margin: 0;
  text-align: center;
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: 0.2em;
  color: var(--gold);
}
.results-card .sub {
  text-align: center;
  font-style: italic;
  color: var(--ink-dim);
  margin: 2px 0 14px;
  font-size: 16px;
}
.r-row {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 4px 12px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid rgba(233, 201, 130, 0.15);
}
.r-row .portrait {
  width: 48px;
  height: 48px;
  grid-row: span 2;
}
.r-top {
  display: flex;
  justify-content: space-between;
  font-family: var(--display);
  font-size: 14px;
}
.r-top .lvup {
  color: #ffd36b;
  font-size: 12px;
  letter-spacing: 0.1em;
  animation: glow 1.5s ease-in-out infinite;
}
.bar.xp > i {
  background: linear-gradient(90deg, #b8893e, #ffe39a);
  transition: width 1.2s ease;
}
.r-gains {
  grid-column: 2;
  font-size: 13px;
  color: #bfe9d4;
  font-style: italic;
}
.r-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
  flex-wrap: wrap;
}
.teaser {
  margin-top: 14px;
  text-align: center;
  font-style: italic;
  color: var(--ink-dim);
  font-size: 15px;
}

/* ---------- Portrait phones ---------- */
@media (orientation: portrait) {
  #bottom {
    flex-direction: column;
    align-items: stretch;
  }
  #unitcard {
    width: 100%;
    padding: 8px 12px 8px 8px;
  }
  #unitcard .portrait {
    width: 52px;
    height: 52px;
  }
  #unitcard .u-stats,
  #unitcard .u-gear {
    display: none;
  }
  #commands {
    width: 100%;
  }
  #commands.main {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
  }
  #commands.main .cmd-title {
    display: none;
  }
  #commands.main .row {
    display: contents;
  }
  .skill-list {
    max-height: 34vh;
  }
  #hint {
    bottom: calc(var(--safe-b) + 190px);
  }
  #inspect {
    top: calc(var(--safe-t) + 92px);
  }
  #objective {
    top: calc(var(--safe-t) + 66px);
    font-size: 14px;
  }
}

@media (max-height: 430px) and (orientation: landscape) {
  #unitcard .u-gear {
    display: none;
  }
  #objective {
    display: none;
  }
  #inspect {
    top: calc(var(--safe-t) + 64px);
  }
  .btn {
    min-height: 42px;
  }
  .skill-list {
    max-height: 62vh;
  }
}

@media (orientation: landscape) and (min-width: 700px) {
  .results-card {
    width: min(760px, 100%);
    padding: 16px 20px 14px;
  }
  .results-card h2 {
    font-size: 24px;
  }
  .r-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 22px;
  }
}
@media (max-height: 430px) {
  .results-card .sub {
    margin-bottom: 6px;
  }
  .r-row {
    padding: 5px 0;
  }
  .r-row .portrait {
    width: 40px;
    height: 40px;
  }
  .teaser {
    margin-top: 8px;
    font-size: 14px;
  }
  .r-actions {
    margin-top: 10px;
  }
}

/* ---------- Party screen ---------- */
#party {
  align-items: stretch;
  background: radial-gradient(ellipse at 50% 40%, rgba(16, 10, 34, 0.55), rgba(8, 5, 20, 0.88));
}
.party-card {
  width: min(980px, 100%);
  margin: auto;
  max-height: 100%;
  overflow-y: auto;
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.party-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.party-head .hire-top {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
}
.party-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: 0.16em;
  color: var(--gold);
}
.eyebrow {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.party-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
}
.ptab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px 5px 5px;
  border-radius: 999px;
  border: 1px solid rgba(233, 201, 130, 0.25);
  background: rgba(20, 15, 36, 0.6);
  color: var(--ink);
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.06em;
  cursor: pointer;
  flex: 0 0 auto;
}
.ptab img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  image-rendering: auto;
  background: radial-gradient(circle at 50% 35%, #4a3a70, #17122a 75%);
}
.ptab.on {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(90, 66, 130, 0.9), rgba(40, 30, 66, 0.9));
  box-shadow: 0 0 16px rgba(255, 200, 120, 0.25);
}
.spdot {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: linear-gradient(180deg, #f6dea0, #cf9f4f);
  color: #2a1a08;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  display: grid;
  place-items: center;
  padding: 0 4px;
}
.party-body {
  display: grid;
  grid-template-columns: minmax(230px, 300px) 1fr;
  grid-template-rows: auto 1fr;
  grid-template-areas: 'left right' 'detail right';
  gap: 12px 16px;
  min-height: 0;
}
.p-left {
  grid-area: left;
}
.p-right {
  grid-area: right;
}
.p-detail {
  grid-area: detail;
}
.p-detail > .nd-detail,
.p-detail > .nd-hint {
  margin-top: 0;
}
.p-detail .cands {
  margin-top: 0;
}
.p-hero {
  display: flex;
  gap: 12px;
  align-items: center;
}
.portrait.big {
  width: 84px;
  height: 84px;
}
.p-id {
  flex: 1;
  min-width: 0;
}
.p-bars {
  margin-top: 6px;
  max-width: 320px;
}
.p-bars .bar {
  height: 14px;
}
.p-bars .bar span {
  font-size: 11px;
}
.face-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.face-pick {
  width: 64px;
  height: 64px;
  padding: 0;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--panel-edge);
  background: #1c1530;
  opacity: 0.8;
}
.face-pick img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  /* The shape of a face, not its complexion: skin tone is chosen separately. */
  filter: grayscale(1) sepia(0.25) contrast(1.05);
}
.face-pick.on {
  border-color: var(--gold);
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(233, 201, 130, 0.35);
}
.cr-gap {
  width: 12px;
}
.p-help {
  min-width: 44px;
  width: 44px;
  padding: 0;
  border-radius: 50%;
  font-size: 20px;
  font-weight: 700;
}
.p-sp {
  margin-top: 6px;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
  text-transform: uppercase;
}
.p-sp b {
  color: #ffd36b;
  font-size: 15px;
  margin-left: 4px;
}
.p-stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 12px;
}
.pst {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 2px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.pst span {
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--ink-dim);
}
.pst b {
  font-family: var(--display);
  font-size: 16px;
}
.seg {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  margin-bottom: 10px;
}
.seg button {
  flex: 1;
  min-height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.12em;
  cursor: pointer;
}
.seg button.on {
  background: linear-gradient(180deg, rgba(90, 66, 130, 0.95), rgba(46, 34, 76, 0.95));
  color: var(--gold);
  box-shadow: inset 0 1px 0 rgba(255, 240, 210, 0.15);
}
.tree {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.branch {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
.br-name {
  text-align: center;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 4px;
  border-radius: 12px;
  border: 1px solid rgba(233, 201, 130, 0.2);
  background: rgba(20, 15, 36, 0.7);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease;
}
.node:active {
  transform: scale(0.97);
}
.nd-type {
  font-family: var(--display);
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.nd-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  line-height: 1.15;
}
.nd-cost {
  font-size: 12px;
  font-style: italic;
  color: var(--ink-dim);
}
.node.learned {
  border-color: rgba(255, 211, 107, 0.7);
  background: linear-gradient(180deg, rgba(110, 80, 40, 0.55), rgba(40, 28, 20, 0.7));
  box-shadow: inset 0 0 12px rgba(255, 200, 110, 0.18);
}
.node.learned .nd-cost {
  color: #ffd36b;
}
.node.available {
  border-color: #ffd36b;
  animation: glow 2s ease-in-out infinite;
}
.node.locked,
.node.unaffordable {
  opacity: 0.55;
}
.node.picked {
  outline: 2px solid #fff1c4;
  outline-offset: 1px;
}
.link {
  width: 2px;
  height: 12px;
  margin: 0 auto;
  background: rgba(233, 201, 130, 0.2);
}
.link.on {
  background: #ffd36b;
  box-shadow: 0 0 6px rgba(255, 211, 107, 0.7);
}
.nd-detail,
.nd-hint {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(233, 201, 130, 0.15);
}
.nd-hint {
  font-style: italic;
  color: var(--ink-dim);
  font-size: 15px;
}
.nd-title {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
  color: var(--gold);
}
.nd-meta {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: #9cc2ff;
  margin-top: 2px;
}
.nd-desc {
  font-size: 16px;
  margin-top: 6px;
  line-height: 1.3;
}
.nd-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.nd-act {
  flex: 0 0 auto;
  text-align: right;
  max-width: 55%;
}
.nd-act .btn {
  min-height: 40px;
  padding: 0 14px;
}
.nd-status {
  font-style: italic;
  color: var(--ink-dim);
}
.nd-status.ok {
  color: #ffd36b;
}
.slots {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.slot,
.cand {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 2px 10px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(233, 201, 130, 0.22);
  background: rgba(20, 15, 36, 0.7);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  font-family: var(--serif);
}
.slot.on {
  border-color: var(--gold);
}
.sl-label {
  grid-column: 1 / -1;
  font-family: var(--display);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.sl-item,
.cd-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
}
.sl-mods {
  font-size: 14px;
  color: #bfe9d4;
  font-style: italic;
}
.cands {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.cand {
  background: rgba(40, 30, 66, 0.7);
}
.diffs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}
.diffs i {
  font-style: normal;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}
.diffs i.up {
  color: #8dffc0;
  background: rgba(60, 200, 140, 0.15);
}
.diffs i.down {
  color: #ff9d8f;
  background: rgba(255, 100, 90, 0.15);
}
.loot {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(233, 201, 130, 0.15);
  text-align: center;
}
.loot .eyebrow {
  margin-bottom: 4px;
}
.loot span {
  display: inline-block;
  margin: 2px 6px;
  font-family: var(--display);
  font-size: 13px;
  color: #ffe39a;
}
.title-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}

@media (orientation: portrait) {
  .party-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    overflow: visible;
  }
  .ptab {
    flex-direction: column;
    gap: 3px;
    padding: 6px 2px;
    border-radius: 14px;
    font-size: 11px;
  }
  .party-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    grid-template-areas: 'left' 'right' 'detail';
  }
  .tree {
    gap: 6px;
  }
  .nd-name {
    font-size: 12px;
  }
}
@media (max-height: 430px) and (orientation: landscape) {
  .party-card {
    padding: 10px 14px;
    gap: 8px;
  }
  .party-head h2 {
    font-size: 18px;
  }
  .portrait.big {
    width: 64px;
    height: 64px;
  }
  .p-stats {
    margin-top: 6px;
    gap: 4px;
  }
  .pst {
    padding: 2px;
  }
  .pst b {
    font-size: 13px;
  }
  .ptab img {
    width: 26px;
    height: 26px;
  }
  .party-tabs {
    margin-top: -4px;
  }
  .nd-detail {
    padding: 8px 12px;
  }
  .nd-desc {
    font-size: 14px;
    margin-top: 3px;
  }
  .nd-act .btn {
    min-height: 34px;
    font-size: 12px;
  }
  .p-hero .bar {
    margin-top: 3px;
  }
  .node {
    padding: 5px 4px;
  }
  .link {
    height: 8px;
  }
}

/* ---------- Creator ---------- */
#creator,
#company,
#hire,
#shop,
#deploy {
  align-items: stretch;
  background: radial-gradient(ellipse at 50% 40%, rgba(16, 10, 34, 0.6), rgba(8, 5, 20, 0.9));
}
.creator-card,
.company-card,
.hire-card,
.deploy-card {
  width: min(980px, 100%);
  margin: auto;
  max-height: 100%;
  overflow-y: auto;
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cr-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.cr-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--gold);
}
.cr-body {
  display: grid;
  grid-template-columns: minmax(220px, 38%) 1fr;
  gap: 16px;
}
.cr-stage {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: radial-gradient(ellipse at 50% 30%, rgba(90, 60, 130, 0.5), rgba(10, 6, 22, 0.8));
  border: 1px solid rgba(233, 201, 130, 0.2);
  min-height: 300px;
  overflow: hidden;
}
.cr-stage canvas {
  flex: 1;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 220px;
}
.cr-stage,
.cr-controls {
  min-width: 0;
}
.cr-look {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px;
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
}
.cr-look-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
}
.cr-look-n {
  font-style: italic;
  color: var(--ink-dim);
  font-size: 13px;
}
.cr-arrow {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--panel-edge);
  background: rgba(40, 30, 66, 0.9);
  color: var(--gold);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
}
.cr-controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* The character stays in view; only the options scroll. */
.creator-card {
  height: 100%;
  overflow: hidden;
}
.cr-body {
  flex: 1;
  min-height: 0;
  grid-template-rows: minmax(0, 1fr);
}
.cr-controls {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  padding-bottom: 8px;
}
.cr-label {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 6px;
}
.cr-classes {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.cr-class {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid rgba(233, 201, 130, 0.22);
  background: rgba(20, 15, 36, 0.7);
  color: var(--ink);
  cursor: pointer;
}
.cr-class b {
  font-family: var(--display);
  font-size: 13px;
}
.cr-class span {
  font-size: 12px;
  font-style: italic;
  color: var(--ink-dim);
}
.cr-class.on {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(90, 66, 130, 0.9), rgba(40, 30, 66, 0.9));
}
.cr-races {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cr-race {
  min-height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(233, 201, 130, 0.22);
  background: rgba(20, 15, 36, 0.7);
  color: var(--ink);
  font-family: var(--display);
  font-size: 13px;
  cursor: pointer;
}
.cr-race.on {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(90, 66, 130, 0.9), rgba(40, 30, 66, 0.9));
}
.cr-blurb {
  font-size: 15px;
  line-height: 1.3;
}
.cr-blurb em {
  color: #9cc2ff;
}
.cr-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sw {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: var(--c);
  cursor: pointer;
}
.sw.def {
  background: conic-gradient(#2d4d8c 0 25%, #3f6e44 0 50%, #51307a 0 75%, #6aa6c0 0);
}
.sw.on {
  border-color: #fff1c4;
  box-shadow: 0 0 0 2px rgba(255, 211, 107, 0.6), 0 0 12px rgba(255, 211, 107, 0.5);
}
.cr-name {
  display: flex;
  gap: 8px;
}
.cr-name input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: rgba(0, 0, 0, 0.35);
  color: var(--ink);
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: 0.06em;
}
.cr-name input.need {
  border-color: #ff9d8f;
}
.cr-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.cr-cost {
  font-style: italic;
  color: var(--ink-dim);
}
.cr-cost b,
.gold-line {
  color: #ffd36b;
}

/* ---------- Recruit hall & deploy ---------- */
.hire-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.gold {
  font-family: var(--display);
  font-weight: 700;
  font-size: 20px;
  color: #ffd36b;
}
.gold span {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
}
.hire-sub {
  font-style: italic;
  color: var(--ink-dim);
}
.rc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.rc {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(233, 201, 130, 0.2);
  background: rgba(20, 15, 36, 0.7);
}
.rc .portrait {
  width: 64px;
  height: 64px;
}
.rc.custom {
  grid-template-columns: 1fr auto;
  border-style: dashed;
}
.rc-name {
  font-family: var(--display);
  font-weight: 700;
  font-size: 16px;
}
.rc-name .lv {
  font-size: 11px;
  color: var(--gold);
  letter-spacing: 0.12em;
}
.rc-cls {
  color: var(--ink-dim);
  font-size: 14px;
}
.rc-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: 3px;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
}
.rc-stats b {
  color: var(--ink);
  font-size: 12px;
}
.rc-skills {
  font-size: 13px;
  font-style: italic;
  color: #9cc2ff;
  margin-top: 2px;
}
.dp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
}
.dp {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 12px;
  border: 1px solid rgba(233, 201, 130, 0.2);
  background: rgba(20, 15, 36, 0.7);
  color: var(--ink);
  cursor: pointer;
  opacity: 0.6;
}
.dp.on {
  opacity: 1;
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(90, 66, 130, 0.8), rgba(40, 30, 66, 0.85));
}
.dp .portrait {
  width: 56px;
  height: 56px;
}
.dp-name {
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
}
.dp-cls {
  font-size: 12px;
  color: var(--ink-dim);
}
.dp-check {
  position: absolute;
  top: 6px;
  right: 8px;
  font-style: normal;
  color: #ffd36b;
  font-size: 16px;
}
.dismiss {
  margin-top: 12px;
  width: 100%;
  min-height: 38px;
  font-size: 11px;
  color: #ff9d8f;
}

@media (orientation: portrait) {
  .cr-body {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 44%) minmax(0, 1fr);
  }
  .cr-stage {
    min-height: 0;
  }
  .cr-stage canvas {
    min-height: 0;
  }
  .cr-classes {
    grid-template-columns: repeat(2, 1fr);
  }
  .rc {
    grid-template-columns: 52px 1fr;
  }
  .rc .portrait {
    width: 52px;
    height: 52px;
  }
  .rc .btn {
    grid-column: 1 / -1;
  }
  .rc.custom .btn {
    grid-column: auto;
  }
}
@media (max-height: 430px) and (orientation: landscape) {
  .creator-card {
    padding: 10px 14px;
    gap: 6px;
  }
  .cr-head h2 {
    font-size: 17px;
  }
  .cr-stage {
    min-height: 0;
  }
  .cr-stage canvas {
    min-height: 150px;
  }
  .cr-class {
    padding: 5px 4px;
  }
  .cr-label {
    margin-top: 2px;
  }
  .cr-blurb {
    font-size: 13px;
  }
  .sw {
    width: 28px;
    height: 28px;
  }
}

/* ---------- Companions ---------- */
.co-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.co-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 12px;
  border: 1px solid rgba(233, 201, 130, 0.18);
  background: rgba(20, 15, 36, 0.6);
}
.co-img {
  height: min(38vh, 280px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 70%, rgba(255, 190, 120, 0.22), transparent 70%);
}
.co-img img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.co-img img.px {
  height: 70%;
  image-rendering: pixelated;
}
.co-name {
  font-family: var(--display);
  font-size: 16px;
  color: var(--gold);
  text-align: center;
}
.co-name span {
  font-family: var(--serif);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-dim);
}
.co-race {
  font-family: var(--display);
  font-weight: 600;
  font-size: 14px;
  text-align: center;
}
.co-race span {
  display: block;
  font-family: var(--serif);
  font-weight: 500;
  font-style: italic;
  font-size: 13px;
  color: var(--ink-dim);
}
.co-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  font-size: 13px;
  color: var(--ink-dim);
}
.co-nav .cr-arrow {
  flex: 0 0 44px;
}
.co-perk {
  font-size: 13px;
  line-height: 1.3;
  text-align: center;
}
.co-perk em {
  display: block;
  color: #9cc2ff;
}
@media (orientation: portrait) {
  .co-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .co-img {
    height: min(24vh, 220px);
  }
}

#btn-newgame.confirm {
  color: #ffb4a8;
  border-color: rgba(255, 120, 100, 0.6);
}

/* ---------- Open world ---------- */
#world {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
  background: #cdb89c;
}
#world-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.ow-label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(20, 15, 36, 0.62);
  border: 1px solid var(--panel-edge);
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--gold);
  white-space: nowrap;
}
#world-hud {
  position: absolute;
  top: calc(var(--safe-t) + 10px);
  left: calc(var(--safe-l) + 12px);
  right: calc(var(--safe-r) + 12px);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  pointer-events: none;
}
#world-hud .btn,
.wh-place {
  pointer-events: auto;
}
.wh-place {
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(20, 15, 36, 0.55);
  border: 1px solid var(--panel-edge);
}
.wh-name {
  font-family: var(--display);
  font-size: 17px;
  color: var(--gold);
  letter-spacing: 0.08em;
}
.wh-hint {
  font-style: italic;
  font-size: 13px;
  color: var(--ink-dim);
}
.wh-btns {
  display: flex;
  gap: 8px;
}

/* ---------- Loading ---------- */
#loading {
  position: absolute;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: radial-gradient(ellipse at 50% 45%, rgba(40, 28, 70, 0.92), rgba(8, 5, 20, 0.97));
  transition: opacity 0.35s ease;
}
#loading.out {
  opacity: 0;
}
.ld-lantern {
  position: relative;
  width: 76px;
  height: 76px;
}
.ld-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(233, 201, 130, 0.18);
  border-top-color: var(--gold);
  border-right-color: rgba(233, 201, 130, 0.6);
  animation: ld-spin 1.1s linear infinite;
}
.ld-flame {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 20px;
  height: 28px;
  margin: -16px 0 0 -10px;
  border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  background: radial-gradient(ellipse at 50% 70%, #fff6d8, #ffc978 45%, rgba(255, 140, 60, 0) 75%);
  filter: drop-shadow(0 0 12px rgba(255, 190, 110, 0.9));
  animation: ld-flicker 0.9s ease-in-out infinite alternate;
}
.ld-text {
  max-width: min(80vw, 420px);
  text-align: center;
  font-size: 19px;
  font-style: italic;
  color: var(--ink);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.ld-text.swap {
  opacity: 0;
  transform: translateY(6px);
}
@keyframes ld-spin {
  to {
    transform: rotate(360deg);
  }
}
@keyframes ld-flicker {
  from {
    transform: scale(0.92) translateY(1px);
    opacity: 0.85;
  }
  to {
    transform: scale(1.06) translateY(-1px);
    opacity: 1;
  }
}
#banner {
  z-index: 20;
}
#dialogue {
  z-index: 30;
}

/* ---------- Side-view battle ---------- */
#sb {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
#sb button,
#sb .card {
  pointer-events: auto;
}
.sb-order {
  position: absolute;
  top: calc(var(--safe-t) + 6px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 3px 6px;
  border-radius: 999px;
  background: rgba(20, 15, 36, 0.6);
  border: 1px solid var(--panel-edge);
}
.sb-chip {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--player);
  background: #1c1530;
  opacity: 0.85;
}
.sb-chip.enemy {
  border-color: var(--enemy);
}
.sb-chip.now {
  width: 42px;
  height: 42px;
  opacity: 1;
  box-shadow: 0 0 12px rgba(255, 220, 150, 0.8);
}
.sb-chip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sb-callout {
  position: absolute;
  top: calc(var(--safe-t) + 62px);
  left: 50%;
  transform: translate(-50%, -8px);
  padding: 6px 18px;
  border-radius: 10px;
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: 0.12em;
  color: var(--gold);
  background: rgba(20, 15, 36, 0.75);
  border: 1px solid var(--panel-edge);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.sb-callout.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.sb-callout.enemy {
  color: #ffb4a8;
}
.sb-floats {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.sb-ebar {
  position: absolute;
  left: 0;
  top: 0;
  width: 84px;
  text-align: center;
}
.sb-ename {
  display: none;
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #ffd9d2;
  text-shadow: 0 1px 3px #000;
  white-space: nowrap;
}
.sb-ebar.named .sb-ename {
  display: block;
}
.sb-ebar .bar {
  height: 6px;
  margin-top: 2px;
}
.sb-ebar .bar > i {
  background: linear-gradient(90deg, #d8453a, #ff8f6b);
}
.sb-float {
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--display);
  font-weight: 700;
  text-align: center;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9), 0 0 2px #000;
  white-space: nowrap;
  animation: sb-rise 1.3s ease-out forwards;
}
.sb-float small {
  display: block;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
@keyframes sb-rise {
  0% {
    opacity: 0;
    margin-top: 10px;
  }
  15% {
    opacity: 1;
    margin-top: 0;
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    margin-top: -34px;
  }
}
.sb-bottom {
  position: absolute;
  left: calc(var(--safe-l) + 10px);
  right: calc(var(--safe-r) + 10px);
  bottom: calc(var(--safe-b) + 10px);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 10px;
}
.sb-cmd,
.sb-party {
  padding: 6px 10px;
  background: rgba(20, 15, 36, 0.62);
}
.sb-cmd {
  width: min(300px, 40%);
  max-height: 62vh;
  padding: 10px 12px;
  overflow-y: auto;
  transition: opacity 0.2s ease;
}
.sb-cmd.idle {
  opacity: 0.6;
}
.sb-party {
  width: min(330px, 40%);
  display: flex;
  flex-direction: column;
  gap: 0;
}
.sb-member .bar {
  height: 9px;
  margin-top: 0;
}
.sb-member .bar span {
  font-size: 9px;
}
.sb-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 6px;
}
.sb-back {
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}
.sb-wait {
  font-style: italic;
  color: var(--ink-dim);
  min-height: 24px;
}
.sb-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.sb-menu .btn {
  min-height: 40px;
  padding: 0 10px;
  font-size: 13px;
}
.sb-list,
.sb-targets {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sb-skill {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 8px;
  text-align: left;
  padding: 8px 10px;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(233, 201, 130, 0.22);
  background: rgba(20, 15, 36, 0.7);
  color: var(--ink);
  cursor: pointer;
}
.sb-skill:disabled {
  opacity: 0.45;
}
.sb-skill b {
  font-family: var(--display);
  font-size: 14px;
}
.sb-skill .mp {
  color: #9cc2ff;
  font-size: 13px;
}
.sb-skill em {
  grid-column: 1 / -1;
  font-size: 13px;
  color: var(--ink-dim);
}
.sb-targets .btn {
  min-height: 44px;
  justify-content: space-between;
  display: flex;
  align-items: center;
}
.sb-targets small {
  color: var(--ink-dim);
  font-size: 12px;
}
.sb-forecast {
  font-size: 17px;
  line-height: 1.35;
  margin-bottom: 10px;
}
.sb-forecast b {
  color: var(--gold);
}
.sb-forecast .ko {
  color: #ffb4a8;
  font-style: italic;
}
.sb-note {
  font-size: 14px;
  color: #9cc2ff;
  font-style: italic;
}
.sb-menu.two {
  grid-template-columns: 1fr 1.4fr;
}
.sb-member {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) 1.15fr 0.6fr;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
}
.sb-member.on {
  border-color: var(--gold);
  background: rgba(233, 201, 130, 0.08);
}
.sb-member.ko {
  opacity: 0.45;
}
.sb-mname {
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--display);
  font-size: 12px;
}
.sb-row {
  font-family: var(--serif);
  font-size: 11px;
  font-style: italic;
  color: var(--ink-dim);
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}
.sb-row.def {
  color: #6fc3ff;
}
.ptab.dead img,
.dp.dead img {
  filter: grayscale(1) brightness(0.6);
}
.ptab.dead span,
.dp.dead .dp-name {
  color: #b8a8c8;
}
.pst.low b {
  color: #ff9a8a;
}
.pst b small {
  font-size: 11px;
  color: var(--ink-dim);
}
.sb-row.auto {
  color: #d8c8ff;
  background: rgba(180, 150, 255, 0.16);
  font-style: normal;
}
.sb-member.is-auto .sb-nm {
  color: #d8c8ff;
}
/* Threat: a warning in the forecast that a hit will pull a foe's aggro. */
.sb-note.threat {
  color: #ffb09a;
}
/* Threat: how many foes are after this hero. */
.sb-row.aggro {
  color: #ffb09a;
  background: rgba(255, 110, 80, 0.18);
  font-style: normal;
}
.sb-nm {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sb-mname .sb-row {
  flex: none;
}
.sb-row.aggro {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: none;
}
.sb-row.aggro svg {
  width: 13px;
  height: 9px;
}
.sb-row.aggro.tank {
  color: #ffd9a0;
  background: rgba(255, 180, 90, 0.16);
}
.sb-st {
  display: flex;
  gap: 3px;
  margin-left: auto;
}
.sb-st i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: 0 0 6px var(--c);
}
.sb-bars {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 6px;
}
.sb-bars .bar {
  height: 10px;
  margin-top: 3px;
}
.sb-bars .bar span {
  font-size: 10px;
}
@media (orientation: portrait) {
  .sb-bottom {
    flex-direction: column;
    align-items: stretch;
  }
  .sb-cmd,
  .sb-party {
    width: auto;
  }
  .sb-cmd {
    max-height: 34vh;
  }
  .sb-party {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 8px;
  }
  /* Narrow columns: the name and who's being watched matter more than the row. */
  .sb-mname .sb-row:not(.aggro) {
    display: none;
  }
  .sb-row.aggro {
    padding: 0 3px;
    gap: 1px;
  }
  .sb-member {
    grid-template-columns: minmax(0, 1.6fr) 1fr 0.55fr;
    gap: 4px;
    padding: 3px 6px;
  }
}
@media (max-height: 430px) and (orientation: landscape) {
  .sb-party {
    gap: 2px;
    padding: 6px 10px;
  }
  .sb-member {
    padding: 2px 6px;
  }
  .sb-cmd {
    max-height: 70vh;
  }
}
/* On a phone the place panel is kept small (owner, 2026-10-07: it covered a quarter of the
   screen): tighter padding, smaller type, shorter bars, the hint gone. */
@media (orientation: landscape) and (max-height: 500px), (orientation: portrait) and (max-width: 500px) {
  .wh-hint {
    display: none;
  }
  .wh-place {
    padding: 5px 10px;
    border-radius: 10px;
  }
  .wh-place .eyebrow {
    font-size: 10px;
  }
  .wh-name {
    font-size: 13px;
  }
  .wh-vitals {
    max-width: 150px;
    margin: 3px 0 1px;
    gap: 2px;
  }
  .wh-vital {
    width: 38px;
    height: 38px;
  }
  .wh-vital span {
    font-size: 12px;
    line-height: 36px;
  }
  .wh-vitals {
    gap: 8px;
    margin: 4px 0 10px;
  }
  .wh-quest {
    max-width: 180px;
    margin-top: 2px;
    font-size: 11px;
    line-height: 1.2;
  }
  .wh-quest i {
    font-size: 9px;
  }
}
@media (orientation: portrait) {
  .wh-hint {
    display: none;
  }
  .wh-name {
    font-size: 15px;
  }
  .wh-btns {
    gap: 6px;
  }
  .wh-btns .btn {
    padding: 0 12px;
    font-size: 13px;
  }
}

/* ---------- Map ---------- */
#minimap {
  position: absolute;
  right: calc(var(--safe-r) + 12px);
  bottom: calc(var(--safe-b) + 12px);
  width: 118px;
  height: 118px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--gold);
  background: rgba(20, 15, 36, 0.6);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), inset 0 0 0 1px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  z-index: 5;
}
#minimap canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}
#worldmap {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: radial-gradient(ellipse at 50% 45%, rgba(30, 20, 40, 0.88), rgba(8, 5, 20, 0.96));
}
#worldmap canvas {
  position: absolute;
  inset: calc(var(--safe-t) + 70px) calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 10px);
  width: calc(100% - var(--safe-l) - var(--safe-r) - 20px);
  height: calc(100% - var(--safe-t) - var(--safe-b) - 80px);
  cursor: crosshair;
}
.wm-head {
  position: absolute;
  top: calc(var(--safe-t) + 10px);
  left: calc(var(--safe-l) + 14px);
  right: calc(var(--safe-r) + 14px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.wm-hint {
  font-style: italic;
  font-size: 13px;
  color: var(--ink-dim);
}
@media (orientation: landscape) and (max-height: 500px) {
  #worldmap canvas {
    inset: calc(var(--safe-t) + 10px) calc(var(--safe-r) + 10px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 190px);
    width: calc(100% - var(--safe-l) - var(--safe-r) - 200px);
    height: calc(100% - var(--safe-t) - var(--safe-b) - 20px);
  }
  .wm-head {
    right: auto;
    width: 160px;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  #minimap {
    width: 104px;
    height: 104px;
  }
}

#update-toast {
  position: absolute;
  top: calc(var(--safe-t) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #f3d99a, #c9a24e);
  color: #2a1a08;
  font-family: var(--display);
  font-size: 13px;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.ow-bubble {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 220px;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(252, 246, 232, 0.95);
  color: #2a1e10;
  font-size: 16px;
  font-style: italic;
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: opacity 0.4s ease;
}
.ow-bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -7px;
  margin-left: -7px;
  border: 7px solid transparent;
  border-top-color: rgba(252, 246, 232, 0.95);
  border-bottom: 0;
}
.ow-bubble.out {
  opacity: 0;
}

/* The creator's live 3D model */
.cr-3d {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: calc(100% - 60px);
  touch-action: none;
}
.cr-facebtn {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 12px;
}
.cr-stage.has3d .cr-3d,
.cr-stage.has3d .cr-facebtn {
  display: block;
}
.cr-zoom {
  display: none;
  position: absolute;
  top: 56px;
  right: 8px;
  flex-direction: column;
  gap: 6px;
}
.cr-zoom .btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  font-size: 20px;
}
.cr-stage.has3d .cr-zoom {
  display: flex;
}
.cr-stage.has3d > canvas:not(.cr-3d) {
  visibility: hidden;
}

/* The character sheet's live 3D model */
.p-show {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: stretch;
}
.p-show .p-stats {
  flex: 1;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
  margin-top: 0;
  gap: 4px;
}
.p-show .p-stats {
  min-width: 0;
}
.p-show .pst {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px;
}
.p-show .pst b {
  font-size: 14px;
}
.p-stage {
  display: none;
  position: relative;
  flex: 0 0 75%;
  height: min(42vh, 300px);
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 30%, rgba(90, 60, 130, 0.45), rgba(10, 6, 22, 0.7));
  border: 1px solid rgba(233, 201, 130, 0.2);
  overflow: hidden;
}
.p-stage.has3d {
  display: block;
}
.p-3d {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
.p-facebtn {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}
.p-armbtn {
  position: absolute;
  top: 8px;
  left: 8px;
  min-height: 34px;
  padding: 0 12px;
  font-size: 12px;
}
.p-armbtn.on {
  border-color: rgba(233, 201, 130, 0.6);
  color: #ffd36b;
}
.p-armor {
  margin-top: 8px;
}

.sound-panel {
  position: absolute;
  z-index: 60;
  width: 220px;
  max-height: calc(100vh - var(--safe-t) - var(--safe-b) - 70px);
  overflow: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sound-panel label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--gold);
}
.sound-panel input[type='range'] {
  width: 100%;
  height: 32px;
  accent-color: #e9c982;
}

/* Hair colors apply to 3D looks only */
.hair3d {
  display: none;
}
.creator-card.has3d .hair3d {
  display: flex;
}
.creator-card.has3d .cr-label.hair3d {
  display: block;
}

.sp-mode button {
  flex: 1;
}
/* Real-time battle skills: a cooldown sweep over each button */
.rt-skills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
}
.rt-skill {
  position: relative;
  min-height: 46px;
  padding: 6px 8px;
  text-align: left;
  border-radius: 10px;
  border: 1px solid rgba(233, 201, 130, 0.3);
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.55) var(--cd), rgba(40, 30, 66, 0.9) var(--cd));
  color: var(--ink);
  cursor: pointer;
}
.rt-skill.on {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(233, 201, 130, 0.6);
}
.rt-skill:disabled {
  opacity: 0.55;
}
.rt-skill b {
  display: block;
  font-family: var(--display);
  font-size: 13px;
}
.rt-skill span {
  font-size: 12px;
  color: var(--ink-dim);
}
#sb.rt .sb-order .sb-chip {
  pointer-events: auto;
  cursor: pointer;
  padding: 0;
}
.sb-chip.ko {
  opacity: 0.35;
}

.sb-ebar.hero .bar > i {
  background: linear-gradient(90deg, #3fb88e, #7ff0bf);
}
#sb.rt .sb-ename {
  display: block;
  font-size: 10px;
}
#sb.rt .sb-ebar {
  width: 64px;
}

/* Real-time: health floats over each hero, so the party panel steps aside */
#sb.rt .sb-party {
  display: none;
}
#sb.rt .sb-bottom {
  justify-content: center;
}
#sb.rt .sb-cmd {
  width: fit-content;
  flex: none;
  max-width: 100%;
  padding: 6px;
  overflow: visible;
}
/* (On a phone held upright the thumb stick has the corner: the bar sits above it.) */
@media (pointer: coarse) and (orientation: portrait) {
  #sb.rt .sb-bottom {
    bottom: calc(var(--safe-b) + 142px);
  }
}
@media (pointer: coarse) and (orientation: landscape) {
  #sb.rt .sb-bottom {
    padding-left: 130px;
  }
}
/* The action bar: square buttons with their key, a cooldown sweep rising from below */
.rt-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 5px;
}
.rt-slot {
  position: relative;
  width: 58px;
  height: 54px;
  padding: 14px 2px 2px;
  border-radius: 8px;
  border: 1px solid rgba(233, 201, 130, 0.35);
  background: linear-gradient(0deg, rgba(0, 0, 0, 0.7) var(--cd, 0%), rgba(40, 30, 66, 0.92) var(--cd, 0%));
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
}
.rt-slot kbd {
  position: absolute;
  top: 2px;
  left: 5px;
  font: 10px var(--display);
  color: var(--gold);
}
.rt-slot b {
  display: block;
  font: 10.5px/1.05 var(--display);
}
.rt-slot span {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  color: #9fc4ff;
}
.rt-slot.on {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(233, 201, 130, 0.6);
}
.rt-slot:disabled {
  opacity: 0.5;
}
.rt-slot.rt-pause {
  padding-top: 2px;
  width: 62px;
}
.rt-cast {
  position: relative;
  height: 16px;
  margin-bottom: 5px;
  border-radius: 8px;
  border: 1px solid rgba(233, 201, 130, 0.4);
  background: rgba(0, 0, 0, 0.5);
  overflow: hidden;
  visibility: hidden;
}
.rt-cast.on {
  visibility: visible;
}
.rt-cast i,
.rt-frame .bar.cast i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #c9952e, #ffe6a8);
}
.rt-cast span {
  position: absolute;
  inset: 0;
  font: 11px/16px var(--display);
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}
/* You and your target, top left */
.rt-frames {
  position: absolute;
  top: calc(var(--safe-t) + 44px);
  left: calc(var(--safe-l) + 10px);
  display: flex;
  gap: 8px;
  pointer-events: none;
}
.rt-frame {
  display: flex;
  gap: 6px;
  align-items: center;
  width: auto;
  max-width: 260px;
  padding: 4px 8px;
  border-radius: 10px;
  border: 1px solid var(--panel-edge);
  background: rgba(20, 15, 36, 0.72);
}
.rt-frame.foe {
  border-color: rgba(255, 106, 90, 0.6);
}
.rt-frame.none {
  opacity: 0.6;
  min-height: 40px;
}
.rt-frame img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  object-fit: cover;
}
.rt-frame > div {
  flex: 1;
  min-width: 0;
}
.rt-frame b {
  display: block;
  font: 12px var(--display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rt-frame b i {
  font-size: 9px;
  font-style: normal;
}
.rt-frame small {
  font-size: 10px;
  color: var(--ink-dim);
}
.rt-frame .rings {
  display: flex;
  gap: 6px;
  margin-top: 2px;
}
/* (A circle with the number in it, the ring filled to the share left (owner, 2026-10-07): HP green,
   MP blue; the foe's cast is still a bar.) */
.rt-frame .bar {
  position: relative;
  width: 42px;
  height: 42px;
  margin-top: 0;
  border-radius: 50%;
  border: 1px solid rgba(233, 201, 130, 0.55);
  /* (An orb that fills from the bottom to the share left, the number in it: owner, 2026-10-07,
     "like Diablo style".) */
  background: linear-gradient(to top, var(--ring, #7ff0bf) calc(var(--p, 100) * 1%), rgba(0, 0, 0, 0.5) 0);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  flex: none;
}
.rt-frame .bar::before {
  content: '';
  position: absolute;
  left: 20%;
  top: 8%;
  width: 30%;
  height: 18%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}
.rt-frame .bar.hp {
  --ring: #2f9d72;
}
.rt-frame .bar.mp {
  --ring: #3b6fd0;
}
.rt-frame.foe .bar.hp {
  --ring: #b8402f;
}
/* (Underlined numbers in place of bars, to save space (owner, 2026-10-07): the number sits on a
   two-pixel line that shortens as it falls. The foe's cast is still a bar.) */
.rt-frame .bar i {
  display: none;
}
.rt-frame .bar.cast {
  width: auto;
  height: 12px;
  margin-top: 3px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  flex: 1;
}
.rt-frame .bar.cast::before {
  display: none;
}
.rt-frame .bar.cast i {
  display: block;
  height: 100%;
}
.rt-frame .bar.hp i {
  background: linear-gradient(90deg, #3fb88e, #7ff0bf);
}
.rt-frame.foe .bar.hp i {
  background: linear-gradient(90deg, #b8402f, #ff8a6a);
}
.rt-frame .bar.mp i {
  background: linear-gradient(90deg, #3b6fd0, #8fc0ff);
}
.rt-frame .bar span {
  position: absolute;
  inset: 0;
  transform: none;
  font: 13px/40px var(--display);
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}
.rt-frame .bar.hp span {
  color: #9ff5cf;
}
.rt-frame .bar.mp span {
  color: #a9ccff;
}
.rt-frame.foe .bar.hp span {
  color: #ffb09a;
}
.rt-frame .bar.cast span {
  inset: 0;
  font-size: 9px;
  line-height: 12px;
  text-align: center;
  color: #fff;
}
@media (max-width: 480px) {
  .rt-frame {
    width: 140px;
  }
  .rt-slot {
    width: 52px;
    height: 50px;
  }
}

.sb-view {
  position: absolute;
  top: calc(var(--safe-t) + 6px);
  right: calc(var(--safe-r) + 10px);
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
  pointer-events: auto;
}

.sb-status {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  gap: 3px;
  white-space: nowrap;
}
.sb-status span {
  font-family: var(--display);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
  background: color-mix(in srgb, var(--c) 45%, rgba(10, 8, 20, 0.8));
  border: 1px solid var(--c);
  box-shadow: 0 0 8px var(--c);
}

/* Short landscape phones: compact stats so they fit beside the figure. */
@media (max-height: 430px) and (orientation: landscape) {
  .p-show .pst {
    padding: 0 5px;
  }
  .p-show .pst b {
    font-size: 12px;
  }
}

/* ---------- Chapter I: tracker, waystones, journal ---------- */
.wh-btns {
  flex-wrap: wrap;
  justify-content: flex-end;
}
.wh-quest {
  display: block;
  max-width: 260px;
  margin-top: 4px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  pointer-events: auto;
}
.wh-quest i {
  display: block;
  font-family: var(--display);
  font-style: normal;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
}
#waystone-panel,
.wm-travel {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 16px);
  transform: translateX(-50%);
  width: min(360px, calc(100% - 150px));
  padding: 12px 16px;
  pointer-events: auto;
  z-index: 6;
  text-align: center;
}
.wm-travel {
  z-index: 45;
  width: min(340px, calc(100% - 32px));
}
.ws-name {
  font-family: var(--display);
  color: var(--gold);
  letter-spacing: 0.08em;
  font-size: 15px;
}
.ws-text {
  font-style: italic;
  font-size: 13px;
  color: var(--ink-dim);
  margin: 4px 0 10px;
}
.ws-btns {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}
@media (orientation: portrait) {
  .wh-quest {
    max-width: 170px;
    font-size: 12px;
  }
  #waystone-panel {
    width: calc(100% - 32px);
    bottom: calc(var(--safe-b) + 140px);
  }
}

#journal {
  align-items: stretch;
  background: radial-gradient(ellipse at 50% 40%, rgba(16, 10, 34, 0.6), rgba(8, 5, 20, 0.9));
}
.journal-card {
  width: min(760px, 100%);
  margin: auto;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 16px;
}
.jn-progress .bar {
  margin: 0;
}
.jn-pane {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 2px;
}
.jn-intro {
  margin: 0;
  font-style: italic;
  color: var(--ink-dim);
}
.jn-quest,
.jn-legend {
  flex: none;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(233, 201, 130, 0.14);
}
.jn-quest.done {
  opacity: 0.7;
}
.jn-legend {
  background: linear-gradient(135deg, rgba(60, 40, 90, 0.35), rgba(0, 0, 0, 0.3));
  border-style: dashed;
}
.jn-qhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.jn-qtitle {
  font-family: var(--display);
  color: var(--gold);
  font-size: 16px;
  letter-spacing: 0.05em;
}
.jn-tag {
  flex: none;
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(141, 255, 192, 0.14);
  color: #8dffc0;
}
.jn-tag.lock {
  background: rgba(179, 140, 255, 0.16);
  color: #cbb2ff;
}
.jn-giver {
  font-size: 12px;
  font-style: italic;
  color: var(--ink-dim);
}
.jn-summary {
  margin: 6px 0;
  line-height: 1.4;
}
.jn-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.jn-steps li {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.jn-steps li i {
  flex: none;
  width: 9px;
  height: 9px;
  border: 1px solid var(--gold);
  transform: rotate(45deg);
}
.jn-steps li.done {
  color: var(--ink-dim);
  text-decoration: line-through;
}
.jn-steps li.done i {
  background: var(--gold);
}
.jn-steps b {
  color: #ffd36b;
  margin-left: 4px;
}
.jn-empty {
  font-style: italic;
  color: var(--ink-dim);
}
.jn-road {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.jn-ch {
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid rgba(233, 201, 130, 0.35);
  background: rgba(233, 201, 130, 0.08);
}
.jn-ch.ahead {
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.3);
}
.jn-ch.more {
  text-align: center;
}
.jn-chname {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.jn-chtitle {
  font-family: var(--display);
  font-size: 16px;
  color: var(--gold);
}
.jn-ch.ahead .jn-chtitle {
  color: #b9a8d8;
}
.jn-chblurb {
  font-style: italic;
  font-size: 13px;
  color: var(--ink-dim);
}
@media (max-height: 430px) and (orientation: landscape) {
  .journal-card {
    padding: 10px 14px;
    gap: 8px;
  }
  .journal-card .party-head h2 {
    font-size: 18px;
  }
}

/* ---------- Chapter I: camp ---------- */
.sb-menu .btn.wide {
  grid-column: span 2;
}
#camp {
  align-items: stretch;
  background: radial-gradient(ellipse at 50% 70%, rgba(90, 40, 10, 0.55), rgba(8, 5, 20, 0.92));
}
.camp-card {
  width: min(900px, 100%);
  margin: auto;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px 16px;
}
.cp-note {
  font-style: italic;
  color: #ffd9a0;
  font-size: 14px;
}
.cp-body {
  overflow-y: auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  align-content: start;
}
.cp-body section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cp-talks {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cp-talk {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  min-height: 52px;
  border-radius: 12px;
  border: 1px solid rgba(255, 190, 100, 0.4);
  background: rgba(255, 160, 60, 0.1);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cp-talk img {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  object-fit: cover;
}
.cp-talk b {
  display: block;
  font-family: var(--display);
  color: var(--gold);
}
.cp-talk i {
  font-size: 13px;
  color: var(--ink-dim);
}
.cp-quiet,
.cp-meal {
  font-style: italic;
  color: var(--ink-dim);
  font-size: 14px;
}
.cp-meal b {
  color: #ffd36b;
  font-style: normal;
}
.cp-perks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cp-perk {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  color: var(--ink-dim);
}
.cp-perk.on {
  border: 1px solid rgba(141, 255, 192, 0.5);
  color: #8dffc0;
}
.cp-perk small {
  opacity: 0.75;
}
.cp-recipe {
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(233, 201, 130, 0.14);
}
.cp-recipe.locked {
  border-style: dashed;
  opacity: 0.7;
}
.cp-rhead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.cp-rhead b {
  font-family: var(--display);
  color: var(--gold);
  font-weight: 600;
}
.cp-rhead small {
  color: #ffd36b;
  margin-left: 4px;
}
.cp-rhead .btn {
  min-height: 36px;
  padding: 0 14px;
}
.cp-desc {
  font-size: 13px;
  margin: 4px 0;
  line-height: 1.35;
}
.cp-desc i {
  color: var(--ink-dim);
}
.cp-needs,
.cp-pantry {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.cp-need,
.cp-item {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 106, 61, 0.12);
  color: #ffb49a;
}
.cp-need.ok {
  background: rgba(141, 255, 192, 0.12);
  color: #8dffc0;
}
.cp-item {
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
}
.cp-item b {
  color: #ffd36b;
}
.cp-forage {
  float: right;
  min-height: 30px;
  padding: 0 10px;
  font-size: 11px;
}
@media (orientation: portrait) {
  .cp-body {
    grid-template-columns: 1fr;
  }
  .camp-card .hire-top {
    flex-direction: column;
    align-items: stretch;
  }
}
.p-perk b {
  color: #8dffc0;
  font-style: normal;
}
.sb-auto {
  position: absolute;
  top: calc(var(--safe-t) + 44px);
  right: calc(var(--safe-r) + 10px);
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
  pointer-events: auto;
}
.sb-auto.on {
  border-color: rgba(141, 255, 192, 0.6);
  color: #8dffc0;
}
.rt .sb-auto {
  display: none;
}

/* ---------- Chapter I: the reveal ---------- */
#reveal {
  position: absolute;
  inset: 0;
  z-index: 70;
  background: #140f1e;
  transition: opacity 0.5s ease;
}
#reveal.fade {
  opacity: 0;
  pointer-events: none;
}
.rv-map,
.rv-map canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.rv-title {
  position: absolute;
  top: calc(var(--safe-t) + 14px);
  left: 0;
  right: 0;
  text-align: center;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}
.rv-title h1 {
  margin: 2px 0;
  font-family: var(--display);
  color: var(--gold);
  font-size: clamp(22px, 5vw, 38px);
  letter-spacing: 0.06em;
}
.rv-sub {
  font-style: italic;
  font-size: 16px;
}
.rv-more {
  position: absolute;
  top: calc(var(--safe-t) + 12px);
  right: calc(var(--safe-r) + 12px);
  bottom: calc(var(--safe-b) + 12px);
  width: min(460px, 52%);
  padding: 14px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transform: translateX(24px);
  pointer-events: none;
  transition: opacity 0.8s ease, transform 0.8s ease;
}
.rv-open .rv-more {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.rv-chs,
.rv-paths,
.rv-faces {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rv-ch {
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px dashed rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.3);
}
.rv-ch b {
  font-family: var(--display);
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--ink-dim);
}
.rv-ch span {
  font-family: var(--display);
  color: #b9a8d8;
}
.rv-ch i,
.rv-legends {
  font-size: 13px;
  color: var(--ink-dim);
  font-style: italic;
}
.rv-pcls {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: baseline;
}
.rv-pcls > b {
  font-family: var(--display);
  color: var(--gold);
  width: 100%;
  font-size: 13px;
}
.rv-path {
  display: flex;
  flex-direction: column;
  padding: 4px 9px;
  border-radius: 10px;
  background: rgba(40, 30, 60, 0.6);
  border: 1px solid rgba(185, 168, 216, 0.25);
  filter: saturate(0.6);
}
.rv-path em {
  font-style: normal;
  font-family: var(--display);
  color: #cbb2ff;
  font-size: 13px;
}
.rv-path small {
  font-size: 11px;
  color: var(--ink-dim);
}
.rv-faces {
  flex-direction: row;
  flex-wrap: wrap;
}
.rv-face {
  flex: 1 1 45%;
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-dim);
  font-style: italic;
}
.rv-sil {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--display);
  color: #6e6488;
  background: radial-gradient(circle at 50% 35%, #2c2440, #120e1c);
  border: 1px dashed rgba(185, 168, 216, 0.3);
}
.rv-actions {
  display: flex;
  justify-content: center;
  margin-top: auto;
}
.rv-skip {
  position: absolute;
  bottom: calc(var(--safe-b) + 14px);
  left: calc(var(--safe-l) + 14px);
}
.rv-open .rv-skip {
  display: none;
}
@media (orientation: portrait) {
  .rv-more {
    top: auto;
    left: calc(var(--safe-l) + 12px);
    width: auto;
    height: 58%;
    transform: translateY(24px);
  }
}
.paths-ahead {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px dashed rgba(185, 168, 216, 0.25);
  background: rgba(20, 14, 34, 0.45);
}
.pa-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.pa-hint {
  margin-top: 6px;
  font-size: 12px;
  font-style: italic;
  color: var(--ink-dim);
}
.ptab.empty {
  opacity: 0.55;
  border-style: dashed;
  pointer-events: none;
  font-style: italic;
}
.ptab.empty .rv-sil {
  width: 26px;
  height: 26px;
  font-size: 12px;
}
.rv-title {
  padding: 6px 12px 22px;
  background: linear-gradient(rgba(16, 11, 26, 0.85), rgba(16, 11, 26, 0));
}
.rv-map {
  width: auto;
  height: auto;
  transition: right 0.8s ease, bottom 0.8s ease;
}
.rv-open .rv-map {
  right: min(480px, 54%);
}
@media (orientation: portrait) {
  .rv-open .rv-map {
    right: 0;
    bottom: 58%;
  }
  .rv-open .rv-title h1 {
    font-size: 22px;
  }
}
.rv-open .rv-title h1 {
  font-size: clamp(20px, 3.4vw, 28px);
}

/* ---------- Finishing moves ---------- */
.fin-flash {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 250, 230, 0.85), rgba(255, 240, 200, 0.2));
  animation: fin-flash 0.55s ease-out forwards;
}
.node.level {
  opacity: 0.55;
}
.node.level .nd-cost {
  color: var(--gold);
}
.fin-flash.soft {
  background: radial-gradient(ellipse at 50% 50%, rgba(255, 250, 230, 0.5), rgba(255, 240, 200, 0.08));
  animation-duration: 0.4s;
}
@keyframes fin-flash {
  from { opacity: 1; }
  to { opacity: 0; }
}
.pa-path {
  min-width: 128px;
}
.pa-path b {
  font-size: 12px;
  color: #8dffc0;
}
.pa-path.woke {
  filter: none;
  border-color: rgba(141, 255, 192, 0.55);
  background: rgba(40, 80, 60, 0.45);
}
.pa-path.woke em {
  color: #8dffc0;
}
.pa-path.sealed {
  opacity: 0.5;
}
.pa-seal {
  font-style: italic;
}
.pa-bar {
  display: block;
  height: 5px;
  margin: 4px 0 2px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}
.pa-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #9d8aff, #cbb2ff);
}
.cp-forges {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cp-forge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 5px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  font-family: var(--display);
  font-size: 13px;
}
.cp-forge small {
  display: block;
  font-family: var(--body, inherit);
  color: var(--ink-dim);
}
.cp-forge small b {
  color: #ffd36b;
  font-weight: 600;
}
.cp-forge .btn {
  min-height: 34px;
  padding: 0 12px;
}
.cp-gold {
  float: right;
  color: #ffd36b;
  letter-spacing: 0.05em;
}
.ow-label.stone {
  font-size: 10px;
  color: #bcd2ff;
  border-color: rgba(159, 196, 255, 0.35);
}
.cine .sb-bottom,
.cine .sb-order,
.cine .sb-view,
.cine .sb-auto {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.sb-bottom,
.sb-order {
  transition: opacity 0.35s ease;
}
#worldmap canvas {
  touch-action: none;
}
.wm-zoom {
  position: absolute;
  right: calc(var(--safe-r) + 16px);
  bottom: calc(var(--safe-b) + 16px);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2;
}
.wm-zoom .btn {
  width: 46px;
  min-height: 46px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}
.ow-label small {
  font-size: 10px;
  color: #9ff3ff;
  margin-left: 4px;
  letter-spacing: 0.08em;
}
.ow-label small {
  font-size: 10px;
  color: #9ff3ff;
  margin-left: 4px;
  letter-spacing: 0.08em;
}
.tr-lv,
.jn-lv {
  font-family: var(--display);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #9ff3ff;
  font-weight: 600;
}
.sb-skill .quick {
  font-style: normal;
  font-size: 11px;
  color: #8dffc0;
  margin-left: 4px;
}

/* ---------- Guided tours ---------- */
#coach {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}
.co-spot {
  position: fixed;
  border-radius: 14px;
  border: 2px solid #ffd36b;
  box-shadow: 0 0 0 9999px rgba(8, 5, 20, 0.55), 0 0 18px rgba(255, 211, 107, 0.6);
  pointer-events: none;
  transition: left 0.25s ease, top 0.25s ease, width 0.25s ease, height 0.25s ease;
  animation: co-pulse 1.6s ease-in-out infinite;
}
@keyframes co-pulse {
  50% { box-shadow: 0 0 0 9999px rgba(8, 5, 20, 0.55), 0 0 28px rgba(255, 211, 107, 0.95); }
}
.co-note {
  position: fixed;
  width: min(320px, calc(100vw - 24px));
  padding: 12px 14px;
  pointer-events: auto;
  font-size: 15px;
  line-height: 1.4;
}
.co-note b {
  color: #ffd36b;
}
.co-btns {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}
.co-btns .btn {
  min-height: 38px;
  padding: 0 14px;
}
#btn-world-party {
  position: relative;
}
#btn-world-party .spdot {
  position: absolute;
  top: -6px;
  right: -6px;
}

.icon-btn.muted {
  opacity: 0.55;
}

/* ---------- Shop ---------- */
.rc.item {
  grid-template-columns: 1fr auto;
}
.shop-tabs {
  margin: 4px 0 8px;
  max-width: 260px;
}
#shop {
  z-index: 80;
}

/* ---------- Creator: alignment ---------- */
.cr-align {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.cr-align .cr-race {
  padding-left: 6px;
  padding-right: 6px;
}

/* The sundial beside the time of day */
#wh-time .dial {
  width: 30px;
  height: 19px;
  vertical-align: -4px;
  margin-right: 6px;
}

/* ---------- The world menu (one button, a drop-down) ---------- */
.wh-btns {
  position: relative;
}
#btn-menu {
  font-size: 20px;
}
.world-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  min-width: 170px;
  z-index: 30;
}
.world-menu.hidden {
  display: none;
}
.world-menu .btn {
  width: 100%;
  min-height: 44px;
  position: relative;
}
#btn-menu {
  position: relative;
}

/* ---------- The thumb stick (touch devices): faint until touched ---------- */
#stick {
  position: absolute;
  left: calc(var(--safe-l, 0px) + 18px);
  bottom: calc(var(--safe-b, 0px) + 18px);
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 1px solid rgba(233, 201, 130, 0.5);
  background: rgba(20, 15, 36, 0.35);
  opacity: 0.28;
  transition: opacity 0.25s ease;
  touch-action: none;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
}
#stick.on {
  opacity: 0.8;
}
#stick i {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(233, 201, 130, 0.55);
  border: 1px solid rgba(255, 240, 200, 0.7);
}

/* A hero fighting on their own: a clear, tappable badge on their row */
.sb-member .sb-row.auto {
  background: #d9a441;
  color: #1a1226;
  border-radius: 6px;
  padding: 1px 7px;
  font-weight: 700;
  letter-spacing: 0.08em;
}
.sb-member.is-auto {
  outline: 1px solid rgba(217, 164, 65, 0.7);
}

/* ---------- Shop: compare ---------- */
.rc.item {
  grid-template-columns: 1fr auto auto;
}
.cmp {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid rgba(233, 201, 130, 0.2);
  display: grid;
  gap: 3px;
  font-size: 14px;
}
.cmp-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  align-items: baseline;
}
.cmp-row.off {
  opacity: 0.5;
}
.cmp-row span {
  color: var(--ink-dim);
}
.cmp em {
  font-style: normal;
  font-weight: 700;
}
.cmp em.up {
  color: #8fe08a;
}
.cmp em.down {
  color: #ff8a7a;
}
@media (max-width: 520px) {
  .rc.item {
    grid-template-columns: 1fr auto;
  }
  .rc.item .rc-info {
    grid-column: 1 / -1;
  }
}

.rc.item,
.rc.item .rc-info {
  grid-template-columns: 1fr auto;
  grid-column: auto;
}
.rc-acts {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cmp-btn {
  min-width: 44px;
  padding: 0;
  font-size: 20px;
}
.cmp-btn.on {
  border-color: #d9a441;
  color: #ffd36b;
}
@media (max-width: 520px) {
  .rc.item {
    grid-template-columns: 1fr;
  }
  .rc-acts .btn:last-child {
    flex: 1;
  }
}

#wh-time .cal {
  display: block;
  margin-top: 2px;
  opacity: 0.8;
  letter-spacing: 0.14em;
}

/* Things that can be tapped carry a gold diamond */
.ow-label.npc::before,
.ow-label.stone::before {
  content: '\25C6';
  color: #ffd36b;
  margin-right: 6px;
  font-size: 0.8em;
}
.ow-label.npc,
.ow-label.stone {
  pointer-events: none;
}

/* ---------- Taking gear off and on (swimming) ---------- */
#gear-meter {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-b, 0px) + 96px);
  transform: translateX(-50%);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid rgba(233, 201, 130, 0.45);
  background: rgba(20, 15, 36, 0.82);
  font-family: var(--display);
  letter-spacing: 0.08em;
  color: #f0dca8;
  z-index: 12;
}
#gear-meter.on {
  display: flex;
}
#gear-meter i {
  display: block;
  width: 180px;
  height: 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}
#gear-meter b {
  display: block;
  height: 100%;
  width: 0;
  background: #d9a441;
}

/* Frames per second (settings: Frame rate: Shown) */
#fps {
  position: fixed;
  left: calc(var(--safe-l, 0px) + 8px);
  bottom: calc(var(--safe-b, 0px) + 4px);
  font: 600 12px/1 ui-monospace, monospace;
  color: #9ff39f;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
  z-index: 300;
}

/* The store's cards: a picture of the piece at the left (its own model, or a glyph). */
.rc.item .rc-pic {
  float: left;
  margin: 2px 14px 6px 0;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  border: 1px solid rgba(214, 178, 106, 0.35);
  background: radial-gradient(circle at 50% 40%, rgba(255, 236, 190, 0.16), rgba(20, 14, 30, 0.55)) center / contain no-repeat;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  background-color: rgba(20, 14, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: rgba(232, 205, 150, 0.7);
}
.cmp-btn {
  width: auto;
  min-width: 44px;
  padding: 0 12px;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.rc.item .rc-info {
  display: block;
}
.rc.item .cmp {
  clear: both;
}

/* The journal: each quest's dot, the same color as the one beside its people in the world. */
.jn-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 9px;
  border-radius: 50%;
  border: 2px solid rgba(20, 14, 30, 0.9);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18);
  color: #2a1c0a;
  font: 700 12px Georgia, serif;
  vertical-align: -2px;
}

/* The place panel at the top left lets taps through to the world behind it (someone may be
   standing there); only its quest line is a button. */
#world-hud .wh-place {
  pointer-events: none;
}
#world-hud .wh-place .wh-quest {
  pointer-events: auto;
}

/* The notice board's and the inventory's screens: laid out like the store's. */
#board,
#inventory,
#build,
#saves {
  align-items: stretch;
  background: radial-gradient(ellipse at 50% 40%, rgba(16, 10, 34, 0.6), rgba(8, 5, 20, 0.9));
  z-index: 80;
}

/* Someone the mouse is over, who can be spoken to: their name brightens. */
.ow-label.npc.hot {
  background: rgba(60, 42, 14, 0.9);
  border-color: #ffd36b;
  color: #fff3c8;
  box-shadow: 0 0 14px rgba(255, 211, 107, 0.55);
}

/* The settings panel never runs off the screen: it is as tall as there is room for, and
   scrolls inside itself (a short landscape phone can't show it all at once). */
.sound-panel {
  max-height: calc(100dvh - var(--safe-t) - var(--safe-b) - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Equipment: the slots stand round the figure (Party screen, Equipment tab) */
.p-show.doll {
  flex-direction: column-reverse;
}
.p-show.doll .p-stats {
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: auto;
}
.p-show.doll .p-stage {
  display: block;
  flex: none;
  height: max(296px, min(46vh, 340px));
}
.p-show.doll .p-facebtn,
.p-show.doll .p-armbtn {
  display: none;
}
.doll-pic {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  transform: translate(-50%, -50%);
  border-radius: 12px;
  opacity: 0.9;
}
.doll-col {
  position: absolute;
  display: flex;
  gap: 5px;
  pointer-events: none;
}
.doll-col.l,
.doll-col.r {
  top: 6px;
  bottom: 6px;
  flex-direction: column;
  justify-content: space-between;
}
.doll-col.l {
  left: 6px;
}
.doll-col.r {
  right: 6px;
  justify-content: flex-start;
  gap: 12px;
  top: 34px;
}
.doll-col.b {
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
}
.doll-slot {
  pointer-events: auto;
  position: relative;
  flex: none;
  width: 54px;
  height: 54px;
  padding: 0;
  border-radius: 9px;
  border: 1px solid rgba(233, 201, 130, 0.45);
  background: rgba(12, 8, 26, 0.78);
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
}
.doll-slot i {
  display: block;
  height: 36px;
  font: normal 20px/36px serif;
  color: rgba(233, 201, 130, 0.75);
  background: center / contain no-repeat;
}
.doll-slot small {
  display: block;
  padding: 0 2px;
  font: 8.5px/1 var(--display);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink-dim);
}
.doll-slot .doll-tag {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 2px 0 1px;
  font: 7.5px/1 var(--display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-align: center;
  color: var(--gold);
  background: rgba(12, 8, 26, 0.82);
  z-index: 1;
}
.doll-slot.full small {
  color: var(--ink);
}
.doll-slot.on {
  box-shadow: 0 0 0 2px var(--gold), 0 0 12px rgba(233, 201, 130, 0.7);
}
.doll-slot.sealed {
  border-style: dashed;
  border-color: rgba(233, 201, 130, 0.2);
  opacity: 0.55;
}
.doll-slot.untrained::after {
  content: '!';
  position: absolute;
  top: 1px;
  right: 4px;
  font: 12px var(--display);
  color: #ff9a7a;
}
.cand.untrained {
  border-style: dashed;
}
.cd-off {
  color: #ff9a7a;
}
.training {
  margin-top: 14px;
}
.train-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.train {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  min-height: 44px;
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid rgba(233, 201, 130, 0.18);
  background: rgba(20, 15, 36, 0.6);
}
.train b {
  font: 12px var(--display);
}
.train.has small {
  color: #7ff0bf;
}
.train .btn {
  min-height: 36px;
  padding: 0 8px;
  font-size: 11px;
}

@media (orientation: portrait) {
  #sb.rt .rt-frames {
    top: calc(var(--safe-t) + 56px);
  }
  #sb.rt .sb-view {
    top: calc(var(--safe-t) + 118px);
  }
}

/* A skill that would break the spell your target is casting */
.rt-slot.react {
  border-color: #ffd36b;
  animation: rt-react 0.5s ease-in-out infinite alternate;
}
@keyframes rt-react {
  from { box-shadow: 0 0 4px rgba(255, 211, 107, 0.5); }
  to { box-shadow: 0 0 16px rgba(255, 211, 107, 1); }
}

/* Health and magic, large: over the action bar in a real-time fight, and under the place
   name on the road */
.rt-vitals {
  display: flex;
  gap: 5px;
  margin-bottom: 5px;
}
.rt-vital,
.wh-vital {
  position: relative;
  flex: none;
  width: 48px;
  height: 48px;
  min-width: 0;
  border-radius: 50%;
  border: 1px solid rgba(233, 201, 130, 0.55);
  background: linear-gradient(to top, var(--ring, #2f9d72) calc(var(--p, 100) * 1%), rgba(0, 0, 0, 0.5) 0);
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.6);
  overflow: visible;
}
.wh-vital::before {
  content: '';
  position: absolute;
  left: 20%;
  top: 8%;
  width: 30%;
  height: 18%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}
.wh-vital.hp {
  --ring: #2f9d72;
}
.wh-vital.mp {
  --ring: #3b6fd0;
}
.wh-vital.hp.low {
  --ring: #b8402f;
}
.wh-vital em {
  position: absolute;
  left: 0;
  right: 0;
  top: 100%;
  font: 8px var(--display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  color: var(--ink-dim);
}
.rt-vital i,
.wh-vital i {
  display: block;
  height: 100%;
  transition: width 0.25s ease;
}
.wh-vital i {
  display: none;
}
.rt-vital.hp i,
.wh-vital.hp i {
  background: linear-gradient(90deg, #2f9d72, #7ff0bf);
}
.rt-vital.mp i,
.wh-vital.mp i {
  background: linear-gradient(90deg, #3b6fd0, #8fc0ff);
}
.rt-vital.hp.low i,
.wh-vital.hp.low i {
  background: linear-gradient(90deg, #b8402f, #ff8a6a);
}
.rt-vital.hp.low {
  animation: rt-react 0.5s ease-in-out infinite alternate;
}
.rt-vital span,
.wh-vital span {
  position: absolute;
  inset: 0;
  font: 11px/17px var(--display);
  letter-spacing: 0.04em;
  text-align: center;
  color: #fff;
  text-shadow: 0 1px 2px #000;
}
.wh-vital span {
  inset: 0;
  line-height: 46px;
  text-align: center;
  font-size: 14px;
}
.wh-vital.hp span {
  color: #9ff5cf;
}
.wh-vital.mp span {
  color: #a9ccff;
}
.wh-vital.hp.low span {
  color: #ffb09a;
}
.wh-vitals {
  display: flex;
  flex-direction: row;
  gap: 10px;
  margin: 5px 0 12px;
  max-width: 220px;
}
/* One set of bars in a fight, at the top: your frame's, large enough to read at a glance */
.rt-frame.me {
  width: auto;
}
/* (Status chips under the orbs: the sign, the name, the seconds left; debuffs in red.) */
.rt-st {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 3px;
  max-width: 240px;
}
.rt-st em {
  font: 10px var(--display);
  font-style: normal;
  letter-spacing: 0.03em;
  padding: 1px 5px;
  border-radius: 8px;
  border: 1px solid var(--c, #fff);
  color: var(--c, #fff);
  background: rgba(0, 0, 0, 0.45);
  white-space: nowrap;
}
.rt-st em.bad {
  border-style: dashed;
}
.rt-frame .rt-side {
  flex: 1;
  min-width: 60px;
  align-self: center;
}
.rt-frame .rt-after {
  display: block;
}
/* The wheel on a phone (see `layoutWheel`): the bar's card becomes a point at the bottom right, each
   button set out from it by its angle and radius; Attack is the hub. */
#sb.wheel .sb-cmd {
  position: fixed;
  left: auto;
  top: auto;
  right: calc(var(--safe-r) + 54px);
  bottom: calc(var(--safe-b) + 54px);
  width: 0;
  height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  overflow: visible;
}
#sb.wheel .rt-cast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 16px);
  transform: translateX(-50%);
  width: 220px;
}
#sb.wheel .rt-bar {
  display: block;
  width: 0;
  height: 0;
}
#sb.wheel .rt-bar > .rt-slot {
  position: absolute;
  left: 0;
  top: 0;
  width: 52px;
  height: 52px;
  padding: 0 3px;
  border-radius: 50%;
  transform: translate(calc(cos(var(--a, 0deg)) * var(--r, 0px) - 50%), calc(sin(var(--a, 0deg)) * var(--r, 0px) * -1 - 50%));
  font-size: 10px;
  line-height: 1.05;
}
#sb.wheel .rt-bar > .rt-slot kbd {
  display: none;
}
#sb.wheel .rt-bar > .rt-slot b {
  font-size: 10px;
}
#sb.wheel .rt-bar > .rt-slot span {
  position: static;
  display: block;
  font-size: 9px;
}
#sb.wheel .rt-bar > .rt-slot.hub {
  width: 78px;
  height: 78px;
  font-size: 13px;
  border-width: 2px;
}
#sb.wheel .rt-bar > .rt-slot.hub b {
  font-size: 13px;
}
#sb.wheel .rt-bar > .rt-slot.outer {
  width: 42px;
  height: 42px;
  opacity: 0.9;
}
#sb.wheel .rt-bar > .rt-slot.outer b {
  font-size: 8px;
}
#sb.wheel .rt-bar > .rt-slot.outer span {
  font-size: 8px;
}
.rt-frame.me .bar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(233, 201, 130, 0.55);
}
.rt-frame.me .bar span {
  font: 14px/42px var(--display);
}
.rt-frame.me .bar.hp.low i {
  background: linear-gradient(90deg, #b8402f, #ff8a6a);
}
@media (max-width: 480px) {
  .rt-frame.me {
    width: 190px;
  }
}

/* The bar's own buttons (Pause, Speed, Foe unhurt) show what they are set to */
.rt-slot.rt-pause span {
  position: static;
  display: block;
  font-size: 11px;
  color: var(--gold);
}

.sb-cmd.many .rt-bar {
  gap: 3px;
}
.sb-cmd.many .rt-slot {
  width: 49px;
  height: 46px;
  padding-top: 13px;
}
.sb-cmd.many .rt-slot b {
  font-size: 8.5px;
}
.sb-cmd.many .rt-slot span {
  font-size: 8.5px;
}
.sb-cmd.many .rt-slot.rt-pause {
  width: 50px;
  padding-top: 2px;
}

/* The tuning panel (test mode): a slider for each number of a move */
/* The action bar on the road (the same buttons as in a fight). Dim with no one to fight near. */
.load-sheet {
  position: fixed;
  z-index: 120;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 24px));
  max-height: calc(100% - var(--safe-t) - var(--safe-b) - 24px);
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  background: rgba(20, 15, 36, 0.96);
}
.load-sheet .ls-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  color: var(--gold);
}
.load-sheet .ls-sent {
  flex: 1;
  font-size: 12px;
  color: #d8d4e8;
}
.load-sheet .load-report {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 6px 0 0;
  font: 11px/1.3 ui-monospace, Menlo, monospace;
  color: #d8d4e8;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}
#skill-tip {
  position: fixed;
  z-index: 40;
  padding: 10px 12px;
  background: rgba(20, 15, 36, 0.94);
  pointer-events: none;
}
#skill-tip h3 {
  margin: 0 0 4px;
  font: 15px var(--display);
  color: var(--gold);
}
#skill-tip p {
  margin: 0 0 6px;
  font-size: 15px;
  line-height: 1.25;
}
#skill-tip ul {
  margin: 0;
  padding-left: 16px;
  font-size: 14px;
  color: #d8d4e8;
}
#world-bar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 10px);
  transform: translateX(-50%);
  max-width: calc(100% - 20px);
  padding: 6px;
  background: rgba(20, 15, 36, 0.62);
  opacity: 0.45;
  transition: opacity 0.3s;
  z-index: 6;
}
#world-bar.ready {
  opacity: 1;
}
#world-bar .wb-target {
  min-height: 0;
  text-align: center;
  font: 12px var(--display);
  color: #ff9a7a;
}
#world-bar.ready .wb-target {
  padding-bottom: 4px;
}
#world-bar.nudge {
  animation: wb-nudge 0.25s;
}
@keyframes wb-nudge {
  30% { transform: translateX(calc(-50% - 5px)); }
  70% { transform: translateX(calc(-50% + 5px)); }
}
@media (pointer: coarse) and (orientation: portrait) {
  #world-bar {
    bottom: calc(var(--safe-b) + 142px);
  }
}
@media (pointer: coarse) and (orientation: landscape) {
  #world-bar {
    left: calc(50% + 65px);
    max-width: calc(100% - 150px);
  }
}
/* What a road fight won, told in passing (no results screen). */
#spoils {
  position: fixed;
  /* (Below the place and health panel, which it overlapped.) */
  top: calc(var(--safe-t) + 182px);
  left: 50%;
  transform: translate(-50%, -8px);
  max-width: min(520px, 86vw);
  padding: 8px 16px;
  border: 1px solid rgba(231, 198, 107, 0.6);
  border-radius: 12px;
  background: rgba(20, 15, 36, 0.88);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s, transform 0.5s;
  z-index: 30;
}
#spoils.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
/* (On a wide screen it sits top right, beside the menu button: in the middle it covered her.) */
@media (orientation: landscape) {
  #spoils {
    top: calc(var(--safe-t) + 10px);
    left: auto;
    right: calc(var(--safe-r) + 74px);
    max-width: min(420px, 44vw);
    transform: translate(0, -8px);
  }
  #spoils.show {
    transform: translate(0, 0);
  }
}
#spoils b {
  display: block;
  font-family: Cinzel, serif;
  font-size: 15px;
  color: #e7c66b;
}
#spoils span {
  display: block;
  font-size: 14px;
}
#spoils i {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  color: #8dffc0;
}
/* The phase of the move in hand, in test mode (top right, under the view buttons). */
.rt-phase {
  position: absolute;
  top: calc(var(--safe-t) + 118px);
  right: calc(var(--safe-r) + 10px);
  max-width: min(300px, 46vw);
  padding: 6px 10px;
  border: 1px solid rgba(231, 198, 107, 0.55);
  border-radius: 10px;
  background: rgba(20, 15, 36, 0.86);
  text-align: right;
  pointer-events: none;
}
.rt-phase b {
  display: block;
  font-family: Cinzel, serif;
  font-size: 14px;
  color: #e7c66b;
}
.rt-phase span {
  font-size: 12px;
  opacity: 0.8;
}
.rt-tune {
  position: absolute;
  top: calc(var(--safe-t) + 150px);
  /* (On the left, by the owner's wish, 2026-10-06: the right side is where she stands.) */
  left: calc(var(--safe-l) + 10px);
  width: min(300px, 46vw);
  max-height: calc(100% - var(--safe-t) - 300px);
  min-height: 120px;
  overflow-y: auto;
  padding: 8px 10px;
  background: rgba(20, 15, 36, 0.86);
  pointer-events: auto;
  font-size: 12px;
}
.rt-tune-head,
.rt-tune-foot {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  margin: 2px 0 6px;
}
.rt-tune select {
  flex: 1;
  min-height: 32px;
  background: #1c1530;
  color: var(--ink);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  font: 13px var(--display);
}
.rt-tune .btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 11px;
}
.rt-tune label {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 0 6px;
  align-items: center;
  margin: 3px 0;
  color: var(--ink-dim);
}
.rt-tune label span {
  grid-column: 1 / -1;
}
.rt-tune label b {
  text-align: right;
  color: var(--ink);
  font-weight: normal;
}
.rt-tune label.changed span,
.rt-tune label.changed b {
  color: var(--gold);
}
.rt-tune input[type='range'] {
  width: 100%;
}
.rt-tune textarea {
  width: 100%;
  height: 70px;
  margin-top: 6px;
  background: #120d20;
  color: var(--ink);
  border: 1px solid var(--panel-edge);
  border-radius: 8px;
  font: 11px monospace;
}

/* (Compact: name, slider and value on one line; the panel as tall as the screen allows.) */
.rt-tune {
  top: calc(var(--safe-t) + 52px);
  width: min(380px, 52vw);
  max-height: calc(100% - var(--safe-t) - 150px);
  font-size: 11px;
}
.rt-tune label {
  grid-template-columns: 42% 1fr 36px;
  margin: 1px 0;
}
.rt-tune label span {
  grid-column: auto;
}
.sb-cmd.many .rt-slot {
  width: 46px;
}
.sb-cmd.many .rt-slot.rt-pause {
  width: 46px;
}
.sb-cmd.many .rt-slot.rt-pause b {
  font-size: 8px;
}

/* The fight's own Settings button, under View */
.sb-settings {
  top: calc(var(--safe-t) + 46px);
}
@media (orientation: portrait) {
  #sb.rt .sb-settings {
    top: calc(var(--safe-t) + 158px);
  }
}

/* Real-time: damage numbers pop, and are thrown up and out to a side */
.sb-float.out {
  animation: sb-out 1.25s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
  -webkit-text-stroke: 1px rgba(0, 0, 0, 0.55);
}
/* (With `translate` and `scale`, not `transform`: the float's place on screen is its transform.) */
@keyframes sb-out {
  0% {
    opacity: 0;
    translate: 0 6px;
    scale: 0.5;
  }
  12% {
    opacity: 1;
    translate: calc(var(--dx) * 0.35) -14px;
    scale: 1.35;
  }
  30% {
    translate: calc(var(--dx) * 0.7) -30px;
    scale: 1;
  }
  75% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    translate: var(--dx) -58px;
    scale: 0.95;
  }
}
/* Effects over a foe: larger, with the seconds left */
#sb.rt .sb-status span {
  font-size: 12px;
  padding: 2px 8px;
}
#sb.rt .sb-status span b {
  font-weight: normal;
  opacity: 0.8;
}
/* The Tune card's two lists (what is tuned, which part of it) share the row and may wrap. */
.rt-tune-head {
  flex-wrap: wrap;
}
.rt-tune-head select {
  flex: 1 1 40%;
  min-width: 0;
}

/* Real time (owner, 2026-10-06): your frame top left, the foe's top right; Settings is a gear
   on the bar, not a button in the corner; no top strip for one hero alone. */
#sb.rt .rt-frames {
  right: calc(var(--safe-r) + 10px);
  justify-content: space-between;
}
#sb.rt.alone .rt-frames {
  top: calc(var(--safe-t) + 8px);
}
#sb.rt .sb-settings {
  display: none;
}
.rt-slot.rt-gear {
  font-size: 22px;
  line-height: 1;
}
#sb.rt .rt-phase {
  top: calc(var(--safe-t) + 96px);
}

/* The move workshop in the Tune card: a move's steps as buttons, and Play / Let go. */
.rt-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 4px;
}
.rt-steps .btn {
  flex: 1 1 auto;
  min-height: 28px;
  padding: 0 8px;
  font-size: 10px;
}
.rt-steps .btn.on {
  border-color: var(--gold);
  color: var(--gold);
}
.rt-step-hint {
  font: italic 11px var(--body);
  opacity: 0.8;
  margin: 0 0 4px;
}

/* The account on the title screen. */
#acct { margin-top: 14px; font: 15px var(--body, 'Cormorant Garamond', serif); color: var(--ink-dim); }
#acct .acct-line { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
#acct .acct-line b { color: var(--gold); font-weight: 600; }
#acct .btn { min-height: 44px; }
/* (A panel over the title, in the middle of the screen: below the buttons it fell off a phone held sideways.) */
#acct .acct-form { position: fixed; z-index: 50; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(360px, calc(100vw - 32px)); max-height: calc(100dvh - 24px); overflow: auto; display: grid; gap: 8px; padding: 14px 16px; text-align: left; }
#acct label { display: grid; gap: 4px; color: var(--ink-dim); font-size: 14px; }
#acct input:not([type='checkbox']) { min-height: 44px; padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(233, 201, 130, 0.45); background: rgba(12, 8, 26, 0.78); color: var(--ink); font: 17px var(--body, 'Cormorant Garamond', serif); }
#acct .acct-keep { display: flex; gap: 8px; align-items: center; }
#acct .acct-msg { min-height: 18px; color: #ffb09a; font-size: 14px; }
#acct .acct-btns { display: flex; gap: 8px; flex-wrap: wrap; }

/* A duel asked, awaited or offered: a line at the top of the road. */
#duel { position: fixed; z-index: 30; left: 50%; top: calc(env(safe-area-inset-top, 0px) + 10px); transform: translateX(-50%); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 24px); padding: 8px 12px; border-radius: 12px; border: 1px solid rgba(233, 201, 130, 0.45); background: rgba(20, 15, 36, 0.86); color: var(--ink); font: 16px var(--body, 'Cormorant Garamond', serif); }
#duel b { color: var(--gold); }
#duel .btn { min-height: 44px; }

/* In a duel the bar has only what both players share: no pause, speed, test mode or its tools. */
body.dueling [data-act='pause'], body.dueling [data-act='rtspeed'], body.dueling [data-act='rttest'], body.dueling [data-act='rtfoes'], body.dueling [data-act='rtforce'], body.dueling [data-act='rtclass'], body.dueling [data-act='rtkit'], body.dueling [data-act='rtmelee'], body.dueling [data-act='rttune'] { display: none !important; }

/* A company of players (main.js "Travelling together"): who travels with you, under the health panel. */
#group { position: fixed; z-index: 29; left: calc(env(safe-area-inset-left, 0px) + 10px); top: calc(env(safe-area-inset-top, 0px) + 118px); display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 6px 10px; border-radius: 10px; border: 1px solid rgba(233, 201, 130, 0.35); background: rgba(20, 15, 36, 0.78); color: var(--ink); font: 15px var(--body, 'Cormorant Garamond', serif); }
#group span::before { content: '\25C6'; color: var(--gold); margin-right: 6px; font-size: 10px; }
#group .btn { min-height: 44px; padding: 0 12px; }
#duel .btn + .btn { margin-left: 0; }
/* How a companion has been told to fight, under their portrait in a real-time fight. */
#sb.rt .sb-order .sb-chip small { position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%); white-space: nowrap; font: 11px var(--body, 'Cormorant Garamond', serif); color: var(--gold); text-shadow: 0 1px 2px #000; pointer-events: none; }
#sb.rt .sb-order .sb-chip { position: relative; overflow: visible; }
#sb.rt .sb-order .sb-chip img { border-radius: 50%; }

/* A companion's call-out (realtime.js `callOut`): the callout strip, but small and in a speaking voice. */
.sb-callout.say { font: italic 17px var(--body, 'Cormorant Garamond', serif); letter-spacing: 0; text-transform: none; padding: 6px 14px; max-width: min(70vw, 460px); }
#sb.rt .sb-order .sb-chip small { font-size: 10px; max-width: 40px; overflow: hidden; text-overflow: clip; }
/* (Spoken lines sit low, like subtitles: clear of the foes' labels at the top. On a phone's wheel, at the foot.) */
.sb-callout.say { top: auto; bottom: calc(var(--safe-b, 0px) + 112px); white-space: normal; text-align: center; }
#sb.wheel .sb-callout.say { bottom: calc(var(--safe-b, 0px) + 14px); max-width: 46vw; }

/* A quick order to the company that is on (realtime.js `setCompany`). */
.rt-slot.rt-ord.on { border-color: var(--gold); box-shadow: 0 0 10px rgba(233, 201, 130, 0.55) inset; }
.rt-slot.rt-ord.on b { color: var(--gold); }

/* Who travels with the captain (party.js): one waiting at camp is shown dimmed among the tabs. */
.ptab.camp img { filter: grayscale(0.7) brightness(0.7); }
.ptab.camp span::after { content: ' \00b7 camp'; color: var(--muted, #9a94b0); font-size: 0.8em; }
.p-travel { margin-bottom: 10px; }
.p-full { margin: 6px 0 0; color: #ffb0a0; font-style: italic; }
#sb.wheel .sb-callout.say { left: 40%; max-width: 34vw; }
@media (orientation: portrait) { #sb.wheel .sb-callout.say { left: 50%; max-width: 84vw; bottom: calc(var(--safe-b, 0px) + 262px); } }

/* An account's characters on the title screen (main.js `roster`). */
#acct .acct-chars { display: grid; gap: 6px; margin: 10px auto 0; max-width: 460px; }
#acct .acct-char { display: flex; gap: 8px; align-items: center; padding: 4px 8px 4px 12px; border-radius: 10px; border: 1px solid rgba(233, 201, 130, 0.22); background: rgba(20, 15, 36, 0.55); }
#acct .acct-char.on { border-color: var(--gold); }
#acct .acct-char span { flex: 1; text-align: left; color: var(--ink); }
#acct .acct-char small { color: var(--ink-dim); }
#acct .acct-char em { color: var(--gold); font-style: italic; padding: 0 8px; }
/* (The list is a card over the title, as the sign-in form is: on a phone held sideways it ran off the foot of the screen.) */
#acct .acct-chars.card { position: fixed; z-index: 50; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 460px); max-height: calc(100vh - 24px); overflow-y: auto; margin: 0; padding: 12px; }
#acct .acct-head { display: flex; justify-content: space-between; align-items: center; color: var(--gold); font-family: var(--display); letter-spacing: 0.08em; }

/* THE OPENING SCREEN's characters (main.js `roster`): a row of cards on the title itself, scrolled sideways if they
   do not fit; the one in play edged in gold. Signed in, the crest and the name stand smaller so the row fits a
   phone held sideways. */
#acct .char-row { display: flex; gap: 10px; justify-content: safe center; overflow-x: auto; padding: 4px 12px 8px; max-width: 100vw; margin: 6px auto 4px; -webkit-overflow-scrolling: touch; }
#acct .char-card { position: relative; flex: 0 0 auto; width: 104px; display: grid; justify-items: center; gap: 2px; padding: 8px 6px 8px; border-radius: 12px; border: 1px solid rgba(233, 201, 130, 0.25); background: rgba(20, 15, 36, 0.62); color: var(--ink); cursor: pointer; text-align: center; }
#acct .char-card.on { border-color: var(--gold); box-shadow: 0 0 14px rgba(233, 201, 130, 0.35); cursor: default; }
#acct .char-card img, #acct .char-card > i { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; object-position: 50% 12%; border: 1px solid rgba(233, 201, 130, 0.4); background: rgba(40, 30, 64, 0.8); }
#acct .char-card > i { display: grid; place-items: center; font: 26px var(--display); font-style: normal; color: var(--gold); }
#acct .char-card b { font: 600 15px var(--body, 'Cormorant Garamond', serif); max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#acct .char-card small { color: var(--ink-dim); font-size: 12px; }
#acct .char-card.ghost { width: auto; padding: 14px 18px; cursor: default; }
#acct .char-x { position: absolute; top: -6px; right: -6px; width: 30px; height: 30px; min-height: 0; border-radius: 50%; border: 1px solid rgba(233, 201, 130, 0.3); background: rgba(20, 15, 36, 0.9); color: var(--ink-dim); font-size: 12px; cursor: pointer; }
#acct.busy { opacity: 0.5; pointer-events: none; }
#acct .acct-line span { color: var(--ink-dim); font-style: italic; }
.title-inner.signed .crest { transform: scale(0.6); margin: -14px auto -16px; }
.title-inner.signed h1 { font-size: clamp(30px, 7vh, 64px); margin: 0; }
@media (max-height: 460px) { .title-inner.signed .subtitle { display: none; } #acct { margin-top: 2px; } #acct .char-card { padding: 6px; } #acct .char-card img, #acct .char-card > i { width: 44px; height: 44px; } }
#acct .acct-line { margin-bottom: 14px; }
.title-inner.signed #acct .acct-line { margin: 0 0 8px; font-size: 14px; }

/* A member's core attributes on the Party screen (party.js): five numbers, a + beside each while there are points to place. */
.p-attrs { margin: 4px 0 10px; }
.p-attr-row { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.p-attr { display: grid; justify-items: center; gap: 2px; padding: 6px 2px; border-radius: 10px; border: 1px solid rgba(233, 201, 130, 0.22); background: rgba(20, 15, 36, 0.5); }
.p-attr span { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-dim); }
.p-attr b { font: 600 20px var(--display); color: var(--gold); }
.p-attr b small { font: 12px var(--body, serif); margin-left: 2px; }
.p-attr b small.up { color: #9ff5cf; }
.p-attr b small.down { color: #ffb09a; }
.p-attr .btn { min-height: 44px; min-width: 44px; padding: 0; }
.p-attr-way { margin-top: 6px; min-height: 44px; }
@media (max-width: 520px) { .p-attr span { font-size: 9px; } }

/* THE SIMPLE BAR (realtime.js `FULL_BAR`): what is for managing a company waits behind More. */
#sb.rt:not(.full) .rt-more { display: none !important; }
.p-attr-note { margin: 6px 0 0; font-size: 13px; color: var(--ink-dim); font-style: italic; }

/* The mender's own buttons (Pulse, Shift, the weaves): on the bar only while they hold mending ground. */
#sb.rt:not(.mending) .rt-mend { display: none !important; }
.rt-slot.rt-mend b { color: #9ff5cf; }

/* The skill tree takes as many branches as a weapon has (the rod has four since Wind). */
.tree { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); }

#acct .acct-line .acct-member { color: var(--gold); font-style: normal; }

/* A gift code on the title (main.js `gift`). */
#acct .acct-gift input { min-height: 44px; width: 190px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(233, 201, 130, 0.4); background: rgba(10, 8, 20, 0.6); color: var(--ink); font: 16px Georgia, serif; letter-spacing: 0.08em; text-transform: uppercase; }

/* The title's links to the terms (legal/*.html). */
.title-legal { display: flex; gap: 6px; justify-content: center; margin-top: 4px; }
.title-legal a { min-height: 44px; min-width: 44px; padding: 0 10px; display: inline-flex; align-items: center; color: var(--ink-dim); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }

/* Agreeing to the terms (main.js `mustAgree`). */
#acct .acct-terms { align-items: flex-start; font-size: 14px; line-height: 1.3; text-align: left; }
#acct .acct-terms input { min-width: 22px; min-height: 22px; margin-top: 2px; }
#acct .acct-terms a, #acct .acct-agree a { color: var(--gold); }
#acct .acct-agree { display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; max-width: 520px; margin: 0 auto 12px; padding: 12px 14px; border: 1px solid rgba(233, 201, 130, 0.5); border-radius: 12px; background: rgba(20, 15, 36, 0.92); }
#acct .acct-agree b { color: var(--gold); font-family: 'Cinzel', Georgia, serif; letter-spacing: 0.06em; }
#btn-begin.held { opacity: 0.45; }

/* Signing in with an account they already have: one button for each provider switched on (main.js). */
#acct .acct-sso { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; width: 100%; }
#acct .acct-sso .btn { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }

/* The shop on the title (main.js `shopHTML`; tools/pay.mjs). */
#acct .acct-shop { display: flex; flex-direction: column; gap: 6px; max-width: 560px; max-height: 46vh; overflow: auto; margin: 0 auto 10px; padding: 10px 12px; text-align: left; border: 1px solid rgba(233, 201, 130, 0.4); border-radius: 12px; background: rgba(20, 15, 36, 0.94); }
#acct .shop-row { display: flex; gap: 10px; align-items: center; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.07); }
#acct .shop-row span { display: flex; flex-direction: column; }
#acct .shop-row b { color: var(--gold); font-weight: 600; }
#acct .shop-row small { color: var(--ink-dim); font-size: 13px; }
#acct .shop-row i { color: #9ff5cf; font-size: 14px; }
#acct .shop-row .btn { min-height: 44px; white-space: nowrap; }
#acct .shop-head { margin-top: 6px; color: var(--ink-dim); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
#acct .shop-foot, #acct .shop-test { color: var(--ink-dim); font-size: 13px; }
#acct .shop-test { color: #ffb09a; }
#acct .shop-foot a { color: var(--gold); }
#acct .shop-cur { display: flex; gap: 6px; flex-wrap: wrap; }
#acct .shop-cur .btn { min-height: 44px; font-size: 13px; }
#acct .shop-cur .btn.on { border-color: var(--gold); color: var(--gold); }
/* (Kept inside a phone's width: the title's column is wider than the screen there.) */
#acct .acct-shop { width: min(560px, calc(100vw - 24px)); max-width: none; box-sizing: border-box; position: relative; left: 50%; transform: translateX(-50%); margin-left: 0; margin-right: 0; }
#acct .shop-row span { min-width: 0; flex: 1 1 auto; }
#acct .shop-row .btn { flex: none; }
#acct .shop-land { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; color: var(--ink-dim); font-size: 14px; }
#acct .shop-land select { min-height: 44px; flex: 1 1 160px; padding: 0 10px; border-radius: 10px; border: 1px solid rgba(233, 201, 130, 0.4); background: rgba(10, 8, 20, 0.8); color: var(--ink); font: 16px Georgia, serif; }

/* Other players in a shared fight, under your own frame (realtime.js `coMates`). */
#sb .rt-mates { position: absolute; left: max(10px, env(safe-area-inset-left)); top: calc(max(10px, env(safe-area-inset-top)) + 92px); display: flex; flex-direction: column; gap: 4px; pointer-events: none; }
#sb .rt-mate { width: 132px; padding: 3px 8px 5px; border-radius: 8px; background: rgba(20, 15, 36, 0.78); border: 1px solid rgba(233, 201, 130, 0.3); }
#sb .rt-mate b { display: block; font: 600 11px 'Cinzel', Georgia, serif; color: var(--gold); letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sb .rt-mate .bar { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, 0.12); overflow: hidden; }
#sb .rt-mate .bar i { display: block; height: 100%; background: #5fd08a; }
#sb .rt-mate.down { opacity: 0.5; }
#sb .rt-mate.down .bar i { background: #b04a4a; }

/* The Friends screen (src/friends.js). */
#friends .fr-panel { width: min(560px, 100%); max-height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
#friends .fr-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#friends .fr-head h2 { margin: 0; }
#friends .fr-body { overflow: auto; display: flex; flex-direction: column; gap: 8px; }
#friends .fr-row { display: flex; gap: 8px; flex-wrap: wrap; }
#friends .fr-row input { flex: 1 1 180px; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid rgba(233, 201, 130, 0.4); background: rgba(10, 8, 20, 0.6); color: var(--ink); font: 16px Georgia, serif; }
#friends .fr-row .btn, #friends .rc-acts .btn { min-height: 44px; }
#friends .fr-note { color: #ffd9a0; font-size: 15px; }
#friends .fr-dot { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: #5a5668; }
#friends .fr-dot.on { background: #6fe39a; box-shadow: 0 0 6px #6fe39a; }
#friends .rc-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
