/* ============================================================
   screen-battle.css  ―  バトル画面・オーバーレイ
   battle.html と index.html の出撃前選択で読み込む
   ============================================================ */

#screen-battle {
  --battle-frame-light: rgba(204, 204, 204, 0.5);
  --battle-frame-subtle: rgba(109, 118, 136, 0.5);
  --battle-text-main: var(--ui-text-main);
  --battle-text-subtle: var(--ui-text-subtle);
  --battle-hp: #4ec94e;
  --battle-hp-dark: #369936;
  --battle-mp: #6ec1ff;
  --battle-mp-dark: #3f8fd0;
  /* プレイヤーのGゲージ＝チャージ色（暖色）。MPの青と被らないようにする */
  --battle-gauge: #ffa733;
  --battle-gauge-dark: #d97e1f;
  --battle-enemy-gauge: #a56bff;
  --battle-enemy-gauge-dark: #7542d2;
  --battle-word-lines: 1;
  --battle-word-font-size: 1.56rem;
  --battle-word-line-height: 1.35;
  --battle-extra-word-height: 0px;
  /* 共通の1.5倍拡大後も、バトルの背景と表示領域の高さを一致させる。 */
  height: calc(100dvh / var(--ui-scale));
  background: linear-gradient(to bottom, #030312 0%, #0b1230 62%, #091020 100%);
  overflow: hidden;
}

#screen-battle::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0, 0, 0, 0.08) 3px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  z-index: 10;
}

#screen-battle .pixel-stars {
  z-index: 0;
}

/* zoom / DPI 設定に関係なく必ず画面中央に配置される */
.battle-container {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 11;
  transform: translate(-50%, -50%);
  width: min(94%, 720px);
  max-height: calc((100dvh - 24px) / var(--ui-scale));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 0 20px;
  font-family: "DotGothic16", monospace;
  color: var(--ui-text-main);
}

.enemy-area,
.typing-area,
.player-area,
.overlay-content {
  background: rgba(0, 0, 8, 0.92);
  box-shadow:
    0 0 0 2px #000000,
    0 0 0 4px var(--battle-frame-light),
    0 0 0 6px #000000;
  border-radius: 0;
}

.enemy-area,
.typing-area,
.player-area {
  flex-shrink: 0;
}

.enemy-area {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(180px, 0.9fr);
  align-items: end;
  gap: 18px;
  min-height: 218px;
  padding: 16px 20px 18px;
  overflow: hidden;
}

.enemy-info-panel,
.player-status-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.enemy-header,
.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  color: var(--battle-text-main);
  font-family: "DotGothic16", monospace;
  font-size: 1.15rem;
  letter-spacing: 1px;
}

#enemy-count {
  color: var(--battle-text-subtle);
}

/* 予告は文字でも通常攻撃と大技を区別し、既存の敵情報の幅で折り返す。 */
.enemy-intent {
  margin: 0;
  color: var(--battle-text-subtle);
  font-family: "DotGothic16", monospace;
  font-size: 0.8rem;
  line-height: 1.35;
  min-height: calc(0.8rem * 1.35 * 2);
  overflow-wrap: anywhere;
}

.enemy-intent.is-heavy {
  color: #ffad80;
}

.skill-enemy-intent {
  flex-shrink: 0;
  margin-bottom: 10px;
}

/* 状態異常バッジ（敵・プレイヤー共通） */
.status-icons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 20px;
}

/* 暗色の枠にドット絵アイコンを乗せ、色は枠線で種別を示す（アイコンが潰れないため） */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 1px 4px 1px 2px;
  background: rgba(8, 8, 20, 0.92);
  border: 1px solid;
  border-radius: 3px;
  color: var(--ui-text-main);
}

