:root {
  color-scheme: dark;
  --ink: #edf6f6;
  --muted: #a8bcc4;
  --dim: #6f8490;
  --night: #050b12;
  --night-2: #081321;
  --panel: rgba(8, 17, 28, 0.76);
  --panel-strong: rgba(5, 12, 20, 0.92);
  --line: rgba(205, 235, 236, 0.18);
  --line-strong: rgba(222, 244, 242, 0.32);
  --accent: #a77cff;
  --accent-2: #f2d070;
  --accent-soft: rgba(167, 124, 255, 0.18);
  --danger: #ff745d;
  --success: #8ee6a6;
  --danger-soft: #ffad94;
  --success-soft: #a6e88b;
  --focus: #8be7ff;

  /* Neutral surfaces. Collapsed from 12 near-identical dark blues that sat
     within a few RGB units of each other. Alpha varies by use, hue does not. */
  --scrim: 3, 8, 13;
  --surface: 5, 12, 20;
  --surface-lift: #0d2137;

  /* Text tiers. Four steps replacing 10 near-identical off-whites. */
  --ink-2: #c8d8db;

  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, 0.4);
  --inset-hi: inset 0 1px rgba(255, 255, 255, 0.16);

  /* Radii. --radius-lg stays 24px because live rules depend on that value;
     --radius-panel is the 18px workhorse the battle/region panels all use. */
  --radius-xs: 8px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-panel: 18px;
  --radius-lg: 24px;
  --radius-pill: 999px;

  /* Type scale. Replaces ~30 ad hoc sizes; 11px is the hard floor so no
     mobile override may go below it. */
  --fs-2xs: 0.6875rem;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.125rem;
  --fs-lg: 1.375rem;
  --fs-xl: 1.75rem;

  /* Tracking for uppercase micro-labels. */
  --ls-caps: 0.12em;
  --ls-eyebrow: 0.2em;

  /* Spacing, 4px grid. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;

  /* Motion. */
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 450ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);

  /* Horizontal inset shared by every stacked battle panel. Without one token
     the panels used 8/10/17/18px and stepped visibly down both edges. */
  --gutter: 18px;

  --safe-top: max(14px, env(safe-area-inset-top));
  --safe-bottom: max(14px, env(safe-area-inset-bottom));
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

#app[data-theme="verdant"] {
  --accent: #a6e36b;
  --accent-2: #e6d38a;
  --accent-soft: rgba(166, 227, 107, 0.17);
}

#app[data-theme="mossfen"] {
  --accent: #67dc9d;
  --accent-2: #c583ff;
  --accent-soft: rgba(103, 220, 157, 0.17);
}

#app[data-theme="frost"] {
  --accent: #9ee9ff;
  --accent-2: #d9f8ff;
  --accent-soft: rgba(158, 233, 255, 0.17);
}

#app[data-theme="sand"] {
  --accent: #e9bc65;
  --accent-2: #71ddd0;
  --accent-soft: rgba(233, 188, 101, 0.17);
}

#app[data-theme="ashen"] {
  --accent: #ff7b43;
  --accent-2: #ffd070;
  --accent-soft: rgba(255, 123, 67, 0.17);
}

#app[data-theme="astral"] {
  --accent: #aa7fff;
  --accent-2: #efce70;
  --accent-soft: rgba(170, 127, 255, 0.17);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}


