:root {
  color-scheme: dark;
  --bg: #111213;
  --panel: rgba(21, 22, 24, 0.88);
  --panel-strong: rgba(28, 29, 31, 0.95);
  --line: rgba(235, 220, 184, 0.18);
  --text: #f3ead8;
  --muted: #b7aa94;
  --gold: #d6ad58;
  --red: #b63b34;
  --red-bright: #e05042;
  --jade: #78b69b;
  --blue: #6f95c9;
  --ink: #07080a;
  --card: #ead9b7;
  --card-text: #2b2018;
  font-family:
    ui-serif, "Songti SC", STSong, "Noto Serif CJK SC", Georgia, serif;
}

* {
  box-sizing: border-box;
}

html,
body,
#app {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 12%, rgba(182, 59, 52, 0.22), transparent 30%),
    radial-gradient(circle at 80% 2%, rgba(111, 149, 201, 0.16), transparent 28%),
    linear-gradient(135deg, #0a0b0d 0%, #17181a 44%, #0d1113 100%);
  color: var(--text);
}

button {
  min-height: 38px;
  border: 1px solid rgba(214, 173, 88, 0.45);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(66, 61, 51, 0.98), rgba(35, 34, 32, 0.98));
  color: var(--text);
  cursor: pointer;
  font: inherit;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    background 140ms ease,
    opacity 140ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(232, 197, 119, 0.9);
  background: linear-gradient(180deg, rgba(83, 75, 58, 0.98), rgba(45, 42, 36, 0.98));
}

button:disabled,
.disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.primary {
  border-color: rgba(224, 80, 66, 0.85);
  background: linear-gradient(180deg, #bc463e, #822a28);
  color: #fff4e5;
}

.app {
  min-height: 100vh;
}

.title-screen,
.end-screen {
  position: relative;
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 0.95fr) minmax(360px, 1.05fr);
  gap: 42px;
  align-items: center;
  padding: clamp(24px, 5vw, 70px);
  overflow: hidden;
}

.title-screen::before,
.end-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.026) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, black, transparent 78%);
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 680px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--jade);
  font-size: 0.82rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 20px;
  max-width: 760px;
  font-size: clamp(3rem, 8vw, 7.4rem);
  line-height: 0.96;
  color: #fff0d0;
  text-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.55rem, 3vw, 2.5rem);
  color: #fff0d0;
}

h3 {
  margin-bottom: 12px;
  font-size: 1.05rem;
  color: #f8ddb0;
}

.lede {
  max-width: 620px;
  color: #d8c8aa;
  font-size: clamp(1rem, 2vw, 1.22rem);
  line-height: 1.9;
}

.difficulty-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.difficulty-row button {
  min-width: 132px;
  padding: 0 18px;
}

.title-art {
  position: relative;
  z-index: 1;
  min-height: 440px;
  display: grid;
  place-items: center;
}

.title-art img {
  width: min(100%, 820px);
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border: 1px solid rgba(214, 173, 88, 0.32);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 8px clamp(12px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 9, 11, 0.86);
  backdrop-filter: blur(14px);
}

.brand {
  flex: 1;
  min-width: 148px;
  color: #f6dfad;
  font-weight: 800;
}

.stat {
  min-width: max-content;
  padding: 7px 10px;
  border: 1px solid rgba(214, 173, 88, 0.18);
  border-radius: 6px;
  color: #e8d9ba;
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.92rem;
}

.icon-btn {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.audio-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
  padding: 4px 6px;
  border: 1px solid rgba(214, 173, 88, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
}

.audio-toggle {
  font-weight: 900;
}

.audio-toggle.off {
  border-color: rgba(183, 170, 148, 0.25);
  color: var(--muted);
}

.volume-slider {
  width: 92px;
  accent-color: var(--gold);
}

.title-audio {
  position: absolute;
  top: clamp(16px, 3vw, 28px);
  right: clamp(16px, 3vw, 28px);
  z-index: 2;
}

.end-card .audio-controls {
  justify-content: center;
  width: max-content;
  margin: 18px auto 0;
}

.layout,
.combat-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 20px;
  padding: 22px clamp(12px, 3vw, 28px) 28px;
}

