/* ============================================================
   ゴムナガの野望 〜長靴覇王伝〜  style.css
   黒漆×金の重厚和風 + かわいい長靴たち
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "MS PMincho", serif;
  background: #14100c; color: #e8dfc8; overflow: hidden;
  user-select: none; -webkit-user-select: none;
}
button { font-family: inherit; cursor: pointer; touch-action: manipulation; }
.hidden { display: none !important; }
.dim { color: #9c917a; font-size: .85em; }
b { color: #f2e9cf; }

/* ================= タイトル ================= */
#title-screen {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 18px; z-index: 50;
  background:
    radial-gradient(ellipse 90% 60% at 50% -10%, #3a3050 0%, transparent 60%),
    radial-gradient(ellipse 70% 50% at 80% 100%, #2a1c14 0%, transparent 55%),
    linear-gradient(180deg, #171226 0%, #241a14 55%, #171009 100%);
}
.title-clouds {
  position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background:
    radial-gradient(ellipse 220px 60px at 15% 30%, rgba(201,162,39,.10), transparent 70%),
    radial-gradient(ellipse 300px 70px at 85% 20%, rgba(201,162,39,.08), transparent 70%),
    radial-gradient(ellipse 260px 60px at 70% 75%, rgba(201,162,39,.07), transparent 70%),
    radial-gradient(ellipse 200px 50px at 25% 80%, rgba(160,120,60,.08), transparent 70%);
}
#title-logo { text-align: center; z-index: 1; }
#title-kicker { letter-spacing: .5em; color: #b3a684; font-size: 14px; margin-bottom: 10px; }
#title-main {
  font-size: clamp(44px, 9vw, 92px); font-weight: 900; color: #f2e9cf; letter-spacing: .08em;
  text-shadow: 0 2px 0 #6e5a1e, 0 5px 0 #4a3c12, 0 10px 24px rgba(0,0,0,.7), 0 0 46px rgba(201,162,39,.35);
}
#title-sub {
  margin-top: 8px; font-size: clamp(18px, 3vw, 30px); color: #c9a227; letter-spacing: .55em; text-indent: .55em;
  text-shadow: 0 2px 8px rgba(0,0,0,.8);
}
#title-btns { display: flex; gap: 18px; z-index: 1; margin-top: 6px; }
.title-btn {
  font-size: 20px; padding: 13px 34px; border-radius: 6px; border: 2px solid #8a6f22;
  background: linear-gradient(180deg, #3a2c1a, #241a10); color: #f2e9cf; letter-spacing: .2em;
  box-shadow: 0 4px 14px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,235,180,.15);
  transition: transform .12s, box-shadow .12s;
}
.title-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,.7), 0 0 18px rgba(201,162,39,.25); }
#title-parade { display: flex; gap: 6px; margin-top: 10px; z-index: 1; flex-wrap: wrap; justify-content: center; max-width: 92vw; }
.parade-boot { animation: parade-hop 1.6s ease-in-out infinite; }
.parade-boot svg { filter: drop-shadow(0 4px 6px rgba(0,0,0,.5)); }
@keyframes parade-hop { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
#title-note { color: #b3a684; letter-spacing: .3em; font-size: 13px; z-index: 1; }
#title-disclaimer {
  position: absolute; bottom: 12px; left: 0; right: 0; text-align: center;
  font-size: 10.5px; line-height: 1.7; color: #7d735f;
}

