/* ==========================================================
 * field.css
 * ----------------------------------------------------------
 * ▸ フィールド画面 (field.html) 専用スタイル
 * ▸ CSS変数は style.css の :root を継承
 * ========================================================== */

.field-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 22px 80px;
  position: relative;
  z-index: 1;
}

/* ---------- ヘッダー ---------- */
.field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

/* ---------- HUD ---------- */
.field-hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.hud-card {
  background:
    linear-gradient(135deg, rgba(91, 140, 255, 0.05), transparent 60%),
    var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: border-color 0.2s, transform 0.2s;
}
.hud-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
}

.hud-label {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--text-3);
}

.hud-value {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-1);
}

.hud-value--mono {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--accent-3);
}

.hud-unit {
  font-size: 11px;
  font-family: var(--font-mono);
  margin-left: 4px;
  color: var(--text-3);
  letter-spacing: 0.1em;
}

/* ゴールドHUDカード - 黄金色 */
.hud-card--gold {
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(255, 203, 71, 0.10), transparent 55%),
    var(--bg-2);
  border-color: rgba(255, 203, 71, 0.28);
}
.hud-card--gold:hover {
  border-color: rgba(255, 203, 71, 0.55);
  box-shadow: var(--glow-gold);
}
.hud-card--gold .hud-label {
  color: var(--gold);
  text-shadow: 0 0 8px rgba(255, 203, 71, 0.35);
}
.hud-card--gold .hud-value {
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 60%, var(--gold-deep));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-flex;
  align-items: baseline;
}
.hud-card--gold .hud-gold-icon {
  -webkit-text-fill-color: var(--gold);
  color: var(--gold);
  margin-right: 6px;
  filter: drop-shadow(0 0 6px rgba(255, 203, 71, 0.55));
}
.hud-card--gold .hud-unit {
  -webkit-text-fill-color: var(--gold-deep);
  color: var(--gold-deep);
}

@keyframes goldPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.08); box-shadow: var(--glow-gold); }
  100% { transform: scale(1); }
}
.hud-card--gold.gold-gain {
  animation: goldPop 0.5s ease;
}

/* ---------- フィールドキャンバス ---------- */
.field-board {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}

.field-board::before {
  /* 上端のアクセントライン */
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  opacity: 0.7;
}

.field-canvas-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  position: relative;
}

#fieldCanvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: #06070d;
  box-shadow:
    0 0 30px rgba(91, 140, 255, 0.15),
    inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.field-controls-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 10px 0 4px;
  color: var(--text-2);
  font-size: 13px;
  flex-wrap: wrap;
}

.key-hint {
  display: inline-flex;
  gap: 4px;
}

kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-1);
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 3px 7px;
  min-width: 22px;
  text-align: center;
}

.key-hint-or {
  color: var(--text-3);
  font-size: 11px;
  font-family: var(--font-mono);
}

.key-hint-text {
  color: var(--text-3);
  font-family: var(--font-body);
  font-size: 12px;
}

/* ---------- 十字キー (モバイル/タッチ用) ---------- */
.dpad {
  display: none;  /* 通常PCでは非表示 */
  width: 180px;
  height: 180px;
  margin: 16px auto 4px;
  position: relative;
}

.dpad-btn {
  position: absolute;
  width: 60px;
  height: 60px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  transition: background 0.1s, border-color 0.1s;
}
.dpad-btn:active {
  background: var(--accent);
  color: var(--bg-0);
  border-color: var(--accent);
  box-shadow: var(--glow-accent);
}

.dpad-up    { top: 0;     left: 60px; }
.dpad-left  { top: 60px;  left: 0;    }
.dpad-down  { top: 120px; left: 60px; }
.dpad-right { top: 60px;  left: 120px; }

/* ---------- 凡例 ---------- */
.legend {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.legend-title {
  font-family: var(--font-display);
  font-size: 14px;
  letter-spacing: 0.2em;
  color: var(--accent-3);
  margin-bottom: 14px;
}

.legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-1);
}

.legend-list em {
  font-style: normal;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-left: auto;
  letter-spacing: 0.05em;
}

