:root {
  color-scheme: dark;
  --ink: #f7ead0;
  --muted: #b8a98c;
  --panel: rgba(31, 25, 25, 0.86);
  --panel-strong: rgba(18, 15, 17, 0.94);
  --line: rgba(225, 175, 93, 0.26);
  --gold: #dca64d;
  --red: #8e2f2e;
  --red-hot: #de5c3e;
  --blue: #3b6f8f;
  --green: #6f8b45;
  --shadow: rgba(0, 0, 0, 0.5);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 8%, rgba(158, 78, 42, 0.28), transparent 34%),
    linear-gradient(180deg, #271c1f 0%, #131116 45%, #0c0b0e 100%);
  overflow: hidden;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  display: grid;
  grid-template-rows: 82px 1fr 228px 104px;
  width: 100vw;
  height: 100vh;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.32), transparent 20%, transparent 80%, rgba(0, 0, 0, 0.32)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0 1px, transparent 1px 84px);
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 26px 10px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(24, 18, 18, 0.95), rgba(20, 15, 18, 0.78));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.sigil {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  color: #241409;
  font-size: 30px;
  font-weight: 900;
  background: linear-gradient(145deg, #f0c36e, #9d5b24);
  border: 2px solid #f6d38b;
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(221, 149, 63, 0.36);
}

h1,
h2,
p {
  margin: 0;
}

.brand-lockup h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

.brand-lockup p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.run-stats {
  display: flex;
  gap: 10px;
}

.stat-pill,
.pile-count {
  min-width: 74px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(9, 8, 10, 0.44);
}

.stat-pill span,
.pile-count span {
  display: block;
  color: var(--muted);
  font-size: 11px;
}

.stat-pill strong,
.pile-count strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 15px;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) 280px minmax(300px, 1fr);
  align-items: end;
  gap: 32px;
  padding: 34px 66px 24px;
}

.stage::before {
  position: absolute;
  inset: auto 0 0;
  height: 42%;
  content: "";
  background: linear-gradient(180deg, transparent, rgba(78, 47, 33, 0.4));
  pointer-events: none;
}

.entity {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  min-height: 430px;
}

.entity.monster {
  cursor: crosshair;
}

.intent-spire {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  margin-bottom: 12px;
  color: #1d1211;
  font-size: 24px;
  font-weight: 900;
  background: linear-gradient(180deg, #f2d084, #b5602a);
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
}

.character-art {
  position: relative;
  display: grid;
  width: 285px;
  height: 348px;
  place-items: center;
  border: 1px solid rgba(246, 191, 108, 0.28);
  border-radius: 46% 46% 12px 12px;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 230, 158, 0.25), transparent 22%),
    linear-gradient(155deg, rgba(121, 42, 43, 0.9), rgba(32, 26, 34, 0.95));
  box-shadow:
    inset 0 -28px 70px rgba(0, 0, 0, 0.48),
    0 22px 55px rgba(0, 0, 0, 0.4);
}

.combat-effect-icon {
  position: absolute;
  top: -16px;
  right: 18px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: #241409;
  font-weight: 900;
  border: 2px solid #f8ddb0;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff0b8, #d49a3b);
  box-shadow: 0 0 20px rgba(230, 184, 82, 0.42);
}

.combat-float {
  position: absolute;
  right: 18px;
  top: 72px;
  z-index: 5;
  display: grid;
  min-width: 58px;
  min-height: 42px;
  place-items: center;
  pointer-events: none;
  animation: combat-float-rise 1780ms ease-out forwards;
}

.combat-float.damage span {
  color: #ff5f4a;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
  text-shadow:
    0 2px 0 rgba(44, 6, 4, 0.92),
    0 0 18px rgba(255, 57, 38, 0.58);
}

.shield-float {
  position: relative;
  display: grid;
  width: 52px;
  height: 58px;
  place-items: center;
  color: #f7ead0;
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 0 rgba(15, 30, 50, 0.72);
}

.shield-float::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background:
    linear-gradient(145deg, #d9f1ff, #5f9cca 54%, #2c5577);
  clip-path: polygon(50% 0, 93% 16%, 84% 74%, 50% 100%, 16% 74%, 7% 16%);
  filter:
    drop-shadow(0 2px 0 rgba(13, 32, 49, 0.92))
    drop-shadow(0 0 16px rgba(116, 190, 241, 0.48));
}

.character-art.monster {
  background:
    radial-gradient(circle at 50% 24%, rgba(135, 210, 219, 0.22), transparent 23%),
    linear-gradient(155deg, rgba(43, 83, 91, 0.9), rgba(31, 25, 37, 0.96));
}

.character-art span {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 92px;
  font-weight: 900;
  text-shadow: 0 8px 20px var(--shadow);
}

.character-art.player.combat-fx-hit {
  animation: player-combat-hit 420ms ease-out;
}

.entity-plate {
  width: min(360px, 100%);
  margin-top: -18px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.36);
}

.entity-plate small {
  color: var(--gold);
  font-size: 12px;
}

.entity-plate h2 {
  margin: 4px 0 10px;
  font-size: 22px;
  letter-spacing: 0;
}

.hp-bar {
  position: relative;
  height: 22px;
  overflow: hidden;
  border: 1px solid rgba(251, 211, 143, 0.32);
  border-radius: 4px;
  background: #221417;
}

.hp-bar span {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, #822b2e, #d84e36);
  transition: width 180ms ease;
}

.hp-bar strong {
  position: relative;
  z-index: 1;
  display: grid;
  height: 100%;
  place-items: center;
  font-size: 12px;
}

.entity-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.block-badge,
.buff {
  padding: 5px 8px;
  color: #e9dcc4;
  font-size: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  background: rgba(36, 44, 54, 0.8);
}

.buff {
  background: rgba(62, 68, 31, 0.78);
}

.buff.muted {
  color: #938776;
  background: rgba(25, 22, 24, 0.7);
}

.phase-banner {
  position: relative;
  z-index: 2;
  align-self: center;
  padding: 18px 18px 16px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(11, 10, 13, 0.72);
  box-shadow: 0 15px 34px rgba(0, 0, 0, 0.3);
}

.phase-banner span,
.phase-banner strong,
.phase-banner small {
  display: block;
}

.phase-banner span {
  color: var(--gold);
  font-size: 13px;
}

.phase-banner strong {
  margin: 7px 0;
  font-size: 30px;
}

.phase-banner small {
  color: var(--muted);
  line-height: 1.45;
}