.panel,
.log-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.3);
  animation: panelRise 360ms ease both;
}

.panel {
  padding: clamp(18px, 3vw, 28px);
}

@keyframes panelRise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.hint {
  color: var(--muted);
  line-height: 1.7;
}

.route-map {
  display: grid;
  grid-template-columns: repeat(5, minmax(96px, 1fr));
  grid-template-rows: repeat(8, 86px);
  gap: 12px;
  min-height: 760px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(116, 44, 40, 0.2), transparent 36%),
    rgba(5, 7, 9, 0.36);
}

.map-node {
  position: relative;
  --node-opacity: 0.38;
  width: 100%;
  min-height: 76px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 2px;
  padding: 8px;
  opacity: 0.38;
  transform: translateY(0);
  animation: mapNodeIn 280ms ease both;
  animation-delay: calc(var(--i, 0) * 42ms + var(--lane, 0) * 18ms);
}

.map-node.available {
  --node-opacity: 1;
  opacity: 1;
  box-shadow: 0 0 0 2px rgba(224, 80, 66, 0.22), 0 0 24px rgba(224, 80, 66, 0.2);
  animation:
    mapNodeIn 280ms ease both,
    nodeBreath 1800ms ease-in-out 320ms infinite;
}

.map-node.available::after {
  content: "";
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(244, 199, 111, 0.45);
  border-radius: inherit;
  opacity: 0;
  animation: nodeRing 1800ms ease-out infinite;
}

.map-node.visited {
  --node-opacity: 0.62;
  opacity: 0.62;
  border-color: rgba(120, 182, 155, 0.55);
}

.map-node span {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(214, 173, 88, 0.14);
  color: #f1d389;
  font-weight: 800;
  transition: transform 160ms ease;
}

.map-node.available span {
  animation: nodeIconFloat 1600ms ease-in-out infinite;
}

.map-node strong {
  font-size: 0.9rem;
}

.map-node small {
  color: var(--muted);
  font-size: 0.72rem;
}

@keyframes mapNodeIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: var(--node-opacity);
    transform: translateY(0) scale(1);
  }
}

@keyframes nodeBreath {
  0%,
  100% {
    transform: translateY(0) scale(1);
    box-shadow: 0 0 0 2px rgba(224, 80, 66, 0.2), 0 0 22px rgba(224, 80, 66, 0.16);
  }
  50% {
    transform: translateY(-2px) scale(1.025);
    box-shadow: 0 0 0 2px rgba(240, 202, 116, 0.32), 0 0 34px rgba(224, 80, 66, 0.32);
  }
}

@keyframes nodeRing {
  0% {
    opacity: 0.58;
    transform: scale(0.96);
  }
  100% {
    opacity: 0;
    transform: scale(1.16);
  }
}

@keyframes nodeIconFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-3px);
  }
}

.log-panel {
  align-self: start;
  position: sticky;
  top: 78px;
  padding: 18px;
}

.log-panel p {
  margin: 0 0 12px;
  color: #d1c2a7;
  font-size: 0.92rem;
  line-height: 1.55;
}

.combat-layout {
  grid-template-columns: minmax(0, 1fr) 310px;
}

.battlefield {
  min-width: 0;
}

.arena {
  position: relative;
  --fighter-half-width: max(105px, min(17vw, 170px));
  --player-anchor-x: calc(6% + var(--fighter-half-width));
  --enemy-anchor-x: calc(94% - var(--fighter-half-width));
  --player-anchor-y: 45%;
  --enemy-anchor-y: 43%;
  min-height: 480px;
  overflow: hidden;
  border: 1px solid rgba(214, 173, 88, 0.28);
  border-radius: 8px;
  background: #101113;
  animation: arenaIn 420ms ease both;
}

.arena-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.78;
  transform: scale(1.035);
  animation: battlefieldDrift 16s ease-in-out infinite alternate;
}