html,
body {
  width: 100%;
  height: 100%;
  /* Tracks the dynamic viewport so the layout follows a mobile browser's URL
     bar instead of being sized against a height that is briefly wrong. The
     100% above stays as the fallback for anything without dvh. */
  height: 100dvh;
  margin: 0;
  overflow: hidden;
  /* manipulation kills the double-tap-to-zoom delay, which otherwise eats
     rapid taps on the combat buttons. Pinch zoom is deliberately preserved. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  background: var(--night);
}

body {
  color: var(--ink);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
[tabindex]:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
}

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

h1,
h2,
h3 {
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0.025em;
}

h1 {
  font-size: clamp(4rem, 11vw, 8.6rem);
  line-height: 0.84;
  margin-bottom: 24px;
  text-shadow: 0 8px 36px rgba(0, 0, 0, 0.7), 0 0 44px var(--accent-soft);
}

h2 {
  font-size: clamp(1.55rem, 3vw, 2.7rem);
  line-height: 1;
  margin-bottom: 8px;
}

h3 {
  font-size: 1.22rem;
  line-height: 1.08;
  margin-bottom: 8px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

small {
  color: var(--muted);
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
  background: var(--night);
}

#ambient-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 40;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0.75;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow: hidden;
}

.screen.is-active {
  display: block;
  animation: screen-in 520ms cubic-bezier(.2, .8, .2, 1) both;
}

@keyframes screen-in {
  from { opacity: 0; transform: scale(1.015); }
  to { opacity: 1; transform: scale(1); }
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.glass-panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.055), transparent 32%),
    var(--panel);
  box-shadow: var(--shadow), inset 0 1px rgba(255, 255, 255, 0.05);
  -webkit-backdrop-filter: blur(18px) saturate(1.16);
  backdrop-filter: blur(18px) saturate(1.16);
}

.button,
.icon-button {
  position: relative;
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.button:not(:disabled):hover,
.icon-button:not(:disabled):hover {
  transform: translateY(-2px);
}

.button:not(:disabled):active,
.icon-button:not(:disabled):active {
  transform: translateY(0) scale(0.985);
}

.button {
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(8, 18, 30, 0.72);
  font-weight: 750;
  letter-spacing: 0.01em;
}

.button-primary {
  border-color: color-mix(in srgb, var(--accent) 66%, white 8%);
  background:
    linear-gradient(115deg, color-mix(in srgb, var(--accent) 60%, #111 40%), color-mix(in srgb, var(--accent-2) 24%, #07121c 76%));
  box-shadow: 0 12px 40px var(--accent-soft), inset 0 1px rgba(255, 255, 255, 0.16);
}

.button-primary:hover {
  box-shadow: 0 18px 52px var(--accent-soft), inset 0 1px rgba(255, 255, 255, 0.2);
}

.button-secondary {
  border-color: color-mix(in srgb, var(--accent-2) 55%, transparent);
  background: linear-gradient(115deg, rgba(17, 30, 43, 0.92), color-mix(in srgb, var(--accent-soft) 60%, rgba(6, 13, 22, 0.94)));
}

.button-ghost {
  background: rgba(6, 13, 22, 0.54);
}

.button-small {
  min-height: 38px;
  padding: 0 15px;
  font-size: 0.82rem;
}

.button-large {
  display: grid;
  align-content: center;
  justify-items: start;
  width: min(100%, 390px);
  min-height: 78px;
  padding: 14px 24px;
  border-radius: 20px;
  text-align: left;
}

.button-large span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
}

.button-large small {
  margin-top: 4px;
  font-size: 0.76rem;
  font-weight: 500;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(5, 12, 20, 0.68);
  font-size: 1.35rem;
}

/* Menu */
.screen-menu {
  background: #06101d;
}

.menu-map,
.menu-vignette,
.menu-traveller {
  position: absolute;
  inset: -4%;
  pointer-events: none;
}

.menu-map {
  background-image: url("assets/ui/world-map.webp");
  background-position: center;
  background-size: cover;
  filter: saturate(0.83) brightness(0.58) contrast(1.08);
  transform: translate(calc(var(--menu-x, 0) * 1px), calc(var(--menu-y, 0) * 1px)) scale(1.09);
  animation: menu-drift 20s ease-in-out infinite alternate;
}

.menu-vignette {
  inset: 0;
  z-index: 1;
  background:
    radial-gradient(circle at 68% 44%, transparent 0 16%, rgba(3, 8, 14, 0.12) 36%, rgba(3, 8, 14, 0.76) 78%),
    linear-gradient(90deg, rgba(3, 8, 14, 0.96) 0 28%, rgba(3, 8, 14, 0.55) 51%, rgba(3, 8, 14, 0.24) 100%),
    linear-gradient(0deg, rgba(3, 8, 14, 0.95), transparent 40%);
}

.menu-traveller {
  inset: auto 3vw -6vh auto;
  z-index: 2;
  width: min(50vw, 780px);
  height: min(76vh, 780px);
  background: url("assets/ui/traveller.webp") center / cover no-repeat;
  opacity: 0.7;
  filter: saturate(0.9) contrast(1.12);
  -webkit-mask-image: linear-gradient(to left, black 0 72%, transparent 100%), linear-gradient(to top, black 0 82%, transparent 100%);
  mask-image: linear-gradient(to left, black 0 72%, transparent 100%), linear-gradient(to top, black 0 82%, transparent 100%);
  -webkit-mask-composite: source-in;
  mask-composite: intersect;
  transform: translate(calc(var(--menu-x, 0) * -0.35px), calc(var(--menu-y, 0) * -0.35px));
}

@keyframes menu-drift {
  0% { transform: translate(calc(var(--menu-x, 0) * 1px), calc(var(--menu-y, 0) * 1px)) scale(1.09); }
  100% { transform: translate(calc(var(--menu-x, 0) * 1px - 16px), calc(var(--menu-y, 0) * 1px + 8px)) scale(1.12); }
}

.menu-shell {
  position: relative;
  z-index: 4;
  display: grid;
  width: min(100%, 760px);
  height: 100%;
  align-content: center;
  padding: clamp(28px, 5.5vw, 90px);
}

.brand-lockup {
  max-width: 690px;
}

.brand-mark {
  width: 64px;
  height: 64px;
  margin-bottom: 18px;
  filter: drop-shadow(0 0 26px var(--accent-soft));
}

.menu-subtitle {
  max-width: 610px;
  margin-bottom: 34px;
  color: #d2e1e4;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 2vw, 1.3rem);
}

.menu-actions {
  display: grid;
  gap: 12px;
  max-width: 390px;
}

.build-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 30px;
}

.build-strip span {
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(4, 10, 18, 0.48);
  color: var(--muted);
  font-size: 0.75rem;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.build-strip b {
  color: var(--accent-2);
}

.menu-footnote {
  position: absolute;
  z-index: 4;
  right: max(24px, 4vw);
  bottom: var(--safe-bottom);
  margin: 0;
  color: rgba(218, 237, 239, 0.58);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* World */
.screen-world {
  padding: var(--safe-top) 16px var(--safe-bottom);
  background:
    radial-gradient(circle at 50% 30%, var(--accent-soft), transparent 38%),
    linear-gradient(180deg, #0b1b2e, #050c14);
}

.world-header {
  position: relative;
  z-index: 8;
  display: flex;
  min-height: 72px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto 14px;
  padding: 10px 14px;
  border-radius: 20px;
}

.world-title-block,
.world-stats {
  display: flex;
  align-items: center;
}

.world-title-block {
  gap: var(--space-3);
  /* Without min-width:0 the flex item refuses to shrink below its content, so
     the title wrapped to three lines on a 390px viewport instead of the box
     narrowing. */
  min-width: 0;
}

.world-title-block > div {
  min-width: 0;
}

.world-title-block h2 {
  margin: 0;
  font-size: clamp(1.25rem, 2.2vw, 2rem);
  text-wrap: balance;
}

.world-title-block .eyebrow {
  margin-bottom: 3px;
}

.world-stats {
  gap: 8px;
}

.stat-chip,
.level-chip,
.mode-badge {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 13, 22, 0.64);
  color: var(--muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.stat-chip b,
.level-chip {
  color: var(--ink);
}

.world-layout {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 390px);
  gap: 14px;
  height: calc(100% - 86px);
  max-width: 1900px;
  margin: 0 auto;
}

.map-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #09203a;
  box-shadow: var(--shadow);
  isolation: isolate;
}

.world-map-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.015) translate(calc(var(--map-x, 0) * 1px), calc(var(--map-y, 0) * 1px));
  transition: transform 700ms cubic-bezier(.2, .8, .2, 1), filter 500ms ease;
  filter: saturate(0.92) brightness(0.9) contrast(1.03);
}