.combat-floor {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: 170px 1fr 170px;
  align-items: center;
  gap: 18px;
  padding: 12px 24px 18px;
  border-top: 1px solid rgba(229, 173, 84, 0.18);
  background: linear-gradient(180deg, rgba(18, 15, 16, 0.42), rgba(12, 10, 12, 0.9));
}

.pile-panel,
.action-panel {
  display: grid;
  gap: 13px;
  justify-items: center;
}

.energy-orb {
  display: grid;
  width: 98px;
  height: 98px;
  place-items: center;
  color: #101018;
  background:
    radial-gradient(circle at 50% 36%, #eaf4ff 0 15%, #8ac3de 16% 40%, #31617e 75%),
    #2a536a;
  border: 3px solid #c5e4f1;
  border-radius: 50%;
  box-shadow:
    inset 0 -14px 28px rgba(17, 43, 68, 0.48),
    0 0 28px rgba(97, 168, 201, 0.35);
}

.energy-orb strong {
  margin-top: 12px;
  font-size: 38px;
  line-height: 0.8;
}

.energy-orb span {
  margin-top: -18px;
  font-size: 13px;
  font-weight: 800;
}

.pile-counts {
  display: flex;
  gap: 8px;
}

.hand {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 10px;
  min-height: 194px;
}

.card {
  position: relative;
  width: 132px;
  height: 182px;
  padding: 15px 12px 13px;
  color: var(--ink);
  text-align: left;
  border: 2px solid rgba(241, 194, 117, 0.4);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(155deg, #3e2527, #171319);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.38);
  cursor: grab;
  transform: rotate(var(--card-tilt)) translateY(6px);
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

.card:hover,
.card:focus-visible {
  z-index: 5;
  outline: none;
  border-color: rgba(255, 220, 151, 0.78);
  box-shadow: 0 20px 34px rgba(0, 0, 0, 0.5);
  transform: rotate(0deg) translateY(-16px) scale(1.08);
}

.card.skill {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(155deg, #253b43, #15151b);
}

.card.power {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(155deg, #3c3f25, #15151b);
}

.card.disabled {
  cursor: not-allowed;
  filter: grayscale(0.75) brightness(0.72);
}

.card-fx-source-hidden {
  opacity: 0.16;
}

.cost {
  position: absolute;
  top: 9px;
  left: 9px;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  color: #111018;
  font-weight: 900;
  background: linear-gradient(180deg, #e7f2ff, #5da2c8);
  border-radius: 50%;
}

.card-type {
  display: block;
  margin-left: 34px;
  color: var(--gold);
  font-size: 11px;
}

.card strong {
  display: block;
  margin-top: 24px;
  font-size: 18px;
  line-height: 1.15;
}

.card p {
  margin-top: 16px;
  color: #e7d8be;
  font-size: 13px;
  line-height: 1.45;
}

.end-turn,
.ghost-button {
  width: 134px;
  min-height: 46px;
  color: #21130d;
  font-weight: 900;
  border: 1px solid #f5cf80;
  border-radius: 6px;
  background: linear-gradient(180deg, #e9b75a, #9a4c25);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.32);
  cursor: pointer;
}

.end-turn:disabled {
  color: #80715e;
  border-color: rgba(173, 144, 101, 0.28);
  background: rgba(48, 42, 39, 0.7);
  cursor: not-allowed;
}

.ghost-button {
  color: var(--ink);
  background: rgba(16, 14, 17, 0.64);
}

.log-panel {
  display: grid;
  align-content: start;
  gap: 4px;
  padding: 12px 26px;
  color: #d8c8aa;
  border-top: 1px solid rgba(229, 173, 84, 0.18);
  background: rgba(8, 7, 9, 0.84);
  overflow: hidden;
}

.log-panel p {
  font-size: 13px;
  line-height: 1.35;
}

.card-fx-layer {
  position: absolute;
  inset: 0;
  z-index: 17;
  pointer-events: none;
}

.flying-card {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 26;
  margin: 0;
  pointer-events: none;
  opacity: 1;
  transform: translate3d(var(--from-x), var(--from-y), 0) translate(-50%, -50%) rotate(var(--from-rotate, 0deg)) scale(1);
  transform-origin: center;
  will-change: transform, opacity;
  backface-visibility: hidden;
  contain: layout paint style;
  animation: card-flight var(--flight-duration, 520ms) cubic-bezier(0.2, 0.82, 0.25, 1) forwards;
}

.flying-card.flight-pause {
  animation-name: card-flight-pause;
  animation-duration: var(--flight-duration, 780ms);
  animation-timing-function: linear;
}

.slash-fx,
.impact-ring,
.shield-fx,
.power-aura,
.damage-number,
.block-number,
.power-number {
  position: fixed;
  pointer-events: none;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.slash-fx {
  z-index: 27;
  left: var(--x);
  top: var(--y);
  width: 210px;
  height: 120px;
  transform: translate(-50%, -50%) rotate(-18deg);
  animation: slash-burst 420ms ease-out forwards;
}

.slash-fx::before,
.slash-fx::after {
  position: absolute;
  content: "";
  border-radius: 999px;
  transform-origin: 50% 50%;
}

.slash-fx::before {
  inset: 48px 8px 48px;
  background: linear-gradient(90deg, transparent, #fff3c7 18%, #f26a3e 55%, transparent);
  box-shadow:
    0 0 16px rgba(247, 117, 57, 0.86),
    0 0 34px rgba(247, 117, 57, 0.45);
}

.slash-fx::after {
  inset: 34px 28px;
  border: 3px solid rgba(255, 223, 160, 0.72);
  border-right-color: transparent;
  border-left-color: transparent;
}

.impact-ring {
  z-index: 26;
  left: var(--x);
  top: var(--y);
  width: 86px;
  height: 86px;
  border: 3px solid rgba(255, 219, 137, 0.78);
  border-radius: 50%;
  box-shadow: 0 0 28px rgba(222, 92, 62, 0.62);
  transform: translate(-50%, -50%);
  animation: impact-ring 500ms ease-out forwards;
}

.shield-fx {
  z-index: 26;
  left: var(--x);
  top: var(--y);
  display: grid;
  width: 138px;
  height: 154px;
  place-items: center;
  color: #f7ead0;
  font-size: 36px;
  font-weight: 900;
  text-shadow: 0 2px 0 rgba(15, 30, 50, 0.72);
  transform: translate(-50%, -50%);
  animation: shield-pop 620ms ease-out forwards;
}

.shield-fx::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background: linear-gradient(145deg, #d9f1ff, #5f9cca 54%, #2c5577);
  clip-path: polygon(50% 0, 93% 16%, 84% 74%, 50% 100%, 16% 74%, 7% 16%);
  filter:
    drop-shadow(0 2px 0 rgba(13, 32, 49, 0.92))
    drop-shadow(0 0 22px rgba(116, 190, 241, 0.66));
}

.power-aura {
  z-index: 26;
  left: var(--x);
  top: var(--y);
  width: 190px;
  height: 92px;
  border: 3px solid rgba(238, 202, 112, 0.72);
  border-radius: 50%;
  box-shadow:
    inset 0 0 20px rgba(238, 202, 112, 0.26),
    0 0 28px rgba(238, 202, 112, 0.36);
  transform: translate(-50%, -50%) rotateX(66deg);
  animation: aura-rise 720ms ease-out forwards;
}

.power-aura::before,
.power-aura::after {
  position: absolute;
  content: "";
  border-radius: 50%;
}

.power-aura::before {
  inset: 18px;
  border: 2px solid rgba(255, 244, 186, 0.52);
}

.power-aura::after {
  inset: 38px 72px;
  background: rgba(255, 232, 139, 0.9);
  box-shadow:
    -42px -10px 0 rgba(255, 232, 139, 0.58),
    44px 8px 0 rgba(255, 232, 139, 0.52);
}

.damage-number,
.block-number,
.power-number {
  z-index: 28;
  left: var(--x);
  top: var(--y);
  min-width: 58px;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 40px;
  font-weight: 900;
  transform: translate(-50%, -50%);
  animation: number-rise 880ms ease-out forwards;
}

.damage-number.dramatic-number,
.block-number.dramatic-number,
.power-number.dramatic-number {
  min-width: 96px;
  font-size: 72px;
  letter-spacing: 0;
  animation: number-rise-dramatic 1180ms cubic-bezier(0.16, 0.84, 0.24, 1) forwards;
}

.damage-number {
  color: #ff634b;
  text-shadow:
    0 2px 0 rgba(44, 6, 4, 0.92),
    0 0 18px rgba(255, 57, 38, 0.58);
}

.block-number,
.power-number {
  color: #f9e8b6;
  text-shadow:
    0 2px 0 rgba(38, 29, 10, 0.92),
    0 0 18px rgba(248, 205, 102, 0.58);
}

.block-number.dramatic-number {
  color: #e7f7ff;
  text-shadow:
    0 3px 0 rgba(13, 32, 49, 0.95),
    0 0 18px rgba(116, 190, 241, 0.9),
    0 0 38px rgba(116, 190, 241, 0.56);
}

.power-number.dramatic-number {
  color: #fff0a3;
  text-shadow:
    0 3px 0 rgba(70, 45, 8, 0.95),
    0 0 18px rgba(255, 232, 132, 0.95),
    0 0 38px rgba(255, 198, 72, 0.72);
}

.entity.monster.hit-shake .character-art {
  animation: hit-shake 360ms ease-out;
}

.entity.player.guard-pulse .character-art {
  animation: guard-pulse 520ms ease-out;
}

.entity.player.power-pulse .character-art {
  animation: power-pulse 620ms ease-out;
}

.result-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.66);
}

.result-panel {
  position: relative;
  width: 390px;
  padding: 28px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.combat-menu-panel {
  display: grid;
  justify-items: stretch;
  gap: 14px;
}

.pause-menu-actions {
  display: grid;
  gap: 12px;
}

.menu-wide-button {
  width: 100%;
}

.settings-slider {
  display: grid;
  grid-template-columns: 82px 1fr 48px;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--ink);
  text-align: left;
}

.settings-slider span,
.settings-slider strong {
  color: #e8d5b8;
  font-size: 13px;
  font-weight: 900;
}

.settings-slider strong {
  text-align: right;
}

.settings-slider input {
  width: 100%;
  accent-color: var(--gold);
}

.result-panel span {
  color: var(--gold);
  font-size: 13px;
}

.result-panel h2 {
  margin: 8px 0 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
}

.result-panel p {
  margin-bottom: 18px;
  color: var(--muted);
}

.defeat-overlay {
  gap: 18px;
  align-content: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(138, 0, 0, 0.36), rgba(0, 0, 0, 0) 30%),
    rgba(0, 0, 0, 0.82);
}

.defeat-sigil {
  position: relative;
  color: #9c1111;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(64px, 12vw, 146px);
  font-weight: 900;
  line-height: 0.9;
  text-shadow:
    0 0 8px rgba(255, 30, 30, 0.42),
    0 0 24px rgba(122, 0, 0, 0.8),
    0 8px 0 rgba(0, 0, 0, 0.8);
  animation: defeat-sigil-in 900ms ease-out both;
}

.defeat-overlay p {
  margin: 0 0 12px;
  color: #d5c6b2;
  font-size: 16px;
  letter-spacing: 0.08em;
}

.defeat-overlay .end-turn {
  min-width: 168px;
}

@keyframes defeat-sigil-in {
  0% {
    opacity: 0;
    filter: blur(16px);
    transform: scale(1.34);
  }
  55% {
    opacity: 1;
    filter: blur(1px);
    transform: scale(0.96);
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 45%, rgba(104, 65, 36, 0.34), transparent 32%),
    rgba(0, 0, 0, 0.68);
}

.math-modal {
  position: relative;
  width: min(520px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid rgba(238, 190, 112, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(64, 43, 34, 0.94), rgba(16, 13, 16, 0.97)),
    var(--panel-strong);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.58);
}

.modal-rune {
  position: absolute;
  top: -26px;
  left: calc(50% - 26px);
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  color: #21130d;
  font-size: 30px;
  font-weight: 900;
  border: 2px solid #f4d188;
  border-radius: 50%;
  background: linear-gradient(145deg, #f0c36e, #9d5b24);
}

.math-modal-header {
  text-align: center;
}

.math-modal-header span,
.problem-panel small,
.help-panel span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.math-modal-header h2 {
  margin: 8px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
}

.math-modal-header p {
  color: var(--muted);
  font-size: 14px;
}

.problem-panel {
  margin: 22px 0 16px;
  padding: 18px;
  text-align: center;
  border: 1px solid rgba(238, 190, 112, 0.24);
  border-radius: 8px;
  background: rgba(8, 7, 9, 0.52);
}

.problem-panel small,
.problem-panel strong {
  display: block;
}

.problem-panel strong {
  margin-top: 8px;
  font-size: 26px;
  line-height: 1.3;
}

.inline-fraction {
  display: inline-grid;
  min-width: 1.24em;
  margin: 0 0.16em;
  vertical-align: middle;
  line-height: 1;
}

.inline-fraction span {
  display: block;
  padding: 0.02em 0.14em;
  text-align: center;
}

.inline-fraction span:first-child {
  border-bottom: 2px solid currentColor;
}

.answer-row {
  display: grid;
  grid-template-columns: 1fr 116px;
  gap: 10px;
}

.answer-row input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  color: var(--ink);
  font-size: 20px;
  border: 1px solid rgba(238, 190, 112, 0.36);
  border-radius: 6px;
  background: rgba(8, 7, 9, 0.72);
  outline: none;
}

.answer-row input:focus {
  border-color: #f1c978;
  box-shadow: 0 0 0 3px rgba(220, 166, 77, 0.16);
}

.structured-answer {
  align-items: end;
}

.structured-answer label {
  display: grid;
  gap: 6px;
}

.structured-answer label span {
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.remainder-answer {
  grid-template-columns: 1fr auto 1fr 116px;
}

.remainder-mark {
  align-self: center;
  color: #f1d99d;
  font-size: 20px;
  font-weight: 900;
}

.fraction-answer {
  grid-template-columns: 96px 116px;
  justify-content: center;
  align-items: center;
}

.fraction-line {
  width: 100%;
  height: 2px;
  background: #f1d99d;
}

.fraction-input-stack {
  display: grid;
  gap: 6px;
  align-items: center;
}

.fraction-input-stack label {
  justify-items: center;
}

.fraction-input-stack input {
  min-height: 40px;
  padding: 0 8px;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
  border: 0;
}

.challenge-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

.answer-feedback {
  margin-top: 14px;
  padding: 10px 12px;
  color: #f7e1b4;
  border: 1px solid rgba(238, 190, 112, 0.24);
  border-radius: 6px;
  background: rgba(113, 75, 34, 0.42);
}

.answer-feedback.danger {
  color: #ffd4cc;
  border-color: rgba(222, 92, 62, 0.4);
  background: rgba(115, 35, 31, 0.5);
}

.help-panel {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(222, 92, 62, 0.38);
  border-radius: 8px;
  background: rgba(25, 15, 15, 0.68);
}

.help-panel strong {
  font-size: 18px;
}

.help-panel p {
  color: #e8d5b8;
  line-height: 1.5;
}

.modal-cancel {
  display: block;
  margin: 16px auto 0;
}

.meta-screen {
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 12%, rgba(148, 75, 43, 0.26), transparent 34%),
    linear-gradient(180deg, #24191c 0%, #111014 58%, #08080a 100%);
}

.menu-screen,
.setup-screen,
.preload-screen {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.menu-screen,
.preload-screen {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 26px;
  padding: 28px;
  text-align: center;
}

.menu-screen::before,
.preload-screen::before,
.setup-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 50% 38%, rgba(26, 8, 12, 0.08), rgba(0, 0, 0, 0.48) 62%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.22), rgba(0, 0, 0, 0.58));
}

.menu-bg-video {
  position: absolute;
  inset: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-hero {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.82);
}

.sigil.large {
  width: 82px;
  height: 82px;
  font-size: 52px;
}

.brand-hero h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 56px;
}

.brand-hero p,
.meta-note {
  color: var(--muted);
}

.menu-actions {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  justify-content: center;
}

.continue-button {
  position: relative;
  min-width: 150px;
}

.start-confirm-panel {
  display: grid;
  gap: 20px;
  width: min(420px, calc(100vw - 42px));
  text-align: center;
}

.start-confirm-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 12px;
}

.menu-screen .meta-note {
  position: relative;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.82);
}

.preload-panel {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  width: min(420px, calc(100vw - 48px));
  padding: 28px;
  border: 1px solid rgba(238, 190, 112, 0.28);
  border-radius: 8px;
  background: rgba(13, 10, 12, 0.62);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.52);
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.82);
}