.status-icon {
  display: block;
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.status-remain {
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
  letter-spacing: 1px;
}

/* 種別ごとの枠線色 */
.status-poison { border-color: #9b6dd6; }
.status-paralyze { border-color: #e0b83a; }
.status-slow { border-color: #6ec1ff; }
.status-curse { border-color: #a884d8; }

.enemy-visual-panel {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  min-height: 160px;
}

.enemy-sprite-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 100%;
  min-height: 168px;
  padding-top: 8px;
}

.enemy-sprite {
  position: relative;
  z-index: 2;
  display: block;
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(4px 4px 0 rgba(0, 0, 0, 0.4));
  animation: enemy-idle 1.2s ease-in-out infinite alternate;
}

.enemy-shadow {
  width: 86px;
  height: 14px;
  margin-top: -2px;
  background:
    repeating-linear-gradient(
      to right,
      rgba(0, 0, 0, 0.52) 0px,
      rgba(0, 0, 0, 0.52) 8px,
      rgba(0, 0, 0, 0.34) 8px,
      rgba(0, 0, 0, 0.34) 12px
    );
  opacity: 0.8;
}

.enemy-attack-flash {
  position: absolute;
  top: 18px;
  right: 16px;
  bottom: 22px;
  left: 16px;
  opacity: 0;
  background:
    linear-gradient(
      120deg,
      transparent 0%,
      transparent 34%,
      rgba(255, 255, 255, 0.86) 34%,
      rgba(230, 190, 100, 0.92) 46%,
      rgba(255, 120, 48, 0.88) 58%,
      transparent 58%,
      transparent 100%
    );
  z-index: 3;
}

.typing-area {
  /* お題の長さで後続パネルが動かないよう、ローマ字の行数を先に確保する。 */
  display: grid;
  grid-template-rows: auto calc(var(--battle-word-font-size) * var(--battle-word-line-height) * var(--battle-word-lines));
  align-items: center;
  justify-items: center;
  padding: 18px 20px 20px;
  text-align: center;
}

.word-japanese {
  color: var(--battle-text-subtle);
  font-family: "DotGothic16", monospace;
  font-size: 1.12rem;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.word-romaji {
  font-family: "Press Start 2P", monospace;
  display: inline-block;
  max-width: 100%;
  min-width: 0;
  font-size: var(--battle-word-font-size);
  letter-spacing: 2px;
  line-height: var(--battle-word-line-height);
  word-break: break-all;
  color: var(--ui-text-main);
  transform-origin: center;
}

.word-romaji .typed {
  color: var(--ui-text-muted);
}

.word-romaji .current {
  color: var(--ui-text-main);
}

.word-romaji .remaining {
  color: var(--ui-text-main);
}

.word-romaji.is-typing-hit {
  animation: word-hit-pop 0.12s ease-out;
}

.player-area {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  padding: 16px 20px;
}

.battle-log {
  height: 144px;
  min-height: 0;
  overflow-y: auto;
  scrollbar-gutter: stable;
  padding: 12px 14px;
  background: rgba(10, 10, 26, 0.9);
  box-shadow:
    inset 0 0 0 2px #000000,
    inset 0 0 0 4px #2a2a42;
}

.log-line {
  color: var(--battle-text-subtle);
  font-family: "DotGothic16", monospace;
  font-size: 1rem;
  line-height: 1.3;
  padding: 4px 0;
  overflow-wrap: anywhere;
  border-bottom: 1px solid rgba(204, 204, 204, 0.12);
}

.log-line.is-damage {
  color: var(--battle-text-main);
}

.log-line:last-child {
  border-bottom: none;
}

.bar-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bar-container label {
  color: var(--battle-text-subtle);
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
  letter-spacing: 1px;
}

.bar-container label {
  min-width: 40px;
}

.bar-text {
  color: var(--battle-text-main);
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
  letter-spacing: 1px;
  min-width: 72px;
  text-align: right;
}

.enemy-area .bar-container:first-of-type label,
.player-status-panel .bar-container:first-of-type label,
.player-stat-row label {
  color: var(--battle-text-subtle);
}

.enemy-area .bar-container:first-of-type .bar-text,
.player-status-panel .bar-container:first-of-type .bar-text {
  color: var(--battle-hp);
}

.bar {
  position: relative;
  flex: 1;
  height: 18px;
  background: #080811;
  box-shadow:
    inset 0 0 0 2px #000000,
    inset 0 0 0 4px #24243a;
  border-radius: 0;
  overflow: hidden;
}

.bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to right,
    transparent 0px,
    transparent 10px,
    rgba(0, 0, 0, 0.28) 10px,
    rgba(0, 0, 0, 0.28) 12px
  );
  pointer-events: none;
}

.bar-fill {
  height: 100%;
  border-radius: 0;
  transition: width 0.15s steps(8, end);
}

.hp-bar {
  background:
    repeating-linear-gradient(
      to right,
      var(--battle-hp) 0px,
      var(--battle-hp) 8px,
      var(--battle-hp-dark) 8px,
      var(--battle-hp-dark) 12px
    );
}

.mp-bar {
  background:
    repeating-linear-gradient(
      to right,
      var(--battle-mp) 0px,
      var(--battle-mp) 8px,
      var(--battle-mp-dark) 8px,
      var(--battle-mp-dark) 12px
    );
}

.mp-text {
  color: var(--battle-mp);
}

.enemy-gauge-bar {
  background:
    repeating-linear-gradient(
      to right,
      var(--battle-enemy-gauge) 0px,
      var(--battle-enemy-gauge) 8px,
      var(--battle-enemy-gauge-dark) 8px,
      var(--battle-enemy-gauge-dark) 12px
    );
}

.gauge-bar {
  background:
    repeating-linear-gradient(
      to right,
      var(--battle-gauge) 0px,
      var(--battle-gauge) 8px,
      var(--battle-gauge-dark) 8px,
      var(--battle-gauge-dark) 12px
    );
}

.gauge-bar.gauge-full {
  background:
    repeating-linear-gradient(
      to right,
      var(--battle-gauge) 0px,
      var(--battle-gauge) 8px,
      #ff5b2e 8px,
      #ff5b2e 12px
    );
  animation: battle-ready-flash 0.6s steps(2, end) infinite;
}

.player-stat-row .bar-text {
  color: var(--battle-mp);
}

.enemy-area.is-attacking .enemy-sprite {
  animation: enemy-attack-lunge 0.36s steps(3, end);
}

.enemy-area.is-attacking .enemy-shadow {
  animation: enemy-shadow-shift 0.36s steps(3, end);
}

.enemy-area.is-attacking .enemy-attack-flash {
  animation: enemy-attack-flash-show 0.36s steps(2, end);
}

.player-area.is-hit {
  animation: player-hit-shake 0.36s steps(2, end);
}

@keyframes enemy-idle {
  from {
    transform: translateY(0px);
  }

  to {
    transform: translateY(-6px);
  }
}

@keyframes enemy-attack-lunge {
  0% {
    transform: translate(0, 0) scale(1);
  }

  40% {
    transform: translate(-18px, 6px) scale(1.08);
  }

  100% {
    transform: translate(0, 0) scale(1);
  }
}

@keyframes enemy-shadow-shift {
  0% {
    transform: scaleX(1);
  }

  40% {
    transform: translateX(-10px) scaleX(1.18);
  }

  100% {
    transform: scaleX(1);
  }
}

@keyframes enemy-attack-flash-show {
  0% {
    opacity: 0;
    transform: translateX(-24px);
  }

  50% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateX(20px);
  }
}

@keyframes player-hit-shake {
  0% {
    transform: translateX(0);
    filter: brightness(1);
  }

  25% {
    transform: translateX(-8px);
    filter: brightness(1.2);
  }

  50% {
    transform: translateX(8px);
  }

  100% {
    transform: translateX(0);
    filter: brightness(1);
  }
}

@keyframes battle-ready-flash {
  from {
    filter: brightness(0.9);
  }

  to {
    filter: brightness(1.2);
  }
}

@keyframes word-hit-pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.03);
  }

  100% {
    transform: scale(1);
  }
}

/* === オーバーレイ === */
.overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.12s ease-out,
    visibility 0s linear 0.12s;
}

.overlay.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.overlay-content {
  min-width: 320px;
  max-width: 450px;
  padding: 26px 28px;
  text-align: center;
  font-family: "DotGothic16", monospace;
  opacity: 0;
  transform: translate3d(0, 6px, 0);
  transition:
    opacity 0.12s ease-out,
    transform 0.12s ease-out;
}

