:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  background: #f5f7fc;
  color: #192844;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { max-width: 100%; overflow-x: hidden; }
body { margin: 0; }
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #192844; outline-offset: 3px; }
[hidden] { display: none !important; }
.battle {
  width: min(100%, 540px);
  min-height: 100dvh;
  margin: auto;
  padding: calc(env(safe-area-inset-top) + 12px) 24px calc(env(safe-area-inset-bottom) + 20px);
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.arena {
  position: relative;
  flex: none;
  height: clamp(250px, 43dvh, 340px);
  overflow: hidden;
  border-radius: 22px;
  background: #dff2fa;
}
#artwork { width: 100%; height: 100%; display: block; }
.enemy-status { position: absolute; top: 18px; left: 18px; right: 18px; }
.status-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; white-space: nowrap; }
.enemy-status .status-line { font-size: 17px; }
.enemy-status strong { font-weight: 700; }
.hp-track { overflow: hidden; width: 100%; border-radius: 99px; }
.hp-track span { display: block; width: 100%; height: 100%; border-radius: inherit; transition: width .25s ease; }
.enemy-track { height: 6px; margin-top: 8px; background: rgba(25,40,68,.1); }
.enemy-track span { background: #ff876f; }
.player-status { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.health-icon { width: 44px; height: 44px; flex: none; display: grid; place-items: center; background: #dff5eb; color: #00856a; border-radius: 13px; }
.health-icon svg { width: 21px; height: 21px; }
.player-detail { flex: 1; min-width: 0; }
.player-detail .status-line { flex-wrap: wrap; row-gap: 4px; }
.player-detail .status-line > strong { font-size: 17px; }
.player-value { display: inline-flex; align-items: baseline; gap: 5px; }
.player-value strong { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; }
.player-value span { font-size: 16px; font-weight: 600; color: #5d6b84; }
.player-track { height: 7px; margin-top: 8px; background: #dfe5f0; }
.player-track span { background: #20b889; }
.player-track.low span { background: #ff876f; }
.enemy-name { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; white-space: normal; }
.enemy-name small { font-size: 13px; color: #5d6b84; white-space: nowrap; }
.progression { margin-top: -8px; }
.progression-line { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: #5d6b84; }
.progression-line strong { color: #3d5afe; }
.xp-track { height: 5px; margin-top: 5px; background: #dfe5f0; }
.xp-track span { width: 0; background: #3d5afe; }
.reward { margin: 0; padding: 12px; border-radius: 12px; background: #dff5eb; color: #007453; font-size: 16px; font-weight: 700; line-height: 1.6; text-align: center; white-space: pre-line; overflow-wrap: anywhere; }
.save-notice { margin: 0; color: #5d6b84; font-size: 13px; }
.battle-spacer { flex: 1 0 0; min-height: 0; }
.battle-message {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 112px;
  margin: 0;
  padding: 16px;
  border: 1px solid #d4e5d8;
  border-radius: 16px;
  background: #ecf5ee;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  white-space: pre-line;
}
.action-panel { display: flex; flex-direction: column; gap: 10px; }
.primary-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  height: clamp(88px, 12dvh, 108px);
  border: 0;
  border-radius: 17px;
  font-size: 18px;
  font-weight: 700;
  transition: transform .12s ease, opacity .12s ease;
}
.action:active:not(:disabled), .flee:active:not(:disabled), .rematch:active { transform: scale(.96); }
.action svg { width: 25px; height: 25px; overflow: visible; }
.action:disabled, .flee:disabled { opacity: .4; cursor: default; }
.action-attack { color: white; background: #3d5afe; }
.action-defend { color: #192844; background: #e4ebfa; }
.action-heal { color: white; background: #00856a; }
.heal-label { display: inline-flex; gap: 4px; align-items: center; white-space: nowrap; }
.heals-left { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(255,255,255,.2); font-size: 15px; }
.flee, .rematch { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; border-radius: 14px; font-size: 18px; font-weight: 700; transition: transform .12s ease, opacity .12s ease; }
.flee { min-height: 50px; border: 1px solid #dfe5f0; color: #5d6b84; background: white; }
.flee svg { width: 20px; height: 20px; }
.rematch { min-height: 62px; border: 0; color: white; background: #3d5afe; border-radius: 17px; }
.result { position: absolute; z-index: 3; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(245,247,252,.94); text-align: center; }
.result span { font-size: 29px; }
.result strong { font-size: 36px; font-weight: 900; }
.result.victory { color: #007453; }
.guard-mark { position: absolute; z-index: 1; top: 66%; left: 31%; width: 88px; height: 88px; transform: translate(-50%, -50%); color: rgba(61,90,254,.4); pointer-events: none; }
.guard-mark svg { width: 100%; height: 100%; }
.effect-number { position: absolute; z-index: 2; top: 48%; left: 79%; transform: translate(-50%, -50%); min-width: 76px; padding: 2px 8px; border-radius: 12px; background: rgba(255,255,255,.96); color: #d83d3d; font-size: 28px; font-weight: 800; text-align: center; pointer-events: none; animation: float-number .74s ease-out forwards; }
.effect-number.heal { color: #00856a; left: 29%; top: 43%; }
.effect-number.enemy { left: 29%; top: 43%; }
.effect-number.guarded { color: #3d5afe; }
@keyframes float-number { from { opacity: 1; transform: translate(-50%,-50%); } to { opacity: 0; transform: translate(-50%,-110%); } }
@media (max-height: 700px) {
  .battle { gap: 12px; padding-top: calc(env(safe-area-inset-top) + 8px); padding-bottom: calc(env(safe-area-inset-bottom) + 12px); }
  .arena { height: clamp(230px, 38dvh, 270px); }
  .battle-message { min-height: 96px; font-size: 23px; }
  .action { height: 88px; }
  .flee { min-height: 48px; }
}
@media (max-width: 360px) {
  .battle { padding-left: 16px; padding-right: 16px; }
  .battle-message { font-size: 23px; }
  .player-detail .status-line > strong { font-size: 15px; }
  .player-value span { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