.preload-panel h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 46px;
}

.preload-panel p {
  color: var(--muted);
}

.preload-bar {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(238, 190, 112, 0.35);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.38);
}

.preload-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #b5602a, #f2d084);
  transition: width 160ms ease;
}

.meta-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(16, 13, 15, 0.72);
}

.meta-header span {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.meta-header h1 {
  margin-top: 5px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 32px;
}

.setup-screen,
.map-screen,
.mistake-screen,
.shop-screen,
.reward-screen {
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.reward-choice-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 18px;
  width: min(1080px, calc(100vw - 48px));
  margin: 44px auto 22px;
}

.reward-card {
  display: grid;
  grid-template-rows: 38px auto minmax(74px, auto) minmax(70px, auto) 48px;
  gap: 14px;
  min-height: 430px;
  padding: 24px;
  color: var(--ink);
  border: 1px solid rgba(238, 190, 112, 0.32);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(220, 166, 77, 0.16), transparent 42%),
    rgba(12, 10, 12, 0.72);
  text-align: center;
}

.reward-card h2 {
  align-self: center;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
}

.reward-art {
  position: relative;
  display: grid;
  aspect-ratio: 4 / 3;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(238, 190, 112, 0.26);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 35%, rgba(239, 199, 118, 0.2), transparent 36%),
    rgba(255, 246, 205, 0.08);
}