.map-stage:hover .world-map-image {
  transform: scale(1.035) translate(calc(var(--map-x, 0) * 1px), calc(var(--map-y, 0) * 1px));
}

.map-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(4, 10, 18, 0.35), transparent 25%, transparent 72%, rgba(4, 10, 18, 0.2)),
    linear-gradient(0deg, rgba(4, 10, 18, 0.45), transparent 30%);
  z-index: 1;
}

.region-nodes {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.region-node {
  --node-accent: var(--accent);
  position: absolute;
  display: grid;
  width: 50px;
  height: 50px;
  place-items: center;
  padding: 0;
  border: 1px solid color-mix(in srgb, var(--node-accent) 75%, white 15%);
  border-radius: 50%;
  background: color-mix(in srgb, #07111d 82%, var(--node-accent) 18%);
  box-shadow: 0 0 0 8px color-mix(in srgb, var(--node-accent) 12%, transparent), 0 12px 28px rgba(0, 0, 0, 0.46), inset 0 1px rgba(255, 255, 255, 0.18);
  color: var(--node-accent);
  cursor: pointer;
  transform: translate(-50%, -50%);
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.region-node::before,
.region-node::after {
  position: absolute;
  content: "";
  inset: -9px;
  border: 1px solid color-mix(in srgb, var(--node-accent) 34%, transparent);
  border-radius: 50%;
  animation: node-pulse 2.8s ease-out infinite;
}

.region-node::after {
  inset: -18px;
  animation-delay: 1.4s;
}

.region-node:hover,
.region-node.is-selected {
  transform: translate(-50%, -50%) scale(1.12);
  background: color-mix(in srgb, #07111d 66%, var(--node-accent) 34%);
  box-shadow: 0 0 0 10px color-mix(in srgb, var(--node-accent) 20%, transparent), 0 18px 35px rgba(0, 0, 0, 0.52), 0 0 38px color-mix(in srgb, var(--node-accent) 38%, transparent);
}

.region-node-icon {
  font-size: 1.25rem;
  text-shadow: 0 0 14px currentColor;
}

.region-node-label {
  position: absolute;
  top: 58px;
  left: 50%;
  width: max-content;
  max-width: 150px;
  padding: 6px 9px;
  border: 1px solid color-mix(in srgb, var(--node-accent) 34%, transparent);
  border-radius: 8px;
  background: rgba(4, 11, 18, 0.78);
  color: #f0f6f5;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.74rem;
  text-shadow: 0 2px 10px #000;
  transform: translateX(-50%);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.region-node.is-secret .region-node-label::after {
  content: " · secret";
  color: var(--node-accent);
  font-family: inherit;
  font-size: var(--fs-2xs);
  text-transform: uppercase;
}

@keyframes node-pulse {
  0% { opacity: 0; transform: scale(0.65); }
  25% { opacity: 0.7; }
  100% { opacity: 0; transform: scale(1.35); }
}

.map-instruction {
  position: absolute;
  z-index: 4;
  left: 16px;
  bottom: 16px;
  max-width: min(480px, calc(100% - 32px));
  padding: 9px 12px;
  border-radius: 12px;
  color: #c8d8db;
  font-size: 0.75rem;
}

.region-panel {
  min-width: 0;
  overflow: auto;
  border-radius: var(--radius-lg);
  padding: 18px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-soft) transparent;
}

.region-empty {
  display: grid;
  min-height: 100%;
  align-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
}

.region-empty img {
  width: 74px;
  margin-bottom: 20px;
  opacity: 0.82;
}

.region-empty p:last-child {
  max-width: 320px;
}

.region-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.region-heading h3 {
  margin-bottom: 5px;
  font-size: 1.7rem;
}

.region-heading p:last-child {
  margin-bottom: 0;
  font-size: 0.84rem;
}

.boss-cards {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.boss-card {
  position: relative;
  display: grid;
  min-height: 238px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #09131d;
  cursor: pointer;
  isolation: isolate;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.boss-card:hover {
  transform: translateY(-4px);
  border-color: color-mix(in srgb, var(--accent) 58%, transparent);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.36), 0 0 28px var(--accent-soft);
}

.boss-card-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms cubic-bezier(.2, .8, .2, 1), filter 250ms ease;
}

.boss-card:hover .boss-card-image {
  transform: scale(1.065);
  filter: saturate(1.12);
}

.boss-card-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(0deg, rgba(3, 8, 13, 0.97) 0 22%, rgba(3, 8, 13, 0.42) 66%, rgba(3, 8, 13, 0.08)), linear-gradient(90deg, rgba(3, 8, 13, 0.3), transparent 70%);
}

.boss-card-content {
  position: relative;
  z-index: 2;
  display: grid;
  align-content: end;
  padding: 16px;
}

.boss-card-topline {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tier-tag,
.clear-tag {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(var(--surface), 0.66);
  color: var(--ink-2);
  font-size: var(--fs-2xs);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.clear-tag {
  border-color: rgba(142, 230, 166, 0.42);
  color: var(--success);
}

.boss-card-content h4 {
  margin: 0 0 5px;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 500;
}

.boss-card-content p {
  display: -webkit-box;
  margin: 0 0 12px;
  overflow: hidden;
  font-size: 0.76rem;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.boss-card-actions {
  display: flex;
  gap: 8px;
}

.boss-card-actions .button {
  min-height: 36px;
  padding: 0 13px;
  font-size: 0.72rem;
}

/* Battle */
.screen-battle {
  background: #05090f;
  isolation: isolate;
}

.battle-backdrop,
.battle-art,
.battle-scrim,
.battle-grain,
#battle-fx,
.stage-flash {
  position: absolute;
  inset: 0;
}

.battle-backdrop {
  z-index: -5;
  background-position: center;
  background-size: cover;
  transform: scale(1.08);
  filter: saturate(1.12) contrast(1.04);
  transition: background-image 300ms ease;
}

.battle-art {
  z-index: -4;
  width: 100%;
  height: 100%;
  /* `cover` rather than `contain`: the landscape arenas are 1122x930, so on a
     390x844 phone `contain` rendered them 390x323 and left 62% of the viewport
     as dead letterbox. --arena-focus is set per boss in game.js; it also pushes
     the crop past the title card baked into the left third of those images. */
  object-fit: var(--art-fit, contain);
  object-position: var(--arena-focus, 58% 45%);
  filter: saturate(1.02) contrast(1.03) brightness(0.86);
  /* --art-shift nudges the creature down into the band of screen left visible
     between the boss HUD and the player HUD; --art-scale gives that shift room
     to move without exposing an uncovered edge. */
  transform: translate3d(
      calc(var(--stage-x, 0) * 1px),
      calc(var(--stage-y, 0) * 1px + var(--art-shift, 0px)),
      0
    )
    scale(var(--art-scale, 1.015));
  transition: filter 250ms ease;
  animation: arena-breathe 9s ease-in-out infinite alternate;
}

.battle-scrim {
  z-index: -3;
  background:
    radial-gradient(circle at 52% 43%, transparent 0 28%, rgba(4, 8, 13, 0.06) 50%, rgba(4, 8, 13, 0.65) 100%),
    linear-gradient(90deg, rgba(4, 8, 13, 0.54), transparent 28%, transparent 70%, rgba(4, 8, 13, 0.36)),
    linear-gradient(0deg, rgba(4, 8, 13, 0.98) 0 13%, rgba(4, 8, 13, 0.36) 34%, transparent 60%, rgba(4, 8, 13, 0.46) 100%);
}

.battle-grain {
  z-index: -2;
  pointer-events: none;
  opacity: 0.14;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.42'/%3E%3C/svg%3E");
  mix-blend-mode: overlay;
}

#battle-fx {
  z-index: 4;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.stage-flash {
  z-index: 5;
  pointer-events: none;
  background: white;
  opacity: 0;
}

.stage-flash.is-hit {
  animation: hit-flash 300ms ease-out;
}

@keyframes hit-flash {
  0% { opacity: 0; }
  20% { opacity: 0.28; }
  100% { opacity: 0; }
}

/* These keyframes must thread --art-shift/--art-scale through themselves: the
   animation runs infinitely, so it overrides the base transform on .battle-art
   and any framing set only there would never take effect. */
@keyframes arena-breathe {
  0% {
    transform: translate3d(
        calc(var(--stage-x, 0) * 1px - 4px),
        calc(var(--stage-y, 0) * 1px - 2px + var(--art-shift, 0px)),
        0
      )
      scale(var(--art-scale, 1.015));
  }
  100% {
    transform: translate3d(
        calc(var(--stage-x, 0) * 1px + 5px),
        calc(var(--stage-y, 0) * 1px + 4px + var(--art-shift, 0px)),
        0
      )
      scale(calc(var(--art-scale, 1.015) * 1.025));
  }
}

/* The arenas are 1122x930 (AR 1.21). Once the viewport is taller than that,
   `contain` letterboxes hard — at 390x844 it rendered 390x323 and left 62% of
   the screen dead. Switch to a focused crop only in that range; wider viewports
   keep `contain`, where `cover` would instead magnify the art and blow up the
   title card baked into its top-left. */
@media (max-aspect-ratio: 6 / 5) {
  .battle-art {
    --art-fit: cover;
    /* The HUD panels occupy the top of a tall screen, which is where these
       arenas put the creature's head; nudge it down into the open band. */
    --art-scale: 1.14;
    --art-shift: 34px;
  }
}

.battle-art.motion-lunge { animation: motion-lunge 900ms cubic-bezier(.18,.9,.24,1); }
.battle-art.motion-slam { animation: motion-slam 900ms cubic-bezier(.2,.8,.2,1); }
.battle-art.motion-cast { animation: motion-cast 1100ms ease-in-out; }
.battle-art.motion-sweep { animation: motion-sweep 950ms ease-in-out; }
.battle-art.motion-spin { animation: motion-spin 1100ms ease-in-out; }
.battle-art.motion-ascend { animation: motion-ascend 1200ms ease-in-out; }
.battle-art.motion-roar { animation: motion-roar 1000ms ease-in-out; }
.battle-art.motion-summon { animation: motion-summon 1100ms ease-in-out; }
.battle-art.motion-hit { animation: motion-hit 420ms ease-out; filter: saturate(0.7) brightness(1.45); }

@keyframes motion-lunge {
  0%,100% { transform: scale(1.02); }
  38% { transform: translate(-3.5vw, 2vh) scale(1.11); filter: brightness(1.1) saturate(1.2); }
  58% { transform: translate(-4.5vw, 3vh) scale(1.14); }
}

@keyframes motion-slam {
  0%,100% { transform: scale(1.02); }
  28% { transform: translateY(-2.5vh) scale(1.055); }
  45% { transform: translateY(2.2vh) scale(1.08); filter: brightness(1.18); }
  52% { transform: translate(-0.6vw, 1.4vh) rotate(-0.35deg) scale(1.07); }
  59% { transform: translate(0.6vw, 1.4vh) rotate(0.35deg) scale(1.07); }
}

@keyframes motion-cast {
  0%,100% { transform: scale(1.02); filter: brightness(0.86); }
  48% { transform: translateY(-1vh) scale(1.075); filter: brightness(1.14) saturate(1.25); }
}

@keyframes motion-sweep {
  0%,100% { transform: scale(1.02); }
  35% { transform: translateX(1.8vw) rotate(0.7deg) scale(1.07); }
  60% { transform: translateX(-1.8vw) rotate(-0.7deg) scale(1.085); filter: brightness(1.12); }
}

@keyframes motion-spin {
  0%,100% { transform: scale(1.02) rotate(0); }
  45% { transform: scale(1.08) rotate(0.6deg); filter: saturate(1.25) brightness(1.08); }
  65% { transform: scale(1.08) rotate(-0.6deg); }
}

@keyframes motion-ascend {
  0%,100% { transform: scale(1.02); }
  36% { transform: translateY(-2.8vh) scale(1.08); filter: brightness(1.15) saturate(1.25); }
  62% { transform: translateY(-1.2vh) scale(1.11); }
}

@keyframes motion-roar {
  0%,100% { transform: scale(1.02); }
  35% { transform: scale(1.10); filter: brightness(1.18) contrast(1.08); }
  48% { transform: translateX(-0.45vw) scale(1.09); }
  55% { transform: translateX(0.45vw) scale(1.09); }
}

@keyframes motion-summon {
  0%,100% { transform: scale(1.02); }
  35% { transform: translateY(-1vh) scale(1.075); filter: saturate(1.32) brightness(1.15); }
  70% { transform: translateY(0.5vh) scale(1.065); }
}

@keyframes motion-hit {
  0%,100% { transform: scale(1.02); }
  18% { transform: translateX(1vw) rotate(0.5deg) scale(1.035); }
  36% { transform: translateX(-0.8vw) rotate(-0.5deg) scale(1.035); }
  56% { transform: translateX(0.5vw) scale(1.03); }
}

.battle-topbar {
  position: absolute;
  z-index: 10;
  top: var(--safe-top);
  left: var(--gutter);
  right: var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}

.battle-topbar > * {
  pointer-events: auto;
}

.mode-badge {
  color: var(--accent-2);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.boss-hud {
  position: absolute;
  z-index: 9;
  top: calc(var(--safe-top) + 50px);
  left: 50%;
  width: min(600px, calc(100% - var(--gutter) * 2));
  padding: 14px var(--space-4) var(--space-3);
  border-radius: var(--radius-panel);
  transform: translateX(-50%);
}

/* On a wide viewport the art is centred and shown whole, which puts the boss's
   head directly behind this centred card (measured: card y 64-216, face y~162).
   Shifting the art down cannot fix it — scaling about the centre moves anything
   above the centre further up — so move the card aside instead. There is ample
   width here, and the creature stays centre-frame.
   Must follow the base rule: a media query adds no specificity. */
@media (min-aspect-ratio: 6 / 5) {
  .boss-hud {
    left: var(--gutter);
    width: min(460px, calc(50% - var(--gutter) * 2));
    transform: none;
  }
}

.hud-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hud-heading h2,
.hud-heading h3 {
  margin: 0;
}

.hud-heading.compact h3 {
  font-size: 1rem;
}

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

.bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.meter {
  position: relative;
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.44);
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.55);
}

.meter-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  transition: width 440ms cubic-bezier(.2,.8,.2,1);
}

.meter-boss .meter-fill {
  background: linear-gradient(90deg, #ff6e59, #f9bc60 70%, #fff0a2);
  box-shadow: 0 0 18px rgba(255, 105, 74, 0.45);
}

.meter-player .meter-fill {
  background: linear-gradient(90deg, #4fbe7a, #a6e88b);
  box-shadow: 0 0 18px rgba(91, 213, 133, 0.38);
}

.meter-focus .meter-fill {
  background: linear-gradient(90deg, #5d79e8, #8be7ff);
  box-shadow: 0 0 18px rgba(91, 187, 255, 0.38);
}

.meter-text {
  min-width: 64px;
  color: #edf6f6;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.status-pills {
  display: flex;
  min-height: 22px;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: rgba(var(--surface), 0.58);
  color: var(--muted);
  font-size: var(--fs-2xs);
  text-transform: capitalize;
}

.status-pill.positive { color: var(--success); border-color: rgba(142, 230, 166, 0.35); }
.status-pill.negative { color: #ffad94; border-color: rgba(255, 116, 93, 0.35); }

.telegraph {
  position: absolute;
  z-index: 12;
  top: 50%;
  left: 4vw;
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  width: min(520px, calc(100% - 32px));
  overflow: hidden;
  border-color: color-mix(in srgb, var(--accent) 48%, transparent);
  border-radius: 18px;
  transform: translateY(-50%);
  animation: telegraph-in 480ms cubic-bezier(.2,.8,.2,1) both;
}

.telegraph[hidden] {
  display: none;
}

.telegraph img {
  width: 150px;
  height: 100%;
  min-height: 126px;
  object-fit: cover;
}

.telegraph > div {
  padding: 14px;
}

.telegraph h3 {
  margin-bottom: 5px;
  font-size: 1.35rem;
}

.telegraph p:last-child {
  margin: 0;
  font-size: 0.76rem;
}

@keyframes telegraph-in {
  from { opacity: 0; transform: translate(-28px, -50%) scale(0.96); }
  to { opacity: 1; transform: translate(0, -50%) scale(1); }
}

.turn-banner {
  position: absolute;
  z-index: 13;
  top: 44%;
  left: 50%;
  min-width: min(80vw, 560px);
  pointer-events: none;
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.5rem, 4vw, 3.1rem);
  text-align: center;
  text-shadow: 0 4px 28px #000, 0 0 22px var(--accent-soft);
  transform: translate(-50%, -50%);
  opacity: 0;
}

.turn-banner.is-visible {
  animation: banner-pop 1000ms ease both;
}

@keyframes banner-pop {
  0% { opacity: 0; transform: translate(-50%, -35%) scale(0.92); letter-spacing: 0.18em; }
  22%, 68% { opacity: 1; transform: translate(-50%, -50%) scale(1); letter-spacing: 0.06em; }
  100% { opacity: 0; transform: translate(-50%, -62%) scale(1.03); letter-spacing: 0.03em; }
}

.battle-bottom {
  position: absolute;
  z-index: 10;
  left: var(--gutter);
  right: var(--gutter);
  bottom: var(--safe-bottom);
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) minmax(520px, 1.2fr);
  align-items: end;
  gap: 14px;
}

.player-hud {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  padding: 12px;
  border-radius: 18px;
}

.player-vitals {
  min-width: 0;
}

.focus-row {
  margin-top: 5px;
}

.player-portrait {
  position: relative;
  width: 76px;
  height: 92px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: radial-gradient(circle at 50% 35%, var(--accent-soft), transparent 48%), linear-gradient(160deg, #13283b, #071019 70%);
}

.cat-face {
  position: absolute;
  z-index: 4;
  top: 20px;
  left: 23px;
  width: 31px;
  height: 29px;
  border-radius: 48% 48% 44% 44%;
  background: linear-gradient(145deg, #3a4351, #141a22 70%);
  box-shadow: inset 0 2px rgba(255, 255, 255, 0.09), 0 6px 12px rgba(0, 0, 0, 0.45);
}

.cat-face i {
  position: absolute;
  top: 11px;
  width: 4px;
  height: 3px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 7px var(--accent-2);
}

.cat-face i:first-child { left: 7px; }
.cat-face i:last-child { right: 7px; }

.cat-ear {
  position: absolute;
  z-index: 3;
  top: 11px;
  width: 18px;
  height: 23px;
  background: #1d252f;
  clip-path: polygon(50% 0, 100% 100%, 0 78%);
}

.cat-ear-left { left: 19px; transform: rotate(-11deg); }
.cat-ear-right { right: 19px; transform: scaleX(-1) rotate(-11deg); }

.cat-cloak {
  position: absolute;
  z-index: 2;
  left: 18px;
  bottom: -8px;
  width: 45px;
  height: 55px;
  background: linear-gradient(120deg, #253748, #0a1119 75%);
  clip-path: polygon(48% 0, 83% 15%, 100% 100%, 62% 88%, 45% 100%, 25% 87%, 0 100%, 15% 18%);
  filter: drop-shadow(0 8px 8px rgba(0, 0, 0, 0.55));
}

.cat-sword {
  position: absolute;
  z-index: 5;
  right: 8px;
  bottom: 10px;
  width: 3px;
  height: 62px;
  border-radius: 999px;
  background: linear-gradient(#efffff, #76cbeb 50%, #213d5b);
  box-shadow: 0 0 9px rgba(126, 218, 255, 0.55);
  transform: rotate(42deg);
  transform-origin: bottom;
}

.cat-tail {
  position: absolute;
  z-index: 1;
  left: 8px;
  bottom: 14px;
  width: 32px;
  height: 24px;
  border: 6px solid #1b2630;
  border-right-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  transform: rotate(-28deg);
}

.command-panel {
  min-width: 0;
  padding: 12px;
  border-radius: 18px;
}

.command-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.command-heading h3 {
  margin: 0;
}

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

.command-card {
  position: relative;
  display: grid;
  min-height: 84px;
  align-content: space-between;
  gap: 7px;
  padding: 11px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(5, 13, 22, 0.72);
  cursor: pointer;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.command-card:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, rgba(5, 13, 22, 0.82) 82%, var(--accent-soft) 18%);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.command-card:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.command-card-key {
  position: absolute;
  top: 7px;
  right: 7px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.05);
  color: var(--accent-2);
  font-size: var(--fs-2xs);
  font-weight: 800;
}

.command-card-name {
  max-width: calc(100% - 24px);
  color: #f4f8f7;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.9rem;
  line-height: 1.05;
}

.command-card-meta {
  color: var(--muted);
  font-size: var(--fs-2xs);
}

.command-card-cost {
  color: #91ddf5;
}

.command-card.lab-card {
  min-height: 116px;
  padding: 0;
  background-position: center;
  background-size: cover;
}

.command-card.lab-card::after {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(0deg, rgba(3, 8, 13, 0.96), rgba(3, 8, 13, 0.08) 70%);
}

.command-card.lab-card > * {
  position: relative;
  z-index: 2;
}

.command-card.lab-card .command-card-name {
  align-self: end;
  max-width: 100%;
  padding: 48px 10px 9px;
  font-size: 0.86rem;
}

.command-hint {
  margin: var(--space-2) 0 0;
  /* was --dim, which computes to 3.06:1 over bright arena art — below AA */
  color: var(--muted);
  font-size: var(--fs-2xs);
  text-align: right;
}

.battle-log {
  position: absolute;
  z-index: 9;
  right: var(--gutter);
  bottom: calc(var(--safe-bottom) + 182px);
  width: min(430px, calc(100% - var(--gutter) * 2));
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  pointer-events: none;
  opacity: 0.9;
}

.battle-log:empty {
  display: none;
}

.damage-layer {
  position: absolute;
  inset: 0;
  z-index: 14;
  pointer-events: none;
}

.damage-number {
  position: absolute;
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 4vw, 3.2rem);
  font-weight: 700;
  text-shadow: 0 3px 18px #000, 0 0 16px currentColor;
  transform: translate(-50%, -50%);
  animation: damage-rise 1000ms ease-out forwards;
}

.damage-number.damage-boss { left: 70%; top: 40%; color: #fff2a9; }
.damage-number.damage-player { left: 28%; top: 63%; color: #ff967f; }
.damage-number.damage-heal { left: 28%; top: 63%; color: #9df4ad; }
.damage-number.damage-ward { left: 28%; top: 63%; color: #9deaff; font-size: 1.35rem; }

@keyframes damage-rise {
  0% { opacity: 0; transform: translate(-50%, -10%) scale(0.68); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1.16); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(0.9); }
}

.encounter-end {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 7, 12, 0.74);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.encounter-end[hidden] {
  display: none;
}

.encounter-card {
  width: min(560px, 100%);
  padding: 30px;
  border-radius: 24px;
  text-align: center;
  animation: end-card-in 540ms cubic-bezier(.2,.9,.2,1) both;
}

.encounter-card h2 {
  font-size: clamp(2rem, 5vw, 3.7rem);
}

.encounter-card p {
  max-width: 460px;
  margin-right: auto;
  margin-left: auto;
}

.end-reward {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin: 8px auto 22px;
  padding: 0 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-2);
  font-weight: 800;
}

.end-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

@keyframes end-card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Dialog, toast, loader */
.help-dialog {
  width: 100%;
  max-width: 860px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.help-dialog::backdrop {
  background: rgba(2, 7, 12, 0.76);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.help-card {
  position: relative;
  max-height: min(86vh, 780px);
  overflow: auto;
  padding: 28px;
  border-radius: 24px;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
}

.help-card h2 {
  margin-bottom: 24px;
}

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

.help-grid section {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.025);
}

.help-grid section p {
  margin: 0;
  font-size: 0.82rem;
}

kbd {
  display: inline-grid;
  min-width: 25px;
  min-height: 24px;
  place-items: center;
  padding: 0 5px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--accent-2);
  font-size: 0.72rem;
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.28);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.025);
}

.setting-row span {
  display: grid;
  gap: 3px;
}

.setting-row small {
  font-size: 0.74rem;
}

.setting-row input {
  width: 44px;
  height: 24px;
  accent-color: var(--accent);
}

.dialog-done {
  width: 100%;
  margin-top: 16px;
}

.toast {
  position: fixed;
  z-index: 80;
  top: calc(var(--safe-top) + 12px);
  left: 50%;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(5, 13, 22, 0.9);
  color: #eaf4f4;
  font-size: 0.78rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  transform: translate(-50%, -20px);
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

/* The update prompt is the one toast that must be clickable. */
.toast.is-action {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  cursor: pointer;
  pointer-events: auto;
}

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

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  background: radial-gradient(circle at center, #10283d, #050b12 62%);
  transition: opacity 500ms ease, visibility 500ms ease;
}

.loading-screen.is-hidden {
  visibility: hidden;
  opacity: 0;
}

.loading-screen img {
  width: 74px;
  animation: loader-pulse 1.8s ease-in-out infinite;
}

.loading-screen p {
  margin-top: 14px;
  color: #c4d8da;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

@keyframes loader-pulse {
  0%,100% { transform: scale(0.92); filter: drop-shadow(0 0 8px var(--accent-soft)); opacity: 0.75; }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 28px var(--accent)); opacity: 1; }
}

/* Responsive */
@media (max-width: 1100px) {
  .world-layout {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  }

  .battle-bottom {
    grid-template-columns: minmax(270px, 0.72fr) minmax(470px, 1.28fr);
  }

  .command-card-name {
    font-size: 0.82rem;
  }
}

@media (max-width: 900px) {
  .menu-traveller {
    width: 68vw;
    opacity: 0.45;
  }

  .world-layout {
    display: block;
  }

  .map-stage {
    height: 100%;
  }

  .region-panel {
    position: absolute;
    z-index: 8;
    right: 12px;
    bottom: 12px;
    width: min(390px, calc(100% - 24px));
    max-height: calc(100% - 24px);
    transform: translateX(calc(100% + 30px));
    transition: transform 350ms cubic-bezier(.2,.8,.2,1);
  }

  .region-panel.is-open {
    transform: translateX(0);
  }

  .world-stats .stat-chip:first-child {
    display: none;
  }

  .battle-bottom {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .player-hud {
    width: min(520px, 100%);
  }

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

  .battle-log {
    bottom: calc(var(--safe-bottom) + 294px);
  }

  .telegraph {
    top: 42%;
    left: 16px;
  }
}

@media (max-width: 680px) {
  :root {
    /* One inset for every stacked battle panel. Previously the topbar, boss
       HUD, command panel and log each used their own (10/17/8/8px) and stepped
       visibly down both edges of the screen. */
    --gutter: 10px;
  }

  .menu-shell {
    align-content: end;
    padding: 24px 18px calc(var(--safe-bottom) + 40px);
  }

  .brand-mark {
    width: 50px;
    height: 50px;
    margin-bottom: 12px;
  }

  h1 {
    font-size: clamp(4rem, 20vw, 6.2rem);
    margin-bottom: 16px;
  }

  .menu-subtitle {
    max-width: 95%;
    margin-bottom: 20px;
    font-size: 0.98rem;
  }

  .menu-actions {
    /* 2-up only where the subtitles actually fit. Below ~440px this collapses
       to a single column instead of squeezing both cards to ~172px. */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    max-width: none;
  }

  .button-large {
    min-height: 72px;
    padding: 12px 15px;
  }

  .button-large span {
    font-size: 1rem;
  }

  .button-large small {
    font-size: var(--fs-2xs);
  }

  .menu-actions .button-ghost {
    grid-column: 1 / -1;
  }

  .build-strip {
    display: none;
  }

  .menu-footnote,
  .menu-traveller {
    display: none;
  }

  .world-header {
    min-height: 62px;
    gap: var(--space-3);
  }

  .world-title-block h2 {
    font-size: var(--fs-md);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .world-title-block .eyebrow {
    font-size: var(--fs-2xs);
    letter-spacing: var(--ls-caps);
  }

  .world-stats .stat-chip,
  .world-help {
    display: none;
  }

  .world-stats .stat-chip:last-of-type {
    display: inline-flex;
  }

  .region-node {
    width: 43px;
    height: 43px;
  }

  .region-node-label {
    top: 50px;
    max-width: 132px;
    font-size: var(--fs-xs);
  }

  .map-instruction {
    display: none;
  }

  .boss-hud {
    top: calc(var(--safe-top) + 46px);
    padding: 10px 12px;
  }

  .boss-hud h2 {
    font-size: 1.25rem;
  }

  .boss-hud .eyebrow {
    font-size: var(--fs-2xs);
    letter-spacing: var(--ls-caps);
  }

  .battle-topbar {
    left: var(--gutter);
    right: var(--gutter);
  }

  .battle-topbar .mode-badge {
    display: none;
  }

  .battle-bottom {
    left: var(--gutter);
    right: var(--gutter);
  }

  .player-hud {
    grid-template-columns: 55px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .player-portrait {
    width: 55px;
    height: 74px;
  }

  .cat-face { left: 15px; top: 16px; transform: scale(.82); }
  .cat-ear-left { left: 12px; top: 8px; }
  .cat-ear-right { right: 11px; top: 8px; }
  .cat-cloak { left: 9px; transform: scale(.82); transform-origin: bottom; }
  .cat-sword { right: 7px; bottom: 6px; height: 49px; }
  .cat-tail { left: 2px; bottom: 8px; transform: rotate(-28deg) scale(.75); }

  .player-hud h3,
  .command-heading h3 {
    font-size: 0.88rem;
  }

  .player-hud .eyebrow,
  .command-heading .eyebrow {
    font-size: var(--fs-2xs);
    letter-spacing: var(--ls-caps);
  }

  .command-panel {
    padding: 8px;
  }

  .command-heading {
    margin-bottom: 6px;
  }

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

  .command-card {
    min-height: 62px;
    padding: 8px;
  }

  .command-card.lab-card {
    min-height: 80px;
  }

  .command-card.lab-card .command-card-name {
    padding: 30px 8px 7px;
  }

  .command-card-key {
    width: 19px;
    height: 19px;
    top: 5px;
    right: 5px;
  }

  .command-card-name {
    font-size: 0.76rem;
  }

  .command-card-meta {
    font-size: var(--fs-2xs);
  }

  .command-hint {
    display: none;
  }

  .battle-log {
    right: var(--gutter);
    bottom: calc(var(--safe-bottom) + 256px);
    width: calc(100% - var(--gutter) * 2);
  }

  .telegraph {
    top: 40%;
    left: var(--gutter);
    grid-template-columns: 96px minmax(0, 1fr);
    width: calc(100% - var(--gutter) * 2);
  }

  .telegraph img {
    width: 96px;
    min-height: 100px;
  }

  .telegraph > div {
    padding: 10px;
  }

  .telegraph h3 {
    font-size: 1rem;
  }

  .telegraph p:last-child {
    display: -webkit-box;
    overflow: hidden;
    font-size: var(--fs-2xs);
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

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

  .help-card {
    padding: 22px 16px;
  }

  .end-actions {
    flex-direction: column-reverse;
  }
}

@media (max-height: 680px) and (min-width: 681px) {
  .boss-hud {
    top: calc(var(--safe-top) + 44px);
    padding: 10px 14px;
  }

  .battle-bottom {
    bottom: 8px;
  }

  .player-portrait {
    height: 76px;
  }

  .command-card {
    min-height: 68px;
  }

  .battle-log {
    bottom: 150px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

#app[data-reduced-motion="true"] .menu-map,
#app[data-reduced-motion="true"] .battle-art,
#app[data-reduced-motion="true"] .region-node::before,
#app[data-reduced-motion="true"] .region-node::after,
#app[data-reduced-motion="true"] .loading-screen img {
  animation: none !important;
}

#app[data-reduced-motion="true"] .world-map-image,
#app[data-reduced-motion="true"] .boss-card-image,
#app[data-reduced-motion="true"] .screen.is-active {
  transition-duration: 1ms !important;
  animation-duration: 1ms !important;
}
