/* Battle fits the screen. The hand, explanations and full route scroll within it. */
.battle-view {
  --enemy-height: 134px;
  --hand-card-height: 220px;
  --hand-scale: 1.25;
  height: 100svh;
  height: 100dvh;
  min-height: 0;
  padding: max(2px, env(safe-area-inset-top)) 10px max(4px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: 48px var(--enemy-height) 48px 24px 36px minmax(0,1fr) 48px;
  gap: 0;
  position: relative;
}
.battle-view > * { min-width: 0; min-height: 0; }
.battle-view > .battle-top { grid-row: 1; }
.battle-view > .enemy-box { grid-row: 2; }
.battle-view > .player-box { grid-row: 3; }
.battle-view > .battle-benefits { grid-row: 4; }
.battle-view > .hand-heading { grid-row: 5; }
.battle-view > .battle-information { grid-row: 6; }
.battle-view > .battle-actions { grid-row: 7; }
.battle-heading-copy { flex: 1; min-width: 0; }
.battle-view .battle-top { height: 48px; }
.battle-latest-log { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 26px; padding: 2px 5px; border: 1px solid #535463; border-radius: 5px; background: #242733; text-align: left; }
.log-caption { flex-shrink: 0; font-size: 11px; color: var(--gold); }
.battle-view .battle-top .log { flex: 1; min-width: 0; min-height: 0; margin: 0; padding: 0; font-size: 13px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.battle-view .enemy-box { min-height: 0; padding: 4px 8px; display: grid; grid-template-rows: 22px 60px 18px 18px 6px; }
.battle-view .enemy-heading h1 { font-size: 14px; letter-spacing: .03em; }
.battle-view .portrait-region { height: 60px; margin: 0; }
.battle-view #enemy-sprite { width: 60px; height: 60px; }
.battle-view .intent { margin: 0; line-height: 1.4; font-size: 13px; }
.battle-view .enemy-box > .hp-label { margin: 0; font-size: 12px; }
.battle-view #enemy-tags { position: absolute; top: 4px; right: 56px; max-width: 48%; flex-wrap: nowrap; overflow-x: auto; margin: 0; background: #16181fcc; }
.battle-view .boss-rule { position: absolute; top: 29px; right: 8px; width: calc(50% - 47px); margin: 0; font-size: 11px; line-height: 1.35; max-height: 60px; overflow-y: auto; }
.battle-view #enemy-block { font-size: 14px; line-height: 1.2; }
.battle-view .player-box { margin: 2px 0; gap: 8px; }
.battle-view .energy { width: 56px; height: 56px; flex-basis: 56px; }
.battle-view #energy-value { font-size: 24px; }
.battle-view .energy small { align-self: center; margin: 0; line-height: 1; white-space: nowrap; }
.battle-view button, .battle-view a { -webkit-tap-highlight-color: transparent; }
.battle-view .energy-preview { display: none; }
.battle-view .player-health > .hp-label:first-child { margin-bottom: 3px; }
.battle-view .player-health { position: relative; }
.battle-view .block-badge { flex: 0 0 56px; width: 56px; height: 48px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 1px solid #5aa9ff; border-radius: 10px; background: #203349; color: #b9dcff; }
.battle-view .block-badge small { font-size: 11px; line-height: 1.2; }
.battle-view .block-badge strong { font-size: 22px; line-height: 1.15; font-variant-numeric: tabular-nums; }
.battle-view #piles { font-size: 9px; }
.battle-view #player-tags { flex-wrap: nowrap; flex-shrink: 0; margin: 0; }
.battle-view .battle-benefits { display: flex; align-items: center; gap: 6px; overflow: hidden; white-space: nowrap; }
.battle-view .benefits-scroll { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; height: 100%; overflow-x: auto; }
.battle-view .benefits-scroll { scrollbar-width: none; }
.battle-view .relic-pill { min-height: 24px; padding: 2px 4px; }
.battle-view .turn-phase { font-size: 12px; margin: 0; flex-shrink: 0; }
.battle-view .active-powers { display: flex; flex: 0 0 auto; margin: 0; padding: 0; border: 0; }
.battle-view .active-power { width: auto; min-height: 24px; padding: 0 4px; gap: 3px; border: 0; margin: 0; }
.battle-view .active-power img { flex-shrink: 0; width: 24px; height: 24px; }
.battle-view .active-power span { font-size: 10px; }
.battle-view .relics { flex-wrap: nowrap; flex: 0 0 auto; min-height: 0; }
.battle-view .empty-relics { display: none; }
.battle-view .hand-heading { margin: 0; align-items: center; }
.battle-view .hand-heading .text-button { padding: 2px; min-height: 36px; font-size: 11px; }
.battle-view .hand { grid-row: 1; height: 100%; min-height: 0; margin: 0 0 0 -10px; padding: 6px 23px; align-items: center; overflow-y: hidden; }
.battle-view .hand-slot { flex-basis: 120px; }
.battle-view .hand .card { width: 120px; height: var(--hand-card-height); min-height: 0; padding: 24px 6px 12px; gap: 2px; display: grid; grid-template-rows: 54px 28px 12px minmax(0,1fr) 12px; justify-items: center; }
.battle-view .hand .card.selected { transform: translateX(var(--selection-shift,0px)) scale(var(--selection-scale,var(--hand-scale))); transition: opacity .16s, box-shadow .16s; }
.battle-view .hand .card-art { grid-row: 1; height: 54px; }
.battle-view .hand .card-art img { max-height: 54px; width: auto; max-width: 100px; object-fit: contain; }
.battle-view .hand .card-name { grid-row: 2; font-size: 11px; line-height: 1.2; }
.battle-view .hand .card-author { grid-row: 3; font-size: 8px; }
.battle-view .hand .card-text { grid-row: 4; align-self: start; display: block; font-size: 11px; line-height: 1.35; }
.battle-view .hand .card-role { display: none; }
.battle-view .hand .card-tier { grid-row: 5; font-size: 9px; margin-top: 0; padding: 1px 4px; line-height: 1.1; }
.battle-view .hand .card-cost { width: 18px; height: 18px; top: 3px; left: 5px; font-size: 12px; }
.battle-view .hand .pack-dot { top: 9px; }
.battle-view .battle-information { min-height: 0; overflow: visible; border: 0; background: transparent; margin: 0 0 4px; display: grid; grid-template-rows: minmax(0,1fr) 36px; }
.battle-view .selected-card, .battle-view .battle-hints { background: #24212b; border: 1px solid #8e773d !important; border-radius: 8px !important; }
.battle-view .selection-bar { grid-row: 2; display: flex; align-items: center; justify-content: space-between; gap: 4px; min-width: 0; }
.battle-view .selection-bar .text-button { min-height: 36px; padding: 2px 4px; font-size: 12px; white-space: nowrap; color: var(--gold); }
.battle-view .selected-card, .battle-view .battle-hints { height: 100%; overflow-y: auto; overscroll-behavior: contain; margin: 0; padding: 6px 8px; border: 0; border-radius: 0; }
.battle-view .selected-card, .battle-view .battle-hints { grid-row: 1; min-height: 0; }
.battle-view .selected-card { display: flex; flex-direction: column; overflow: hidden; position: relative; }
.battle-view .selected-copy { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 12px; }
.battle-view .effect-scroll-cue { position: absolute; bottom: 6px; right: 6px; color: var(--gold); pointer-events: none; }
.battle-view #selected-cost { min-width: 0; padding: 0; margin: 0; color: #d9d4e2; font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.battle-view .selected-card p { font-size: 16px; line-height: 1.45; margin: 0 0 3px; }
.battle-view .selected-card #selected-role, .battle-view .selected-card #selected-cost { font-size: 12px; line-height: 1.5; }
.battle-view .tutorial-hint { padding: 0; margin: 0; border: 0; background: transparent; }
.battle-view .tutorial-hint h2 { font-size: 16px; }
.battle-view .tutorial-hint p { font-size: 16px; }
.battle-view .block-help { font-size: 14px; }
.battle-view .battle-actions { position: static; padding: 0; gap: 6px; background: transparent; }
.battle-view .battle-actions .button { flex: 1; min-width: 0; padding: 4px; font-size: 12px; line-height: 1.3; }
.battle-view .battle-actions #end-btn.primary { box-shadow: 0 0 12px #ffd23f55; }
.battle-view [hidden] { display: none !important; }
.battle-view .storage-note, .map-view .storage-note { position: absolute; top: 36px; left: 10px; right: 10px; z-index: 12; padding: 4px; background: #382329; }
@media (max-height: 650px) {
  .battle-view { --hand-card-height: 160px; --hand-scale: 1.18; grid-template-rows: 48px var(--enemy-height) 48px 24px 32px minmax(0,1fr) 48px; }
  .battle-view .hand-heading .text-button { min-height: 32px; }
  .battle-view .battle-information { grid-template-rows: minmax(0,1fr) 30px; }
  .battle-view .selection-bar .text-button { min-height: 30px; }
  .battle-view .hand .card { padding-top: 20px; grid-template-rows: 24px 26px 10px minmax(0,1fr) 12px; }
  .battle-view .hand .card-art, .battle-view .hand .card-art img { height: 24px; max-height: 24px; }

}
/* Keep current location near the bottom; the saved road rises above it. */
.map-view { height: 100svh; height: 100dvh; padding: max(4px, env(safe-area-inset-top)) 12px max(4px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; position: relative; }
.map-view .battle-top { flex: 0 0 36px; }
.map-view .map-status { flex: 0 0 auto; }
.map-view .map-guidance { flex: 0 0 auto; }
.map-window { min-height: 0; flex: 1; position: relative; overflow-y: auto; overscroll-behavior: contain; border-radius: 12px; background: #16181f; box-shadow: inset 0 0 0 1px #5b4a2e; }
/* 夜の古地図（下から竹林→宿場町→峠→山頂の塔）。下から上へ進む順路と絵の並びを揃えてある。
   地点の文字が読めるよう、上に紺の半透明を重ねて沈ませる。 */
.map-route { position: relative; height: 880px; margin: 0; background: linear-gradient(#16181f55, #16181f99), url('../assets/map-bg.png') center / 100% 100% no-repeat; image-rendering: pixelated; }
.map-route .map-nodes, .map-route > svg { height: 770px; }
.map-current-marker { position: absolute; left: 0; right: 0; text-align: center; color: #a9e0c1; font-size: 12px; font-weight: 700; pointer-events: none; }
.map-view .battle-actions { flex: 0 0 48px; position: static; padding: 0; background: transparent; }
.map-view .battle-story-links { flex: 0 0 44px; margin: 0; }
.card-grid { grid-auto-rows: 1fr; align-items: stretch; }
.card-grid .card { height: 100%; }
.shop-cards > article { display: grid; grid-template-rows: minmax(0,1fr) auto; }
.shop-cards .card { height: 100%; }
.detail-card > .card { height: auto; min-height: 240px; }
.battle-log-history { margin: 0; padding-left: 24px; font-size: 16px; line-height: 1.6; }
.battle-log-history li { margin-bottom: 14px; }
.battle-log-history small { color: var(--muted); font-size: 11px; }

/* 確定ボタンを常に見せる。詳細は縦に長く、スマホでは「デッキに加える」「戻る」が
   画面外にあり、スクロールしないと押せなかった。シートの下端に貼り付けておく。 */
.detail-actions {position:sticky;bottom:calc(-1 * max(22px, env(safe-area-inset-bottom)));z-index:2;gap:8px;margin:16px -14px 0;padding:10px 14px max(12px, env(safe-area-inset-bottom));background:linear-gradient(#21242e00,var(--panel) 14px);}
.detail-actions [data-action="detail-back"] {min-height:44px;padding:8px 16px;}
/* スマホでは絵と説明を横に並べて縦を詰める（絵は飾りなので小さくてよい）。 */
@media (max-width: 599px) {
  .detail-card {grid-template-columns:112px minmax(0,1fr);gap:12px;align-items:start;justify-items:stretch;margin:4px 0 12px;}
  .detail-card > .card {width:112px;min-width:112px;height:auto;min-height:170px;padding:28px 6px 10px;}
  .detail-copy {padding:12px;}
  .detail-copy h3 {font-size:20px;margin:4px 0 8px;}
  .detail-copy p {margin:6px 0;}
  .detail-context {padding:12px;}
}