.reward-art img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.reward-art img[src$=".png"] {
  min-height: 100%;
}

.reward-art span {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 5px 8px;
  color: #2a1b12;
  font-size: 12px;
  font-weight: 900;
  border-radius: 999px;
  background: rgba(239, 199, 118, 0.88);
}

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

.reward-effect {
  min-height: 50px;
  padding: 12px;
  border: 1px solid rgba(238, 190, 112, 0.18);
  border-radius: 6px;
  background: rgba(255, 246, 205, 0.07);
}

.reward-card .reward-flavor {
  color: #f0dfbd;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
  font-style: italic;
}

.reward-card .end-turn {
  width: 100%;
}

.merchant-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 22px;
  width: min(1180px, calc(100vw - 48px));
  margin: 44px auto 22px;
}

.merchant-wallet {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 24px;
  border: 1px solid rgba(238, 190, 112, 0.32);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 0%, rgba(220, 166, 77, 0.18), transparent 42%),
    rgba(12, 10, 12, 0.72);
}

.merchant-wallet span,
.merchant-wallet small {
  color: var(--muted);
  font-weight: 800;
}

.merchant-wallet strong {
  color: var(--gold);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 72px;
  line-height: 1;
}

.merchant-wallet .ghost-button {
  width: 100%;
  margin-top: 20px;
}

.merchant-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 16px;
}