.arena::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 12%, rgba(0, 0, 0, 0.28) 62%, rgba(0, 0, 0, 0.6));
  pointer-events: none;
}

.arena-atmosphere {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.arena-atmosphere span {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: rgba(255, 179, 91, 0.78);
  box-shadow: 0 0 12px rgba(255, 128, 54, 0.8);
  transform: scale(var(--scale));
  animation: emberRise 4200ms ease-in infinite;
  animation-delay: var(--delay);
}

@keyframes arenaIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes battlefieldDrift {
  from {
    transform: scale(1.035) translateX(-8px);
  }
  to {
    transform: scale(1.07) translateX(8px);
  }
}

@keyframes emberRise {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(var(--scale));
  }
  12% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translateY(-120px) translateX(32px) scale(calc(var(--scale) * 0.65));
  }
}

.fighter {
  position: absolute;
  z-index: 2;
  bottom: 28px;
  width: min(34vw, 340px);
  min-width: 210px;
}

.fighter::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 46px;
  width: 62%;
  height: 24px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.58), transparent 70%);
  transform: translateX(-50%);
  filter: blur(2px);
  opacity: 0.78;
}

.fighter.player {
  left: 6%;
}

.fighter.enemy {
  right: 6%;
}

.fighter img {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 310px;
  object-fit: contain;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.55));
  transform-origin: 50% 100%;
  animation: fighterIdle 3200ms ease-in-out infinite;
}

.fighter.enemy img {
  animation-delay: -1500ms;
}

.fighter.pulse img {
  animation: hitPulse 220ms ease;
}

.fighter.player.pulse img {
  animation-name: playerHitPulse;
}

@keyframes hitPulse {
  0% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(8px);
  }
  70% {
    transform: translateX(-5px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes playerHitPulse {
  0% {
    transform: translateX(0);
  }
  35% {
    transform: translateX(-8px);
  }
  70% {
    transform: translateX(5px);
  }
  100% {
    transform: translateX(0);
  }
}

.arena.intent-attack .fighter.enemy::after,
.arena.intent-blockAttack .fighter.enemy::after,
.arena.intent-buff .fighter.enemy::after {
  content: "";
  position: absolute;
  inset: 12% 8% 20%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(224, 80, 66, 0.26), transparent 68%);
  animation: intentAura 1300ms ease-in-out infinite;
}

.arena.intent-block .fighter.enemy::after {
  content: "";
  position: absolute;
  inset: 18% 12% 24%;
  z-index: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(116, 185, 220, 0.24), transparent 68%);
  animation: intentAura 1500ms ease-in-out infinite;
}

@keyframes fighterIdle {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-5px) rotate(0.45deg);
  }
}

@keyframes intentAura {
  0%,
  100% {
    opacity: 0.3;
    transform: scale(0.96);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.08);
  }
}

.action-layer {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
}

.battle-action {
  position: absolute;
  left: 50%;
  top: 47%;
  width: 120px;
  height: 120px;
  opacity: 0;
  transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(var(--power));
}

.battle-action.target-enemy {
  left: var(--enemy-anchor-x);
  top: var(--enemy-anchor-y);
}

.battle-action.target-player {
  left: var(--player-anchor-x);
  top: var(--player-anchor-y);
}

.battle-action.slash,
.battle-action.slash-heavy,
.battle-action.multi-slash,
.battle-action.enemy-strike {
  width: 220px;
  height: 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(255, 245, 206, 0.96), rgba(255, 107, 74, 0.82), transparent);
  filter: drop-shadow(0 0 12px rgba(255, 101, 64, 0.72));
  animation: slashSweep 520ms ease-out forwards;
}

.battle-action.slash-heavy {
  height: 26px;
  background: linear-gradient(90deg, transparent, rgba(255, 238, 178, 1), rgba(222, 60, 46, 0.96), transparent);
  animation-duration: 640ms;
}

.battle-action.multi-slash::before,
.battle-action.multi-slash::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: inherit;
}

.battle-action.multi-slash::before {
  transform: translateY(-26px) rotate(13deg);
}

.battle-action.multi-slash::after {
  transform: translateY(26px) rotate(-12deg);
}