.overlay.active .overlay-content {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.overlay-content h2,
.overlay-content h3 {
  color: var(--ui-text-main);
  font-family: "DotGothic16", monospace;
  font-size: 1.55rem;
  letter-spacing: 2px;
  margin-bottom: 14px;
}

.overlay-content p {
  color: var(--ui-text-subtle);
  font-size: 1rem;
  margin-bottom: 8px;
}

/* === バトル開始カウントダウン（PT-002） === */
.countdown-overlay {
  /* 閉じる途中の出撃前パネルより手前に表示する。 */
  z-index: 101;
  background: rgba(0, 0, 8, 0.7);
  /* 終了時に暗転を残さず、お題の表示と入力開始を揃える。 */
  transition: none;
}

.overlay-content.countdown-content {
  width: min(84%, 340px);
  min-width: 0;
  max-width: 340px;
  max-height: calc(92dvh / var(--ui-scale));
  overflow-y: auto;
  padding: 24px 20px;
  background: #080d1a;
  transform: none;
  transition: none;
}

.countdown-content .countdown-title {
  margin-bottom: 24px;
  font-size: 1.1rem;
  line-height: 1.6;
  letter-spacing: 2px;
}

.countdown-value {
  display: block;
  color: var(--ui-accent);
  font-family: "Press Start 2P", monospace;
  font-size: 3.5rem;
  line-height: 1.3;
  text-shadow: 3px 3px 0 #604a20;
}

.countdown-steps {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 22px 0;
}

.countdown-step {
  width: 32px;
  height: 6px;
  border: 1px solid #39475e;
  background: #151d2d;
}

.countdown-step.is-active {
  border-color: var(--ui-accent);
  background: var(--ui-accent);
}

.countdown-content .countdown-hint {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.7;
}

.countdown-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* === 一時停止（元の入力・技選択の上に表示する） === */
.pause-overlay {
  z-index: 102;
  background: rgba(0, 0, 8, 0.8);
  transition: none;
}

.overlay-content.pause-content {
  width: min(84%, 340px);
  min-width: 0;
  max-width: 340px;
  max-height: calc(92dvh / var(--ui-scale));
  padding: 24px 20px;
  overflow-y: auto;
  background: #080d1a;
  transform: none;
  transition: none;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 18px 0;
}

.pause-content .pause-button {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid #657086;
  border-radius: 0;
  background: #1b2130;
  color: var(--ui-text-main);
  font-family: "DotGothic16", monospace;
  font-size: 0.95rem;
  line-height: 1.5;
  cursor: pointer;
}

/* 共通の #screen-battle .btn-primary による金色・透明背景の上書きを避ける。 */
.pause-content .pause-button-primary {
  border-color: #8b9cb6;
  background: #233149;
}

.pause-content .pause-button:hover,
.pause-content .pause-button:focus-visible {
  outline: 2px solid var(--ui-text-main);
  outline-offset: 3px;
  background: #30384b;
}

.pause-content #pause-confirm-title {
  font-size: 1.2rem;
  line-height: 1.6;
}

#screen-battle.is-paused .battle-container *,
#screen-battle.is-paused #skill-overlay * {
  animation-play-state: paused !important;
}

/* === 技選択オーバーレイ（SCR-05） === */
.overlay-content.battle-prepare {
  --battle-frame-light: rgba(204, 204, 204, 0.5);
  --prepare-selected-border: #7396c4;
  --prepare-selected-bg: #16263f;
  display: flex;
  flex-direction: column;
  width: min(94vw, 780px);
  min-width: 0;
  max-width: 780px;
  max-height: calc(96dvh / var(--ui-scale));
  padding: 18px 24px 16px;
  text-align: left;
}

.prepare-header {
  position: relative;
  flex-shrink: 0;
  padding: 0 62px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  text-align: center;
}

.battle-prepare h2 {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 5px;
  color: var(--ui-text-main);
  font-size: 1.2rem;
  letter-spacing: 3px;
  white-space: nowrap;
}

.battle-prepare h2::before,
.battle-prepare h2::after {
  content: '';
  flex: 1;
  height: 2px;
  background: linear-gradient(to right, transparent, #777777);
}

.battle-prepare h2::after {
  background: linear-gradient(to left, transparent, #777777);
}

.battle-prepare .prepare-intro {
  margin-bottom: 0;
  font-size: 0.85rem;
  line-height: 1.45;
}

.prepare-selection {
  display: flex;
  position: absolute;
  top: 2px;
  right: 0;
  flex-shrink: 0;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  color: var(--ui-text-main);
  font-family: "DotGothic16", monospace;
  white-space: nowrap;
}

.prepare-selection strong {
  font-size: 1.15rem;
  line-height: 1;
}

.prepare-selection span {
  color: var(--ui-text-subtle);
  font-size: 0.7rem;
}

.prepare-slots {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  flex-shrink: 0;
  margin: 14px 0 17px;
}

.prepare-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 38px;
  padding: 8px 8px 8px 28px;
  background: var(--prepare-selected-bg);
  box-shadow: inset 0 0 0 2px var(--prepare-selected-border);
  border: 0;
  border-radius: 0;
  color: var(--ui-text-main);
  font-family: "DotGothic16", monospace;
  text-align: left;
}

button.prepare-slot {
  width: 100%;
  cursor: pointer;
}

button.prepare-slot:hover {
  background: var(--ui-selected-bg);
}

/* 操作位置はカーソルで示し、選択済みの青枠を変えない。 */
button.prepare-slot:focus-visible {
  outline: none;
}

.prepare-slot.is-empty {
  background: rgba(0, 0, 8, 0.5);
  color: var(--ui-text-subtle);
  box-shadow: inset 0 0 0 1px #444444;
}

.prepare-slot-key {
  display: inline-flex;
  flex: 0 0 24px;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: #090911;
  box-shadow: inset 0 0 0 1px #555555;
  color: var(--ui-text-main);
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
}

.is-empty .prepare-slot-key {
  background: transparent;
  box-shadow: inset 0 0 0 1px #444444;
  color: var(--ui-text-subtle);
}

.prepare-slot-name {
  min-width: 0;
  overflow: hidden;
  font-size: 0.8rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prepare-list-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
  margin-bottom: 7px;
}

.battle-prepare .prepare-list-heading h3 {
  margin-bottom: 0;
  color: var(--ui-text-main);
  font-size: 0.95rem;
  letter-spacing: 0;
}

.prepare-list-heading span {
  color: var(--ui-text-subtle);
  font-size: 0.72rem;
}

.prepare-skill-list {
  flex: 1;
  min-height: 0;
  gap: 6px;
  margin-bottom: 12px;
}

.battle-prepare .skill-option {
  grid-template-columns: minmax(0, 1fr) auto;
  min-height: 52px;
  padding: 6px 10px 6px 32px;
  background: transparent;
  box-shadow: inset 0 -1px 0 #44444e;
}

.battle-prepare .skill-option::before {
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: 3px;
}

.battle-prepare .skill-option.is-selected {
  background: var(--prepare-selected-bg);
  box-shadow: inset 0 0 0 2px var(--prepare-selected-border);
}

.battle-prepare .skill-option:not(.is-selected):not(:disabled):hover,
.battle-prepare .skill-option:not(.is-selected):not(:disabled):focus-visible {
  background: var(--skill-type-bg);
  box-shadow: inset 0 -1px 0 #888888;
  outline: none;
}

.battle-prepare .skill-option.is-selected:hover,
.battle-prepare .skill-option.is-selected:focus-visible {
  background: var(--prepare-selected-bg);
  box-shadow: inset 0 0 0 2px var(--prepare-selected-border);
  outline: none;
}

/* 一覧の操作位置は内側のカーソルで示し、白い枠を追加しない。 */
#prepare-overlay .battle-prepare .skill-option:focus-visible {
  outline: none;
}