.merchant-item {
  display: grid;
  gap: 14px;
  min-height: 240px;
  padding: 22px;
  border: 1px solid rgba(238, 190, 112, 0.28);
  border-radius: 8px;
  background: rgba(12, 10, 12, 0.62);
}

.merchant-item span {
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
}

.merchant-item h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 26px;
}

.merchant-item p {
  color: var(--muted);
  line-height: 1.5;
}

.merchant-item.bought {
  border-color: rgba(132, 190, 94, 0.72);
}

.setup-form {
  display: grid;
  gap: 24px;
  width: min(980px, calc(100vw - 48px));
  margin: 36px auto;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.grade-grid {
  grid-template-columns: repeat(6, minmax(90px, 1fr));
}

.grade-select-panel {
  align-content: center;
  min-height: 54vh;
}

.choice-card {
  display: grid;
  gap: 6px;
  min-height: 112px;
  place-items: center;
  color: var(--ink);
  border: 1px solid rgba(238, 190, 112, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
    rgba(8, 7, 9, 0.54);
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease;
}

.choice-card:hover,
.choice-card:focus-visible {
  outline: none;
  border-color: rgba(244, 209, 136, 0.78);
  background:
    linear-gradient(180deg, rgba(233, 183, 90, 0.18), transparent),
    rgba(31, 25, 25, 0.86);
  transform: translateY(-4px);
}

.choice-card span {
  font-size: 22px;
  font-weight: 900;
}

.choice-card small {
  color: var(--muted);
}

.start-run-button {
  justify-self: center;
}

.difficulty-backdrop {
  position: absolute;
  inset: 0;
  z-index: 14;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 34%, rgba(162, 83, 43, 0.38), transparent 38%),
    rgba(0, 0, 0, 0.72);
}

.difficulty-select {
  width: min(1120px, calc(100vw - 48px));
  padding: 24px;
  border: 1px solid rgba(238, 190, 112, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(51, 34, 29, 0.94), rgba(12, 10, 13, 0.98)),
    var(--panel-strong);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.62);
}

.difficulty-select header {
  text-align: center;
}

.difficulty-select header span {
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
}

.difficulty-select h2 {
  margin: 8px 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
}

.difficulty-select header p {
  color: var(--muted);
}

.difficulty-roster {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.difficulty-hero {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  min-height: 312px;
  padding: 12px 12px 16px;
  color: var(--ink);
  text-align: center;
  border: 1px solid rgba(238, 190, 112, 0.28);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 232, 174, 0.14), transparent 28%),
    linear-gradient(160deg, rgba(61, 34, 35, 0.98), rgba(13, 12, 16, 0.98));
  box-shadow: 0 20px 46px rgba(0, 0, 0, 0.42);
  cursor: pointer;
  opacity: 0;
  animation: heroRise 420ms ease forwards;
  animation-delay: var(--delay);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease;
}

.difficulty-hero:hover,
.difficulty-hero:focus-visible {
  z-index: 2;
  outline: none;
  border-color: rgba(244, 209, 136, 0.86);
  box-shadow:
    0 28px 60px rgba(0, 0, 0, 0.56),
    0 0 28px rgba(220, 166, 77, 0.22);
  filter: brightness(1.08);
  transform: translateY(-10px) scale(1.03);
}

.difficulty-hero.medium {
  background:
    radial-gradient(circle at 50% 18%, rgba(140, 209, 221, 0.14), transparent 28%),
    linear-gradient(160deg, rgba(36, 61, 67, 0.98), rgba(13, 12, 16, 0.98));
}

.difficulty-hero.hard {
  background:
    radial-gradient(circle at 50% 18%, rgba(180, 98, 214, 0.13), transparent 28%),
    linear-gradient(160deg, rgba(56, 38, 72, 0.98), rgba(13, 12, 16, 0.98));
}

.difficulty-hero.challenge {
  background:
    radial-gradient(circle at 50% 18%, rgba(222, 92, 62, 0.18), transparent 28%),
    linear-gradient(160deg, rgba(82, 31, 28, 0.98), rgba(13, 12, 16, 0.98));
}

.hero-portrait {
  position: relative;
  display: grid;
  width: 100%;
  min-height: 248px;
  aspect-ratio: 4 / 5;
  place-items: end center;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(238, 190, 112, 0.22);
  border-radius: 46% 46% 8px 8px;
  background:
    radial-gradient(circle at 50% 20%, rgba(255, 238, 184, 0.18), transparent 23%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(0, 0, 0, 0.28));
}

.hero-portrait strong {
  align-self: end;
  margin-bottom: 26px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 34px;
  text-shadow: 0 8px 20px rgba(0, 0, 0, 0.48);
}

.spine-mount {
  width: 100%;
  height: 100%;
}

.spine-mount canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.spine-mount[data-spine-error="true"] {
  display: grid;
  place-items: end center;
  padding-bottom: 26px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 900;
}

.difficulty-spine {
  position: absolute;
  inset: -12% -14% -8%;
  width: auto;
  height: auto;
}

.difficulty-spine[data-spine-id="player_02"] {
  inset: -12% -13% -12% -13%;
}

.difficulty-spine[data-spine-id="player_03"] {
  inset: -26% -20% -14% -20%;
  transform: translate(-6%, -14%) scale(1.05);
  transform-origin: center center;
}

.difficulty-spine[data-spine-id="player_04"] {
  inset: -16% -13% -11% -13%;
}

.difficulty-spine[data-spine-id="player_01"] {
  inset: -12% -14% -10% -10%;
}

.combat-spine {
  position: absolute;
  inset: -18% -22% -2%;
  --spine-x: 0%;
  --spine-y: 0%;
  --spine-scale: 1;
  --spine-facing: 1;
  width: auto;
  height: auto;
  transform: translate(var(--spine-x), var(--spine-y)) scaleX(var(--spine-facing)) scale(var(--spine-scale));
  transform-origin: center bottom;
}

.character-art.player .combat-spine {
  --spine-facing: -1;
}

.character-art.monster .combat-spine {
  --spine-y: 18%;
}

.difficulty-title {
  color: var(--gold);
  font-size: 22px;
  font-weight: 900;
}

@keyframes heroRise {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes player-combat-hit {
  0% {
    filter: brightness(1);
    transform: translateX(0);
  }
  18% {
    filter: brightness(1.3) saturate(1.4);
    transform: translateX(-10px);
  }
  36% {
    transform: translateX(8px);
  }
  54% {
    filter: brightness(1.18) saturate(1.2);
    transform: translateX(-5px);
  }
  100% {
    filter: brightness(1);
    transform: translateX(0);
  }
}

@keyframes combat-float-rise {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.82);
  }
  16% {
    opacity: 1;
    transform: translateY(0) scale(1.08);
  }
  70% {
    opacity: 1;
    transform: translateY(-12px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px) scale(0.94);
  }
}