.battle-action.enemy-strike {
  background: linear-gradient(90deg, transparent, rgba(255, 205, 151, 0.96), rgba(191, 46, 40, 0.85), transparent);
  animation-name: enemySlashSweep;
}

.battle-action.impact,
.battle-action.mark,
.battle-action.mark-burst {
  width: 120px;
  height: 120px;
  border: 2px solid rgba(255, 211, 104, 0.8);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 111, 64, 0.24), transparent 58%);
  animation: impactBurst 620ms ease-out forwards;
}

.battle-action.mark-burst {
  border-color: rgba(255, 224, 118, 0.9);
  background: radial-gradient(circle, rgba(255, 198, 73, 0.34), transparent 62%);
}

.battle-action.mark {
  border-color: rgba(255, 199, 86, 0.72);
  background: radial-gradient(circle, rgba(255, 199, 86, 0.22), transparent 62%);
}

.battle-action.guard {
  width: 150px;
  height: 190px;
  border: 3px solid rgba(153, 221, 255, 0.76);
  border-radius: 48% 48% 42% 42%;
  background: radial-gradient(ellipse, rgba(119, 198, 235, 0.18), transparent 70%);
  box-shadow: inset 0 0 22px rgba(163, 225, 255, 0.28), 0 0 22px rgba(98, 171, 204, 0.32);
  animation: guardFlash 700ms ease-out forwards;
}

.battle-action.command,
.battle-action.drum,
.battle-action.oath,
.battle-action.strategy,
.battle-action.wind {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  border: 2px solid rgba(246, 210, 126, 0.72);
  background:
    conic-gradient(from 90deg, rgba(246, 210, 126, 0), rgba(246, 210, 126, 0.44), rgba(246, 210, 126, 0)),
    radial-gradient(circle, rgba(255, 218, 135, 0.2), transparent 66%);
  animation: commandPulse 820ms ease-out forwards;
}

.battle-action.drum {
  border-color: rgba(224, 80, 66, 0.72);
  background: radial-gradient(circle, rgba(224, 80, 66, 0.28), transparent 66%);
}

.battle-action.oath {
  border-color: rgba(255, 201, 218, 0.7);
  background: radial-gradient(circle, rgba(255, 145, 178, 0.24), transparent 64%);
}

.battle-action.strategy {
  border-radius: 8px;
  border-color: rgba(120, 182, 155, 0.76);
  background:
    linear-gradient(90deg, rgba(120, 182, 155, 0.15) 0 8px, transparent 8px 18px),
    radial-gradient(circle, rgba(120, 182, 155, 0.24), transparent 64%);
}

.battle-action.wind {
  border-color: rgba(177, 224, 210, 0.76);
  background: conic-gradient(from 180deg, transparent, rgba(177, 224, 210, 0.52), transparent 42%);
}

.battle-action.arrows {
  width: 250px;
  height: 120px;
  background:
    linear-gradient(105deg, transparent 0 38%, rgba(255, 237, 178, 0.96) 39% 42%, rgba(245, 91, 54, 0.9) 43% 46%, transparent 47%),
    linear-gradient(102deg, transparent 0 48%, rgba(255, 237, 178, 0.9) 49% 52%, rgba(245, 91, 54, 0.82) 53% 56%, transparent 57%),
    linear-gradient(108deg, transparent 0 58%, rgba(255, 237, 178, 0.9) 59% 62%, rgba(245, 91, 54, 0.82) 63% 66%, transparent 67%);
  filter: drop-shadow(0 0 10px rgba(255, 99, 54, 0.74));
  animation: arrowsFall 620ms ease-out forwards;
}

.battle-action.fire {
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 80%, rgba(255, 236, 147, 0.9), transparent 18%),
    radial-gradient(circle at 44% 56%, rgba(255, 126, 62, 0.7), transparent 32%),
    radial-gradient(circle at 62% 62%, rgba(196, 43, 36, 0.58), transparent 42%);
  filter: blur(0.2px) drop-shadow(0 0 18px rgba(255, 91, 42, 0.76));
  animation: fireBloom 760ms ease-out forwards;
}

