:root {
  color-scheme: dark;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Noto Sans JP", sans-serif;
  --ink: #f3ead7;
  --ink-soft: #c2b79e;
  --night: #101821;
  --night-deep: #080d12;
  --panel: rgba(17, 26, 34, 0.9);
  --gold: #e5bd69;
  --gold-light: #ffe3a5;
  --red: #a73b32;
  --red-light: #e56a50;
  --green: #64886a;
  --blue: #5f8fa7;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background: var(--night-deep);
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--gold-light);
  outline-offset: 4px;
}

.audio-toggle {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 120;
  min-width: 68px;
  padding: 8px 10px;
  border: 2px solid #10161c;
  outline: 2px solid rgba(229, 189, 105, 0.72);
  color: var(--gold-light);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  background: #18232c;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.48);
  cursor: pointer;
}

.audio-toggle:hover {
  color: #10161c;
  background: var(--gold);
}

.app,
.screen {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.screen[hidden] {
  display: none;
}

.title-screen {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(circle at 68% 18%, rgba(142, 61, 46, 0.18), transparent 24%),
    linear-gradient(180deg, #192836 0%, #111b25 54%, #080d12 100%);
}

.title-screen::after {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: linear-gradient(180deg, black, transparent 74%);
}

.title-atmosphere {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

.moon {
  position: absolute;
  top: 9%;
  right: 13%;
  width: clamp(90px, 13vw, 180px);
  aspect-ratio: 1;
  border-radius: 50%;
  opacity: 0.58;
  background: #edc87d;
  box-shadow: 0 0 90px rgba(229, 189, 105, 0.26);
}

.mountain {
  position: absolute;
  right: -7%;
  bottom: -12%;
  width: 84%;
  height: 58%;
  opacity: 0.86;
  background: #121e27;
  clip-path: polygon(0 82%, 13% 55%, 24% 66%, 40% 20%, 54% 62%, 68% 38%, 83% 71%, 100% 42%, 100% 100%, 0 100%);
}

.mountain-back {
  right: 24%;
  bottom: -4%;
  width: 92%;
  opacity: 0.44;
  background: #31424a;
  transform: scaleX(-1);
}

.ember {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--red-light);
  box-shadow: 0 0 14px var(--red-light);
  animation: ember-rise 6s ease-in infinite;
}

.ember-one {
  left: 13%;
  bottom: 13%;
}

.ember-two {
  right: 18%;
  bottom: 7%;
  animation-delay: -2.2s;
}

.ember-three {
  right: 37%;
  bottom: 16%;
  animation-delay: -4.1s;
}

.title-content {
  width: min(92vw, 920px);
  padding: 48px 24px;
  text-align: center;
}

.dragon-mark {
  display: grid;
  width: 78px;
  height: 78px;
  margin: 0 auto 22px;
  place-items: center;
  transform: rotate(45deg);
  border: 1px solid rgba(229, 189, 105, 0.68);
  color: var(--gold-light);
  background: rgba(8, 13, 18, 0.5);
  box-shadow:
    0 0 0 8px rgba(229, 189, 105, 0.05),
    0 18px 50px rgba(0, 0, 0, 0.3);
}

.dragon-mark span {
  transform: rotate(-45deg);
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.title-kicker {
  margin: 0 0 15px;
  color: var(--gold);
  font-size: clamp(0.62rem, 1.4vw, 0.78rem);
  font-weight: 800;
  letter-spacing: 0.34em;
}

#game-title {
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: Georgia, "Yu Mincho", "Hiragino Mincho ProN", serif;
  text-shadow: 0 14px 34px rgba(0, 0, 0, 0.46);
}

.title-en {
  font-size: clamp(2.8rem, 8.4vw, 6.9rem);
  font-weight: 500;
  line-height: 0.95;
  letter-spacing: 0.055em;
}

.title-ja {
  margin-top: 20px;
  color: var(--gold-light);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1rem, 2.4vw, 1.45rem);
  font-weight: 600;
  letter-spacing: 0.3em;
}

.hero-name-entry {
  display: grid;
  width: min(78vw, 310px);
  margin: clamp(26px, 4.5vh, 42px) auto 0;
  gap: 9px;
  color: var(--gold-light);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.hero-name-entry input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid rgba(229, 189, 105, 0.58);
  border-radius: 2px;
  outline: 3px solid rgba(4, 7, 10, 0.66);
  color: #fff3c5;
  font: 800 1.05rem/1.2 "Yu Mincho", "Hiragino Mincho ProN", serif;
  letter-spacing: 0.15em;
  text-align: center;
  background: rgba(7, 12, 17, 0.86);
  box-shadow: inset 0 0 20px rgba(229, 189, 105, 0.08);
}

.hero-name-entry input:focus {
  border-color: var(--gold-light);
  box-shadow: 0 0 22px rgba(229, 189, 105, 0.22);
}

.primary-button {
  min-width: 230px;
  margin-top: clamp(24px, 4vh, 38px);
  padding: 15px 28px;
  border: 1px solid rgba(229, 189, 105, 0.65);
  border-radius: 3px;
  color: var(--night-deep);
  font-weight: 900;
  letter-spacing: 0.14em;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    filter 180ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.08);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.42);
}

.primary-button:active {
  transform: translateY(1px);
}

.title-note {
  margin: 17px 0 0;
  color: rgba(243, 234, 215, 0.46);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.game-screen {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: auto;
  padding: clamp(10px, 2vw, 24px);
  background:
    radial-gradient(circle at 15% 10%, rgba(99, 132, 114, 0.22), transparent 30%),
    var(--night-deep);
}

.game-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 0 2px 11px;
}

.mini-title,
.area-name {
  margin: 0;
}

.mini-title {
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: clamp(0.7rem, 1.5vw, 0.9rem);
  font-weight: 700;
  letter-spacing: 0.18em;
}

.area-name {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.text-button {
  padding: 7px 0;
  border: 0;
  border-bottom: 1px solid rgba(229, 189, 105, 0.34);
  color: var(--ink-soft);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: transparent;
  cursor: pointer;
}

.text-button:hover {
  color: var(--gold-light);
}

.game-shell {
  display: grid;
  width: min(100%, 1120px, max(320px, calc(177.778vh - 330px)));
  width: min(100%, 1120px, max(320px, calc(177.778dvh - 330px)));
  min-height: 0;
  margin: 0 auto;
  align-content: center;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(229, 189, 105, 0.28);
  border-radius: 10px;
  background: #1d3028;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.canvas-wrap::before {
  position: absolute;
  inset: 0;
  z-index: 5;
  content: "";
  border: 4px solid rgba(8, 12, 14, 0.72);
  outline: 2px solid rgba(229, 189, 105, 0.34);
  outline-offset: -7px;
  pointer-events: none;
}

.canvas-wrap::after {
  position: absolute;
  inset: 0;
  z-index: 4;
  content: "";
  opacity: 0.11;
  background: repeating-linear-gradient(180deg, transparent 0 3px, rgba(4, 8, 10, 0.32) 3px 4px);
  mix-blend-mode: multiply;
  pointer-events: none;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
}

.hud {
  position: absolute;
  top: 15px;
  left: 15px;
  width: min(270px, calc(100% - 30px));
  padding: 12px 14px;
  border: 1px solid rgba(229, 189, 105, 0.32);
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.24);
  pointer-events: none;
}

.hud-name-row,
.meter-row {
  display: flex;
  align-items: center;
}

.hud-name-row {
  justify-content: space-between;
  margin-bottom: 9px;
}