@keyframes card-flight {
  0% {
    opacity: 1;
    transform: translate3d(var(--from-x), var(--from-y), 0) translate(-50%, -50%) rotate(var(--from-rotate, 0deg)) scale(1);
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--to-x), var(--to-y), 0) translate(-50%, -50%) rotate(var(--to-rotate, -10deg)) scale(0.42);
  }
}

@keyframes card-flight-pause {
  0% {
    opacity: 1;
    transform: translate3d(var(--from-x), var(--from-y), 0) translate(-50%, -50%) rotate(var(--from-rotate, 0deg)) scale(1);
  }
  42% {
    opacity: 1;
    transform: translate3d(var(--mid-x), var(--mid-y), 0) translate(-50%, -50%) rotate(var(--mid-rotate, -2deg)) scale(0.82);
  }
  56% {
    opacity: 1;
    transform: translate3d(var(--mid-x), var(--mid-y), 0) translate(-50%, -50%) rotate(var(--mid-rotate, -2deg)) scale(0.82);
  }
  82% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--to-x), var(--to-y), 0) translate(-50%, -50%) rotate(var(--to-rotate, -10deg)) scale(0.42);
  }
}

@keyframes slash-burst {
  0% {
    opacity: 0;
    filter: blur(5px);
    transform: translate(-50%, -50%) rotate(-18deg) scale(0.55);
  }
  38% {
    opacity: 1;
    filter: blur(0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-18deg) scale(1.24);
  }
}

@keyframes impact-ring {
  from {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.34);
  }
  to {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.7);
  }
}

@keyframes shield-pop {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.45);
  }
  36% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -62%) scale(1.16);
  }
}

@keyframes aura-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -42%) rotateX(66deg) scale(0.52);
  }
  35% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -58%) rotateX(66deg) scale(1.28);
  }
}

@keyframes number-rise {
  0% {
    opacity: 0;
    transform: translate(-50%, -20%) scale(0.72);
  }
  24% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -118%) scale(1.08);
  }
}

@keyframes number-rise-dramatic {
  0% {
    opacity: 0;
    filter: blur(2px);
    transform: translate(-50%, 8%) scale(0.42) rotate(-8deg);
  }
  18% {
    opacity: 1;
    filter: blur(0);
    transform: translate(-50%, -34%) scale(1.38) rotate(3deg);
  }
  34% {
    transform: translate(-50%, -52%) scale(1.08) rotate(0deg);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -156%) scale(1.2) rotate(0deg);
  }
}

@keyframes hit-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(12px);
  }
  42% {
    transform: translateX(-8px);
  }
  64% {
    transform: translateX(5px);
  }
}

@keyframes guard-pulse {
  0%,
  100% {
    filter: none;
  }
  45% {
    filter: drop-shadow(0 0 24px rgba(105, 183, 238, 0.78));
  }
}

@keyframes power-pulse {
  0%,
  100% {
    filter: none;
  }
  45% {
    filter: drop-shadow(0 0 26px rgba(238, 202, 112, 0.8));
  }
}

.map-stats {
  display: flex;
  gap: 10px;
}

.route-map-layout {
  display: block;
  width: min(1680px, calc(100vw - 42px));
  margin: 18px auto;
}

.parchment-map {
  position: relative;
  min-height: min(760px, calc(100vh - 230px));
  overflow: hidden;
  border: 2px solid rgba(92, 60, 39, 0.58);
  border-radius: 6px;
  background:
    radial-gradient(circle at 20% 40%, rgba(255, 226, 156, 0.25), transparent 18%),
    radial-gradient(circle at 70% 72%, rgba(126, 78, 35, 0.2), transparent 20%),
    linear-gradient(90deg, rgba(96, 58, 31, 0.18), transparent 7%, transparent 93%, rgba(96, 58, 31, 0.18)),
    #b99d70;
  box-shadow:
    inset 0 0 44px rgba(79, 48, 28, 0.46),
    0 22px 58px rgba(0, 0, 0, 0.38);
}

.parchment-map::before,
.parchment-map::after {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
}

.parchment-map::before {
  background:
    repeating-linear-gradient(0deg, rgba(65, 43, 28, 0.05) 0 1px, transparent 1px 32px),
    repeating-linear-gradient(90deg, rgba(65, 43, 28, 0.04) 0 1px, transparent 1px 42px);
}

.parchment-map::after {
  border: 10px solid rgba(67, 41, 25, 0.18);
  box-shadow: inset 0 0 0 1px rgba(244, 217, 157, 0.18);
}