.battle-action.curse,
.battle-action.smoke {
  width: 170px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(96, 111, 112, 0.58), rgba(42, 51, 52, 0.22), transparent 70%);
  filter: blur(1px);
  animation: smokeBloom 760ms ease-out forwards;
}

.battle-action.shockwave {
  left: 52%;
  top: 58%;
  width: 360px;
  height: 90px;
  border: 3px solid rgba(255, 219, 129, 0.7);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255, 214, 116, 0.2), transparent 62%);
  animation: shockwave 860ms ease-out forwards;
}

@keyframes slashSweep {
  0% {
    opacity: 0;
    transform: translate(calc(-70% + var(--dx)), calc(-50% + var(--dy))) rotate(-24deg) scaleX(0.2);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-28% + var(--dx)), calc(-50% + var(--dy))) rotate(-24deg) scaleX(1.1);
  }
}

@keyframes enemySlashSweep {
  0% {
    opacity: 0;
    transform: translate(calc(-18% + var(--dx)), calc(-50% + var(--dy))) rotate(24deg) scaleX(0.2);
  }
  25% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-76% + var(--dx)), calc(-50% + var(--dy))) rotate(24deg) scaleX(1.08);
  }
}

@keyframes impactBurst {
  0% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.25);
  }
  22% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.35);
  }
}

@keyframes guardFlash {
  0% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.72);
  }
  24% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.08);
  }
}

@keyframes commandPulse {
  0% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.48) rotate(0deg);
  }
  28% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.18) rotate(95deg);
  }
}

@keyframes arrowsFall {
  0% {
    opacity: 0;
    transform: translate(calc(-78% + var(--dx)), calc(-96% + var(--dy))) rotate(-12deg);
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-38% + var(--dx)), calc(-18% + var(--dy))) rotate(-12deg);
  }
}

@keyframes fireBloom {
  0% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-38% + var(--dy))) scale(0.46);
  }
  36% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-58% + var(--dy))) scale(1.34);
  }
}

@keyframes smokeBloom {
  0% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-30% + var(--dy))) scale(0.6);
  }
  28% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-74% + var(--dy))) scale(1.4);
  }
}

@keyframes shockwave {
  0% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scaleX(0.18) scaleY(0.4);
  }
  22% {
    opacity: 0.96;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scaleX(1.35) scaleY(1.25);
  }
}

.float-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.float-text {
  position: absolute;
  left: var(--enemy-anchor-x);
  bottom: calc(280px + var(--dy));
  min-width: 68px;
  padding: 6px 10px;
  border: 1px solid rgba(255, 237, 184, 0.34);
  border-radius: 999px;
  background: rgba(10, 10, 12, 0.76);
  color: #ffe2a2;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
  transform: translateX(calc(-50% + var(--dx)));
  animation: floatUp 850ms ease-out forwards;
}

.float-text.player {
  left: var(--player-anchor-x);
}

.float-text.damage {
  color: #ff806b;
  border-color: rgba(255, 93, 75, 0.48);
}

.float-text.block {
  color: #aee6ff;
  border-color: rgba(98, 171, 204, 0.5);
}

.float-text.heal,
.float-text.morale,
.float-text.buff {
  color: #b9f0a8;
  border-color: rgba(116, 196, 104, 0.48);
}

.float-text.mark,
.float-text.mark-damage,
.float-text.debuff {
  color: #ffd06a;
  border-color: rgba(238, 181, 75, 0.48);
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translateX(calc(-50% + var(--dx))) translateY(14px) scale(0.94);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(calc(-50% + var(--dx))) translateY(-44px) scale(1.08);
  }
}

.plate {
  padding: 10px 12px;
  border: 1px solid rgba(214, 173, 88, 0.35);
  border-radius: 8px;
  background: rgba(11, 12, 14, 0.82);
}

.plate strong,
.plate span,
.plate em {
  display: block;
}

.plate strong {
  color: #ffe1a0;
}