.battle-prepare .skill-option:disabled {
  opacity: 0.52;
  background: rgba(0, 0, 8, 0.8);
  cursor: not-allowed;
}

.battle-prepare .skill-option-main {
  grid-column: 1;
}

.battle-prepare .skill-option-type,
.battle-prepare .skill-option-mp {
  grid-column: 2;
}

.battle-prepare .skill-option-name {
  font-size: 0.96rem;
}

.battle-prepare .skill-option-desc {
  color: var(--ui-text-subtle);
  font-size: 0.75rem;
}

.prepare-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
  padding-top: 10px;
  border-top: 1px solid #364051;
}

/* 出撃前の戻る・開始も、文字を動かさず操作中の項目にだけカーソルを表示する。 */
.prepare-actions .pixel-cursor {
  display: inline-block;
  width: 1em;
  min-width: 1em;
  margin-right: 8px;
  /* ボタン本文の文字サイズを継承せず、戻ると開始の記号を同じ寸法にする。 */
  font: 0.85rem/1 "DotGothic16", monospace;
  letter-spacing: 0;
  vertical-align: middle;
  visibility: hidden;
  animation: none;
}

.prepare-actions button:not(:disabled):focus .pixel-cursor {
  visibility: visible;
  animation: var(--menu-cursor-animation);
}

.battle-prepare .btn-secondary {
  border-radius: 0;
  border: none;
  color: var(--ui-text-subtle);
  font-family: "DotGothic16", monospace;
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.battle-prepare .btn-secondary:hover,
.battle-prepare .btn-secondary:focus-visible {
  color: var(--ui-text-main);
}

.battle-prepare .btn-secondary:focus-visible {
  outline: none;
}

.battle-prepare .btn-primary {
  min-height: 44px;
  font-family: "DotGothic16", monospace;
}

#prepare-overlay .battle-prepare .btn-primary {
  margin-top: 0;
  background: transparent;
  color: var(--ui-accent);
  box-shadow: none;
}

#prepare-overlay .battle-prepare .btn-primary:focus-visible {
  outline: none;
}

#prepare-overlay .battle-prepare .btn-primary:disabled {
  background: transparent;
  box-shadow: none;
  color: #666666;
  cursor: not-allowed;
}

.overlay-content.skill-select {
  display: flex;
  flex-direction: column;
  width: min(60vw, 760px);
  min-width: 0;
  max-width: 760px;
  max-height: 64dvh;
  padding: 20px 22px 18px;
  text-align: left;
  contain: paint;
}

.skill-title-wrap {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.skill-title {
  color: var(--ui-text-main);
  font-family: "DotGothic16", monospace;
  font-size: 1.12rem;
  letter-spacing: 0;
  margin: 0;
  text-shadow: 2px 2px 0 #000000;
}

.skill-enemy-gauge {
  --skill-enemy-gauge-color: #a56bff;
  display: grid;
  flex-shrink: 0;
  grid-template-columns: 34px minmax(0, 1fr) 54px;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 12px;
  padding: 6px 8px;
  background: rgba(8, 8, 18, 0.82);
  box-shadow:
    inset 0 0 0 1px #000000,
    inset 0 0 0 2px rgba(165, 107, 255, 0.24);
}

.skill-enemy-gauge.is-warning {
  --skill-enemy-gauge-color: #f2d45c;
}

.skill-enemy-gauge.is-danger {
  --skill-enemy-gauge-color: #ff6c5c;
}

.skill-enemy-gauge-label {
  color: var(--ui-text-subtle);
  font-family: "DotGothic16", monospace;
  font-size: 0.82rem;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
  white-space: nowrap;
}

.skill-enemy-gauge-track {
  position: relative;
  height: 10px;
  background: #070711;
  box-shadow:
    inset 0 0 0 1px #000000,
    inset 0 0 0 2px #222238;
  overflow: hidden;
}

.skill-enemy-gauge-track::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to right,
    transparent 0px,
    transparent 8px,
    rgba(0, 0, 0, 0.32) 8px,
    rgba(0, 0, 0, 0.32) 10px
  );
}

.skill-enemy-gauge-bar {
  width: 0;
  height: 100%;
  background: var(--skill-enemy-gauge-color);
  transition:
    width 0.1s linear,
    background-color 0.1s linear;
}

.skill-enemy-gauge-text {
  color: var(--skill-enemy-gauge-color);
  font-family: "Press Start 2P", monospace;
  font-size: 0.48rem;
  letter-spacing: 0;
  text-align: right;
}

.skill-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  min-height: 0;
  margin-bottom: 12px;
  overflow-y: auto;
}