.hud-name {
  color: var(--gold-light);
  font-family: Georgia, serif;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.hud-level {
  color: var(--ink-soft);
  font-size: 0.64rem;
  font-weight: 800;
}

.meter-row {
  gap: 7px;
  margin-top: 5px;
  font-size: 0.58rem;
  font-weight: 800;
}

.meter-row > span {
  width: 20px;
  color: var(--ink-soft);
}

.meter-row b {
  width: 55px;
  color: var(--ink);
  font-size: 0.56rem;
  text-align: right;
}

.meter {
  flex: 1;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.meter-hp {
  background: linear-gradient(90deg, #9f342f, #e76b50);
}

.meter-mp {
  background: linear-gradient(90deg, #3f718c, #75b1c9);
}

.objective {
  position: absolute;
  right: 15px;
  bottom: 15px;
  max-width: calc(100% - 30px);
  margin: 0;
  padding: 10px 14px;
  border-radius: 4px;
  color: var(--ink);
  font-size: clamp(0.58rem, 1.5vw, 0.72rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  background: rgba(8, 13, 18, 0.78);
  pointer-events: none;
}

.game-controls {
  display: flex;
  min-height: 88px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 4px 0;
}

.touch-controls {
  display: flex;
  align-items: center;
  gap: 18px;
}

.game-controls > p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.game-controls > p strong {
  color: var(--gold-light);
}

kbd {
  padding: 3px 7px;
  border: 1px solid rgba(229, 189, 105, 0.28);
  border-radius: 4px;
  color: var(--gold-light);
  font: inherit;
  background: rgba(255, 255, 255, 0.05);
}

.d-pad {
  display: grid;
  grid-template: repeat(3, 34px) / repeat(3, 34px);
  gap: 3px;
}

.d-pad-button {
  display: grid;
  border: 1px solid rgba(229, 189, 105, 0.3);
  border-radius: 5px;
  place-items: center;
  color: var(--gold-light);
  font-size: 0.66rem;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  touch-action: none;
  user-select: none;
}

.d-pad-button:active,
.d-pad-button.is-held {
  color: var(--night-deep);
  background: var(--gold);
}

.action-button {
  width: 72px;
  height: 72px;
  border: 1px solid rgba(229, 189, 105, 0.56);
  border-radius: 50%;
  color: var(--night-deep);
  font-size: 0.66rem;
  font-weight: 900;
  line-height: 1.35;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  touch-action: manipulation;
}

.action-button:active {
  transform: translateY(2px);
}

.interaction-prompt {
  position: absolute;
  left: 50%;
  bottom: 68px;
  z-index: 7;
  margin: 0;
  padding: 9px 13px;
  transform: translateX(-50%);
  border: 1px solid rgba(229, 189, 105, 0.44);
  border-radius: 5px;
  color: var(--ink);
  font-size: 0.7rem;
  font-weight: 800;
  white-space: nowrap;
  background: rgba(8, 13, 18, 0.88);
  box-shadow: 0 9px 24px rgba(0, 0, 0, 0.34);
  pointer-events: none;
}

.interaction-prompt kbd {
  margin-right: 6px;
}

.interaction-prompt span {
  margin-right: 6px;
  padding: 3px 7px;
  border: 1px solid rgba(229, 189, 105, 0.28);
  color: var(--gold-light);
  background: rgba(255, 255, 255, 0.05);
}

.pointer-guide {
  position: absolute;
  bottom: 15px;
  left: 15px;
  z-index: 6;
  margin: 0;
  padding: 8px 11px;
  border: 1px solid rgba(142, 215, 209, 0.5);
  color: #c8f4ed;
  font-size: clamp(0.56rem, 1.4vw, 0.68rem);
  font-weight: 800;
  letter-spacing: 0.05em;
  background: rgba(8, 19, 23, 0.84);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.34);
  pointer-events: none;
}

.scene-intertitle {
  position: absolute;
  inset: 0;
  z-index: 36;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: #e9e7df;
  background: #05070b;
}

.scene-intertitle[hidden] {
  display: none;
}

.scene-intertitle::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.2;
  background:
    radial-gradient(circle at 50% 42%, rgba(95, 112, 145, 0.2), transparent 42%),
    linear-gradient(180deg, rgba(5, 7, 11, 0), rgba(0, 0, 0, 0.68));
}

.scene-intertitle-copy {
  position: relative;
  margin-top: -2%;
  text-align: center;
}

.scene-intertitle-copy p {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(0.9rem, 2.2vw, 1.18rem);
  font-weight: 500;
  line-height: 2;
  letter-spacing: 0.1em;
}

.scene-intertitle-copy .scene-intertitle-time {
  margin-bottom: 20px;
  color: #cbd3e1;
  font-size: clamp(1.25rem, 3.4vw, 1.9rem);
  letter-spacing: 0.22em;
}

.scene-intertitle-next {
  position: absolute;
  right: 6%;
  bottom: 7%;
  min-width: 92px;
  padding: 10px 16px;
  border: 1px solid rgba(203, 211, 225, 0.42);
  border-radius: 4px;
  color: #dce2ed;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
}

.scene-intertitle-next:hover,
.scene-intertitle-next:focus-visible {
  color: #080b11;
  background: #dce2ed;
}

.scene-intertitle.is-entering .scene-intertitle-copy {
  animation: scene-intertitle-in 1500ms ease-out both;
}

.scene-intertitle.is-entering .scene-intertitle-next {
  animation: scene-intertitle-button-in 1800ms 700ms ease-out both;
}

@keyframes scene-intertitle-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scene-intertitle-button-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.dialogue-panel {
  position: absolute;
  right: 4%;
  bottom: 4%;
  left: 4%;
  z-index: 30;
  min-height: 150px;
  padding: 24px 132px 24px 28px;
  border: 1px solid rgba(229, 189, 105, 0.66);
  border-radius: 7px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(25, 36, 45, 0.98), rgba(9, 15, 20, 0.98)),
    var(--night);
  box-shadow: 0 22px 55px rgba(0, 0, 0, 0.52);
  cursor: pointer;
  touch-action: manipulation;
}

.dialogue-speaker {
  margin: 0 0 12px;
  color: var(--gold);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.dialogue-panel[data-tone="hero"] .dialogue-speaker {
  color: #8edcff;
}

.dialogue-panel[data-tone="heroine"] .dialogue-speaker {
  color: #ff9f9b;
}

.dialogue-panel[data-tone="enemy"] .dialogue-speaker {
  color: #f56c76;
  text-shadow: 0 0 12px rgba(213, 35, 68, 0.55);
}

.dialogue-panel[data-tone="light"] .dialogue-speaker {
  color: #fff0a8;
  text-shadow: 0 0 12px rgba(255, 223, 108, 0.42);
}

.dialogue-panel[data-tone="people"] .dialogue-speaker {
  color: #b9e5be;
}

.dialogue-line {
  margin: 0;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(0.96rem, 2.4vw, 1.3rem);
  font-weight: 600;
  line-height: 1.7;
  letter-spacing: 0.04em;
}

.dialogue-next {
  position: absolute;
  right: 24px;
  bottom: 22px;
  min-width: 86px;
  padding: 10px 14px;
  border: 1px solid rgba(229, 189, 105, 0.48);
  border-radius: 4px;
  color: var(--gold-light);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  background: rgba(229, 189, 105, 0.08);
  cursor: pointer;
}

.dialogue-next:hover {
  color: var(--night-deep);
  background: var(--gold);
}

.battle-panel {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 25% 42%, rgba(167, 59, 50, 0.23), transparent 30%),
    linear-gradient(135deg, rgba(11, 18, 24, 0.98), rgba(30, 25, 29, 0.98));
}

.battle-panel::before {
  position: absolute;
  inset: 0;
  content: "";
  opacity: 0.14;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
}

.battle-panel.is-imperial-aura {
  background:
    radial-gradient(circle at 25% 42%, rgba(116, 36, 168, 0.34), transparent 34%),
    repeating-linear-gradient(135deg, rgba(88, 34, 120, 0.12) 0 8px, transparent 8px 16px),
    linear-gradient(135deg, #090c15, #241329);
}

.battle-panel.is-imperial-aura .battle-enemy-side::after {
  position: absolute;
  inset: 9% 7% 17%;
  z-index: 3;
  border: 6px double rgba(207, 99, 255, 0.82);
  content: "";
  background:
    repeating-conic-gradient(from 0deg, rgba(202, 91, 255, 0.18) 0 8deg, transparent 8deg 22deg),
    radial-gradient(circle, transparent 0 46%, rgba(113, 40, 153, 0.34) 47% 67%, transparent 68%);
  box-shadow:
    inset 0 0 28px rgba(195, 67, 255, 0.44),
    0 0 24px rgba(146, 49, 199, 0.62);
  pointer-events: none;
  animation: imperial-aura-pulse 900ms steps(4, end) infinite alternate;
}

.battle-panel.is-aura-breaking .battle-enemy-side {
  animation: aura-break-flash 520ms steps(5, end) both;
}

.battle-panel.is-rampaging {
  background:
    radial-gradient(circle at 25% 42%, rgba(255, 46, 22, 0.42), transparent 38%),
    repeating-linear-gradient(125deg, rgba(176, 30, 22, 0.17) 0 6px, transparent 6px 14px),
    linear-gradient(135deg, #170707, #310f0d);
}

.battle-panel.is-rampage-windup .battle-enemy-side {
  animation: rampage-windup 220ms steps(4, end) both;
}

.battle-panel.is-rampage-hit {
  animation: rampage-impact 360ms steps(7, end) both;
}

.battle-panel.is-rampage-hit::after {
  position: absolute;
  inset: 0;
  z-index: 11;
  content: "";
  background:
    linear-gradient(118deg, transparent 0 39%, rgba(255, 241, 198, 0.94) 40% 43%, transparent 44% 100%),
    radial-gradient(circle at 48% 48%, rgba(255, 71, 42, 0.72), transparent 48%);
  pointer-events: none;
  animation: rampage-impact-flash 360ms steps(7, end) both;
}

.battle-panel.is-rampage-defeat {
  background: linear-gradient(135deg, #050507, #10070a);
}

.battle-panel.is-rampage-defeat .battle-enemy-side {
  filter: grayscale(0.55) brightness(0.38);
  transform: translateY(3px);
  transition:
    filter 520ms steps(5, end),
    transform 520ms steps(5, end);
}

.battle-panel.is-rampage-defeat .battle-command-side {
  filter: brightness(0.62);
  transition: filter 520ms steps(5, end);
}

.battle-panel.is-lineage-awakened {
  background:
    linear-gradient(125deg, rgba(255, 85, 85, 0.13), rgba(255, 227, 101, 0.12), rgba(101, 210, 255, 0.14), rgba(186, 111, 255, 0.14)),
    radial-gradient(circle at 25% 42%, rgba(255, 248, 192, 0.38), transparent 36%),
    #101824;
  animation: lineage-field 1400ms steps(7, end) infinite alternate;
}

.battle-enemy-side,
.battle-command-side {
  position: relative;
  z-index: 1;
}

.battle-enemy-side {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  padding: 28px;
  border-right: 1px solid rgba(229, 189, 105, 0.18);
}

#enemy-canvas {
  width: min(100%, 320px);
  height: auto;
  image-rendering: pixelated;
}

.battle-effect {
  --sacred-color: #fff1a8;
  --sacred-glow: rgba(255, 225, 112, 0.72);
  position: absolute;
  top: 8%;
  left: 7%;
  z-index: 4;
  display: grid;
  width: 86%;
  height: 61%;
  overflow: hidden;
  place-items: center;
  opacity: 0;
  clip-path: polygon(8% 0, 92% 0, 92% 5%, 97% 5%, 97% 14%, 100% 14%, 100% 86%, 97% 86%, 97% 95%, 92% 95%, 92% 100%, 8% 100%, 8% 95%, 3% 95%, 3% 86%, 0 86%, 0 14%, 3% 14%, 3% 5%, 8% 5%);
  background: radial-gradient(circle, var(--sacred-glow), transparent 63%);
  pointer-events: none;
}

.battle-effect::before,
.battle-effect::after {
  position: absolute;
  content: "";
}

.battle-effect::before {
  inset: 7%;
  border: 8px double var(--sacred-color);
  background:
    repeating-conic-gradient(from 45deg, var(--sacred-glow) 0 7deg, transparent 7deg 18deg),
    radial-gradient(circle, transparent 0 28%, var(--sacred-color) 29% 34%, transparent 35%);
}

.battle-effect::after {
  top: -20%;
  bottom: -20%;
  left: 47%;
  width: 8%;
  background: var(--sacred-color);
  box-shadow:
    -38px 0 0 color-mix(in srgb, var(--sacred-color) 55%, transparent),
    38px 0 0 color-mix(in srgb, var(--sacred-color) 55%, transparent);
}

.battle-effect b {
  position: relative;
  z-index: 2;
  display: grid;
  width: 64px;
  height: 64px;
  place-items: center;
  border: 5px solid #10131a;
  outline: 4px solid var(--sacred-color);
  color: #0a0d12;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 2rem;
  font-weight: 900;
  background: var(--sacred-color);
  text-shadow: 2px 2px 0 rgba(255, 255, 255, 0.45);
}

.battle-effect.tone-red {
  --sacred-color: #ff604d;
  --sacred-glow: rgba(255, 57, 42, 0.78);
}

.battle-effect.tone-blue {
  --sacred-color: #65c9ff;
  --sacred-glow: rgba(46, 145, 255, 0.78);
}

.battle-effect.tone-yellow {
  --sacred-color: #ffe45c;
  --sacred-glow: rgba(255, 208, 34, 0.8);
}

.battle-effect.tone-strike {
  --sacred-color: #ffd0a1;
  --sacred-glow: rgba(255, 126, 58, 0.72);
}

.battle-effect.tone-lineage {
  --sacred-color: #fffbd2;
  --sacred-glow: rgba(255, 238, 145, 0.88);
}

.battle-effect.tone-rainbow {
  --sacred-color: #fff;
  --sacred-glow: rgba(255, 255, 255, 0.88);
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.92), transparent 38%),
    conic-gradient(from 45deg, rgba(255, 78, 78, 0.72), rgba(255, 222, 79, 0.76), rgba(87, 239, 157, 0.72), rgba(79, 198, 255, 0.76), rgba(155, 98, 255, 0.75), rgba(255, 78, 175, 0.74), rgba(255, 78, 78, 0.72));
}

.battle-effect.tone-rainbow::before {
  border-color: #fff;
  background:
    repeating-conic-gradient(from 20deg, rgba(255, 255, 255, 0.9) 0 5deg, transparent 5deg 15deg),
    radial-gradient(circle, transparent 0 26%, #fff 27% 32%, transparent 33%);
}

.battle-effect.tone-rainbow b {
  min-width: 84px;
  width: auto;
  padding: 0 8px;
  background: linear-gradient(90deg, #ff6666, #ffe361, #71efa6, #6ed5ff, #b982ff, #ff72bd);
}

.battle-effect.is-active {
  animation: sacred-light-strike 620ms steps(7, end) both;
}

.enemy-name {
  margin: 4px 0 9px;
  color: var(--gold-light);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.enemy-trait {
  margin: 0 0 9px;
  padding: 5px 9px;
  border: 1px solid currentColor;
  color: #d9caac;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: rgba(5, 8, 12, 0.76);
}

.enemy-trait.trait-dark {
  color: #e091ff;
}

.enemy-trait.trait-broken {
  color: #d8ccc1;
  text-decoration: line-through;
}

.enemy-trait.trait-rainbow {
  border-color: #fff7b8;
  color: #fff;
  background: linear-gradient(90deg, rgba(166, 49, 49, 0.72), rgba(138, 112, 28, 0.7), rgba(42, 105, 142, 0.72), rgba(100, 55, 143, 0.72));
}

.battle-announcement {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  flex-direction: column;
  justify-content: center;
  color: #fff5d5;
  text-align: center;
  text-shadow:
    3px 3px 0 #080a0e,
    -2px -2px 0 #080a0e;
  background: rgba(3, 5, 9, 0.72);
  pointer-events: none;
}

.battle-announcement[hidden] {
  display: none;
}

.battle-announcement small,
.battle-announcement span {
  font-weight: 900;
  letter-spacing: 0.34em;
}

.battle-announcement small {
  margin-bottom: 8px;
  font-size: clamp(0.7rem, 2vw, 0.95rem);
}

.battle-announcement strong {
  padding: 8px 22px;
  border-top: 4px double currentColor;
  border-bottom: 4px double currentColor;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1.7rem, 6vw, 3.5rem);
  letter-spacing: 0.12em;
}

.battle-announcement span {
  margin-top: 10px;
  font-size: clamp(0.7rem, 2.2vw, 1rem);
}

.battle-announcement.announcement-dark {
  color: #e291ff;
  background: radial-gradient(circle, rgba(101, 27, 139, 0.82), rgba(3, 5, 9, 0.9) 64%);
}

.battle-announcement.announcement-break {
  color: #fff0b2;
  background: radial-gradient(circle, rgba(255, 180, 63, 0.76), rgba(24, 12, 7, 0.91) 65%);
}

.battle-announcement.announcement-rampage {
  color: #ffb097;
  background: radial-gradient(circle, rgba(171, 27, 18, 0.86), rgba(18, 3, 3, 0.94) 68%);
}

.battle-announcement.announcement-lineage {
  color: #fffbd2;
  background:
    radial-gradient(circle, rgba(255, 255, 255, 0.7), transparent 30%),
    linear-gradient(115deg, rgba(160, 36, 62, 0.88), rgba(137, 111, 30, 0.86), rgba(36, 105, 151, 0.88), rgba(99, 48, 142, 0.88));
}

.battle-announcement.is-active {
  animation: battle-announcement-in 520ms steps(6, end) both;
}

.enemy-meter {
  width: min(220px, 76%);
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.enemy-meter i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #7e2929, #db5744);
  transition: width 280ms ease;
}

.battle-command-side {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding: clamp(24px, 5vw, 52px);
}

.battle-log {
  min-height: 5.4em;
  margin: 0 0 24px;
  padding: 18px 20px;
  border-left: 4px solid var(--red-light);
  color: var(--ink);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(0.9rem, 2vw, 1.08rem);
  font-weight: 600;
  line-height: 1.7;
  background: rgba(255, 255, 255, 0.05);
}

.battle-commands {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}

.battle-commands button,
.battle-retry {
  grid-column: span 3;
  min-height: 72px;
  padding: 13px 14px;
  border: 1px solid rgba(229, 189, 105, 0.34);
  border-radius: 5px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
  transition:
    color 140ms ease,
    border-color 140ms ease,
    background-color 140ms ease;
}

.battle-commands .sacred-light-command {
  --command-color: var(--gold);
  grid-column: span 2;
  letter-spacing: 0.02em;
}

.battle-commands .physical-command,
.battle-commands [data-battle-action="heal"],
.battle-commands [data-battle-action="guard"] {
  grid-column: span 2;
}

.sacred-light-command b {
  display: inline-grid;
  min-width: 1.45em;
  min-height: 1.45em;
  margin-left: 0.2em;
  place-items: center;
  color: #0a0d12;
  font-size: 0.78rem;
  background: var(--command-color);
  box-shadow: inset 0 0 0 2px rgba(8, 12, 17, 0.52);
}

.battle-commands .sacred-red {
  --command-color: #ff604d;
  border-color: rgba(255, 96, 77, 0.72);
  color: #ff8a79;
  background: rgba(145, 39, 37, 0.18);
}

.battle-commands .sacred-blue {
  --command-color: #65c9ff;
  border-color: rgba(101, 201, 255, 0.72);
  color: #91dbff;
  background: rgba(38, 91, 149, 0.2);
}

.battle-commands .sacred-yellow {
  --command-color: #ffe45c;
  border-color: rgba(255, 228, 92, 0.72);
  color: #ffe977;
  background: rgba(157, 121, 28, 0.18);
}

.battle-commands .sacred-rainbow {
  grid-column: 1 / -1;
  min-height: 78px;
  border-color: rgba(255, 255, 255, 0.88);
  color: #fff;
  font-size: 1rem;
  background:
    linear-gradient(90deg, rgba(184, 45, 56, 0.54), rgba(156, 127, 31, 0.54), rgba(36, 125, 91, 0.54), rgba(31, 109, 159, 0.56), rgba(104, 50, 150, 0.56)),
    #111925;
}

.battle-commands .sacred-rainbow b {
  min-width: 3.6em;
  color: #10131a;
  background: linear-gradient(90deg, #ff6c6c, #ffe566, #72efa7, #72d7ff, #bf88ff, #ff7ec5);
}

.battle-commands .sacred-rainbow:hover:not(:disabled) {
  border-color: #fff;
  color: #10131a;
  background: linear-gradient(90deg, #ff7878, #ffe970, #7ff3b0, #7bdbff, #c592ff, #ff89cb);
}

.battle-commands .sacred-red:hover:not(:disabled) {
  border-color: #ff604d;
  color: #160d0c;
  background: #ff604d;
}

.battle-commands .sacred-blue:hover:not(:disabled) {
  border-color: #65c9ff;
  color: #07121a;
  background: #65c9ff;
}

.battle-commands .sacred-yellow:hover:not(:disabled) {
  border-color: #ffe45c;
  color: #171307;
  background: #ffe45c;
}

.battle-commands button:hover:not(:disabled),
.battle-retry:hover {
  border-color: var(--gold);
  color: var(--night-deep);
  background: var(--gold);
}

.battle-commands button:disabled {
  opacity: 0.42;
  cursor: wait;
}

.battle-commands small {
  display: block;
  margin-top: 3px;
  color: inherit;
  font-size: 0.56rem;
  opacity: 0.64;
}

.battle-retry {
  width: 100%;
  color: var(--gold-light);
}

.ending-screen {
  position: relative;
  display: grid;
  overflow: hidden;
  place-items: center;
  isolation: isolate;
  background: #07101d;
}

#ending-canvas {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.ending-copy {
  position: absolute;
  top: 8%;
  left: 50%;
  width: min(90vw, 760px);
  transform: translateX(-50%);
  text-align: center;
  text-shadow: 0 4px 20px rgba(0, 0, 0, 0.72);
}

.ending-copy p {
  margin: 0 0 14px;
  color: var(--gold);
  font-family: Georgia, serif;
  font-size: clamp(1rem, 2.8vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.34em;
}

.ending-copy h2 {
  margin: 0;
  color: #fff8e6;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(1rem, 3vw, 1.65rem);
  font-weight: 600;
  line-height: 1.7;
  letter-spacing: 0.08em;
}

.ending-copy .primary-button {
  min-width: 180px;
  margin-top: 26px;
  padding: 11px 22px;
  font-size: 0.76rem;
}

.ending-credits {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  color: #fff;
  background: transparent;
}

.ending-screen.is-credits {
  background: #000;
}

.ending-screen.is-credits #ending-canvas {
  object-fit: cover;
  background: #000;
}

.ending-credit-roll {
  position: absolute;
  top: 0;
  left: 50%;
  width: min(92vw, 920px);
  margin: 0;
  color: #fff;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(0.72rem, 1.6vw, 1.1rem);
  font-weight: 500;
  line-height: 1.8;
  letter-spacing: 0.12em;
  text-align: center;
  text-shadow:
    0 2px 5px #000,
    0 0 14px #000;
  opacity: 1;
  transform: translate(-50%, -6vh);
  will-change: transform;
}

.ending-thanks {
  position: absolute;
  top: 47%;
  left: 50%;
  width: min(92vw, 1000px);
  margin: 0;
  color: #fff;
  font-family: "Snell Roundhand", "Apple Chancery", "Brush Script MT", cursive;
  font-size: clamp(2.4rem, 8vw, 6.8rem);
  font-weight: 400;
  line-height: 1;
  text-align: center;
  text-shadow:
    0 3px 8px #000,
    0 0 18px #000;
  transform: translate(-50%, -50%);
  animation: ending-thanks-in 2.4s ease-out both;
}

.ending-title-button {
  position: absolute;
  bottom: 8%;
  left: 50%;
  min-width: 180px;
  margin: 0;
  padding: 11px 22px;
  font-size: 0.76rem;
  transform: translateX(-50%);
  pointer-events: auto;
}

.ending-title-button:hover {
  transform: translate(-50%, -2px);
}

@keyframes ending-thanks-in {
  from {
    opacity: 0;
    filter: blur(8px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

.d-pad-button.up {
  grid-area: 1 / 2;
}

.d-pad-button.left {
  grid-area: 2 / 1;
}

.d-pad-button.down {
  grid-area: 2 / 2;
}

.d-pad-button.right {
  grid-area: 2 / 3;
}

@keyframes ember-rise {
  0% {
    opacity: 0;
    transform: translateY(0) scale(0.6);
  }
  22% {
    opacity: 0.9;
  }
  100% {
    opacity: 0;
    transform: translate(26px, -190px) scale(1.2);
  }
}

@keyframes sacred-light-strike {
  0% {
    opacity: 0;
    transform: scale(0.45) rotate(-6deg);
  }
  18% {
    opacity: 1;
    transform: scale(0.78) rotate(3deg);
  }
  52% {
    opacity: 0.96;
    transform: scale(1) rotate(0);
  }
  100% {
    opacity: 0;
    transform: scale(1.42) rotate(4deg);
  }
}

@keyframes imperial-aura-pulse {
  from {
    opacity: 0.58;
    transform: scale(0.96) rotate(-2deg);
  }
  to {
    opacity: 1;
    transform: scale(1.02) rotate(2deg);
  }
}

@keyframes aura-break-flash {
  0% {
    filter: brightness(1);
    transform: translate(0);
  }
  35% {
    filter: brightness(3.2) saturate(0);
    transform: translate(-8px, 3px);
  }
  70% {
    filter: brightness(1.8);
    transform: translate(7px, -2px);
  }
  100% {
    filter: brightness(1);
    transform: translate(0);
  }
}

@keyframes rampage-windup {
  0% {
    filter: brightness(1);
    transform: translateX(0) scale(1);
  }
  100% {
    filter: brightness(0.72) saturate(1.25);
    transform: translateX(-10px) scale(0.97);
  }
}

@keyframes rampage-impact {
  0% {
    filter: brightness(1);
    transform: translate(0);
  }
  14% {
    filter: brightness(2.8) saturate(2);
    transform: translate(-18px, 8px);
  }
  30% {
    filter: brightness(1.65) saturate(1.55);
    transform: translate(13px, -6px);
  }
  48% {
    filter: brightness(1.25) saturate(1.3);
    transform: translate(-8px, 4px);
  }
  68% {
    transform: translate(5px, -2px);
  }
  84% {
    transform: translate(-2px, 1px);
  }
  100% {
    filter: brightness(1);
    transform: translate(0);
  }
}

@keyframes rampage-impact-flash {
  0% {
    opacity: 0;
  }
  14% {
    opacity: 1;
  }
  42% {
    opacity: 0.34;
  }
  100% {
    opacity: 0;
  }
}

@keyframes lineage-field {
  from {
    filter: saturate(0.92) brightness(0.98);
  }
  to {
    filter: saturate(1.28) brightness(1.12);
  }
}

@keyframes battle-announcement-in {
  0% {
    opacity: 0;
    transform: scale(1.16);
  }
  44% {
    opacity: 1;
    transform: scale(0.96);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@media (max-width: 680px) {
  .title-content {
    padding-top: 30px;
  }

  .dragon-mark {
    width: 62px;
    height: 62px;
    margin-bottom: 18px;
  }

  .game-screen {
    align-content: start;
  }

  .game-controls {
    min-height: 100px;
  }

  .game-controls > p {
    display: none;
  }

  .d-pad {
    margin-left: 0;
  }

  .touch-controls {
    width: 100%;
    justify-content: space-between;
  }

  .hud {
    top: 8px;
    left: 8px;
    width: min(220px, calc(100% - 16px));
    padding: 8px 10px;
  }

  .objective {
    right: 8px;
    bottom: 8px;
    padding: 7px 9px;
  }

  .interaction-prompt {
    bottom: 48px;
  }

  .dialogue-panel {
    right: 2.5%;
    bottom: 2.5%;
    left: 2.5%;
    min-height: 132px;
    padding: 18px 78px 18px 18px;
  }

  .dialogue-speaker {
    margin-bottom: 7px;
  }

  .dialogue-next {
    right: 12px;
    bottom: 12px;
    min-width: 58px;
    padding: 8px;
  }

  .battle-panel {
    grid-template-columns: 0.72fr 1.28fr;
  }

  .battle-enemy-side {
    padding: 10px;
  }

  .battle-command-side {
    padding: 13px;
  }

  .battle-log {
    min-height: 4.6em;
    margin-bottom: 10px;
    padding: 10px 12px;
  }

  .battle-commands {
    gap: 6px;
  }

  .battle-commands button {
    min-height: 48px;
    padding: 6px;
    font-size: 0.66rem;
  }
}

/* Deliberate story pacing */
.dialogue-line.is-entering {
  animation: dialogue-line-settle 420ms ease-out both;
}

.dialogue-next:disabled {
  opacity: 0.28;
  cursor: default;
  filter: saturate(0.4);
}

@keyframes dialogue-line-settle {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Twelve distinct forms of 怒涛の獅子奮迅 */
.battle-panel.is-rampage-windup .battle-enemy-side {
  transform-origin: 32% 54%;
  animation-name: rampage-varied-windup;
  animation-duration: var(--rampage-windup-duration, 620ms);
  animation-timing-function: cubic-bezier(0.3, 0, 0.7, 1);
}

.battle-panel.is-rampage-hit {
  animation-name: rampage-varied-impact;
  animation-duration: var(--rampage-impact-duration, 560ms);
  animation-timing-function: steps(7, end);
}

.battle-panel.is-rampage-hit::after {
  animation-duration: var(--rampage-impact-duration, 560ms);
}

.battle-panel.is-rampage-hit::before {
  position: absolute;
  top: 46%;
  right: 19%;
  bottom: auto;
  left: auto;
  z-index: 10;
  width: auto;
  height: auto;
  content: attr(data-rampage-glyph);
  opacity: 0;
  color: rgba(255, 248, 218, 0.94);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: clamp(3rem, 10vw, 7.4rem);
  font-weight: 800;
  line-height: 1;
  text-shadow:
    0 0 18px rgba(255, 221, 150, 0.58),
    5px 5px 0 rgba(86, 12, 14, 0.72);
  background: none;
  transform: translate(50%, -50%);
  pointer-events: none;
  animation: rampage-glyph-impact var(--rampage-impact-duration, 560ms) steps(6, end) both;
}

.battle-panel[data-rampage-style="slash"] {
  --windup-x: -16px;
  --windup-y: 3px;
  --windup-rotate: -2deg;
  --impact-x: -24px;
  --impact-y: 9px;
  --impact-rotate: -1deg;
  --impact-scale: 1;
  --impact-hue: -8deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="slash"]::after {
  background:
    linear-gradient(128deg, transparent 0 35%, rgba(255, 244, 216, 0.96) 36% 38%, rgba(214, 38, 35, 0.88) 39% 41%, transparent 42%),
    linear-gradient(128deg, transparent 0 54%, rgba(255, 177, 128, 0.7) 55% 57%, transparent 58%);
}

.battle-panel[data-rampage-style="punch"] {
  --windup-x: -8px;
  --windup-y: 0px;
  --windup-rotate: 0deg;
  --impact-x: 0px;
  --impact-y: 8px;
  --impact-rotate: 0deg;
  --impact-scale: 1.045;
  --impact-hue: 8deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="punch"]::after {
  background:
    radial-gradient(circle at 58% 48%, rgba(255, 255, 232, 0.98) 0 5%, rgba(255, 142, 55, 0.82) 6% 18%, transparent 35%),
    conic-gradient(from 12deg at 58% 48%, transparent 0 7%, rgba(255, 208, 132, 0.74) 8% 10%, transparent 11% 24%, rgba(255, 208, 132, 0.6) 25% 27%, transparent 28% 100%);
}

.battle-panel[data-rampage-style="charge"] {
  --windup-x: -22px;
  --windup-y: 0px;
  --windup-rotate: 0deg;
  --impact-x: 30px;
  --impact-y: 0px;
  --impact-rotate: 0deg;
  --impact-scale: 1.01;
  --impact-hue: -18deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="charge"]::after {
  background:
    repeating-linear-gradient(0deg, transparent 0 8%, rgba(255, 225, 180, 0.78) 9% 10%, transparent 11% 18%),
    linear-gradient(90deg, rgba(142, 0, 30, 0.15), rgba(255, 73, 43, 0.72), transparent 72%);
}

.battle-panel[data-rampage-style="sweep"] {
  --windup-x: 10px;
  --windup-y: 2px;
  --windup-rotate: 3deg;
  --impact-x: -18px;
  --impact-y: -8px;
  --impact-rotate: 2deg;
  --impact-scale: 1;
  --impact-hue: 18deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="sweep"]::after {
  background:
    linear-gradient(174deg, transparent 0 46%, rgba(255, 245, 203, 0.95) 47% 49%, rgba(203, 61, 37, 0.8) 50% 54%, transparent 55%),
    radial-gradient(ellipse at 50% 65%, rgba(255, 124, 62, 0.48), transparent 58%);
}

.battle-panel[data-rampage-style="lightning"] {
  --windup-x: 0px;
  --windup-y: -9px;
  --windup-rotate: 0deg;
  --impact-x: 5px;
  --impact-y: -13px;
  --impact-rotate: 0deg;
  --impact-scale: 1.01;
  --impact-hue: 132deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="lightning"]::after {
  background:
    conic-gradient(from 195deg at 62% 8%, transparent 0 3%, rgba(222, 212, 255, 0.98) 4% 5%, transparent 6% 11%, rgba(125, 64, 255, 0.9) 12% 14%, transparent 15% 100%),
    radial-gradient(circle at 58% 48%, rgba(105, 50, 202, 0.78), transparent 52%);
}

.battle-panel[data-rampage-style="quake"] {
  --windup-x: 0px;
  --windup-y: -14px;
  --windup-rotate: 0deg;
  --impact-x: 0px;
  --impact-y: 17px;
  --impact-rotate: 0deg;
  --impact-scale: 1.015;
  --impact-hue: 26deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="quake"]::after {
  background:
    repeating-linear-gradient(0deg, transparent 0 13%, rgba(255, 222, 166, 0.56) 14% 15%, transparent 16% 26%),
    radial-gradient(ellipse at 50% 100%, rgba(255, 113, 45, 0.82), transparent 62%);
}

.battle-panel[data-rampage-style="shadow"] {
  --windup-x: 13px;
  --windup-y: 0px;
  --windup-rotate: 1deg;
  --impact-x: 14px;
  --impact-y: -5px;
  --impact-rotate: 1deg;
  --impact-scale: 0.99;
  --impact-hue: 204deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="shadow"]::after {
  background:
    linear-gradient(116deg, transparent 0 25%, rgba(142, 72, 194, 0.75) 26% 28%, transparent 29% 44%, rgba(246, 221, 255, 0.82) 45% 47%, transparent 48% 63%, rgba(98, 35, 141, 0.7) 64% 67%, transparent 68%),
    rgba(13, 4, 24, 0.42);
}

.battle-panel[data-rampage-style="crush"] {
  --windup-x: 0px;
  --windup-y: -24px;
  --windup-rotate: 0deg;
  --impact-x: 0px;
  --impact-y: 22px;
  --impact-rotate: 0deg;
  --impact-scale: 1.025;
  --impact-hue: 34deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="crush"]::after {
  background:
    linear-gradient(90deg, transparent 0 47%, rgba(255, 247, 198, 0.96) 48% 52%, transparent 53%),
    radial-gradient(ellipse at 50% 88%, rgba(255, 178, 55, 0.84), transparent 48%);
}

.battle-panel[data-rampage-style="drain"] {
  --windup-x: 0px;
  --windup-y: 0px;
  --windup-rotate: -1deg;
  --impact-x: 0px;
  --impact-y: 0px;
  --impact-rotate: 0deg;
  --impact-scale: 0.94;
  --impact-hue: 218deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="drain"]::after {
  background:
    repeating-radial-gradient(circle at 58% 50%, rgba(222, 187, 255, 0.72) 0 2%, transparent 3% 9%),
    radial-gradient(circle at 58% 50%, rgba(64, 15, 94, 0.88), rgba(4, 3, 9, 0.72) 58%, transparent 72%);
}

.battle-panel[data-rampage-style="stomp"] {
  --windup-x: 0px;
  --windup-y: -17px;
  --windup-rotate: 0deg;
  --impact-x: 0px;
  --impact-y: 13px;
  --impact-rotate: 0deg;
  --impact-scale: 1;
  --impact-hue: 12deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="stomp"]::after {
  background:
    linear-gradient(0deg, rgba(255, 218, 158, 0.76), transparent 20%),
    repeating-linear-gradient(88deg, transparent 0 8%, rgba(255, 113, 62, 0.54) 9% 10%, transparent 11% 18%);
}

.battle-panel[data-rampage-style="breaker"] {
  --windup-x: -7px;
  --windup-y: -5px;
  --windup-rotate: -2deg;
  --impact-x: -16px;
  --impact-y: -11px;
  --impact-rotate: -2deg;
  --impact-scale: 1.02;
  --impact-hue: -24deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="breaker"]::after {
  background:
    linear-gradient(45deg, transparent 0 47%, rgba(255, 245, 211, 0.92) 48% 51%, transparent 52%),
    linear-gradient(135deg, transparent 0 47%, rgba(255, 74, 47, 0.84) 48% 52%, transparent 53%),
    radial-gradient(circle, rgba(156, 14, 21, 0.62), transparent 54%);
}

.battle-panel[data-rampage-style="finale"] {
  --windup-x: 0px;
  --windup-y: 0px;
  --windup-rotate: 0deg;
  --impact-x: 0px;
  --impact-y: -6px;
  --impact-rotate: 0deg;
  --impact-scale: 1.035;
  --impact-hue: -10deg;
}

.battle-panel.is-rampage-hit[data-rampage-style="finale"]::after {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 255, 236, 0.98) 0 8%, rgba(255, 127, 69, 0.84) 9% 28%, rgba(101, 4, 8, 0.64) 29% 52%, transparent 70%),
    repeating-conic-gradient(from 0deg at 50% 50%, rgba(255, 221, 175, 0.7) 0 2deg, transparent 3deg 17deg);
}

@keyframes rampage-varied-windup {
  from {
    filter: brightness(1) saturate(1);
    transform: translate(0, 0) rotate(0) scale(1);
  }
  to {
    filter: brightness(0.62) saturate(1.35) hue-rotate(var(--impact-hue, 0deg));
    transform: translate(var(--windup-x, -10px), var(--windup-y, 0)) rotate(var(--windup-rotate, 0deg)) scale(0.975);
  }
}

@keyframes rampage-varied-impact {
  0% {
    filter: brightness(1) saturate(1);
    transform: translate(0, 0) rotate(0) scale(1);
  }
  15% {
    filter: brightness(2.8) saturate(1.9) hue-rotate(var(--impact-hue, 0deg));
    transform: translate(var(--impact-x, -18px), var(--impact-y, 8px)) rotate(var(--impact-rotate, 0deg)) scale(var(--impact-scale, 1));
  }
  38% {
    filter: brightness(1.5) saturate(1.45) hue-rotate(var(--impact-hue, 0deg));
    transform: translate(8px, -4px) rotate(0) scale(1);
  }
  62% {
    transform: translate(-4px, 2px);
  }
  100% {
    filter: brightness(1) saturate(1);
    transform: translate(0, 0) rotate(0) scale(1);
  }
}

@keyframes rampage-glyph-impact {
  0% {
    opacity: 0;
    transform: translate(50%, -50%) scale(1.8);
  }
  18% {
    opacity: 1;
    transform: translate(50%, -50%) scale(0.92);
  }
  45% {
    opacity: 0.7;
    transform: translate(50%, -50%) scale(1.04);
  }
  100% {
    opacity: 0;
    transform: translate(50%, -50%) scale(1);
  }
}

/* Restrained white-gold lineage awakening */
.battle-panel.is-lineage-stirring {
  background: #020407;
}

.battle-panel.is-lineage-stirring .battle-enemy-side,
.battle-panel.is-lineage-stirring .battle-command-side {
  filter: grayscale(1) brightness(0.16);
  transition: filter 1200ms ease;
}

.battle-panel.is-lineage-stirring::after {
  position: absolute;
  top: 55%;
  left: 72%;
  z-index: 7;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  content: "";
  background: #fffbe2;
  box-shadow:
    0 0 18px 6px rgba(255, 244, 190, 0.42),
    0 0 70px 18px rgba(169, 211, 225, 0.14);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: lineage-heartbeat 1500ms ease-in-out infinite;
}

.battle-panel.is-lineage-remembering:not(.is-lineage-awakened)::before {
  position: absolute;
  inset: 0;
  z-index: 6;
  content: "";
  opacity: 0;
  background:
    linear-gradient(107deg, transparent 0 16%, rgba(190, 219, 225, 0.18) 16.2% 16.5%, transparent 16.7% 100%),
    linear-gradient(78deg, transparent 0 31%, rgba(255, 239, 184, 0.22) 31.2% 31.5%, transparent 31.7% 100%),
    linear-gradient(121deg, transparent 0 48%, rgba(221, 230, 209, 0.2) 48.2% 48.5%, transparent 48.7% 100%),
    linear-gradient(62deg, transparent 0 66%, rgba(255, 246, 215, 0.24) 66.2% 66.5%, transparent 66.7% 100%);
  pointer-events: none;
  animation: lineage-threads-gather 2100ms ease-out forwards;
}

.battle-panel.is-lineage-awakened {
  background:
    radial-gradient(circle at 72% 55%, rgba(255, 249, 216, 0.22), transparent 28%),
    linear-gradient(135deg, #06101a, #0b1822 56%, #111b21);
  animation: lineage-white-gold-breathe 3000ms ease-in-out infinite alternate;
}

.battle-panel.is-lineage-awakened .battle-enemy-side {
  filter: saturate(0.72) brightness(0.72);
  transition: filter 1600ms ease;
}

.battle-panel.is-lineage-awakened .battle-command-side {
  filter: none;
  background: radial-gradient(circle at 52% 48%, rgba(255, 247, 207, 0.1), transparent 62%);
  transition: filter 1600ms ease;
}

.battle-panel.is-lineage-awakened::before {
  position: absolute;
  inset: 0;
  z-index: 5;
  content: "";
  opacity: 0.72;
  background:
    linear-gradient(90deg, transparent 0 71.8%, rgba(255, 248, 213, 0.58) 72%, transparent 72.25%),
    linear-gradient(75deg, transparent 0 62%, rgba(179, 216, 225, 0.28) 62.2%, transparent 62.45%),
    linear-gradient(105deg, transparent 0 81%, rgba(255, 235, 178, 0.25) 81.2%, transparent 81.45%);
  pointer-events: none;
  animation: lineage-light-rise 2600ms ease-out both;
}

.battle-panel.is-lineage-awakened::after {
  position: absolute;
  top: 55%;
  left: 72%;
  z-index: 6;
  width: 30%;
  aspect-ratio: 1;
  border-radius: 50%;
  content: "";
  background: radial-gradient(circle, rgba(255, 253, 235, 0.72) 0 3%, rgba(255, 240, 184, 0.22) 16%, rgba(145, 201, 216, 0.1) 38%, transparent 70%);
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: lineage-aura-open 2600ms ease-out both;
}

.battle-announcement.announcement-lineage {
  color: #fff8df;
  text-shadow: 0 2px 18px rgba(255, 244, 196, 0.2);
  background:
    linear-gradient(90deg, transparent, rgba(255, 246, 210, 0.07) 30% 70%, transparent),
    rgba(2, 7, 12, 0.91);
}

.battle-announcement.announcement-lineage strong {
  padding: 14px 28px;
  border-top: 1px solid rgba(255, 244, 203, 0.62);
  border-bottom: 1px solid rgba(255, 244, 203, 0.62);
  font-size: clamp(1.45rem, 5vw, 3rem);
  font-weight: 500;
  letter-spacing: 0.16em;
}

.battle-announcement.announcement-lineage small,
.battle-announcement.announcement-lineage span {
  color: rgba(255, 248, 222, 0.62);
  font-weight: 500;
  letter-spacing: 0.28em;
}

.battle-announcement.announcement-lineage small:empty,
.battle-announcement.announcement-lineage span:empty {
  display: none;
}

.battle-announcement.announcement-lineage.is-active {
  animation: lineage-title-reveal 2600ms cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

.enemy-trait.trait-rainbow {
  border-color: rgba(255, 244, 202, 0.7);
  color: #fff8df;
  background: linear-gradient(90deg, rgba(13, 29, 38, 0.88), rgba(78, 72, 48, 0.72), rgba(13, 29, 38, 0.88));
}

@keyframes lineage-heartbeat {
  0%,
  100% {
    opacity: 0.35;
    transform: translate(-50%, -50%) scale(0.65);
  }
  45% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
  58% {
    opacity: 0.55;
    transform: translate(-50%, -50%) scale(0.82);
  }
}

@keyframes lineage-threads-gather {
  0% {
    opacity: 0;
    filter: blur(3px);
    transform: scale(1.08);
  }
  40% {
    opacity: 0.7;
  }
  100% {
    opacity: 1;
    filter: blur(0);
    transform: scale(1);
  }
}

@keyframes lineage-white-gold-breathe {
  from {
    filter: brightness(0.94) saturate(0.82);
  }
  to {
    filter: brightness(1.07) saturate(1);
  }
}

@keyframes lineage-light-rise {
  from {
    opacity: 0;
    transform: translateY(16%);
  }
  to {
    opacity: 0.72;
    transform: translateY(-5%);
  }
}

@keyframes lineage-aura-open {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.08);
  }
  45% {
    opacity: 0.92;
  }
  to {
    opacity: 0.72;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes lineage-title-reveal {
  0% {
    opacity: 0;
    letter-spacing: 0.32em;
    filter: blur(7px);
  }
  32% {
    opacity: 1;
    filter: blur(0);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    letter-spacing: 0.16em;
  }
}

/* Dense pixel-art presentation */
.title-screen {
  background:
    linear-gradient(90deg, transparent 0 49.7%, rgba(255, 255, 255, 0.025) 49.7% 50.3%, transparent 50.3%),
    repeating-linear-gradient(180deg, #142433 0 22px, #13212f 22px 44px, #101b27 44px 66px);
}

.title-screen::after {
  opacity: 0.38;
  background-image:
    linear-gradient(90deg, rgba(255, 225, 157, 0.22) 2px, transparent 2px),
    linear-gradient(rgba(255, 225, 157, 0.12) 2px, transparent 2px);
  background-size: 96px 96px;
  mask-image: linear-gradient(180deg, black, transparent 68%);
}

.moon {
  border-radius: 0;
  clip-path: polygon(25% 0, 75% 0, 75% 8%, 91% 8%, 91% 25%, 100% 25%, 100% 75%, 91% 75%, 91% 91%, 75% 91%, 75% 100%, 25% 100%, 25% 91%, 9% 91%, 9% 75%, 0 75%, 0 25%, 9% 25%, 9% 9%, 25% 9%);
  box-shadow: none;
  filter: drop-shadow(0 0 18px rgba(255, 199, 91, 0.52));
}

.mountain {
  border-top: 8px solid rgba(98, 125, 122, 0.15);
  clip-path: polygon(0 82%, 8% 82%, 8% 70%, 15% 70%, 15% 56%, 24% 56%, 24% 66%, 34% 66%, 34% 48%, 40% 48%, 40% 21%, 48% 21%, 48% 36%, 55% 36%, 55% 62%, 67% 62%, 67% 39%, 75% 39%, 75% 56%, 83% 56%, 83% 71%, 91% 71%, 91% 44%, 100% 44%, 100% 100%, 0 100%);
}

.dragon-mark {
  transform: none;
  border: 3px solid #0c1218;
  outline: 2px solid var(--gold);
  box-shadow:
    0 0 0 7px rgba(229, 189, 105, 0.08),
    8px 8px 0 rgba(0, 0, 0, 0.34);
  clip-path: polygon(18% 0, 82% 0, 82% 8%, 92% 8%, 92% 18%, 100% 18%, 100% 82%, 92% 82%, 92% 92%, 82% 92%, 82% 100%, 18% 100%, 18% 92%, 8% 92%, 8% 82%, 0 82%, 0 18%, 8% 18%, 8% 8%, 18% 8%);
}

.dragon-mark span {
  transform: none;
  text-shadow: 3px 3px 0 #5a351f;
}

.title-en {
  text-shadow:
    3px 0 0 #080c10,
    -3px 0 0 #080c10,
    0 3px 0 #080c10,
    0 -3px 0 #080c10,
    7px 7px 0 rgba(0, 0, 0, 0.45);
}

.primary-button,
.text-button,
.audio-toggle,
.hud,
.objective,
.interaction-prompt,
.dialogue-panel,
.dialogue-next,
.battle-log,
.battle-commands button,
.battle-retry,
.action-button,
.d-pad-button,
.canvas-wrap {
  border-radius: 0;
}

.primary-button,
.battle-commands button,
.battle-retry,
.dialogue-next {
  box-shadow:
    inset 0 0 0 2px rgba(8, 13, 18, 0.56),
    4px 4px 0 rgba(0, 0, 0, 0.4);
}

.hud,
.dialogue-panel,
.battle-log {
  clip-path: polygon(8px 0, calc(100% - 8px) 0, calc(100% - 8px) 4px, 100% 4px, 100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px), calc(100% - 4px) 100%, 8px 100%, 8px calc(100% - 4px), 0 calc(100% - 4px), 0 8px, 4px 8px, 4px 4px, 8px 4px);
}

.meter,
.enemy-meter {
  height: 8px;
  border-radius: 0;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.52);
}

.meter i,
.enemy-meter i {
  border-radius: 0;
}

.dialogue-line,
.battle-log,
.objective,
.hud {
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.52);
}

.battle-panel {
  background:
    repeating-linear-gradient(135deg, rgba(118, 50, 48, 0.12) 0 8px, transparent 8px 16px),
    linear-gradient(135deg, #0c141c, #241a22);
}

.battle-enemy-side {
  border-right-width: 3px;
  border-right-style: double;
}

/* 16-bit console RPG presentation */
:root {
  --window-blue: #071b48;
  --window-blue-light: #12346f;
  --window-edge: #eee7cf;
  --window-shadow: #05070c;
}

body {
  background:
    repeating-linear-gradient(135deg, rgba(52, 73, 96, 0.12) 0 4px, transparent 4px 10px),
    #070c14;
}

.game-screen {
  background:
    linear-gradient(180deg, rgba(40, 71, 91, 0.24), transparent 34%),
    repeating-linear-gradient(90deg, #08101b 0 32px, #0a1420 32px 64px);
}

.game-header {
  padding-bottom: 13px;
}

.mini-title {
  color: #f3d77a;
  text-shadow: 2px 2px 0 #422819;
}

.area-name {
  color: #e7e0cc;
  text-shadow: 2px 2px 0 #03060a;
}

.canvas-wrap {
  border: 5px solid #e8dfc6;
  outline: 4px solid #17294a;
  outline-offset: -9px;
  background: #101823;
  box-shadow:
    0 0 0 5px #05070c,
    9px 11px 0 rgba(0, 0, 0, 0.46),
    0 26px 72px rgba(0, 0, 0, 0.55);
}

.canvas-wrap::before {
  border: 3px solid #101c36;
  outline: 2px solid rgba(255, 248, 214, 0.66);
  outline-offset: -8px;
}

.canvas-wrap::after {
  opacity: 0.08;
  background: repeating-linear-gradient(180deg, transparent 0 2px, rgba(1, 3, 5, 0.36) 2px 3px);
}

.hud,
.objective,
.interaction-prompt,
.pointer-guide,
.dialogue-panel,
.battle-log {
  border: 3px solid var(--window-edge);
  outline: 3px solid var(--window-shadow);
  outline-offset: -7px;
  color: #fffdf1;
  background:
    repeating-linear-gradient(135deg, rgba(77, 119, 190, 0.08) 0 3px, transparent 3px 7px),
    linear-gradient(180deg, rgba(17, 48, 103, 0.98), rgba(5, 18, 53, 0.99));
  box-shadow:
    inset 0 0 0 2px rgba(111, 147, 203, 0.52),
    5px 6px 0 rgba(0, 0, 0, 0.52);
}

.hud {
  width: min(252px, calc(100% - 30px));
  padding: 14px 16px;
}

.hud-name,
.dialogue-speaker {
  color: #ffe786;
  text-shadow: 2px 2px 0 #452916;
}

.hud-level,
.meter-row > span {
  color: #e9e1cd;
}

.meter {
  border: 2px solid #040710;
  background: #101522;
  box-shadow:
    inset 2px 2px 0 rgba(0, 0, 0, 0.62),
    1px 1px 0 rgba(255, 255, 255, 0.15);
}

.meter-hp {
  background: linear-gradient(180deg, #ff9270 0 34%, #d44e3b 35% 67%, #86241f 68%);
}

.meter-mp {
  background: linear-gradient(180deg, #9ee8ff 0 34%, #479ed0 35% 67%, #23537e 68%);
}

.objective {
  padding: 11px 16px;
  font-family: "Osaka-Mono", "Hiragino Kaku Gothic ProN", monospace;
}

.dialogue-panel {
  min-height: 156px;
  padding: 25px 132px 24px 30px;
}

.dialogue-line,
.battle-log {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", serif;
  text-shadow: 2px 2px 0 #02040a;
}

.dialogue-next,
.battle-commands button,
.battle-retry,
.primary-button {
  border: 3px solid #f1e6c7;
  outline: 2px solid #05070c;
  outline-offset: -6px;
  color: #fffbe9;
  background:
    linear-gradient(180deg, #214c89 0 45%, #102e63 46% 100%);
  box-shadow:
    inset 0 0 0 2px #476fa6,
    4px 5px 0 rgba(0, 0, 0, 0.5);
}

.dialogue-next:hover,
.battle-commands button:hover:not(:disabled),
.battle-retry:hover,
.primary-button:hover {
  border-color: #fff6c7;
  color: #fff;
  background: linear-gradient(180deg, #3974b8 0 45%, #1e4d91 46% 100%);
  filter: brightness(1.08);
}

.battle-panel {
  background:
    repeating-linear-gradient(135deg, rgba(68, 93, 128, 0.12) 0 5px, transparent 5px 11px),
    #07101e;
}

.battle-enemy-side {
  padding: 20px;
  border-right: 5px double #dfd5ba;
  background: #050a12;
  box-shadow: inset -4px 0 0 #172f58;
}

#enemy-canvas {
  width: min(100%, 340px);
  border: 3px solid #e7ddc3;
  outline: 3px solid #05070b;
  outline-offset: -7px;
  background: #172437;
  box-shadow:
    inset 0 0 0 2px rgba(72, 99, 139, 0.62),
    5px 6px 0 rgba(0, 0, 0, 0.48);
}

.enemy-name {
  margin-top: 10px;
  color: #fff2b6;
  font-size: 1.08rem;
  text-shadow: 3px 3px 0 #451c19;
}

.enemy-meter {
  height: 11px;
  border: 3px solid #e5dcc5;
  outline: 2px solid #04060a;
  outline-offset: -5px;
  background: #151019;
}

.enemy-meter i {
  background: linear-gradient(180deg, #ff8b63 0 34%, #cf3f34 35% 67%, #792027 68%);
}

.battle-command-side {
  padding: clamp(22px, 4vw, 44px);
  background:
    repeating-linear-gradient(0deg, rgba(81, 118, 173, 0.06) 0 3px, transparent 3px 7px),
    #08152e;
}

.battle-log {
  border-left-width: 3px;
  min-height: 6em;
}

.battle-commands {
  gap: 9px;
}

.battle-commands button {
  min-height: 64px;
  font-family: "Osaka-Mono", "Hiragino Kaku Gothic ProN", monospace;
  text-shadow: 2px 2px 0 #03050a;
}

.battle-commands button:disabled {
  filter: grayscale(0.45) brightness(0.7);
}

.action-button,
.d-pad-button {
  border: 3px solid #e9dfc6;
  outline: 2px solid #05070c;
  outline-offset: -5px;
  color: #fff8de;
  background: linear-gradient(180deg, #315f96, #112f61);
  box-shadow:
    inset 0 0 0 2px rgba(104, 149, 202, 0.65),
    4px 5px 0 rgba(0, 0, 0, 0.48);
}

.action-button:active,
.d-pad-button:active,
.d-pad-button.is-held {
  color: #16100b;
  background: #f4d879;
}

.title-screen {
  background:
    radial-gradient(circle at 72% 19%, rgba(255, 215, 132, 0.22), transparent 18%),
    linear-gradient(180deg, #132c50 0 34%, #315878 35% 53%, #162d33 54% 100%);
}

.title-screen::before {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: -1;
  height: 34%;
  content: "";
  background:
    repeating-linear-gradient(90deg, transparent 0 46px, rgba(255, 237, 175, 0.08) 46px 50px),
    linear-gradient(180deg, #284b3b, #101e24);
  clip-path: polygon(0 42%, 8% 42%, 8% 29%, 17% 29%, 17% 47%, 28% 47%, 28% 18%, 37% 18%, 37% 38%, 48% 38%, 48% 8%, 57% 8%, 57% 41%, 69% 41%, 69% 22%, 79% 22%, 79% 44%, 89% 44%, 89% 28%, 100% 28%, 100% 100%, 0 100%);
}

.dragon-mark {
  width: 86px;
  height: 86px;
  border: 5px double #ffec9a;
  outline: 4px solid #321d18;
  color: #fff0a4;
  background:
    repeating-linear-gradient(135deg, rgba(255, 218, 112, 0.12) 0 5px, transparent 5px 10px),
    #8c352f;
  box-shadow:
    inset 0 0 0 3px #c66d3e,
    7px 8px 0 rgba(0, 0, 0, 0.48);
}

.dragon-mark span {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 2.5rem;
  text-shadow:
    3px 3px 0 #4e211d,
    -2px -2px 0 #fff4bc;
}

.title-en {
  color: #fff3a8;
  font-weight: 800;
  text-shadow:
    4px 0 0 #5c2521,
    -4px 0 0 #5c2521,
    0 4px 0 #5c2521,
    0 -4px 0 #5c2521,
    7px 7px 0 #170d10,
    0 0 20px rgba(255, 218, 117, 0.38);
}

.title-ja {
  color: #fff8d1;
  text-shadow:
    3px 3px 0 #401e1c,
    -1px -1px 0 #a5573b;
}

.title-kicker,
.title-note {
  color: #f4e9c4;
  text-shadow: 2px 2px 0 #06101a;
}

@media (max-width: 680px) {
  .battle-enemy-side {
    padding: 8px;
  }

  .battle-command-side {
    padding: 10px;
  }

  .battle-commands button {
    min-height: 49px;
  }

  .dialogue-panel {
    min-height: 134px;
    padding: 18px 78px 18px 18px;
  }
}

@media (max-height: 760px) {
  .game-screen {
    padding: 6px 10px;
  }

  .game-header {
    align-items: center;
    padding-bottom: 6px;
  }

  .mini-title {
    font-size: 0.62rem;
  }

  .area-name {
    margin-top: 1px;
    font-size: 0.6rem;
  }

  .game-shell {
    width: min(100%, 1120px, max(300px, calc(177.778vh - 250px)));
    width: min(100%, 1120px, max(300px, calc(177.778dvh - 250px)));
  }

  .game-controls {
    min-height: 78px;
    padding-top: 6px;
  }

  .game-controls > p {
    display: none;
  }

  .touch-controls {
    width: 100%;
    justify-content: flex-end;
    gap: 10px;
  }

  .d-pad {
    grid-template: repeat(3, 24px) / repeat(3, 24px);
    gap: 2px;
  }

  .action-button {
    width: 58px;
    height: 58px;
    font-size: 0.58rem;
  }

  .battle-command-side {
    padding: 10px;
  }

  .battle-log {
    min-height: 4em;
    margin-bottom: 8px;
    padding: 8px 10px;
    font-size: clamp(0.68rem, 1.5vw, 0.86rem);
    line-height: 1.4;
  }

  .battle-commands {
    gap: 5px;
  }

  .battle-commands button,
  .battle-retry {
    min-height: 42px;
    padding: 5px 6px;
    font-size: 0.68rem;
  }

  .battle-commands .sacred-rainbow {
    min-height: 52px;
  }
}

@media (max-height: 520px) {
  .game-screen {
    padding: 3px 8px;
  }

  .game-header {
    padding-bottom: 3px;
  }

  .mini-title {
    display: none;
  }

  .game-shell {
    width: min(100%, 1120px, max(280px, calc(177.778vh - 210px)));
    width: min(100%, 1120px, max(280px, calc(177.778dvh - 210px)));
  }

  .game-controls {
    min-height: 62px;
    padding-top: 3px;
  }

  .d-pad {
    grid-template: repeat(3, 19px) / repeat(3, 19px);
  }

  .action-button {
    width: 48px;
    height: 48px;
    font-size: 0.5rem;
  }

  .battle-enemy-side,
  .battle-command-side {
    padding: 6px;
  }

  .battle-log {
    min-height: 3.2em;
    margin-bottom: 4px;
    padding: 5px 7px;
    font-size: 0.6rem;
    line-height: 1.3;
  }

  .battle-commands {
    gap: 3px;
  }

  .battle-commands button,
  .battle-retry {
    min-height: 34px;
    padding: 3px 4px;
    font-size: 0.56rem;
  }

  .battle-commands .sacred-rainbow {
    min-height: 40px;
  }

  .enemy-name {
    margin-top: 4px;
    font-size: 0.72rem;
  }

  .enemy-meter {
    height: 8px;
  }
}

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

/* Refined title presentation */
.title-screen {
  background:
    radial-gradient(circle at 50% 38%, rgba(197, 211, 218, 0.055), transparent 32%),
    linear-gradient(180deg, #0d151d 0%, #080d12 100%);
}

.title-screen::before {
  position: absolute;
  right: 8%;
  bottom: 12%;
  left: 8%;
  z-index: -1;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(226, 213, 176, 0.2), transparent);
  clip-path: none;
}

.title-screen::after {
  opacity: 0.025;
  background-image: linear-gradient(rgba(255, 255, 255, 0.7) 1px, transparent 1px);
  background-size: 100% 4px;
  mask-image: none;
}

.title-content {
  width: min(88vw, 720px);
  padding: 42px 24px;
}

#game-title {
  gap: 16px;
  text-shadow: none;
}

.title-ja {
  margin: 0;
  color: #f3efe5;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  /* 8文字+字間が .title-content の上限幅（720px - padding）に収まる上限にする */
  font-size: clamp(2.25rem, 6.8vw, 4.5rem);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: 0.14em;
  text-shadow: 0 8px 30px rgba(0, 0, 0, 0.32);
}

.title-en {
  color: rgba(229, 220, 196, 0.58);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(0.62rem, 1.3vw, 0.78rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.42em;
  text-shadow: none;
}

.hero-name-entry {
  width: min(76vw, 280px);
  margin-top: clamp(38px, 7vh, 64px);
  gap: 11px;
  color: rgba(243, 239, 229, 0.62);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.16em;
}

.hero-name-entry input {
  padding: 11px 12px;
  border: 0;
  border-bottom: 1px solid rgba(229, 220, 196, 0.45);
  border-radius: 0;
  outline: 0;
  color: #f5f1e8;
  font-size: 1rem;
  font-weight: 500;
  background: transparent;
  box-shadow: none;
}

.hero-name-entry input:focus {
  border-color: #e5d6ad;
  box-shadow: 0 7px 16px -13px rgba(229, 214, 173, 0.9);
}

.title-content .primary-button {
  min-width: 210px;
  margin-top: 32px;
  padding: 13px 26px;
  border: 1px solid rgba(229, 220, 196, 0.5);
  color: #f3efe5;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  background: rgba(255, 255, 255, 0.025);
  box-shadow: none;
}

.title-content .primary-button:hover {
  color: #111820;
  background: #e5d6ad;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.2);
}

.title-note {
  margin-top: 16px;
  color: rgba(243, 239, 229, 0.28);
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-shadow: none;
}

.ending-continue-button {
  position: absolute;
  bottom: 7%;
  left: 50%;
  min-width: 180px;
  padding: 11px 22px;
  transform: translateX(-50%);
  border: 1px solid rgba(255, 248, 222, 0.66);
  color: #fff8e6;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  background: rgba(5, 10, 16, 0.64);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.32);
  cursor: pointer;
}

.ending-continue-button:hover {
  color: #101821;
  background: #fff0c7;
}

@media (max-width: 680px) {
  .title-content {
    padding-top: 24px;
  }

  .title-ja {
    letter-spacing: 0.09em;
  }

  .hero-name-entry {
    margin-top: 34px;
  }
}

.battle-hero-status {
  margin: 0 0 12px;
  padding: 11px 13px;
  border: 2px solid rgba(229, 220, 196, 0.68);
  outline: 2px solid rgba(3, 6, 10, 0.78);
  outline-offset: -5px;
  color: #f6f0dc;
  font-family: "Osaka-Mono", "Hiragino Kaku Gothic ProN", monospace;
  background: rgba(4, 12, 27, 0.86);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35);
  transition: border-color 180ms ease, background-color 180ms ease;
}

.battle-hero-status header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: #fff0ae;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
}

.battle-hero-status header strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.battle-hero-status header span {
  flex: 0 0 auto;
  color: #d8e4f0;
  font-size: 0.7rem;
}

.battle-resource-row {
  display: grid;
  grid-template-columns: 26px minmax(70px, 1fr) minmax(66px, auto);
  align-items: center;
  gap: 8px;
  min-height: 17px;
  font-size: 0.68rem;
}

.battle-resource-row > span {
  color: #dce7ed;
  font-weight: 900;
}

.battle-resource-row > b {
  text-align: right;
  white-space: nowrap;
}

.battle-resource-meter {
  height: 8px;
  overflow: hidden;
  border: 2px solid rgba(231, 224, 204, 0.7);
  background: #100f17;
  box-shadow: inset 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.battle-resource-meter i {
  display: block;
  width: 100%;
  height: 100%;
  transition: width 260ms ease;
}

.battle-resource-hp .battle-resource-meter i {
  background: linear-gradient(180deg, #84ec93 0 40%, #2eaa58 41% 100%);
}

.battle-resource-mp .battle-resource-meter i {
  background: linear-gradient(180deg, #86d8ff 0 40%, #347bc4 41% 100%);
}

.battle-hero-status[data-hp-state="warning"] {
  border-color: #e7bd68;
  background: rgba(31, 25, 12, 0.9);
}

.battle-hero-status[data-hp-state="critical"] {
  border-color: #f0786c;
  background: rgba(45, 10, 18, 0.92);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.35), 0 0 16px rgba(230, 55, 55, 0.24);
}

.battle-hero-status[data-hp-state="critical"] .battle-resource-hp .battle-resource-meter i {
  background: linear-gradient(180deg, #ff9a78 0 40%, #cf3438 41% 100%);
}

@media (max-width: 680px) {
  .battle-hero-status {
    margin-bottom: 7px;
    padding: 7px 9px;
  }

  .battle-hero-status header {
    margin-bottom: 4px;
    font-size: 0.68rem;
  }

  .battle-resource-row {
    grid-template-columns: 22px minmax(44px, 1fr) minmax(52px, auto);
    gap: 5px;
    min-height: 14px;
    font-size: 0.58rem;
  }

  .battle-resource-meter {
    height: 6px;
  }
}

@media (max-height: 760px) {
  .battle-hero-status {
    margin-bottom: 6px;
    padding: 6px 9px;
  }

  .battle-hero-status header {
    margin-bottom: 3px;
  }

  .battle-resource-row {
    min-height: 13px;
  }
}

@media (max-height: 560px) {
  .battle-hero-status {
    margin-bottom: 3px;
    padding: 4px 7px;
  }

  .battle-hero-status header {
    margin-bottom: 2px;
    font-size: 0.6rem;
  }

  .battle-resource-row {
    min-height: 11px;
    font-size: 0.52rem;
  }

  .battle-resource-meter {
    height: 5px;
  }
}

.hero-name-entry input::placeholder {
  color: #f5f1e8;
  opacity: 0.38;
}

.hero-name-entry > small {
  color: rgba(243, 239, 229, 0.46);
  font-size: 0.56rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

@media (max-width: 680px) {
  .audio-toggle {
    top: max(6px, env(safe-area-inset-top));
    right: max(6px, env(safe-area-inset-right));
    min-width: 52px;
    padding: 6px 7px;
    font-size: 0.54rem;
  }

  .title-screen {
    overflow-x: hidden;
    overflow-y: auto;
    place-items: start center;
  }

  .title-content {
    width: 100%;
    min-height: 100dvh;
    padding: max(58px, calc(env(safe-area-inset-top) + 44px)) 18px max(24px, env(safe-area-inset-bottom));
  }

  .title-ja {
    font-size: clamp(1.35rem, 7vw, 2rem);
    letter-spacing: 0.1em;
  }

  .title-en {
    font-size: 0.58rem;
    letter-spacing: 0.28em;
  }

  .hero-name-entry {
    width: min(82vw, 280px);
    margin-top: clamp(28px, 6vh, 46px);
    gap: 8px;
  }

  .hero-name-entry input {
    min-height: 42px;
    font-size: 16px;
  }

  .hero-name-entry > small {
    font-size: 0.54rem;
  }

  .title-content .primary-button {
    margin-top: 25px;
  }

  .game-screen {
    padding-top: max(5px, env(safe-area-inset-top));
    padding-right: max(6px, env(safe-area-inset-right));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
    padding-left: max(6px, env(safe-area-inset-left));
    overflow: hidden;
  }

  .game-header {
    min-height: 34px;
    align-items: center;
    padding: 0 60px 5px 1px;
  }

  .mini-title {
    font-size: 0.54rem;
  }

  .area-name {
    font-size: 0.56rem;
  }

  .game-header > .text-button {
    padding: 5px 0;
    font-size: 0.56rem;
  }

  .canvas-wrap {
    border-width: 3px;
    outline-width: 2px;
    outline-offset: -6px;
    box-shadow: 0 0 0 3px #05070c, 4px 5px 0 rgba(0, 0, 0, 0.42);
  }

  .canvas-wrap::before {
    border-width: 2px;
    outline-width: 1px;
    outline-offset: -5px;
  }

  .hud {
    top: 6px;
    left: 6px;
    width: min(172px, calc(100% - 12px));
    padding: 6px 8px;
    border-width: 2px;
    outline-width: 2px;
    outline-offset: -5px;
  }

  .hud-name-row {
    margin-bottom: 3px;
  }

  .hud-name {
    font-size: 0.58rem;
  }

  .hud-level,
  .meter-row,
  .meter-row b {
    font-size: 0.48rem;
  }

  .meter-row {
    margin-top: 2px;
    gap: 4px;
  }

  .meter-row > span {
    width: 16px;
  }

  .meter-row b {
    width: 44px;
  }

  .meter {
    height: 4px;
  }

  .objective,
  .pointer-guide {
    right: 6px;
    bottom: 6px;
    max-width: calc(100% - 12px);
    padding: 5px 7px;
    border-width: 2px;
    outline-width: 2px;
    outline-offset: -5px;
    font-size: 0.48rem;
  }

  .pointer-guide {
    right: auto;
    left: 6px;
  }

  .interaction-prompt {
    bottom: 38px;
    padding: 5px 7px;
    font-size: 0.52rem;
  }

  .dialogue-panel {
    right: 2%;
    bottom: 2%;
    left: 2%;
    min-height: 0;
    max-height: 62%;
    padding: 10px 58px 10px 13px;
    border-width: 2px;
    outline-width: 2px;
    outline-offset: -5px;
  }

  .dialogue-speaker {
    margin-bottom: 4px;
    font-size: 0.58rem;
  }

  .dialogue-line {
    max-height: 5.8em;
    overflow-y: auto;
    font-size: clamp(0.72rem, 3.2vw, 0.86rem);
    line-height: 1.42;
    -webkit-overflow-scrolling: touch;
  }

  .dialogue-next {
    right: 8px;
    bottom: 8px;
    min-width: 45px;
    padding: 6px 5px;
    font-size: 0.54rem;
  }

  .scene-intertitle-copy {
    width: 90%;
  }

  .scene-intertitle-copy p {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
  }

  .scene-intertitle-copy .scene-intertitle-time {
    margin-bottom: 12px;
    font-size: 1.15rem;
  }

  .scene-intertitle-next {
    right: 5%;
    bottom: 6%;
    min-width: 68px;
    padding: 7px 9px;
    font-size: 0.58rem;
  }

  .battle-panel {
    grid-template-columns: 34% 66%;
  }

  .battle-enemy-side {
    padding: 4px;
    border-right-width: 2px;
    overflow: hidden;
  }

  #enemy-canvas {
    width: 100%;
    max-height: 105px;
    border-width: 1px;
    outline-width: 1px;
    outline-offset: -3px;
    object-fit: contain;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.4);
  }

  .enemy-name {
    margin: 3px 0 1px;
    font-size: 0.56rem;
    line-height: 1.15;
    text-align: center;
  }

  .enemy-trait {
    max-width: 96%;
    margin: 2px 0;
    padding: 2px 3px;
    font-size: 0.42rem;
    line-height: 1.1;
  }

  .enemy-meter {
    width: 86%;
    height: 5px;
    border-width: 1px;
    outline-width: 0;
  }

  .battle-command-side {
    justify-content: center;
    overflow: hidden;
    padding: 4px;
  }

  .battle-hero-status {
    margin-bottom: 3px;
    padding: 4px 6px;
    border-width: 1px;
    outline-width: 1px;
    outline-offset: -3px;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.32);
  }

  .battle-hero-status header {
    margin-bottom: 1px;
    font-size: 0.55rem;
  }

  .battle-hero-status header span {
    font-size: 0.46rem;
  }

  .battle-resource-row {
    grid-template-columns: 18px minmax(28px, 1fr) minmax(46px, auto);
    gap: 3px;
    min-height: 10px;
    font-size: 0.46rem;
  }

  .battle-resource-meter {
    height: 4px;
    border-width: 1px;
  }

  .battle-log {
    min-height: 0;
    height: 42px;
    margin: 0 0 3px;
    overflow-y: auto;
    padding: 4px 5px;
    border-width: 1px;
    outline-width: 1px;
    outline-offset: -3px;
    font-size: 0.48rem;
    line-height: 1.25;
    -webkit-overflow-scrolling: touch;
  }

  .battle-commands {
    gap: 2px;
  }

  .battle-commands button,
  .battle-retry {
    min-height: 27px;
    padding: 2px 2px;
    border-width: 1px;
    outline-width: 1px;
    outline-offset: -3px;
    font-size: 0.46rem;
    line-height: 1.05;
    letter-spacing: 0;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
  }

  .battle-commands small {
    margin-top: 1px;
    font-size: 0.38rem;
  }

  .battle-commands .sacred-rainbow {
    min-height: 34px;
  }

  .battle-announcement small,
  .battle-announcement span {
    font-size: 0.52rem;
    letter-spacing: 0.14em;
  }

  .battle-announcement strong {
    padding: 5px 8px;
    font-size: 1.08rem;
    letter-spacing: 0.06em;
  }

  .game-controls {
    min-height: 86px;
    padding: 7px 2px 0;
  }

  .d-pad {
    grid-template: repeat(3, 27px) / repeat(3, 27px);
    gap: 2px;
  }

  .action-button {
    width: 62px;
    height: 62px;
    font-size: 0.54rem;
  }
}

@media (max-width: 680px) and (orientation: portrait) {
  .game-shell {
    width: 100%;
    align-content: start;
  }

  .touch-controls {
    padding-right: max(2px, env(safe-area-inset-right));
    padding-left: max(2px, env(safe-area-inset-left));
  }
}

@media (max-height: 520px) and (pointer: coarse) {
  .title-content {
    min-height: 100dvh;
    padding-top: max(32px, env(safe-area-inset-top));
  }

  .hero-name-entry {
    margin-top: 18px;
  }

  .title-content .primary-button {
    margin-top: 16px;
  }

  .game-header {
    padding-right: 58px;
  }

  .game-controls {
    min-height: 58px;
    padding-top: 3px;
  }

  .d-pad {
    grid-template: repeat(3, 18px) / repeat(3, 18px);
  }

  .action-button {
    width: 46px;
    height: 46px;
    font-size: 0.48rem;
  }
}

/* The message window occupies its own row below the game screen. */
.game-shell {
  width: min(100%, 1120px, max(280px, calc(177.778vh - 450px)));
  width: min(100%, 1120px, max(280px, calc(177.778dvh - 450px)));
  gap: 10px;
}

.game-text-area {
  position: relative;
  min-height: 148px;
  overflow: hidden;
  border: 5px solid var(--window-edge);
  outline: 4px solid #17294a;
  outline-offset: -9px;
  color: #fffdf1;
  background:
    repeating-linear-gradient(135deg, rgba(77, 119, 190, 0.08) 0 3px, transparent 3px 7px),
    linear-gradient(180deg, rgba(17, 48, 103, 0.98), rgba(5, 18, 53, 0.99));
  box-shadow:
    0 0 0 5px #05070c,
    6px 7px 0 rgba(0, 0, 0, 0.42);
}

.game-text-area .objective,
.game-text-area .interaction-prompt,
.game-text-area .pointer-guide,
.game-text-area .battle-log,
.game-text-area .dialogue-panel {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  min-height: 0;
  margin: 0;
  transform: none;
  border: 0;
  outline: 0;
  border-radius: 0;
  clip-path: none;
  color: #fffdf1;
  background: transparent;
  box-shadow: none;
}

.game-text-area .objective,
.game-text-area .interaction-prompt,
.game-text-area .pointer-guide {
  display: flex;
  left: 0;
  align-items: center;
  padding: 18px 24px;
  font-family: "Osaka-Mono", "Hiragino Kaku Gothic ProN", monospace;
  font-size: clamp(0.72rem, 1.6vw, 0.9rem);
  line-height: 1.55;
  white-space: normal;
  pointer-events: none;
}

.game-text-area .interaction-prompt span {
  flex: 0 0 auto;
  margin-right: 10px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 231, 134, 0.52);
  color: #ffe786;
  background: rgba(255, 255, 255, 0.06);
}

.game-text-area .dialogue-panel {
  z-index: 4;
  padding: 20px 118px 18px 24px;
  cursor: pointer;
}

.game-text-area .dialogue-line {
  max-height: 4.9em;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.game-text-area .battle-log {
  z-index: 3;
  padding: 20px 24px;
  overflow-y: auto;
  font-size: clamp(0.82rem, 1.8vw, 1rem);
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 680px) {
  .game-shell {
    width: 100%;
    gap: 6px;
  }

  .game-text-area {
    min-height: 112px;
    border-width: 3px;
    outline-width: 2px;
    outline-offset: -6px;
    box-shadow:
      0 0 0 3px #05070c,
      3px 4px 0 rgba(0, 0, 0, 0.42);
  }

  .game-text-area .objective,
  .game-text-area .interaction-prompt,
  .game-text-area .pointer-guide {
    padding: 10px 12px;
    font-size: 0.64rem;
    line-height: 1.4;
  }

  .game-text-area .interaction-prompt span {
    margin-right: 7px;
    padding: 3px 6px;
  }

  .game-text-area .dialogue-panel {
    padding: 10px 58px 9px 12px;
  }

  .game-text-area .dialogue-speaker {
    margin-bottom: 4px;
    font-size: 0.58rem;
  }

  .game-text-area .dialogue-line {
    max-height: 5.7em;
    font-size: clamp(0.72rem, 3.2vw, 0.86rem);
    line-height: 1.42;
  }

  .game-text-area .dialogue-next {
    right: 8px;
    bottom: 8px;
    min-width: 44px;
    padding: 6px 5px;
    font-size: 0.54rem;
  }

  .game-text-area .battle-log {
    padding: 10px 12px;
    font-size: 0.68rem;
    line-height: 1.45;
  }
}

@media (max-height: 520px) and (pointer: coarse) {
  .game-shell {
    width: min(100%, 1120px, max(280px, calc(177.778vh - 210px)));
    width: min(100%, 1120px, max(280px, calc(177.778dvh - 210px)));
    gap: 4px;
  }

  .game-text-area {
    min-height: 68px;
  }

  .game-text-area .objective,
  .game-text-area .interaction-prompt,
  .game-text-area .pointer-guide {
    padding: 6px 9px;
    font-size: 0.54rem;
    line-height: 1.25;
  }

  .game-text-area .dialogue-panel {
    padding: 6px 48px 5px 9px;
  }

  .game-text-area .dialogue-speaker {
    margin-bottom: 2px;
    font-size: 0.48rem;
  }

  .game-text-area .dialogue-line {
    max-height: 3.8em;
    font-size: 0.58rem;
    line-height: 1.25;
  }

  .game-text-area .dialogue-next {
    right: 5px;
    bottom: 5px;
    min-width: 38px;
    padding: 4px;
    font-size: 0.46rem;
  }

  .game-text-area .battle-log {
    padding: 6px 8px;
    font-size: 0.56rem;
    line-height: 1.25;
  }
}

/* Keep the complete final tableau visible on every phone aspect ratio. */
.ending-screen {
  background: #03060b;
}

#ending-canvas {
  object-fit: contain;
  object-position: center;
  background: #03060b;
}

@media (max-width: 680px) and (orientation: portrait) {
  .ending-copy {
    top: max(7%, calc(env(safe-area-inset-top) + 16px));
    width: min(90vw, 520px);
  }

  .ending-copy p {
    margin-bottom: 8px;
    font-size: 0.78rem;
  }

  .ending-copy h2 {
    font-size: 0.82rem;
    line-height: 1.55;
  }

  .ending-continue-button {
    bottom: max(7%, calc(env(safe-area-inset-bottom) + 16px));
  }
}

/* Smartphone portrait: a compact stage with a generous message window. */
@media (max-width: 680px) and (orientation: portrait) {
  .game-screen {
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    padding-top: max(5px, env(safe-area-inset-top));
    padding-right: max(7px, env(safe-area-inset-right));
    padding-bottom: max(7px, env(safe-area-inset-bottom));
    padding-left: max(7px, env(safe-area-inset-left));
  }

  .game-header {
    min-height: 36px;
    padding: 0 59px 5px 2px;
  }

  .game-shell {
    width: 100%;
    height: 100%;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto clamp(150px, 28vh, 230px);
    grid-template-rows: auto clamp(150px, 28dvh, 230px);
    align-content: start;
    gap: 8px;
    padding-top: clamp(4px, 1.6vh, 13px);
    padding-top: clamp(4px, 1.6dvh, 13px);
  }

  .canvas-wrap {
    width: 100%;
    align-self: start;
  }

  .game-text-area {
    width: 100%;
    height: auto;
    min-height: 0;
  }

  .game-text-area .objective,
  .game-text-area .interaction-prompt,
  .game-text-area .pointer-guide {
    align-items: center;
    padding: 16px;
    font-size: clamp(0.72rem, 3.2vw, 0.86rem);
    line-height: 1.55;
  }

  .game-text-area .dialogue-panel {
    padding: 15px 70px 14px 16px;
  }

  .game-text-area .dialogue-speaker {
    margin-bottom: 7px;
    font-size: 0.66rem;
  }

  .game-text-area .dialogue-line {
    max-height: calc(100% - 24px);
    font-size: clamp(0.82rem, 3.8vw, 1rem);
    line-height: 1.55;
  }

  .game-text-area .dialogue-next {
    right: 10px;
    bottom: 10px;
    min-width: 50px;
    min-height: 38px;
    padding: 7px 6px;
    font-size: 0.6rem;
  }

  .game-text-area .battle-log {
    padding: 15px 16px;
    font-size: clamp(0.76rem, 3.5vw, 0.92rem);
    line-height: 1.55;
  }

  .meter {
    height: 8px;
    border-width: 1px;
  }

  .meter i {
    min-width: 1px;
    min-height: 100%;
  }

  .battle-panel {
    grid-template-columns: 36% 64%;
  }

  .battle-enemy-side {
    padding: 5px;
  }

  #enemy-canvas {
    max-height: 98px;
  }

  .enemy-name {
    font-size: 0.62rem;
  }

  .battle-command-side {
    padding: 5px;
  }

  .battle-hero-status {
    margin-bottom: 4px;
    padding: 5px 7px;
  }

  .battle-hero-status header {
    font-size: 0.6rem;
  }

  .battle-resource-row {
    grid-template-columns: 19px minmax(30px, 1fr) minmax(48px, auto);
    min-height: 11px;
    font-size: 0.5rem;
  }

  .battle-resource-meter {
    height: 6px;
    border-width: 1px;
  }

  .battle-commands {
    gap: 3px;
  }

  .battle-commands button,
  .battle-retry {
    min-height: 30px;
    padding: 3px;
    font-size: 0.55rem;
    line-height: 1.1;
  }

  .battle-commands small {
    font-size: 0.42rem;
  }
}

/* Smartphone landscape: use the full width as a two-pane RPG layout. */
@media (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
  .game-screen {
    grid-template-rows: auto minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    padding-top: max(3px, env(safe-area-inset-top));
    padding-right: max(7px, env(safe-area-inset-right));
    padding-bottom: max(5px, env(safe-area-inset-bottom));
    padding-left: max(7px, env(safe-area-inset-left));
  }

  .game-header {
    min-height: 27px;
    padding: 0 58px 3px 1px;
  }

  .mini-title {
    display: none;
  }

  .area-name,
  .game-header > .text-button {
    font-size: 0.54rem;
  }

  .game-shell {
    width: 100%;
    height: 100%;
    grid-template-columns: minmax(0, 72%) minmax(150px, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-items: stretch;
    gap: 6px;
    padding: 0;
  }

  .canvas-wrap {
    width: 100%;
    align-self: center;
  }

  .game-text-area {
    width: 100%;
    height: 100%;
    min-height: 0;
  }

  .game-text-area .objective,
  .game-text-area .interaction-prompt,
  .game-text-area .pointer-guide {
    align-items: flex-start;
    padding: 13px 11px;
    font-size: clamp(0.6rem, 1.65vw, 0.72rem);
    line-height: 1.5;
  }

  .game-text-area .interaction-prompt {
    flex-direction: column;
    gap: 8px;
  }

  .game-text-area .interaction-prompt span {
    margin-right: 0;
  }

  .game-text-area .dialogue-panel {
    padding: 12px 11px 48px;
  }

  .game-text-area .dialogue-speaker {
    margin-bottom: 7px;
    font-size: 0.58rem;
  }

  .game-text-area .dialogue-line {
    max-height: calc(100% - 30px);
    font-size: clamp(0.68rem, 1.9vw, 0.82rem);
    line-height: 1.5;
  }

  .game-text-area .dialogue-next {
    right: 9px;
    bottom: 9px;
    min-width: 48px;
    min-height: 34px;
    padding: 6px;
    font-size: 0.54rem;
  }

  .game-text-area .battle-log {
    padding: 12px 11px;
    font-size: clamp(0.62rem, 1.75vw, 0.76rem);
    line-height: 1.5;
  }

  .meter {
    height: 8px;
    border-width: 1px;
  }

  .meter i {
    min-width: 1px;
    min-height: 100%;
  }

  .battle-panel {
    grid-template-columns: 36% 64%;
  }

  .battle-enemy-side {
    padding: 7px;
  }

  #enemy-canvas {
    width: 100%;
    max-height: 165px;
  }

  .enemy-name {
    margin: 5px 0 3px;
    font-size: 0.68rem;
  }

  .enemy-trait {
    font-size: 0.5rem;
  }

  .battle-command-side {
    padding: 7px;
  }

  .battle-hero-status {
    margin-bottom: 5px;
    padding: 6px 8px;
  }

  .battle-hero-status header {
    margin-bottom: 3px;
    font-size: 0.62rem;
  }

  .battle-resource-row {
    grid-template-columns: 20px minmax(36px, 1fr) minmax(52px, auto);
    min-height: 12px;
    font-size: 0.52rem;
  }

  .battle-resource-meter {
    height: 6px;
    border-width: 1px;
  }

  .battle-commands {
    gap: 4px;
  }

  .battle-commands button,
  .battle-retry {
    min-height: 34px;
    padding: 4px;
    font-size: 0.58rem;
  }

  .battle-commands small {
    font-size: 0.44rem;
  }
}

/* Final smartphone override: keep every battle choice at least finger-sized. */
@media (max-width: 680px) and (orientation: portrait) {
  .battle-panel {
    grid-template-columns: 32% 68%;
  }

  .battle-command-side {
    min-height: 0;
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 3px;
    scrollbar-width: none;
  }

  .battle-commands {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-content: start;
    width: 100%;
    gap: 3px;
  }

  .battle-commands .sacred-light-command,
  .battle-commands .physical-command,
  .battle-commands [data-battle-action="heal"],
  .battle-commands [data-battle-action="guard"] {
    grid-column: auto;
  }

  .battle-commands button,
  .battle-retry {
    min-width: 0;
    min-height: 40px;
    padding: 4px 3px;
    font-size: clamp(0.64rem, 2.8vw, 0.76rem);
    line-height: 1.12;
    white-space: nowrap;
  }

  .battle-commands small {
    margin-top: 1px;
    font-size: 0.48rem;
  }

  .battle-commands .sacred-rainbow {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .battle-hero-status {
    flex: 0 0 auto;
    margin-bottom: 3px;
    padding: 3px 5px;
  }

  .battle-hero-status header {
    margin-bottom: 1px;
    font-size: 0.54rem;
    line-height: 1;
  }

  .battle-hero-status header span {
    font-size: 0.44rem;
  }

  .battle-resource-row {
    grid-template-columns: 17px minmax(24px, 1fr) minmax(44px, auto);
    gap: 2px;
    min-height: 9px;
    font-size: 0.46rem;
  }

  .battle-resource-meter {
    height: 4px;
  }
}

@media (max-height: 520px) and (orientation: landscape) and (pointer: coarse) {
  .battle-panel {
    grid-template-columns: 32% 68%;
  }

  .battle-command-side {
    min-height: 0;
    justify-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 5px;
    scrollbar-width: none;
  }

  .battle-commands {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    gap: 5px;
  }

  .battle-commands .sacred-light-command,
  .battle-commands .physical-command,
  .battle-commands [data-battle-action="heal"],
  .battle-commands [data-battle-action="guard"] {
    grid-column: auto;
  }

  .battle-commands button,
  .battle-retry {
    min-height: 44px;
    padding: 5px 4px;
    font-size: 0.66rem;
    line-height: 1.12;
  }

  .battle-commands small {
    font-size: 0.48rem;
  }

  .battle-commands .sacred-rainbow {
    grid-column: 1 / -1;
  }
}

/* Final blow: let the seven-colored light gather before the emperor breaks apart. */
.battle-panel.is-rainbow-finisher {
  background:
    radial-gradient(circle at 24% 50%, rgba(255, 255, 235, 0.3), transparent 30%),
    linear-gradient(135deg, #07101e, #161224);
}

.battle-panel.is-rainbow-finisher::after {
  position: absolute;
  inset: 0;
  z-index: 11;
  content: "";
  background:
    radial-gradient(circle at 24% 50%, #fff 0 2%, rgba(255, 250, 187, 0.94) 4%, rgba(118, 222, 255, 0.5) 13%, transparent 31%),
    conic-gradient(from 0deg at 24% 50%, rgba(255, 87, 87, 0.26), rgba(255, 225, 89, 0.28), rgba(91, 235, 159, 0.25), rgba(88, 199, 255, 0.28), rgba(174, 105, 255, 0.26), rgba(255, 105, 187, 0.25), rgba(255, 87, 87, 0.26));
  transform-origin: 24% 50%;
  pointer-events: none;
  animation: rainbow-finisher-gather 1800ms ease-in both;
}

.battle-panel.is-rainbow-impact::after {
  position: absolute;
  inset: 0;
  z-index: 11;
  content: "";
  background: radial-gradient(circle at 24% 50%, #fff 0 8%, rgba(255, 245, 181, 0.94) 16%, rgba(147, 220, 255, 0.45) 34%, transparent 62%);
  pointer-events: none;
  animation: rainbow-finisher-impact 700ms ease-out both;
}

.battle-panel.is-lion-disintegrating {
  background:
    radial-gradient(circle at 24% 50%, rgba(255, 234, 143, 0.18), transparent 36%),
    #050913;
}

@keyframes rainbow-finisher-gather {
  0% {
    opacity: 0;
    transform: scale(1.28) rotate(-8deg);
  }

  32% {
    opacity: 0.62;
  }

  76% {
    opacity: 0.92;
    transform: scale(0.72) rotate(10deg);
  }

  100% {
    opacity: 1;
    transform: scale(0.22) rotate(18deg);
  }
}

@keyframes rainbow-finisher-impact {
  0% {
    opacity: 1;
    filter: brightness(1.8);
    transform: scale(0.18);
  }

  42% {
    opacity: 0.95;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    filter: brightness(1);
    transform: scale(1.18);
  }
}