/* ================= シナリオ選択 ================= */
#scn-screen { position: fixed; inset: 0; z-index: 46; overflow-y: auto; padding: 16px 20px 40px; background: linear-gradient(180deg, #1c1610, #14100c); }
#scn-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; max-width: 1100px; margin: 10px auto 0; }
.scn-card {
  border: 2px solid #4a3b22; border-radius: 10px; padding: 22px 20px 18px; cursor: pointer;
  background: linear-gradient(180deg, rgba(60,48,30,.5), rgba(30,24,16,.75));
  transition: transform .15s, border-color .15s, box-shadow .15s; text-align: left;
}
.scn-card:hover { transform: translateY(-4px); border-color: #c9a227; box-shadow: 0 12px 26px rgba(0,0,0,.55), 0 0 18px rgba(201,162,39,.25); }
.scn-year { font-size: 44px; font-weight: 900; color: #ffe9a0; letter-spacing: .04em; text-shadow: 0 2px 0 #6e5a1e, 0 5px 14px rgba(0,0,0,.6); }
.scn-year span { font-size: 20px; margin-left: 2px; color: #c9b68a; }
.scn-label { font-size: 22px; font-weight: bold; color: #f2e9cf; letter-spacing: .12em; margin: 4px 0 10px; }
.scn-desc { font-size: 13.5px; line-height: 1.9; color: #b3a684; min-height: 5.5em; }
.scn-go { margin-top: 12px; text-align: right; color: #c9a227; font-size: 14px; letter-spacing: .1em; }

/* ================= 大名選択 ================= */
#select-screen { position: fixed; inset: 0; z-index: 45; overflow-y: auto; padding: 16px 20px 40px; background: linear-gradient(180deg, #1c1610, #14100c); }
.select-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.select-title { font-size: clamp(16px, 2.6vw, 24px); color: #f2e9cf; letter-spacing: .1em; }
#select-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.sel-card {
  position: relative; border: 2px solid #4a3b22; border-radius: 8px; padding: 10px 8px 12px;
  background: linear-gradient(180deg, rgba(60,48,30,.5), rgba(30,24,16,.7));
  text-align: center; cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s;
}
.sel-card:hover { transform: translateY(-4px); border-color: var(--cc); box-shadow: 0 10px 22px rgba(0,0,0,.55), 0 0 16px color-mix(in srgb, var(--cc) 40%, transparent); }
.sel-card::before { content: ''; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--cc); border-radius: 6px 6px 0 0; }
.sel-mon { position: absolute; top: 8px; right: 8px; opacity: .9; }
.sel-boot { margin: 4px auto 2px; }
.sel-boot svg { filter: drop-shadow(0 5px 8px rgba(0,0,0,.5)); }
.sel-name { font-size: 18px; font-weight: bold; color: #f2e9cf; }
.sel-daimyo { font-size: 13px; color: #c9b68a; }
.sel-sub { font-size: 11px; color: #9c917a; margin-top: 3px; }
.select-others-title { text-align: center; color: #9c917a; margin: 22px 0 10px; letter-spacing: .3em; }
#select-others { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.other-clan {
  border: 1px solid #4a3b22; border-left: 4px solid var(--cc); border-radius: 4px;
  background: rgba(40,32,20,.6); color: #e8dfc8; padding: 6px 10px; font-size: 13px;
}
.other-clan:hover { background: rgba(70,56,34,.7); }

/* ================= HUD ================= */
#main-screen { position: fixed; inset: 0; display: flex; flex-direction: column; }
#hud {
  display: flex; align-items: center; gap: 10px; padding: 6px 10px; flex-wrap: wrap;
  background: linear-gradient(180deg, #2c2216, #1c1610); border-bottom: 2px solid #6e5a1e;
  box-shadow: 0 3px 12px rgba(0,0,0,.5); z-index: 20; font-size: 14px;
}
#hud-clan { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; letter-spacing: .06em; }
#hud-date { color: #c9a227; font-weight: bold; letter-spacing: .1em; }
.hud-res b { font-family: inherit; }
#hud-ap { display: inline-flex; gap: 3px; }
#hud-ap i { width: 11px; height: 11px; border-radius: 50%; background: #3a3226; border: 1px solid #6e5a1e; display: inline-block; }
#hud-ap i.on { background: radial-gradient(circle at 35% 35%, #ffe9a0, #c9a227 70%); box-shadow: 0 0 6px rgba(201,162,39,.6); }
.hud-spacer { flex: 1; }
.hud-btn {
  background: linear-gradient(180deg, #3a2e1c, #241c12); color: #e8dfc8; border: 1px solid #6e5a1e;
  border-radius: 4px; padding: 5px 10px; font-size: 13px; letter-spacing: .04em;
}
.hud-btn:hover { background: #4a3a22; }
.hud-btn.primary { background: linear-gradient(180deg, #8a2b2b, #5e1c1c); border-color: #b06a4a; font-weight: bold; }
.hud-btn.primary:hover { background: linear-gradient(180deg, #a03434, #6e2222); }
.hud-btn.glow { animation: btnglow 1.2s ease-in-out infinite; }
@keyframes btnglow { 0%,100% { box-shadow: 0 0 3px rgba(201,162,39,.4);} 50% { box-shadow: 0 0 14px rgba(201,162,39,.9);} }

/* ================= 地図 ================= */
#game-area { flex: 1; display: flex; min-height: 0; position: relative; }
#map-wrap { flex: 1; min-width: 0; position: relative; background: #274b63; }
#map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#map:active { cursor: grabbing; }
.road { stroke: rgba(90,62,26,.5); stroke-width: 3.5; stroke-dasharray: 1 9; stroke-linecap: round; }
.searoute { stroke: rgba(120,170,205,.55); stroke-width: 3; stroke-dasharray: 10 8; stroke-linecap: round; }
.mt { pointer-events: none; }
.lake { fill: #35688a; stroke: #274b63; stroke-width: 3; pointer-events: none; }
.clabel { pointer-events: none; }
.minebadge { pointer-events: none; }
.castle { cursor: pointer; }
.cpole { stroke: #4a3728; stroke-width: 2.6; stroke-linecap: round; }
.cpole.pmine { stroke: #6e5a1e; }
.cflag.pflag { stroke: #ffe9a0; stroke-width: 2.6; filter: drop-shadow(0 0 3px rgba(255,233,160,.55)); }
.cplate { fill: rgba(246,241,226,.82); stroke: rgba(90,70,40,.45); stroke-width: 1; display: none; }
.cname {
  font-size: 15px; text-anchor: middle; fill: #2c2216; font-weight: bold;
  paint-order: stroke; stroke: rgba(246,241,226,.9); stroke-width: 3px; display: none;
}
.csol { font-size: 11.5px; text-anchor: middle; fill: #4a3d2a; paint-order: stroke; stroke: rgba(240,232,208,.8); stroke-width: 3px; display: none; }
#map.zoomed .cname, #map.zoomed .cplate { display: block; }
#map.zoomed2 .csol { display: block; }
.selring { fill: none; stroke: #ffe9a0; stroke-width: 3; animation: selpulse 1.4s ease-in-out infinite; }
@keyframes selpulse { 0%,100% { stroke-opacity: .9; r: 24;} 50% { stroke-opacity: .4; r: 28;} }
.atkring { fill: rgba(220,60,40,.15); stroke: #e05038; stroke-width: 3; stroke-dasharray: 8 5; animation: spin 5s linear infinite; transform-box: fill-box; transform-origin: center; }
.mvring { fill: rgba(60,120,220,.14); stroke: #4a8ad0; stroke-width: 3; stroke-dasharray: 8 5; animation: spin 5s linear infinite; transform-box: fill-box; transform-origin: center; }
@keyframes spin { to { transform: rotate(360deg); } }
.ping { fill: none; stroke: #ff6a4a; stroke-width: 4; animation: pingout 1.2s ease-out forwards; transform-box: fill-box; transform-origin: center; }
@keyframes pingout { 0% { transform: scale(.4); opacity: 1;} 100% { transform: scale(5); opacity: 0;} }
#map-tools { position: absolute; left: 10px; bottom: 12px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
#map-tools button {
  width: 40px; height: 40px; font-size: 18px; border-radius: 6px; border: 1px solid #6e5a1e;
  background: rgba(28,22,16,.85); color: #e8dfc8;
}

/* ================= 右パネル ================= */
#side-panel {
  width: 330px; flex-shrink: 0; overflow-y: auto; padding: 10px;
  background: linear-gradient(180deg, #241c12, #1a140e); border-left: 2px solid #4a3b22;
}
.panel-hint { padding: 24px 10px; text-align: center; color: #9c917a; line-height: 2; }
.cinfo-head { display: flex; gap: 10px; align-items: center; padding: 8px; border: 1px solid #4a3b22; border-left: 5px solid; border-radius: 5px; background: rgba(50,40,24,.4); }
.cinfo-name { font-size: 18px; font-weight: bold; color: #f2e9cf; }
.cinfo-owner { font-size: 13px; color: #c9b68a; }
.capmark { background: #6e5a1e; color: #ffe9a0; border-radius: 3px; padding: 0 5px; font-size: 11px; margin-left: 4px; }
.cinfo-stats { margin: 10px 2px; }
.cs-row { display: flex; align-items: center; gap: 7px; margin: 4px 0; font-size: 13px; }
.cs-row span { width: 34px; color: #b3a684; flex-shrink: 0; }
.cs-row b { width: 58px; text-align: right; flex-shrink: 0; font-size: 13px; }
.cs-bar { flex: 1; height: 9px; background: #100d09; border-radius: 5px; overflow: hidden; border: 1px solid #3a2f1e; }
.cs-bar i { display: block; height: 100%; border-radius: 5px; }
.cinfo-mine {
  font-size: 13px; margin: 6px 2px; padding: 5px 9px; border-radius: 6px; font-weight: bold;
  background: rgba(58,44,20,.55); border: 1px solid #6e5a1e;
}
.cinfo-mine.gold { color: #f0c930; }
.cinfo-mine.silver { color: #d4dbe4; }
.cinfo-mine i { font-style: normal; font-weight: normal; font-size: 12px; color: #c9b68a; margin-left: 4px; }
.cinfo-lord { font-size: 13px; color: #c9b68a; margin: 6px 2px; }
.cinfo-busho-title { font-size: 13px; color: #b3a684; margin: 8px 2px 4px; border-bottom: 1px solid #4a3b22; padding-bottom: 3px; }
.cinfo-busho { max-height: 200px; overflow-y: auto; }
.bchip {
  display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 5px; cursor: pointer;
  border: 1px solid transparent;
}
.bchip:hover { background: rgba(201,162,39,.1); border-color: #4a3b22; }
.bchip-art { width: 36px; flex-shrink: 0; text-align: center; }
.bchip-name { font-size: 14px; color: #f2e9cf; }
.bchip-sub { font-size: 11px; color: #9c917a; }
.bchip.pickable.on { background: rgba(201,162,39,.22); border-color: #c9a227; }
.cmd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 10px; }
.cmd {
  padding: 8px 4px; border-radius: 5px; border: 1px solid #5a4a2a; font-size: 14px; letter-spacing: .04em;
  background: linear-gradient(180deg, #3a2e1c, #241c12); color: #e8dfc8;
}
.cmd i { font-style: normal; font-size: 10px; color: #b3a684; }
.cmd:hover { background: #4a3a22; }
.cmd.atk { background: linear-gradient(180deg, #6e2222, #481414); border-color: #8a4a3a; font-weight: bold; }
.cmd.atk:hover { background: #7e2a2a; }
.cmd.dele.on { border-color: #c9a227; box-shadow: 0 0 8px rgba(201,162,39,.35); }
.dele-mark { background: rgba(47,93,138,.3); border: 1px solid #2f5d8a; color: #a8c8e8; border-radius: 3px; padding: 1px 7px; font-size: 11px; margin-left: 7px; }
.dele-mark.war { background: rgba(126,42,42,.3); border-color: #8a4a3a; color: #e8a888; }
.dele-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.enemy-power { margin-top: 10px; text-align: center; }

/* ================= モーダル・トースト ================= */
.modal-ov {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  background: rgba(8,5,3,.72); animation: fadein .18s;
}
@keyframes fadein { from { opacity: 0; } }
.modal-box {
  min-width: 300px; max-width: min(92vw, 560px); max-height: 86vh; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #2c2216, #1c1610); border: 2px solid #6e5a1e; border-radius: 8px;
  box-shadow: 0 14px 50px rgba(0,0,0,.8), inset 0 1px 0 rgba(255,235,180,.12);
}
.modal-ov.wide .modal-box { max-width: min(94vw, 720px); }
.modal-title { padding: 10px 16px; font-size: 17px; color: #f2e9cf; border-bottom: 1px solid #4a3b22; letter-spacing: .06em; }
.modal-body { padding: 12px 16px; overflow-y: auto; line-height: 1.8; font-size: 14px; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; padding: 10px 14px; border-top: 1px solid #4a3b22; flex-wrap: wrap; }
.mbtn {
  padding: 8px 18px; border-radius: 5px; border: 1px solid #6e5a1e; font-size: 14px;
  background: linear-gradient(180deg, #3a2e1c, #241c12); color: #e8dfc8; letter-spacing: .06em;
}
.mbtn:hover { background: #4a3a22; }
.mbtn.primary { background: linear-gradient(180deg, #8a6f22, #5e4a14); color: #fff6dc; font-weight: bold; }
.mbtn.primary:hover { background: linear-gradient(180deg, #a08028, #6e581a); }
.mbtn.danger { background: linear-gradient(180deg, #6e2222, #481414); border-color: #8a4a3a; }
.mbtn.small { padding: 4px 9px; font-size: 12px; }
#toast-layer { position: fixed; left: 12px; bottom: 14px; z-index: 200; display: flex; flex-direction: column; gap: 7px; pointer-events: none; max-width: min(88vw, 480px); }
.toast {
  background: rgba(28,22,16,.94); border: 1px solid #6e5a1e; border-left: 5px solid #c9a227;
  padding: 8px 14px; border-radius: 5px; font-size: 14px; opacity: 0; transform: translateX(-18px);
  transition: all .3s; box-shadow: 0 4px 14px rgba(0,0,0,.5); line-height: 1.6;
}
.toast.show { opacity: 1; transform: none; }
.toast.hide { opacity: 0; transform: translateY(8px); }
.toast.good { border-left-color: #7ab87a; }
.toast.bad { border-left-color: #c25b3a; }
.toast.big { border-left-color: #e0b030; font-size: 16px; font-weight: bold; box-shadow: 0 0 22px rgba(201,162,39,.35); }
.toast.month { border-left-color: #7a9ac2; }

/* ================= 武将カード・報奨 ================= */
.bcard { display: flex; gap: 16px; align-items: flex-start; }
.bcard-art { flex-shrink: 0; }
.bcard-art svg { filter: drop-shadow(0 6px 10px rgba(0,0,0,.55)); }
.bcard-stats { flex: 1; min-width: 0; }
.stat-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; font-size: 13px; }
.stat-row span { width: 34px; color: #b3a684; }
.stat-row b { width: 30px; text-align: right; }
.stat-bar { flex: 1; height: 8px; background: #100d09; border-radius: 4px; border: 1px solid #3a2f1e; overflow: hidden; }
.stat-bar i { display: block; height: 100%; }
.bcard-misc { margin-top: 8px; font-size: 13px; }
.bcard-items { margin-top: 6px; font-size: 13px; }
.warn { color: #e0a030; font-size: 12px; margin-top: 4px; }
.titem { display: inline-block; background: rgba(201,162,39,.12); border: 1px solid #6e5a1e; border-radius: 4px; padding: 1px 8px; margin: 2px; font-size: 12px; }
.titem.r5 { border-color: #e0b030; color: #ffe9a0; box-shadow: 0 0 8px rgba(224,176,48,.3); }
.titem.r4 { border-color: #b8983a; color: #f0dfa8; }
.pick-busho { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; max-height: 300px; overflow-y: auto; }
.pick-busho.tall { grid-template-columns: 1fr; max-height: 380px; }
.sol-pick { margin-top: 12px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.sol-pick input[type=range] { flex: 1; accent-color: #c9a227; }
.reward-row { border: 1px solid #3a2f1e; margin: 2px 0; }
.reward-row.unhappy { border-color: #8a4a3a; background: rgba(160,60,40,.08); }
.reward-btns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; flex: 1; }
.tlist { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.titembtn { text-align: left; }
.titembtn.r5 { border-color: #e0b030; }
.tre-sec { margin-bottom: 14px; }

/* ================= 外交・家中・記録 ================= */
.dip-list { max-height: 380px; overflow-y: auto; }
.dip-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; border-bottom: 1px dashed #3a2f1e; }
.dip-info { flex: 1; font-size: 14px; }
.rel { font-size: 11px; border-radius: 3px; padding: 1px 6px; margin-left: 6px; }
.rel.ally { background: rgba(122,184,122,.18); color: #9ad89a; border: 1px solid #4a7a4a; }
.rel.truce { background: rgba(122,154,194,.18); color: #a8c8e8; border: 1px solid #4a6a8a; }
.rel.border { background: rgba(194,91,58,.16); color: #e8a888; border: 1px solid #8a4a3a; }
.dip-btns { display: flex; gap: 4px; }
.clan-sum { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 14px; font-size: 13.5px; margin-bottom: 10px; }
.log-list { max-height: 400px; overflow-y: auto; font-size: 13.5px; line-height: 1.9; }
.log-row.big { color: #ffe9a0; font-weight: bold; }
.log-row.good { color: #a8d8a8; }
.log-row.bad { color: #e8a888; }
.help ul { margin: 4px 0 10px 22px; }
.help li { margin: 3px 0; }

/* ================= AIフェイズ ================= */
#ai-phase {
  position: absolute; inset: 0; z-index: 40; background: rgba(10,7,4,.35); pointer-events: all;
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 34px;
}
#ai-phase-text {
  background: rgba(20,14,9,.92); border: 1px solid #6e5a1e; border-radius: 6px; padding: 10px 30px;
  font-size: 17px; letter-spacing: .3em; color: #e8dfc8; animation: aipulse 1.6s ease-in-out infinite;
}
@keyframes aipulse { 0%,100% { opacity: .75;} 50% { opacity: 1;} }

/* ================= 武将ターンの小トースト ================= */
.btoast {
  display: flex; align-items: center; gap: 9px;
  background: rgba(24,18,12,.95); border: 1px solid #6e5a1e; border-left: 5px solid var(--cc, #c9a227);
  border-radius: 6px; padding: 5px 14px 5px 8px; pointer-events: none;
  box-shadow: 0 4px 16px rgba(0,0,0,.55), 0 0 12px rgba(201,162,39,.15);
  opacity: 0; transform: translateX(-18px); transition: all .3s;
}
.btoast.show { opacity: 1; transform: none; }
.btoast.hide { opacity: 0; transform: translateY(8px); }
.btoast-art { flex-shrink: 0; }
.btoast-art svg { display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.5)); }
.btoast-txt i { display: block; font-style: normal; font-size: 11px; color: #b3a684; letter-spacing: .08em; }
.btoast-txt b { display: block; font-size: 15px; color: #ffe9a0; letter-spacing: .12em; }

/* ================= 左下の戦況ウィンドウ(ミニ地図つき) ================= */
#war-window {
  position: fixed; left: 12px; bottom: 14px; z-index: 115; width: 302px;
  background: rgba(22,16,10,.97); border: 1px solid #6e5a1e; border-radius: 8px;
  box-shadow: 0 8px 26px rgba(0,0,0,.65), 0 0 16px rgba(201,162,39,.15);
  opacity: 0; transform: translateY(14px); transition: all .3s; pointer-events: none;
  overflow: hidden;
}
#war-window.show { opacity: 1; transform: none; }
.warwin-head {
  padding: 6px 12px 5px; font-size: 12.5px; color: #e8dfc8; letter-spacing: .1em;
  background: linear-gradient(180deg, #2c2216, #1c1610); border-bottom: 1px solid #6e5a1e;
}
.warwin-map { height: 172px; border-bottom: 1px solid #3a2f1e; }
.warwin-svg { width: 100%; height: 100%; display: block; }
.warwin-svg .cname { display: block; font-size: 17px; }
.warwin-svg .cplate { display: block; }
.warwin-svg .csol { display: none; }
.warwin-arrow {
  stroke: rgba(224,80,56,.9); stroke-width: 5.5; stroke-dasharray: 11 8; stroke-linecap: round;
  animation: warwin-march 0.9s linear infinite;
}
@keyframes warwin-march { to { stroke-dashoffset: -38; } }
.warwin-ring { fill: none; stroke: #ffe9a0; stroke-width: 4; animation: pingout 1.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.warwin-ring.fall { stroke: #ff8a5a; }
.warwin-swords { font-size: 30px; text-anchor: middle; paint-order: stroke; stroke: rgba(20,12,6,.65); stroke-width: 3px; fill: #fff0d8; }
.warwin-row { display: flex; align-items: center; gap: 7px; padding: 7px 12px 6px; font-size: 13.5px; }
.warwin-row svg { vertical-align: -4px; margin-right: 3px; }
.warwin-vs { color: #c25b3a; font-size: 12px; }
.warwin-result { margin-left: auto; font-weight: bold; color: #e8dfc8; letter-spacing: .06em; }
.warwin-result.fall { color: #ffe9a0; }
.warwin-fell { padding: 0 12px 8px; color: #ff9a7a; font-size: 13px; font-weight: bold; letter-spacing: .06em; }
body.warwin-open #toast-layer { bottom: 330px; }
@media (max-width: 860px) {
  #war-window { left: 8px; bottom: calc(45% + 12px); width: 236px; }
  .warwin-map { height: 130px; }
  .warwin-row { font-size: 12px; padding: 6px 9px 5px; }
  .warwin-head { font-size: 11.5px; }
  body.warwin-open #toast-layer { bottom: auto; }
}

/* ================= 合戦画面 ================= */
.bt-layer {
  position: fixed; inset: 0; z-index: 120; overflow: hidden; cursor: pointer;
  background: linear-gradient(180deg, #2c3440 0%, #3a4048 34%, #57503c 62%, #4c4230 100%);
  animation: fadein .3s;
}
.bt-layer.fadeout { opacity: 0; transition: opacity .35s; }
.bt-rain { position: absolute; inset: -60px; pointer-events: none; opacity: .5;
  background: repeating-linear-gradient(112deg, transparent 0 9px, rgba(200,220,255,.16) 9px 10px, transparent 10px 17px);
  animation: rainfall .6s linear infinite; }
@keyframes rainfall { to { transform: translate(-32px, 58px); } }
.bt-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 36%; }
.bt-puddle { position: absolute; background: rgba(40,55,70,.5); border-radius: 50%; filter: blur(1px); }
.bt-puddle.p1 { width: 130px; height: 26px; left: 18%; bottom: 16%; }
.bt-puddle.p2 { width: 90px; height: 20px; left: 55%; bottom: 8%; }
.bt-puddle.p3 { width: 160px; height: 30px; right: 8%; bottom: 22%; }
.bt-head {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 16px; background: rgba(10,8,5,.72); border-bottom: 2px solid #6e5a1e;
}
.bt-side { display: flex; align-items: center; gap: 8px; }
.bt-clan { font-size: 15px; color: #f2e9cf; }
.bt-count { font-size: 22px; font-weight: 900; color: #ffe9a0; font-variant-numeric: tabular-nums; }
.bt-title { font-size: clamp(14px, 2.4vw, 21px); letter-spacing: .18em; color: #e8dfc8; }
.bt-field { position: absolute; inset: 70px 0 0 0; display: flex; }
.bt-army { flex: 1; position: relative; transition: transform .3s; }
.bt-army.atk.charge { transform: translateX(4vw); }
.bt-army.def.charge { transform: translateX(-4vw); }
.bt-army.retreat { transform: translateX(-30vw); opacity: .6; transition: all 1s; }
.bt-generals { position: absolute; top: 6%; left: 0; right: 0; display: flex; justify-content: center; gap: 12px; }
.bt-army.def .bt-generals { top: auto; bottom: 34%; }
.bt-general { text-align: center; }
.bt-general svg { filter: drop-shadow(0 5px 8px rgba(0,0,0,.6)); }
.bt-gname { font-size: 12.5px; color: #f2e9cf; text-shadow: 0 1px 3px #000; margin-top: 2px; }
.bt-troops { position: absolute; bottom: 6%; left: 6%; right: 6%; display: flex; flex-wrap: wrap; gap: 2px; align-items: flex-end; justify-content: center; }
.bt-army.def .bt-troops { bottom: 8%; }
.bt-soldier { animation: soldier-hop .74s ease-in-out infinite; }
@keyframes soldier-hop { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-7px);} }
.bt-castle { position: absolute; top: 2%; left: 50%; transform: translateX(-50%); }
.bt-castle svg { filter: drop-shadow(0 8px 14px rgba(0,0,0,.55)); }
.bt-castle.shake { animation: cshake .5s ease-in-out 2; }
@keyframes cshake { 0%,100% { transform: translateX(-50%);} 25% { transform: translateX(calc(-50% - 8px)) rotate(-1.5deg);} 75% { transform: translateX(calc(-50% + 8px)) rotate(1.5deg);} }
.bt-castle.flagup .bt-flag { animation: flagup .8s ease-out; }
@keyframes flagup { from { transform: translateY(26px); opacity: 0; } }
.bt-center { width: 0; }
.bt-skip { position: absolute; right: 14px; bottom: 10px; font-size: 12px; color: rgba(240,232,208,.6); }
.bt-banner {
  position: absolute; top: 42%; left: 0; right: 0; text-align: center; z-index: 5; pointer-events: none;
  transform: scaleX(0); transition: transform .22s ease-out;
}
.bt-banner span {
  display: inline-block; background: rgba(14,10,6,.92); border-top: 2px solid #c9a227; border-bottom: 2px solid #c9a227;
  color: #f2e9cf; font-size: clamp(16px, 3vw, 26px); letter-spacing: .12em; padding: 12px 34px;
  box-shadow: 0 6px 30px rgba(0,0,0,.6);
}
.bt-banner.show { transform: scaleX(1); }
.bt-banner.hide { opacity: 0; transition: opacity .3s; }
.bt-banner.big span { font-size: clamp(20px, 4vw, 36px); color: #ffe9a0; }
.bt-banner.fell span { color: #ff9a7a; border-color: #c25b3a; }
.bt-banner.trick span { border-color: #b06a9a; }
.bt-dmg {
  position: absolute; z-index: 6; font-size: 21px; font-weight: 900; pointer-events: none;
  text-shadow: 0 2px 4px #000; animation: dmgfloat 1.3s ease-out forwards;
}
.bt-dmg.toD { color: #ffb090; } .bt-dmg.toA { color: #a8c8ff; }
@keyframes dmgfloat { 0% { transform: translateY(0); opacity: 0;} 15% { opacity: 1;} 100% { transform: translateY(-64px); opacity: 0;} }
.bt-puff { position: absolute; top: 46%; z-index: 4; pointer-events: none; }
.bt-puff span {
  position: absolute; width: 26px; height: 26px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ded2b8, #a89a80);
  animation: puffout .8s ease-out forwards;
}
@keyframes puffout { 0% { transform: translate(0,0) scale(.4); opacity: .95; } 100% { transform: translate(var(--dx), var(--dy)) scale(1.9); opacity: 0; } }
/* 一騎討ち */
.bt-duel { position: absolute; inset: 0; z-index: 10; background: rgba(8,6,4,.82); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; opacity: 0; transition: opacity .3s; }
.bt-duel.show { opacity: 1; } .bt-duel.hide { opacity: 0; }
.bt-duel-title { font-size: clamp(22px, 4vw, 38px); color: #ffe9a0; letter-spacing: .35em; text-shadow: 0 0 24px rgba(224,176,48,.5); }
.bt-duel-stage { position: relative; display: flex; align-items: center; gap: clamp(30px, 8vw, 110px); }
.bt-duel-boot { text-align: center; transition: transform .3s; }
.bt-duel-boot.right svg:first-child { transform: scaleX(-1); }
.bt-duel-boot.left.lunge { transform: translateX(34px) translateY(-12px) rotate(6deg); }
.bt-duel-boot.right.lunge { transform: translateX(-34px) translateY(-12px) rotate(-6deg); }
.bt-duel-boot.ko { transform: rotate(78deg) translateY(34px); opacity: .75; transition: all .5s ease-in; }
.bt-duel-boot.win { animation: winbounce .7s ease-in-out 2; }
@keyframes winbounce { 0%,100% { transform: translateY(0);} 40% { transform: translateY(-22px);} }
.bt-duel-vs { font-size: clamp(26px, 5vw, 46px); color: #c25b3a; font-weight: 900; }
.bt-duel-cry { color: #e8dfc8; font-size: 15px; letter-spacing: .2em; }
.bt-duel-result { font-size: clamp(20px, 3.6vw, 32px); color: #ffe9a0; font-weight: bold; letter-spacing: .2em; text-shadow: 0 2px 8px #000; }
.bt-spark {
  position: absolute; left: 50%; top: 40%; width: 90px; height: 90px; transform: translate(-50%,-50%);
  background: radial-gradient(circle, #fff8dc 0%, #ffd870 30%, transparent 70%);
  clip-path: polygon(50% 0, 61% 38%, 100% 38%, 68% 60%, 80% 100%, 50% 74%, 20% 100%, 32% 60%, 0 38%, 39% 38%);
  animation: sparkflash .4s ease-out forwards;
}
@keyframes sparkflash { 0% { transform: translate(-50%,-50%) scale(.3) rotate(0); opacity: 1;} 100% { transform: translate(-50%,-50%) scale(1.6) rotate(22deg); opacity: 0;} }

/* ================= エンディング ================= */
#ending-screen {
  position: fixed; inset: 0; z-index: 160; overflow-y: auto;
  background: radial-gradient(ellipse 80% 60% at 50% 0%, #3a3050, transparent 60%), linear-gradient(180deg, #1c1626, #14100c);
  display: flex; align-items: center; justify-content: center;
}
.end-inner { text-align: center; padding: 40px 18px; }
.end-title { font-size: clamp(40px, 9vw, 86px); font-weight: 900; letter-spacing: .3em; text-indent: .3em; margin-bottom: 18px; }
.end-title.win { color: #ffe9a0; text-shadow: 0 3px 0 #6e5a1e, 0 8px 30px rgba(224,176,48,.5); animation: endglow 2.4s ease-in-out infinite; }
@keyframes endglow { 0%,100% { text-shadow: 0 3px 0 #6e5a1e, 0 8px 30px rgba(224,176,48,.35);} 50% { text-shadow: 0 3px 0 #6e5a1e, 0 8px 46px rgba(224,176,48,.7);} }
.end-title.lose { color: #8a90a8; text-shadow: 0 4px 18px #000; }
.end-boot { margin: 10px 0; }
.end-boot svg { filter: drop-shadow(0 10px 20px rgba(0,0,0,.6)); animation: parade-hop 1.8s ease-in-out infinite; }
.end-text { font-size: clamp(14px, 2.4vw, 19px); line-height: 2.1; margin: 14px 0 20px; }
.end-parade { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; margin: 14px auto 22px; max-width: 900px; }

/* ================= 見届けモード(完全委任) ================= */
#watch-ov {
  position: fixed; inset: 0; z-index: 90; cursor: pointer;
  background: linear-gradient(180deg, rgba(10,7,4,.16), transparent 22%, transparent 74%, rgba(10,7,4,.3));
}
#watch-banner {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
  background: rgba(20,14,9,.94); border: 1px solid #6e5a1e; border-radius: 8px;
  padding: 10px 22px; font-size: 15px; letter-spacing: .1em; color: #e8dfc8;
  box-shadow: 0 6px 24px rgba(0,0,0,.6), 0 0 18px rgba(201,162,39,.2);
}
#watch-banner b { color: #ffe9a0; }
#watch-banner i { font-style: normal; font-size: 11.5px; color: #9c917a; }
.watch-eye { animation: aipulse 1.6s ease-in-out infinite; }
@media (max-width: 860px) {
  #watch-banner { bottom: calc(45% + 14px); font-size: 12.5px; padding: 8px 12px; gap: 7px; }
  #watch-banner i { display: none; }
}

/* ================= 曲名チップ ================= */
#bgm-chip {
  position: fixed; right: 14px; bottom: 14px; z-index: 210; pointer-events: none;
  display: flex; align-items: center; gap: 9px;
  background: rgba(24,18,12,.94); border: 1px solid #6e5a1e; border-radius: 6px;
  padding: 7px 14px 7px 10px; box-shadow: 0 6px 18px rgba(0,0,0,.55), 0 0 14px rgba(201,162,39,.18);
  opacity: 0; transform: translateY(10px); transition: opacity .45s, transform .45s;
}
#bgm-chip.show { opacity: 1; transform: none; }
.bgm-note { color: #ffe9a0; font-size: 19px; animation: notebob 1.1s ease-in-out infinite; }
@keyframes notebob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-3px);} }
#bgm-chip b { display: block; color: #f2e9cf; font-size: 14.5px; letter-spacing: .08em; }
#bgm-chip i { display: block; color: #b3a684; font-size: 11px; font-style: normal; letter-spacing: .12em; }

/* ================= レスポンシブ(スマホ) ================= */
@media (max-width: 860px) {
  #game-area { flex-direction: column; min-height: 0; }
  #map-wrap { min-height: 0; min-width: 0; }
  #map { position: absolute; inset: 0; width: 100%; height: 100%; }
  #side-panel {
    width: 100%; height: 45%; border-left: none; border-top: 2px solid #4a3b22;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }
  /* HUD: 2段コンパクト。ボタンは指で押せる高さを確保 */
  #hud { font-size: 12px; gap: 4px 6px; padding: 5px 6px; }
  #hud-clan { font-size: 13px; }
  #hud-date { font-size: 12.5px; }
  .hud-res { font-size: 11.5px; }
  .hud-btn { padding: 6px 8px; font-size: 12.5px; min-height: 36px; }
  .hud-btn.primary { min-height: 38px; }
  /* トーストは上部へ(下はパネルと被るため) */
  #toast-layer { left: 8px; right: 8px; bottom: auto; top: calc(env(safe-area-inset-top) + 86px); max-width: none; }
  .toast { font-size: 12.5px; padding: 6px 10px; }
  .toast.big { font-size: 14px; }
  /* パネル内 */
  .cinfo-busho { max-height: 26vh; }
  .cmd { padding: 11px 4px; font-size: 14px; }
  .cs-row { font-size: 12.5px; }
  /* モーダル */
  .modal-box { min-width: 0; width: 94vw; max-height: 90vh; }
  .mbtn { min-height: 40px; }
  .mbtn.small { min-height: 32px; }
  .pick-busho { grid-template-columns: 1fr; max-height: 42vh; }
  .bcard { flex-direction: column; align-items: center; }
  .reward-btns .mbtn { padding: 6px 8px; }
  /* 合戦 */
  .bt-general svg { width: 46px; height: auto; }
  .bt-general.big svg { width: 66px; }
  .bt-castle svg { width: 108px; height: auto; }
  .bt-troops svg { width: 21px; height: auto; }
  .bt-duel-boot svg { width: 92px; height: auto; }
  .bt-count { font-size: 17px; }
  .bt-clan { font-size: 12.5px; }
  .bt-head { padding: 7px 8px; }
  .bt-field { inset: 58px 0 0 0; }
  /* 地図ツール */
  #map-tools button { width: 44px; height: 44px; }
  /* 曲名チップはパネルの上に */
  #bgm-chip { bottom: calc(45% + 12px); right: 8px; padding: 5px 10px 5px 8px; }
  #bgm-chip b { font-size: 13px; }
  /* 大名選択 */
  #select-cards { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 8px; }
  .sel-boot svg { width: 68px; height: auto; }
  .sel-name { font-size: 15px; }
}
/* 横持ちスマホなど低い画面 */
@media (max-height: 560px) {
  #title-main { font-size: 42px; }
  #title-sub { font-size: 16px; }
  .title-btn { font-size: 16px; padding: 9px 22px; }
  #title-parade .parade-boot svg { width: 40px; height: auto; }
  #title-note { display: none; }
  #title-disclaimer { position: static; font-size: 9px; line-height: 1.5; margin-top: 4px; }
  #hud { padding: 3px 6px; gap: 3px 5px; }
  .hud-btn, .hud-btn.primary { min-height: 30px; padding: 4px 7px; font-size: 12px; }
  #side-panel { height: 46%; }
  .cinfo-busho { max-height: 18vh; }
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #4a3b22; border-radius: 5px; }
::-webkit-scrollbar-track { background: #1a140e; }