.legend-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border-strong);
}
.legend-swatch[data-terrain="grass"]    { background: #56a85e; }
.legend-swatch[data-terrain="forest"]   { background: #2c7340; }
.legend-swatch[data-terrain="mountain"] { background: linear-gradient(135deg, #7c7c92, #5a5a6e); }
.legend-swatch[data-terrain="sand"]     { background: #d4b878; }
.legend-swatch[data-terrain="road"]     { background: #8a7855; }
.legend-swatch[data-terrain="town"]     { background: #b08850; }
.legend-swatch[data-terrain="water"]    { background: #4a7cc4; }

/* ============================================================
   仮戦闘オーバーレイ
   ============================================================ */
.battle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 13, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
/* ★[hidden]属性を確実に効かせる (display:flex を打ち消す) */
.battle-overlay[hidden] { display: none; }
.battle-overlay.show { opacity: 1; }

.battle-stage {
  position: relative;
  width: 100%;
  max-width: 520px;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(91, 140, 255, 0.18), transparent 65%),
    var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px 28px 28px;
  text-align: center;
  box-shadow:
    0 0 60px rgba(91, 140, 255, 0.3),
    0 20px 40px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transform: scale(0.92);
  transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.battle-overlay.show .battle-stage { transform: scale(1); }

/* 上下のアクセント線 (装飾なのでクリックを奪わない) */
.battle-stage::before,
.battle-stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-3), var(--accent-2), transparent);
  pointer-events: none;
}
.battle-stage::before { top: 0; }
.battle-stage::after  { bottom: 0; }

/* フラッシュ効果 (出現時に光る) */
.battle-flash {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255,255,255,0.4), transparent 60%);
  pointer-events: none;
  opacity: 0;
  animation: battleFlash 0.6s ease-out;
}
@keyframes battleFlash {
  0%   { opacity: 0.8; }
  100% { opacity: 0; }
}

.battle-enemy-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 18px;
}

.battle-enemy-tier {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--bg-2);
  color: var(--accent-3);
  border: 1px solid var(--border-strong);
}

.battle-enemy-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-1);
}

.battle-reward {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  padding: 4px 10px;
  background: rgba(255, 203, 71, 0.12);
  border: 1px solid rgba(255, 203, 71, 0.35);
  border-radius: 4px;
  text-shadow: 0 0 6px rgba(255, 203, 71, 0.4);
}

.battle-sprite-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* 演出レイヤー、クリックを奪わない */
}

.battle-sprite-glow {
  position: absolute;
  inset: 10%;
  background: radial-gradient(circle, rgba(91, 140, 255, 0.4), transparent 70%);
  filter: blur(20px);
  animation: spriteGlow 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes spriteGlow {
  0%, 100% { opacity: 0.5; transform: scale(0.95); }
  50%      { opacity: 0.9; transform: scale(1.05); }
}

.battle-sprite {
  position: relative;
  width: 180px;
  height: 180px;
  animation: spriteFloat 2.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes spriteFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.battle-message {
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 22px;
  min-height: 24px;
  letter-spacing: 0.05em;
}
.battle-message.win {
  color: var(--gold-light);
  text-shadow: 0 0 12px rgba(255, 203, 71, 0.5);
}
.battle-message.flee {
  color: var(--text-2);
}

.battle-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  /* 装飾レイヤーより手前に確実に出して、クリックを受け取れるようにする */
  position: relative;
  z-index: 2;
}

.battle-btn {
  min-width: 140px;
}

.battle-note {
  margin-top: 18px;
  font-size: 11px;
  color: var(--text-3);
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
}

/* ============================================================
   街ダイアログ
   ============================================================ */
.town-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 13, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
/* ★[hidden]属性を確実に効かせる */
.town-overlay[hidden] { display: none; }
.town-overlay.show { opacity: 1; }

.town-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  text-align: center;
  box-shadow:
    0 0 40px rgba(255, 203, 71, 0.18),
    0 16px 32px rgba(0, 0, 0, 0.5);
  transform: scale(0.92);
  transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.town-overlay.show .town-card { transform: scale(1); }

.town-icon {
  font-size: 48px;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(255, 203, 71, 0.6);
  margin-bottom: 8px;
  line-height: 1;
}

.town-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-1);
  margin-bottom: 8px;
}

.town-desc {
  color: var(--text-2);
  margin-bottom: 22px;
  font-size: 14px;
}

.town-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ============================================================
   レスポンシブ
   ============================================================ */