.skill-option {
  --skill-type-color: #b8c0d4;
  --skill-type-bg: rgba(184, 192, 212, 0.12);
  position: relative;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 4px;
  align-items: center;
  min-height: 66px;
  padding: 9px 12px 9px 32px;
  background: rgba(8, 11, 24, 0.96);
  box-shadow:
    inset 0 0 0 2px #000000,
    inset 0 0 0 3px rgba(255, 255, 255, 0.16);
  color: var(--ui-text-main);
  font-family: "DotGothic16", monospace;
  text-align: left;
  cursor: pointer;
  border: none;
  border-radius: 0;
  transition:
    background-color 0.08s ease-out,
    box-shadow 0.08s ease-out;
}

.skill-option::before {
  content: '';
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: 4px;
  background: var(--skill-type-color);
}

/* 種別の色線と数字バッジの間に操作カーソルを収める。 */
.skill-option > .menu-cursor {
  left: 12px;
}

.skill-option[data-type="こうげき"] {
  --skill-type-color: #df6a54;
  --skill-type-bg: rgba(223, 106, 84, 0.14);
}

.skill-option[data-type="まほう"] {
  --skill-type-color: #728cff;
  --skill-type-bg: rgba(114, 140, 255, 0.14);
}

.skill-option[data-type="ぼうぎょ"] {
  --skill-type-color: #58bfd0;
  --skill-type-bg: rgba(88, 191, 208, 0.14);
}

.skill-option[data-type="かいふく"] {
  --skill-type-color: #62c878;
  --skill-type-bg: rgba(98, 200, 120, 0.14);
}

.skill-option[data-type="じょうたい"] {
  --skill-type-color: #c878dc;
  --skill-type-bg: rgba(200, 120, 220, 0.14);
}

.skill-option:not(:disabled):hover,
.skill-option:not(:disabled):focus-visible {
  background: var(--skill-type-bg);
  outline: none;
  box-shadow:
    inset 0 0 0 2px #000000,
    inset 0 0 0 3px rgba(255, 255, 255, 0.16);
}

.skill-option:disabled,
.skill-option.disabled {
  opacity: 0.52;
  cursor: not-allowed;
  background: rgba(8, 8, 14, 0.9);
}

.skill-option.disabled::before {
  background: #565a66;
}

.skill-key-badge {
  grid-column: 1;
  grid-row: 1 / 3;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  background: rgba(0, 0, 0, 0.78);
  box-shadow:
    0 0 0 1px #000000,
    0 0 0 2px rgba(255, 255, 255, 0.2);
  color: var(--ui-text-main);
  font-family: "Press Start 2P", monospace;
  font-size: 0.52rem;
  letter-spacing: 0;
}