.route-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.route-lines path {
  fill: none;
  stroke: rgba(75, 58, 43, 0.44);
  stroke-width: 4px;
  stroke-dasharray: 10 13;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.route-lines path.available {
  stroke: rgba(87, 73, 49, 0.78);
  stroke-width: 4px;
}

.route-lines path.used {
  stroke: rgba(99, 121, 62, 0.88);
  stroke-width: 5px;
  stroke-dasharray: none;
}

.route-node {
  --node-size: 66px;
  --node-icon-size: 42px;
  position: absolute;
  z-index: 2;
  display: grid;
  width: var(--node-size);
  height: var(--node-size);
  place-items: center;
  padding: 4px;
  color: rgba(59, 45, 35, 0.74);
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: default;
  opacity: 0.58;
  transform: translate(-50%, -50%);
}

.route-node span {
  display: grid;
  width: var(--node-icon-size);
  height: var(--node-icon-size);
  place-items: center;
  color: #35291f;
  font-weight: 900;
  border: 3px solid rgba(64, 45, 32, 0.28);
  border-radius: 50%;
  background: rgba(88, 66, 43, 0.22);
}

.route-node img,
.modal-node-icon img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.route-node b,
.modal-node-icon b {
  display: none;
}

.route-node svg,
.modal-node-icon svg {
  width: 68%;
  height: 68%;
  fill: none;
  stroke: currentColor;
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.route-node.normal svg,
.route-node.boss svg {
  fill: currentColor;
  fill-opacity: 0.16;
}

.route-node small {
  position: absolute;
  top: calc(var(--node-size) - 16px);
  color: rgba(49, 37, 28, 0.7);
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.route-node.available {
  opacity: 1;
  cursor: pointer;
  animation: mapPulse 1.6s ease-in-out infinite;
}

.route-node.available span {
  color: #21130d;
  border-color: rgba(251, 225, 159, 0.88);
  background: rgba(245, 207, 116, 0.82);
  box-shadow:
    0 0 20px rgba(223, 173, 75, 0.38),
    inset 0 0 0 2px rgba(255, 247, 208, 0.36);
}

.route-node.selected {
  z-index: 5;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.16);
}

.route-node.boss.selected {
  transform: translate(-50%, -50%) scale(1.06);
}

.route-node.selected span {
  border-color: rgba(255, 250, 215, 0.96);
  background: rgba(251, 217, 118, 0.94);
  box-shadow:
    0 0 0 8px rgba(244, 194, 82, 0.22),
    0 0 28px rgba(245, 202, 96, 0.55),
    inset 0 0 0 2px rgba(255, 252, 226, 0.46);
}

.route-node.visited {
  opacity: 1;
}

.route-node.visited span {
  color: #eaf0d0;
  border-color: rgba(169, 204, 112, 0.75);
  background: rgba(90, 119, 58, 0.68);
}

.route-node.start span,
.modal-node-icon.start {
  color: #704322;
}

.route-node.normal span,
.modal-node-icon.normal {
  color: #5e2f22;
}

.route-node.elite span,
.modal-node-icon.elite {
  color: #4b214d;
}

.route-node.event span,
.route-node.unknown span,
.modal-node-icon.event,
.modal-node-icon.unknown {
  color: #5e4b22;
}

.route-node.shop span,
.modal-node-icon.shop {
  color: #7a5b11;
}

.route-node.start {
  --node-size: 99px;
  --node-icon-size: 63px;
}

.route-node.boss {
  --node-size: 215px;
  --node-icon-size: 145px;
}

.route-node.boss span,
.modal-node-icon.boss {
  color: #5b1e1f;
}

.route-node.boss span {
  font-size: 20px;
}

.route-node.start span,
.route-node.boss span {
  border-width: 4px;
  box-shadow: inset 0 0 0 2px rgba(255, 244, 205, 0.22);
}

.route-node:hover:not(:disabled),
.route-node:focus-visible:not(:disabled) {
  outline: none;
  z-index: 4;
  transform: translate(-50%, -50%) scale(1.1);
}

.route-node.boss:hover:not(:disabled),
.route-node.boss:focus-visible:not(:disabled) {
  transform: translate(-50%, -50%) scale(1.04);
}

.map-node-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 12, 16, 0.42);
  backdrop-filter: blur(2px);
}

.map-node-modal {
  position: relative;
  display: grid;
  width: min(420px, calc(100vw - 40px));
  gap: 14px;
  justify-items: center;
  padding: 28px;
  color: #f5e5c2;
  border: 2px solid rgba(222, 178, 98, 0.52);
  border-radius: 6px;
  background:
    radial-gradient(circle at 50% 0%, rgba(221, 178, 93, 0.16), transparent 42%),
    rgba(26, 32, 33, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.54);
}

.modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #f0dba7;
  border: 1px solid rgba(240, 219, 167, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.modal-node-icon {
  display: grid;
  width: 76px;
  height: 76px;
  place-items: center;
  padding: 8px;
  border: 3px solid rgba(242, 211, 136, 0.56);
  border-radius: 50%;
  background: rgba(244, 210, 130, 0.16);
}

.map-node-modal > span {
  color: #e7c777;
  font-size: 12px;
  font-weight: 900;
}

.map-node-modal h2 {
  font-size: 28px;
  text-align: center;
}

.node-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
}

.node-preview-grid > div {
  min-height: 86px;
  padding: 14px;
  border: 1px solid rgba(242, 211, 136, 0.2);
  border-radius: 6px;
  background: rgba(255, 246, 205, 0.08);
}

.node-preview-grid small {
  display: block;
  color: rgba(245, 229, 194, 0.68);
  font-size: 12px;
  font-weight: 900;
}

.node-preview-grid strong {
  display: block;
  margin-top: 8px;
  color: #fff0c2;
  line-height: 1.35;
}

.node-start-copy {
  width: 100%;
  margin: 0;
  padding: 16px;
  color: #f1dfbb;
  text-align: center;
  line-height: 1.55;
  border: 1px solid rgba(242, 211, 136, 0.2);
  border-radius: 6px;
  background: rgba(255, 246, 205, 0.08);
}

.event-result-modal p {
  margin: 0;
  color: #e9d7b8;
  text-align: center;
  line-height: 1.55;
}

.event-result-modal > strong {
  width: 100%;
  padding: 14px;
  color: #fff0c2;
  text-align: center;
  line-height: 1.45;
  border: 1px solid rgba(242, 211, 136, 0.24);
  border-radius: 6px;
  background: rgba(255, 246, 205, 0.08);
}

.map-node-modal .end-turn {
  width: 100%;
  min-height: 48px;
}

@keyframes mapPulse {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(1.18);
  }
}

.meta-log {
  max-height: 96px;
}

.mistake-screen {
  place-items: start center;
}

.mistake-screen .meta-header {
  width: 100%;
}