.plate span,
.plate em {
  color: #d2c2a4;
  font-size: 0.84rem;
  line-height: 1.45;
}

.bar {
  width: 100%;
  height: 9px;
  overflow: hidden;
  margin: 7px 0 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.11);
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red-bright), #f1c15f);
}

.combat-hud {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  min-height: 58px;
  padding: 10px 0;
}

.combat-hud div {
  min-height: 38px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  color: #dfd0b5;
}

.hand,
.card-grid,
.deck-grid,
.shop-row,
.choice-grid,
.loot-row,
.shop-services,
.relic-row {
  display: grid;
  gap: 12px;
}

.hand {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.card-grid,
.shop-row {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.deck-grid {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  max-height: 58vh;
  overflow: auto;
  padding-right: 4px;
}

.deck-grid.compact {
  max-height: 48vh;
}

.card {
  position: relative;
  min-height: 280px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 7px;
  overflow: hidden;
  padding: 10px;
  border: 2px solid rgba(91, 58, 36, 0.65);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 252, 236, 0.9), rgba(219, 196, 151, 0.95)),
    var(--card);
  color: var(--card-text);
  text-align: left;
  box-shadow: inset 0 0 0 4px rgba(94, 54, 30, 0.12), 0 12px 26px rgba(0, 0, 0, 0.22);
  animation: cardIn 320ms ease both;
  animation-delay: calc(var(--i, 0) * 34ms);
}

.card:hover:not(.disabled) {
  transform: translateY(-7px) rotate(-0.6deg);
  box-shadow: inset 0 0 0 4px rgba(94, 54, 30, 0.12), 0 18px 34px rgba(0, 0, 0, 0.34);
}

.card:active:not(.disabled) {
  transform: translateY(-2px) scale(0.985);
}

.card::before {
  content: "";
  position: absolute;
  inset: -40% -80%;
  z-index: 2;
  background: linear-gradient(115deg, transparent 42%, rgba(255, 255, 255, 0.36) 50%, transparent 58%);
  transform: translateX(-48%) rotate(5deg);
  opacity: 0;
  pointer-events: none;
}

.card:hover:not(.disabled)::before {
  animation: cardGleam 820ms ease;
}

.card-art {
  position: relative;
  display: block;
  height: 108px;
  margin: -2px -2px 6px;
  border: 1px solid rgba(69, 37, 20, 0.45);
  border-radius: 6px;
  background-color: #2b2118;
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(255, 236, 184, 0.18);
}

.card-art::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(0, 0, 0, 0.18));
}

.card.attack .card-art::after {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.2)),
    radial-gradient(circle at 80% 20%, rgba(255, 91, 62, 0.22), transparent 36%);
}

.card.skill .card-art::after {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.2)),
    radial-gradient(circle at 24% 24%, rgba(90, 176, 218, 0.22), transparent 36%);
}

.card.power .card-art::after {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(0, 0, 0, 0.2)),
    radial-gradient(circle at 50% 12%, rgba(246, 210, 126, 0.24), transparent 38%);
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(16px) rotate(1.2deg) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
}

@keyframes cardGleam {
  0% {
    opacity: 0;
    transform: translateX(-58%) rotate(5deg);
  }
  25% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translateX(56%) rotate(5deg);
  }
}

.card.attack {
  border-color: rgba(160, 55, 42, 0.78);
}

.card.skill {
  border-color: rgba(55, 105, 132, 0.78);
}

.card.power {
  border-color: rgba(113, 93, 160, 0.78);
}

.card.status {
  border-color: rgba(77, 78, 81, 0.78);
  filter: grayscale(0.35);
}