.skill-option-main {
  grid-column: 2;
  grid-row: 1 / 3;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.skill-option-name {
  color: var(--ui-text-main);
  font-size: 1rem;
  line-height: 1.2;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.skill-option-desc {
  color: var(--ui-text-subtle);
  font-size: 0.78rem;
  line-height: 1.25;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.skill-option-type {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  padding: 2px 6px 3px;
  background: var(--skill-type-color);
  color: #000000;
  font-family: "DotGothic16", monospace;
  font-size: 0.7rem;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: none;
}

.skill-option-mp {
  grid-column: 3;
  grid-row: 2;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 18px;
  padding: 4px 5px 3px;
  background: rgba(46, 80, 140, 0.35);
  box-shadow:
    inset 0 0 0 1px #000000,
    inset 0 0 0 2px #3c5a92;
  color: #6ec1ff;
  font-family: "Press Start 2P", monospace;
  font-size: 0.48rem;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}

.skill-option.disabled .skill-option-mp {
  background: rgba(120, 30, 30, 0.35);
  box-shadow:
    inset 0 0 0 1px #000000,
    inset 0 0 0 2px #8c3030;
  color: #ff7a7a;
}

.skill-footer {
  display: grid;
  flex-shrink: 0;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.skill-mp-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.skill-mp-row .skill-mp-display {
  padding-top: 6px;
}

.skill-mp-action {
  display: grid;
  justify-items: end;
  gap: 4px;
  margin-left: auto;
  max-width: 100%;
}

.skill-recover-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.skill-mp-recover {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px 5px 28px;
  border: 1px solid #303947;
  border-radius: 0;
  background: transparent;
  color: #aeb8c8;
  font-family: "DotGothic16", monospace;
  font-size: 0.78rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.skill-mp-recover:not(:disabled):hover {
  border-color: #59677d;
  background: #111820;
}

.skill-mp-recover:focus-visible {
  outline: none;
  background: #1b2330;
}

.skill-mp-recover:disabled {
  opacity: 1;
  border-color: #252c37;
  background: transparent;
  color: #8f9aab;
  cursor: not-allowed;
}

/* MP不足時は枠と文字だけを強調し、操作カーソルや配置は変えない。 */
.skill-mp-recover.is-mp-insufficient,
.skill-mp-recover.is-mp-insufficient:not(:disabled):hover {
  border-color: var(--ui-accent);
  color: var(--ui-accent);
}

.skill-recover-key {
  color: inherit;
  font-family: "DotGothic16", monospace;
  font-size: 0.7rem;
}

.skill-footer .skill-hint {
  font-size: 0.72rem;
  line-height: 1.4;
}

.skill-mp-display {
  color: #8fbfff;
  font-family: "DotGothic16", monospace;
  font-size: 0.92rem;
  letter-spacing: 0;
}

/* MP不足の警告（点滅表示）。既定は非表示で flashInsufficientMp() で表示する */
.skill-mp-warning[hidden] {
  display: none;
}

.skill-mp-warning {
  color: #ff6b6b;
  font-family: "DotGothic16", monospace;
  font-size: 0.92rem;
  letter-spacing: 0;
  text-shadow: 0 0 4px rgba(255, 50, 50, 0.6);
}

.skill-mp-warning.is-flash {
  animation: skill-mp-warning-flash 0.18s steps(2, end) 3;
}

@keyframes skill-mp-warning-flash {
  0% { opacity: 1; }
  50% { opacity: 0.25; }
  100% { opacity: 1; }
}

/* MP不足の技を押した時のシェイク演出 */
.skill-option.shake {
  animation: skill-option-shake 0.3s steps(5, end);
}

@keyframes skill-option-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.skill-hint {
  color: var(--ui-text-subtle);
  font-family: "DotGothic16", monospace;
  font-size: 0.82rem;
  letter-spacing: 0;
  margin: 0;
}

.skill-hint-key {
  display: inline-block;
  min-width: 18px;
  padding: 1px 4px;
  margin: 0 2px;
  background: rgba(0, 0, 0, 0.72);
  box-shadow: 0 0 0 1px var(--ui-text-muted);
  color: var(--ui-text-main);
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
  text-align: center;
}

#screen-battle .btn-primary {
  margin-top: 12px;
  font-family: "DotGothic16", monospace;
  font-size: 1rem;
  background: transparent;
  color: var(--ui-accent);
  border: none;
  border-radius: 0;
  box-shadow:
    0 0 0 2px #000000,
    0 0 0 4px var(--battle-frame-light),
    0 0 0 6px #000000;
  padding: 10px 22px;
  letter-spacing: 2px;
  transition: color 0.1s ease;
}

#screen-battle .btn-primary:hover {
  background: transparent;
  color: var(--ui-text-main);
}

/* 狭い画面は表記ゆれを含む長いローマ字にも2行分を確保する。 */
@media (max-width: 840px) {
  #screen-battle {
    --battle-word-lines: 2;
    --battle-extra-word-height: calc(var(--battle-word-font-size) * var(--battle-word-line-height));
  }
}

@media (max-width: 640px) {
  #screen-battle {
    --battle-word-font-size: 1.16rem;
  }

  .battle-container {
    width: 94%;
    gap: 12px;
    padding: 16px 0 18px;
  }

  .enemy-area,
  .player-area {
    grid-template-columns: 1fr;
  }

  .enemy-area,
  .typing-area,
  .player-area {
    padding: 14px 16px;
  }

  .enemy-header,
  .player-header {
    font-size: 1rem;
  }

  .enemy-visual-panel {
    min-height: 138px;
  }

  .enemy-sprite {
    width: 108px;
    height: 108px;
  }

  .word-japanese {
    font-size: 0.92rem;
  }

  .word-romaji {
    letter-spacing: 1px;
  }

  .battle-log {
    height: 136px;
  }

  .log-line,
  .overlay-content p,
  .skill-mp-display,
  .skill-hint,
  #screen-battle .btn-primary {
    font-size: 0.9rem;
  }

  .overlay-content {
    min-width: min(90vw, 320px);
    padding: 22px 18px;
  }

  .overlay-content h2,
  .overlay-content h3 {
    font-size: 1.2rem;
    letter-spacing: 2px;
  }

  .overlay-content.skill-select {
    width: 60vw;
    max-width: 360px;
    padding: 20px 18px 18px;
  }

  .skill-title {
    font-size: 1.05rem;
    letter-spacing: 0;
  }

  .skill-list {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .skill-enemy-gauge {
    grid-template-columns: 32px minmax(0, 1fr) 50px;
    gap: 7px;
    margin-bottom: 10px;
  }

  .skill-enemy-gauge-label {
    font-size: 0.78rem;
  }

  .skill-option {
    grid-template-columns: 28px minmax(0, 1fr);
    grid-template-rows: auto auto;
    min-height: 0;
    padding: 8px 10px 8px 13px;
  }

  .overlay-content.battle-prepare {
    width: 92vw;
    max-height: calc(92dvh / var(--ui-scale));
    padding: 16px;
  }

  .prepare-header {
    padding: 0 0 8px;
  }

  .battle-prepare h2 {
    font-size: 1.05rem;
    gap: 6px;
    letter-spacing: 1px;
    white-space: normal;
  }

  .battle-prepare .prepare-intro {
    font-size: 0.75rem;
  }

  .prepare-selection {
    position: static;
    justify-content: center;
    align-items: baseline;
    flex-direction: row;
    gap: 5px;
    margin-top: 5px;
  }

  .prepare-slots {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    margin: 12px 0 14px;
  }

  .prepare-slot {
    min-height: 37px;
    padding: 6px;
  }

  .prepare-slot-name {
    font-size: 0.72rem;
  }

  .prepare-list-heading {
    flex-wrap: wrap;
    margin-bottom: 7px;
  }

  .prepare-list-heading span {
    font-size: 0.67rem;
  }

  .prepare-skill-list {
    margin-bottom: 8px;
  }

  .battle-prepare .skill-option {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    min-height: 0;
  }

  .battle-prepare .skill-option-main {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .battle-prepare .skill-option-type {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
  }

  .battle-prepare .skill-option-mp {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }

  .prepare-actions {
    justify-content: flex-end;
    padding-top: 10px;
  }

  .skill-option-main {
    grid-column: 2;
    grid-row: 1;
  }

  .skill-option-type {
    grid-column: 2;
    grid-row: 2;
    justify-self: start;
  }

  .skill-option-mp {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
  }

  .skill-option-name {
    font-size: 0.94rem;
  }

  .skill-option-desc {
    font-size: 0.74rem;
  }

  .skill-footer {
    gap: 8px;
  }

  .bar-container label,
  .bar-text,
  .skill-key-badge,
  .skill-enemy-gauge-text,
  .skill-option-mp,
  .skill-hint-key {
    font-size: 0.48rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .overlay,
  .overlay-content,
  .skill-enemy-gauge-bar,
  .skill-option {
    transition: none;
  }
}

/* ============================================================
   演出強化（FUN-4 コンボ / FUN-5 ダメージポップ・画面シェイク）
   ============================================================ */

.typing-area {
  position: relative;
}

.player-area {
  position: relative;
}

/* ノーミス連続コンボ表示 */
.combo-display {
  position: absolute;
  top: 2px;
  right: 16px;
  color: var(--ui-text-subtle);
  font-family: "Press Start 2P", monospace;
  font-size: 0.72rem;
  pointer-events: none;
  z-index: 5;
}

.combo-display.is-pop {
  animation: combo-pop 0.45s ease-out;
}

@keyframes combo-pop {
  0% { transform: scale(0.6); opacity: 0; }
  40% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* ダメージ・回復の数字ポップ */
.damage-popup {
  position: absolute;
  top: 34%;
  color: #ff6b5e;
  font-family: "Press Start 2P", monospace;
  font-size: 0.95rem;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
  pointer-events: none;
  z-index: 6;
  animation: damage-float 0.85s ease-out forwards;
}

.damage-popup.is-heal {
  color: #6ee787;
}

@keyframes damage-float {
  0% { transform: translateY(0); opacity: 0; }
  15% { opacity: 1; }
  100% { transform: translateY(-34px); opacity: 0; }
}

/* ============================================================
   勝利・敗北リザルト（タイトル・クエスト・キャラクター画面のピクセル枠を共用）
   ============================================================ */

#result-overlay {
  background: rgba(3, 3, 18, 0.82);
}

#result-content {
  --result-accent: var(--ui-text-main);
  --result-border: #cccccc;
  --result-inner-border: #555555;
  width: min(540px, calc((100vw - 48px) / var(--ui-scale)));
  min-width: 0;
  max-width: none;
  max-height: calc((100dvh - 48px) / var(--ui-scale));
  overflow-y: auto;
  padding: 20px 28px;
  background: linear-gradient(to bottom, #0e1126, #040512);
  box-shadow:
    0 0 0 2px #000000,
    0 0 0 4px var(--result-border),
    0 0 0 6px #000000;
  color: var(--battle-text-main);
}

#result-content.is-victory {
  --result-accent: var(--ui-accent);
  --result-border: #697b95;
  --result-inner-border: #39475e;
}

#result-content.is-defeat {
  --result-accent: #ff7a7a;
  --result-border: #b48a8a;
}

.result-header {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--battle-frame-subtle);
}