.mistake-panel {
  display: grid;
  gap: 16px;
  width: min(620px, calc(100vw - 36px));
  margin-top: 48px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.mistake-panel small {
  color: var(--gold);
  font-weight: 800;
}

.mistake-panel > strong {
  font-size: 28px;
}

@media (max-width: 1119px) {
  body {
    overflow: hidden;
  }

  #app {
    width: 100vw;
    height: 100vh;
    overflow: hidden;
  }

  .game-shell {
    grid-template-rows: 82px minmax(320px, 1fr) 210px 76px;
    width: 100vw;
    height: 100vh;
  }

  .top-bar {
    padding-inline: 16px;
  }

  .brand-lockup h1 {
    font-size: 24px;
  }

  .run-stats {
    display: none;
  }

  .stage {
    grid-template-columns: minmax(210px, 1fr) minmax(180px, 220px) minmax(210px, 1fr);
    gap: 14px;
    padding: 22px 18px 18px;
  }

  .entity {
    min-height: 390px;
  }

  .intent-spire {
    width: 34px;
    height: 34px;
    margin-bottom: 8px;
    font-size: 19px;
  }

  .character-art {
    width: 210px;
    height: 267px;
  }

  .character-art span {
    font-size: 70px;
  }

  .entity-plate {
    width: 100%;
    max-width: 260px;
    padding: 12px;
  }

  .entity-plate h2 {
    font-size: 19px;
  }

  .phase-banner {
    padding: 14px 12px;
  }

  .phase-banner strong {
    font-size: 25px;
  }

  .combat-floor {
    grid-template-columns: 132px 1fr 132px;
    gap: 10px;
    padding: 10px 12px 14px;
  }

  .energy-orb {
    width: 82px;
    height: 82px;
  }

  .hand {
    gap: 7px;
    min-height: 172px;
  }

  .card {
    width: clamp(92px, 14vw, 124px);
    height: 164px;
    padding: 13px 10px 11px;
  }

  .card strong {
    font-size: 16px;
  }

  .card p {
    font-size: 12px;
  }

  .end-turn,
  .ghost-button {
    width: 118px;
  }

  .log-panel {
    padding: 9px 16px;
  }

  .merchant-layout {
    grid-template-columns: 1fr;
    width: min(760px, calc(100vw - 36px));
    margin-top: 24px;
  }

  .merchant-wallet {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .merchant-wallet strong {
    grid-row: span 2;
    font-size: 56px;
  }

  .merchant-wallet .ghost-button {
    grid-column: 1 / -1;
    justify-self: start;
    width: 180px;
    margin-top: 4px;
  }

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

  .reward-choice-layout {
    grid-template-columns: 1fr;
    width: min(560px, calc(100vw - 36px));
    margin-top: 24px;
  }
}

@media (max-width: 700px) {
  .game-shell {
    grid-template-rows: 70px minmax(284px, 1fr) 190px 76px;
  }

  .top-bar {
    padding: 10px 12px;
  }

  .sigil {
    width: 42px;
    height: 42px;
    font-size: 26px;
  }

  .brand-lockup {
    gap: 10px;
  }

  .brand-lockup h1 {
    font-size: 22px;
  }

  .brand-lockup p {
    font-size: 12px;
  }

  .stage {
    grid-template-columns: minmax(150px, 1fr) 150px minmax(150px, 1fr);
    gap: 8px;
    padding: 16px 10px 12px;
  }

  .entity {
    min-height: 320px;
  }

  .intent-spire {
    width: 30px;
    height: 30px;
    font-size: 17px;
  }

  .character-art {
    width: 162px;
    height: 210px;
  }

  .character-art span {
    font-size: 54px;
  }

  .entity-plate {
    max-width: 178px;
    padding: 10px;
  }

  .entity-plate h2 {
    font-size: 17px;
  }

  .hp-bar {
    height: 20px;
  }

  .phase-banner {
    padding: 12px 8px;
  }

  .phase-banner strong {
    font-size: 22px;
  }

  .phase-banner small {
    font-size: 12px;
  }

  .combat-floor {
    grid-template-columns: 86px 1fr 92px;
    gap: 6px;
    padding: 8px 8px 12px;
  }

  .energy-orb {
    width: 70px;
    height: 70px;
  }

  .energy-orb strong {
    font-size: 30px;
  }

  .energy-orb span {
    margin-top: -14px;
  }

  .pile-counts {
    gap: 4px;
  }

  .pile-count {
    min-width: 40px;
    padding: 6px;
  }

  .hand {
    gap: 4px;
    min-height: 156px;
  }

  .card {
    width: clamp(62px, 12.5vw, 78px);
    height: 146px;
    padding: 10px 7px;
  }

  .cost {
    width: 23px;
    height: 23px;
    top: 7px;
    left: 7px;
  }

  .card-type {
    margin-left: 27px;
    font-size: 10px;
  }

  .card strong {
    margin-top: 20px;
    font-size: 14px;
  }

  .card p {
    margin-top: 10px;
    font-size: 11px;
    line-height: 1.3;
  }

  .end-turn,
  .ghost-button {
    width: 86px;
    min-height: 42px;
    font-size: 13px;
  }

  .log-panel p {
    font-size: 12px;
  }

  .math-modal {
    width: calc(100vw - 24px);
    padding: 22px;
  }

  .meta-header {
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
  }

  .map-stats {
    display: none;
  }

  .choice-grid,
  .grade-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .difficulty-select {
    max-height: calc(100vh - 32px);
    overflow: auto;
    padding: 18px;
  }

  .difficulty-roster {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .difficulty-hero {
    min-height: 260px;
  }

  .hero-portrait strong {
    font-size: 26px;
  }

  .route-map-layout {
    width: calc(100vw - 24px);
  }

  .parchment-map {
    min-height: 460px;
  }

  .route-node {
    --node-size: 54px;
    --node-icon-size: 34px;
  }

  .route-node.start {
    --node-size: 81px;
    --node-icon-size: 51px;
  }

  .route-node.boss {
    --node-size: 135px;
    --node-icon-size: 91px;
  }

  .route-node span {
    font-size: 13px;
  }

  .route-node small {
    display: none;
  }

  .problem-panel strong {
    font-size: 22px;
  }

  .answer-row {
    grid-template-columns: 1fr;
  }

  .remainder-answer,
  .fraction-answer {
    grid-template-columns: 1fr;
  }

  .remainder-mark,
  .fraction-line {
    justify-self: center;
  }

  .fraction-line {
    width: 100%;
  }

  .answer-row .end-turn {
    width: 100%;
  }

  .merchant-wallet {
    grid-template-columns: 1fr;
  }

  .merchant-wallet strong {
    grid-row: auto;
    font-size: 46px;
  }

  .merchant-wallet .ghost-button,
  .merchant-grid .end-turn {
    width: 100%;
  }

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

.merchant-item {
    min-height: 0;
  }
}

.status-cinematic-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.72);
  pointer-events: all;
  animation: status-cinematic-in-out 2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.status-cinematic-overlay img {
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  filter: drop-shadow(0 0 22px rgba(255, 235, 168, 0.22));
  transform-origin: center;
  animation: status-cinematic-image 2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  user-select: none;
  -webkit-user-drag: none;
}

@keyframes status-cinematic-in-out {
  0% {
    opacity: 0;
    backdrop-filter: blur(0);
  }

  16% {
    opacity: 1;
    backdrop-filter: blur(1px);
  }

  78% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    backdrop-filter: blur(0);
  }
}

@keyframes status-cinematic-image {
  0% {
    opacity: 0;
    transform: scale(1.08);
    filter: brightness(1.7) drop-shadow(0 0 34px rgba(255, 255, 255, 0.28));
  }

  18% {
    opacity: 1;
    transform: scale(1);
  }

  74% {
    opacity: 1;
    transform: scale(1.015);
  }

  100% {
    opacity: 0;
    transform: scale(1.03);
    filter: brightness(0.9) drop-shadow(0 0 14px rgba(255, 255, 255, 0.12));
  }
}