.card .cost {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle, #ffe7a2, #9c552e);
  color: #20130a;
  font-weight: 900;
  z-index: 1;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.card strong {
  padding-right: 34px;
  color: #25130f;
  font-size: 1.02rem;
}

.card small {
  color: #684938;
}

.card p {
  margin: auto 0 0;
  min-height: 64px;
  color: #312217;
  line-height: 1.55;
}

.event-hero {
  width: 100%;
  height: 230px;
  margin: 4px 0 18px;
  object-fit: cover;
  border: 1px solid rgba(214, 173, 88, 0.28);
  border-radius: 8px;
  box-shadow: 0 20px 42px rgba(0, 0, 0, 0.25);
}

.loot-row {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin: 16px 0 24px;
}

.loot,
.choice,
.shop-item {
  padding: 16px;
  border: 1px solid rgba(214, 173, 88, 0.24);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  animation: cardIn 300ms ease both;
  animation-delay: calc(var(--i, 0) * 42ms);
}

.loot small,
.choice span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.5;
}

.choice {
  text-align: left;
}

.choice strong {
  display: block;
  color: #ffdf9b;
  font-size: 1.03rem;
}

.choice-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.story {
  max-width: 760px;
  color: #dbc9aa;
  font-size: 1.08rem;
  line-height: 1.9;
}

.shop-item {
  display: grid;
  gap: 10px;
}

.shop-item.sold {
  opacity: 0.56;
}

.shop-services {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  margin: 20px 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.7);
}

.modal-card {
  width: min(980px, 100%);
  max-height: 88vh;
  overflow: auto;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141517;
  box-shadow: 0 22px 80px rgba(0, 0, 0, 0.52);
}

.relic-row {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.relic-row span,
.relic-row em {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(214, 173, 88, 0.2);
  border-radius: 6px;
  color: #efd59f;
  background: rgba(255, 255, 255, 0.05);
}

.end-screen {
  grid-template-columns: 1fr;
  place-items: center;
}

.end-card {
  width: min(620px, 100%);
  padding: clamp(24px, 5vw, 44px);
  border: 1px solid rgba(214, 173, 88, 0.34);
  border-radius: 8px;
  background: rgba(15, 16, 18, 0.9);
  text-align: center;
}

.end-card h1 {
  font-size: clamp(2.5rem, 7vw, 5rem);
}

.end-card p {
  color: #d9c7aa;
  line-height: 1.8;
}

.muted {
  color: var(--muted);
}

@media (max-width: 980px) {
  .title-screen {
    grid-template-columns: 1fr;
  }

  .title-art {
    min-height: 280px;
  }

  .layout,
  .combat-layout {
    grid-template-columns: 1fr;
  }

  .log-panel {
    position: static;
  }

  .route-map {
    grid-template-columns: repeat(5, minmax(58px, 1fr));
    grid-template-rows: repeat(8, 74px);
    gap: 8px;
    padding: 10px;
    min-height: 660px;
  }

  .map-node {
    min-height: 66px;
    padding: 6px;
  }

  .map-node strong {
    font-size: 0.76rem;
  }

  .topbar {
    flex-wrap: wrap;
    position: static;
  }

  .brand {
    flex-basis: calc(100% - 48px);
  }

  .audio-controls {
    margin-left: auto;
  }
}

@media (max-width: 720px) {
  .title-screen {
    padding: 20px;
  }

  .arena {
    --fighter-half-width: max(80px, 22.5%);
    --player-anchor-x: calc(3% + var(--fighter-half-width));
    --enemy-anchor-x: calc(97% - var(--fighter-half-width));
    --player-anchor-y: 46%;
    --enemy-anchor-y: 45%;
    min-height: 540px;
  }

  .fighter {
    width: 45%;
    min-width: 160px;
  }

  .fighter img {
    height: 230px;
  }

  .fighter.player {
    left: 3%;
  }

  .fighter.enemy {
    right: 3%;
  }

  .plate span,
  .plate em {
    font-size: 0.76rem;
  }

  .float-text {
    bottom: calc(218px + var(--dy));
  }

  .hand,
  .card-grid,
  .shop-row,
  .deck-grid {
    grid-template-columns: repeat(auto-fit, minmax(136px, 1fr));
  }

  .card {
    min-height: 252px;
  }

  .card-art {
    height: 86px;
  }

  .event-hero {
    height: 170px;
  }

  .title-audio {
    position: static;
    justify-self: start;
    margin-bottom: 16px;
  }

  .volume-slider {
    width: 76px;
  }
}