.result-eyebrow {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
  color: var(--ui-text-subtle);
  font-family: "Press Start 2P", monospace;
  font-size: 0.55rem;
  line-height: 1.5;
  letter-spacing: 2px;
}

.result-eyebrow::before,
.result-eyebrow::after {
  content: "";
  flex: 1;
  height: 2px;
  background: var(--battle-frame-subtle);
}

#result-content h2 {
  margin: 0 0 8px;
  color: var(--result-accent);
  font-size: 1.8rem;
  line-height: 1.25;
  letter-spacing: 3px;
  text-shadow: 3px 3px 0 #26314a;
}

#result-content .result-message {
  margin: 0;
  color: var(--ui-text-subtle);
  font-size: 0.86rem;
  letter-spacing: 1px;
}

.result-quest {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px 0;
}

.result-portrait {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  background: #030312;
  box-shadow: inset 0 0 0 1px var(--result-inner-border);
}

.result-portrait img {
  display: block;
  width: 44px;
  height: 44px;
  image-rendering: pixelated;
}

.result-quest-info {
  min-width: 0;
  text-align: left;
  line-height: 1.5;
  font-size: 1.05rem;
  letter-spacing: 1px;
  overflow-wrap: anywhere;
}

/* キャラクター名と難易度を同じ補足文字として揃え、余白を確保する */
.result-quest-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 16px;
  margin-top: 8px;
  color: var(--ui-text-subtle);
  font-size: 0.8rem;
  line-height: 1.5;
  letter-spacing: 1px;
}

.result-character-name {
  color: inherit;
  font-size: inherit;
}

.result-difficulty {
  display: inline-flex;
  align-items: baseline;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  white-space: nowrap;
}

.result-difficulty strong {
  color: inherit;
  font-weight: normal;
}

#result-content .result-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  color: var(--ui-text-main);
  font-size: 0.82rem;
  font-weight: normal;
  letter-spacing: 1px;
}

.result-section-title::before,
.result-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--battle-frame-subtle);
}

.result-stats {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 10px;
  margin: 0;
}

.result-stat {
  min-width: 0;
  padding: 10px 6px;
  background: #030312;
  border: 1px solid var(--result-inner-border);
}

.result-stat dt {
  margin-bottom: 8px;
  color: var(--ui-text-subtle);
  font-size: 0.78rem;
}

.result-stat dd {
  margin: 0;
  color: var(--ui-text-main);
  font-family: "DotGothic16", monospace;
  font-size: 1.75rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}

.result-stat-accuracy dd {
  color: var(--battle-hp);
}

.result-stat-combo dd {
  color: var(--battle-mp);
}

.result-stats small {
  margin-left: 4px;
  font-family: "DotGothic16", monospace;
  font-size: 0.76rem;
  font-weight: normal;
}

.result-fastest {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: #030312;
  border: 1px solid var(--result-inner-border);
  text-align: left;
}

.result-fastest dt {
  flex-shrink: 0;
  color: var(--ui-text-subtle);
  font-size: 0.78rem;
}

.result-fastest dd {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px 12px;
  margin: 0;
  min-width: 0;
  font-size: 0.88rem;
  overflow-wrap: anywhere;
}

.result-fastest-speed {
  color: var(--battle-mp);
  white-space: nowrap;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 18px;
}

#result-content .result-actions button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border: none;
  border-radius: 0;
  background: #030312;
  color: var(--ui-text-main);
  box-shadow:
    0 0 0 2px #000000,
    0 0 0 4px #888888;
  font-family: "DotGothic16", monospace;
  font-size: 0.95rem;
  letter-spacing: 1px;
  line-height: 1.4;
  transition: color 0.12s, box-shadow 0.12s;
}

#result-content .result-actions .btn-primary {
  color: var(--ui-accent);
  box-shadow:
    0 0 0 2px #000000,
    0 0 0 4px #cccccc;
}

#result-content .result-actions button:hover,
#result-content .result-actions button:focus-visible {
  outline: none;
  color: var(--ui-text-main);
  box-shadow:
    0 0 0 2px #000000,
    0 0 0 4px var(--ui-focus);
}

#result-content .result-actions .btn-primary:hover,
#result-content .result-actions .btn-primary:focus-visible {
  color: var(--ui-accent);
}

#result-content .result-actions button:active {
  transform: translateY(2px);
}

.result-cursor {
  color: inherit;
  font-size: 0.7rem;
}