@media (max-width: 780px) {
  .field-app { padding: 14px 6px 40px; }
  .field-header { margin-bottom: 14px; padding-bottom: 12px; }
  .field-board { padding: 8px; margin-bottom: 14px; }
  .field-canvas-wrap { margin-bottom: 10px; }
  .dpad { display: block; }   /* モバイルでは十字キー表示 */
  .field-controls-info { display: none; }  /* キー表示は隠す */
  .battle-sprite-wrap { width: 160px; height: 160px; }
  .battle-sprite { width: 140px; height: 140px; }
  .battle-enemy-name { font-size: 18px; }
  .battle-actions { flex-direction: column; }
  .battle-btn { width: 100%; }
}

/* ============================================================
   ショップ (防具屋) オーバーレイ
   ============================================================ */
.shop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 13, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.shop-overlay[hidden] { display: none; }
.shop-overlay.show { opacity: 1; }

.shop-stage {
  width: 100%;
  max-width: 920px;
  max-height: 92vh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 203, 71, 0.10), transparent 55%),
    var(--bg-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow:
    0 0 60px rgba(255, 203, 71, 0.18),
    0 20px 40px rgba(0, 0, 0, 0.5);
  transform: scale(0.94);
  transition: transform 0.35s cubic-bezier(0.2, 1.4, 0.4, 1);
  position: relative;
}
.shop-overlay.show .shop-stage { transform: scale(1); }

/* 上端アクセント線 - 金色 */
.shop-stage::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--gold-light), var(--gold), transparent);
  pointer-events: none;
  z-index: 1;
}

/* ---------- ショップ ヘッダー ---------- */
.shop-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.shop-title-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shop-icon {
  font-size: 26px;
  color: var(--gold);
  text-shadow: 0 0 12px rgba(255, 203, 71, 0.6);
  line-height: 1;
}

.shop-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--text-1);
  margin: 0;
}
.shop-subtitle {
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--text-3);
  margin-left: 10px;
}

.shop-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.shop-gold-display {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 8px 16px;
  background: rgba(255, 203, 71, 0.08);
  border: 1px solid rgba(255, 203, 71, 0.35);
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  background-clip: padding-box;
}
.shop-gold-icon {
  color: var(--gold);
  margin-right: 4px;
  filter: drop-shadow(0 0 6px rgba(255, 203, 71, 0.55));
}
.shop-gold-display #shopGold {
  background: linear-gradient(180deg, var(--gold-light), var(--gold) 60%, var(--gold-deep));
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
.shop-gold-unit {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold-deep);
  margin-left: 4px;
}

.shop-close-btn {
  font-size: 13px;
}

/* ---------- メッセージ ---------- */
.shop-message {
  min-height: 22px;
  padding: 8px 24px;
  font-family: var(--font-body);
  font-size: 13px;
  letter-spacing: 0.05em;
  color: var(--text-2);
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border);
  text-align: center;
  flex-shrink: 0;
}
.shop-message.buy   { color: var(--gold-light); text-shadow: 0 0 6px rgba(255,203,71,0.4); }
.shop-message.equip { color: var(--accent-3); }
.shop-message.error { color: var(--danger); }
.shop-message.info  { color: var(--text-2); }

/* ---------- メイン (2カラム) ---------- */
.shop-main {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

/* ---------- 左カラム: 商品リスト ---------- */
.shop-listing {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  overflow: hidden;
  min-height: 0;
}

.shop-tabs {
  display: flex;
  gap: 4px;
  padding: 14px 20px 0;
  flex-shrink: 0;
}

.shop-tab {
  flex: 1;
  padding: 10px 12px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-3);
  background: transparent;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: all 0.15s;
}
.shop-tab:hover {
  color: var(--text-1);
  background: var(--bg-2);
}
.shop-tab.active {
  color: var(--accent-3);
  background: var(--bg-1);
  border-color: var(--accent);
  border-bottom: 1px solid var(--bg-1);
  margin-bottom: -1px;
  text-shadow: 0 0 8px var(--accent-3);
}

.shop-item-list {
  list-style: none;
  margin: 0;
  padding: 16px 20px 20px;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.shop-item {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  margin-bottom: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s, transform 0.15s;
}
.shop-item:hover {
  border-color: var(--border-strong);
  transform: translateX(2px);
}
.shop-item.equipped {
  border-color: var(--gold);
  box-shadow: 0 0 14px rgba(255, 203, 71, 0.2);
  background:
    linear-gradient(135deg, rgba(255, 203, 71, 0.06), transparent 60%),
    var(--bg-2);
}

.shop-item-sprite {
  width: 56px;
  height: 56px;
  background:
    repeating-linear-gradient(45deg,
      rgba(91,140,255,0.04) 0 4px,
      transparent 4px 8px),
    var(--bg-0);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  image-rendering: pixelated;
}
.shop-item-sprite svg {
  display: block;
  width: 100%;
  height: 100%;
}
.shop-item-sprite-empty {
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 14px;
}

.shop-item-info {
  min-width: 0;
}

.shop-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.shop-item-name {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: 0.05em;
}

.shop-item-tier {
  display: inline-flex;
  padding: 1px 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  border-radius: 3px;
  background: var(--bg-0);
  border: 1px solid var(--border);
  color: var(--text-3);
}
.shop-item-tier[data-tier="1"] { color: #9aa0b0; }
.shop-item-tier[data-tier="2"] { color: var(--accent); border-color: var(--accent); }
.shop-item-tier[data-tier="3"] { color: var(--accent-2); border-color: var(--accent-2); }
.shop-item-tier[data-tier="4"] { color: var(--gold); border-color: var(--gold); text-shadow: 0 0 6px rgba(255,203,71,0.4); }

.shop-item-desc {
  font-size: 12px;
  color: var(--text-3);
  margin: 4px 0 6px;
  line-height: 1.4;
}

.shop-item-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.shop-item-price {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 0 6px rgba(255, 203, 71, 0.3);
}
.shop-item-price.insufficient {
  color: var(--text-3);
  text-shadow: none;
  text-decoration: line-through;
}

.shop-item-owned {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  padding: 2px 8px;
  background: var(--bg-0);
  border-radius: 999px;
}

.shop-item-equipped-tag {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--gold-light);
  padding: 2px 8px;
  background: rgba(255, 203, 71, 0.15);
  border: 1px solid rgba(255, 203, 71, 0.4);
  border-radius: 3px;
}

.shop-item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
  min-width: 70px;
}

.shop-item-actions .btn {
  padding: 6px 10px;
  font-size: 12px;
  letter-spacing: 0.05em;
}

.shop-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
  font-family: var(--font-mono);
  font-size: 13px;
}

/* ---------- 右カラム: プレビュー ---------- */
.shop-preview {
  padding: 20px;
  background: var(--bg-0);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.shop-preview-title {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.25em;
  color: var(--accent-3);
  margin: 0 0 14px;
}

.shop-avatar-preview {
  width: 100%;
  aspect-ratio: 1;
  max-width: 200px;
  margin: 0 auto 16px;
  background:
    repeating-linear-gradient(45deg,
      rgba(91,140,255,0.04) 0 6px,
      transparent 6px 12px),
    var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  image-rendering: pixelated;
}
.shop-avatar-preview svg {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.shop-equipped-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shop-equipped-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.equip-slot-label {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--text-3);
}

.equip-slot-name {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-1);
}
.equip-slot-name.empty {
  color: var(--text-3);
  font-style: italic;
  font-weight: 400;
}

.shop-preview-note {
  font-size: 10px;
  color: var(--text-3);
  text-align: center;
  font-family: var(--font-mono);
  letter-spacing: 0.05em;
  margin: 0;
}

/* ---------- レスポンシブ ---------- */
@media (max-width: 780px) {
  .shop-stage { max-height: 96vh; }
  .shop-header { padding: 14px 16px; flex-wrap: wrap; gap: 10px; }
  .shop-title { font-size: 18px; }
  .shop-subtitle { display: none; }
  .shop-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .shop-preview {
    border-top: 1px solid var(--border);
    flex-direction: row;
    gap: 14px;
    align-items: center;
  }
  .shop-avatar-preview { width: 120px; height: 120px; margin: 0; flex-shrink: 0; }
  .shop-equipped-list { flex: 1; }
  .shop-preview-title { display: none; }
  .shop-preview-note { display: none; }
  .shop-item { grid-template-columns: 48px 1fr; }
  .shop-item-actions { grid-column: 1 / -1; flex-direction: row; min-width: 0; }
  .shop-item-actions .btn { flex: 1; }
}