/* html の zoom: 1.5 を考慮し、小さい画面では2列と縦並びボタンに切り替える。 */
@media (max-width: 600px) {
  #result-content {
    width: calc((100vw - 32px) / var(--ui-scale));
    max-height: calc((100dvh - 32px) / var(--ui-scale));
    padding: 16px 14px;
  }

  #result-content h2 {
    font-size: 1.35rem;
    letter-spacing: 1px;
  }

  .result-eyebrow {
    gap: 8px;
    font-size: 0.44rem;
    letter-spacing: 1px;
  }

  .result-quest {
    padding: 12px 0;
    gap: 10px;
  }

  .result-portrait {
    width: 48px;
    height: 48px;
  }

  .result-portrait img {
    width: 44px;
    height: 44px;
  }

  .result-quest-info {
    font-size: 0.87rem;
  }

  .result-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .result-stat-accuracy {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
  }

  .result-stat-accuracy dt {
    margin: 0;
  }

  .result-stat dd {
    font-size: 1.5rem;
  }

  .result-fastest {
    flex-direction: column;
    gap: 6px;
    padding: 10px;
  }

  .result-fastest dd {
    width: 100%;
    justify-content: space-between;
  }

  .result-actions {
    flex-direction: column;
    gap: 14px;
    margin-top: 18px;
  }

  #result-content .result-actions button {
    min-height: 36px;
    padding: 8px 12px;
  }
}

/* PCでは画面高に応じてバトル本体だけを詰める。ローマ字の大きさは維持する。
   vhはhtmlのzoomでも拡大されるため、各寸法は拡大前の表示可能高さを基準にする。 */
@media (min-width: 641px) {
  #screen-battle .battle-container {
    /* 外枠6pxと被弾時の左右8pxの揺れを含め、演出中も枠を切らない。 */
    padding-left: 14px;
    padding-right: 14px;
  }
}

@media (min-width: 641px) {
  #screen-battle .battle-container {
    --battle-short-height: calc(100dvh / var(--ui-scale) - 356px - var(--battle-extra-word-height));
    --battle-space: clamp(2px, calc(2px + var(--battle-short-height) / 10), 16px);
    --battle-gap: clamp(12px, calc(100dvh / var(--ui-scale) / 40), 14px);
    --battle-enemy-height: clamp(74px, calc(74px + var(--battle-short-height) * 0.55), 218px);
    --battle-sprite-size: clamp(56px, calc(56px + var(--battle-short-height) * 0.3), 128px);
    --battle-log-height: clamp(88px, calc(88px + var(--battle-short-height) * 0.2), 144px);
    gap: var(--battle-gap);
    padding-top: 6px;
    padding-bottom: 6px;
  }

  #screen-battle .enemy-area,
  #screen-battle .typing-area,
  #screen-battle .player-area {
    flex-shrink: 0;
    padding-top: var(--battle-space);
    padding-bottom: var(--battle-space);
  }

  #screen-battle .enemy-area {
    min-height: var(--battle-enemy-height);
  }

  #screen-battle .enemy-info-panel,
  #screen-battle .player-status-panel {
    gap: clamp(4px, calc(100dvh / var(--ui-scale) / 100), 8px);
  }

  #screen-battle .enemy-header,
  #screen-battle .player-header {
    margin-bottom: 0;
    line-height: 1.2;
  }

  #screen-battle .status-icons {
    min-height: 20px;
    line-height: 1;
  }

  #screen-battle .enemy-visual-panel,
  #screen-battle .enemy-sprite-frame {
    min-height: 0;
  }

  #screen-battle .enemy-sprite-frame {
    padding-top: 4px;
  }

  #screen-battle .enemy-sprite {
    width: var(--battle-sprite-size);
    height: var(--battle-sprite-size);
  }

  #screen-battle .enemy-shadow {
    width: calc(var(--battle-sprite-size) * 0.67);
    height: 10px;
  }

  #screen-battle .word-japanese {
    margin-bottom: 4px;
    line-height: 1.2;
  }

  #screen-battle .word-romaji {
    line-height: 1.35;
  }

  #screen-battle .battle-log {
    height: var(--battle-log-height);
    min-height: 0;
    max-height: none;
    padding: 8px 14px;
  }
}

/* 低いPC画面でも、2行のお題・予告・状態異常と18表示pxのゲージを残す。 */
@media (min-width: 641px) and (max-height: 560px) {
  #screen-battle .battle-container {
    gap: 12px;
  }

  #screen-battle .enemy-info-panel,
  #screen-battle .player-status-panel {
    gap: 1px;
  }

  #screen-battle .enemy-header,
  #screen-battle .player-header,
  #screen-battle .word-japanese {
    font-size: 1rem;
  }

  #screen-battle #enemy-intent {
    font-size: 0.65rem;
    line-height: 1.2;
    min-height: calc(0.65rem * 1.2);
  }

  #screen-battle .bar {
    height: 12px;
  }

  #screen-battle .battle-log {
    height: 80px;
  }
}

/* 狭いPC幅でも敵名と体数を1行に収め、敵欄の高さを変えない。
   被弾時の揺れ用の左右余白で、641px幅の敵情報列は約136pxになる。
   最長の「おばけキノコ」と「3/3体目」が収まる文字サイズへ幅に応じて下げる。 */
@media (min-width: 641px) {
  #screen-battle #enemy-name,
  #screen-battle #enemy-count {
    white-space: nowrap;
  }
}

@media (min-width: 641px) and (max-width: 759px) {
  #screen-battle .enemy-header {
    font-size: 0.9rem;
  }
}

@media (min-width: 641px) and (max-width: 699px) {
  #screen-battle .enemy-header {
    gap: 8px;
    font-size: 0.8rem;
    letter-spacing: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .combo-display.is-pop,
  .damage-popup {
    animation: none;
  }

  .damage-popup {
    opacity: 1;
  }
}

/* 書道家の集中倍率バッジ（FUN-1） */
.player-focus {
  margin-left: 8px;
  padding: 1px 6px;
  border: 1px solid rgba(94, 234, 212, 0.55);
  border-radius: 6px;
  color: #5eead4;
  font-family: "DotGothic16", monospace;
  font-size: 0.68rem;
}

.player-focus.is-max {
  border-color: #5eead4;
  color: #5eead4;
  background: rgba(94, 234, 212, 0.12);
}