/* ============================================================
 * 戦闘 HPバー (フェーズ2)
 * ============================================================ */
.battle-hp {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(360px, 80%);
  margin: 6px auto;
}
.battle-hp-label {
  font-family: var(--font-body, sans-serif);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #cdd6ff;
  width: 44px;
  flex-shrink: 0;
}
.battle-hp-bar {
  flex: 1;
  height: 14px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(160, 180, 240, 0.35);
  overflow: hidden;
}
.battle-hp-fill {
  height: 100%;
  width: 100%;
  border-radius: 7px;
  background: linear-gradient(90deg, #45e6a8, #20c080);
  transition: width 0.35s ease;
}
.battle-hp--enemy .battle-hp-fill {
  background: linear-gradient(90deg, #ff7a5c, #e0432a);
}
.battle-hp-fill.low {
  background: linear-gradient(90deg, #ff5b5b, #c02020) !important;
  animation: hpLowPulse 0.9s ease-in-out infinite;
}
@keyframes hpLowPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.battle-hp-text {
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  font-weight: 700;
  color: #e8ecf5;
  width: 56px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

/* 被弾時のスプライト揺れ */
.battle-sprite.hit {
  animation: spriteHit 0.4s ease;
}
@keyframes spriteHit {
  0%   { transform: translateX(0); filter: brightness(1); }
  20%  { transform: translateX(-6px); filter: brightness(2.2); }
  40%  { transform: translateX(6px); }
  60%  { transform: translateX(-4px); }
  80%  { transform: translateX(4px); }
  100% { transform: translateX(0); filter: brightness(1); }
}

/* ============================================================
 * 町に入った/出た バナー (フェーズ3)
 * ============================================================ */
.town-banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 8px 22px;
  background: rgba(10, 12, 24, 0.85);
  border: 1px solid #45e6a8;
  border-radius: var(--radius-sm, 8px);
  color: #d7ffe9;
  font-family: var(--font-display, sans-serif);
  font-size: 15px;
  letter-spacing: 0.12em;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  box-shadow: 0 0 18px -4px #45e6a8;
}
.town-banner.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
 * 魔法 (じゅもん) / NPC助太刀 UI  (フェーズ3続き)
 * ============================================================ */
/* MPバー (青紫) */
.battle-mp-fill {
  background: linear-gradient(90deg, #8a6bff, #5b8cff) !important;
}
.battle-mp--player .battle-hp-label { color: #b9a6ff; }

/* じゅもんボタン (神秘力カラー) */
.btn-magic {
  background: linear-gradient(135deg, rgba(138, 107, 255, 0.22), rgba(91, 140, 255, 0.12));
  border: 1px solid #8a6bff;
  color: #e7deff;
}
.btn-magic:hover:not(:disabled) {
  border-color: #a98bff;
  box-shadow: 0 0 16px -3px #8a6bff;
}

/* じゅもん選択メニュー */
.battle-spell-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
}
.battle-spell-item {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "name cost" "desc desc";
  gap: 2px 10px;
  text-align: left;
  padding: 10px 14px;
  background: rgba(20, 16, 40, 0.7);
  border: 1px solid #5a4a8a;
  border-radius: var(--radius-sm, 8px);
  color: #e7deff;
  font-family: var(--font-display, sans-serif);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.battle-spell-item:hover:not(:disabled) {
  border-color: #a98bff;
  background: rgba(40, 30, 70, 0.85);
}
.battle-spell-item:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.battle-spell-item .spell-name { grid-area: name; font-size: 15px; letter-spacing: 0.06em; }
.battle-spell-item .spell-cost { grid-area: cost; color: #8a6bff; font-size: 13px; align-self: center; }
.battle-spell-item .spell-desc { grid-area: desc; color: #9aa0bf; font-size: 12px; }
.battle-spell-back {
  align-self: center;
  margin-top: 2px;
  padding: 6px 18px;
  background: transparent;
  border: 1px solid var(--border-strong, #444);
  border-radius: var(--radius-sm, 8px);
  color: #c7cce0;
  cursor: pointer;
}
.battle-spell-back:hover { border-color: #8a6bff; }
