.battle-history { width:min(1100px, calc(100% - 2rem)); margin:2rem auto 5rem; }
.battle-history[hidden], .battle-incoming[hidden] { display:none; }
.battle-filters,.battle-dialog-actions { display:flex; gap:.55rem; flex-wrap:wrap; margin-block:1rem; }
.battle-filters a,.battle-dialog-actions a,.battle-dialog-actions button,.battle-history button { padding:.55rem .8rem; border:1px solid #bdad94; border-radius:.35rem; background:#fcf8ee; color:#273f36; min-height:44px; }
.battle-filters [aria-current] { background:#dce7d8; border-color:#55765f; }
.battle-history-row { display:flex; justify-content:space-between; gap:.6rem 1.5rem; flex-wrap:wrap; color:#293d34; background:#faf6eb; border:1px solid #d6cab5; border-left:4px solid #829987; padding:.9rem; margin:.5rem 0; border-radius:.35rem; }
.battle-result { --battle-accent:#d6af66; color:#29342d; background:#f5efe2; border:1px solid #c9baa0; border-radius:.7rem; overflow:hidden; }
.battle-result[data-outcome=victory] { --battle-accent:#b8ddac; }
.battle-result[data-outcome=defeat] { --battle-accent:#f5aaa0; }
.battle-result-hero { padding:clamp(1rem,4vw,3rem); color:#fcf2da; background:linear-gradient(135deg,#172922,#344539 65%,#4a4537); border-top:5px solid var(--battle-accent); }
.battle-result-hero p { margin:.4rem 0; }
.battle-result-hero h2 { margin:.15rem 0 .65rem; color:var(--battle-accent); font-size:clamp(2rem,6vw,4.5rem); line-height:1.05; text-transform:uppercase; letter-spacing:.04em; }
.battle-result h3 { color:#293d34; margin:.2rem 0 .5rem; }
.battle-result > h3 { padding-inline:1rem; }
.battle-comparison { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.65rem; margin:.75rem; }
.battle-section { background:#fffbf1; border:1px solid #d9ccb5; padding:.85rem; border-radius:.35rem; margin:.75rem; min-width:0; overflow-wrap:anywhere; }
.battle-comparison > .battle-section,.battle-section .battle-section { margin:0; }
.battle-section .battle-section { margin-top:.6rem; padding:.5rem; }
.battle-metrics,.battle-formations,.battle-timeline { padding:0; margin:.5rem 0; list-style:none; }
.battle-formations li,.battle-metrics li { display:flex; align-items:center; gap:.6rem; padding:.45rem 0; border-bottom:1px solid #e3dacc; }
.battle-formations p { margin:.25rem 0; }
.battle-metrics strong { margin-left:auto; text-align:right; }
.battle-glyph { display:inline-grid; place-items:center; flex:none; color:inherit; }
.battle-timeline { display:flex; gap:.5rem 1.5rem; flex-wrap:wrap; padding:.7rem 1rem; }
.battle-timeline li { border-left:2px solid #879b7e; padding-left:.55rem; }
.battle-wave summary { cursor:pointer; padding:.7rem 0; font-weight:700; }
.battle-incoming { position:fixed; inset:auto 1rem 6rem auto; z-index:22; max-width:min(30rem, calc(100% - 2rem)); padding:.7rem 1rem; color:#fff1db; background:#503827; border:1px solid #c99960; border-radius:.4rem; box-shadow:0 6px 22px #0004; }
.battle-incoming a { color:#ffe4b5; }
.battle-result-dialog { width:min(850px,calc(100% - 1rem)); max-height:90dvh; border:1px solid #a69071; border-radius:.7rem; background:#f5efe2; color:#29342d; padding:.7rem; }
.battle-result-dialog::backdrop { background:#121b16ba; }
.battle-dialog-actions { margin:.2rem 0 .6rem; justify-content:flex-end; }
@media (prefers-reduced-motion:no-preference) { .battle-result-hero { animation:battle-reveal .3s ease-out; } @keyframes battle-reveal { from { opacity:.45; } to { opacity:1; } } }
@media (max-width:600px) { .battle-comparison { grid-template-columns:minmax(0,1fr); } .battle-history { width:calc(100% - 1rem); } }
/* The history owns its layout. The atlas grid and dark theme text are global. */
body[data-page="battle-history"] .page-location { display:none; }
#battle-history-root:not([hidden]) { display:block; width:min(1120px,calc(100% - 2rem)); min-height: min(64vh, 38rem); padding:0; margin:clamp(1rem,3vw,2.5rem) auto 3rem; color:#24343a; }
.battle-history-hero { display:grid; grid-template-columns:auto minmax(0,1fr) auto; align-items:center; gap:1rem; margin:0 0 1rem; padding:clamp(1rem,3vw,2rem); border:1px solid #3f574b; border-radius:.85rem; background:linear-gradient(115deg,#203830,#365247); color:#fff8e9; }
.battle-history-hero h1 { margin:0; color:inherit; font-size:clamp(1.5rem,4vw,2.4rem); line-height:1.12; }
.battle-history-hero p { margin:.4rem 0 0; color:#e1ebdf; }
.battle-history-hero a { color:#fff8e9; padding:.6rem 0; text-underline-offset:.2em; }
.battle-history-hero > .battle-glyph { width:3.25rem; height:3.25rem; border-radius:.6rem; background:#ffffff16; color:#e5c891; }
.battle-history .battle-glyph svg { width:24px; height:24px; background:none; border:0; }
.battle-history-panel { background:#fbf9f2; border:1px solid #d6d7c9; border-radius:.85rem; box-shadow:0 6px 18px #24343a0a; }
.battle-history .battle-filters { margin:0; padding:.85rem; border-bottom:1px solid #deded0; }
.battle-history .battle-filters a { display:inline-flex; align-items:center; border-radius:.5rem; text-decoration:none; font-weight:600; color:#344942; }
.battle-history .battle-filters a:hover { background:#e7eee2; }
.battle-history .battle-filters a[aria-current="page"] { background:#31574c; color:#fffaf0; border-color:#31574c; }
.battle-history-content { padding:clamp(.65rem,2vw,1.25rem); }
.battle-history-empty { display:grid; justify-items:center; text-align:center; gap:.55rem; padding:clamp(1.5rem,5vw,3.5rem) 1rem; }
.battle-history-empty .battle-glyph { color:#31574c; background:#e4ebe0; width:3rem; height:3rem; border-radius:.65rem; }
.battle-history-empty h2,.battle-history-empty p { margin:0; color:inherit; }
.battle-history-empty p,.battle-history-status { color:#4e6267; }
.battle-history-empty a { color:#245749; font-weight:600; padding:.55rem .8rem; }
body[data-page="battle-history"] .game-footer { background:#f8f7f1; border-color:#d6d7c9; color:#4e6267; }
body[data-page="battle-history"] .game-footer :is(span,p) { color:#394d50; }
body[data-page="battle-history"] .game-footer :is(small,a) { color:#315b51; }
@media (max-width:600px) {
  #battle-history-root:not([hidden]) { width:calc(100% - 1rem); }
  .battle-history-hero { grid-template-columns:auto minmax(0,1fr); gap:.6rem; }
  .battle-history-hero a { grid-column:2; padding:0; }
}
.battle-result :is(.battle-section,.battle-timeline) p { color:#465952; }
.battle-result-hero p { color:#eee4ce; }
.battle-result .battle-glyph svg,.battle-incoming .battle-glyph svg { width:24px; height:24px; background:none; border:0; }
.battle-incoming > p { color:#fff1db; }
/* Incoming attacks are actionable events, separate from completed reports. */
.battle-upcoming{margin:0 0 18px;padding:clamp(16px,3vw,24px);border:1px solid #bd8b61;border-radius:12px;background:linear-gradient(135deg,#342c2d,#112c40 80%);color:#edf5fb}
.battle-upcoming[hidden]{display:none}
.battle-upcoming>h2{margin:0 0 8px;color:#ffe0a9;font-size:clamp(21px,3vw,28px)}
.battle-upcoming>p{margin:0 0 18px;color:#ccdfeb;line-height:1.6}
.battle-upcoming-card{padding:18px;margin:12px 0 0;border:1px solid #71889b;border-left:4px solid #f2b56e;border-radius:8px;background:#0b2435;min-width:0;scroll-margin-top:24px}
.battle-upcoming-card[data-selected=true]{outline:2px solid #f0c77e;outline-offset:3px}
.battle-upcoming-identity{display:flex;gap:14px;align-items:center;min-width:0}
.battle-upcoming-identity>img{width:100px;height:74px;object-fit:cover;border:1px solid #7493a8;border-radius:6px;flex:none}
.battle-upcoming-identity>.battle-glyph{width:48px;height:48px;border:1px solid #b18a61;border-radius:8px;background:#64402d;color:#ffe3b0}
.battle-upcoming-identity>div{min-width:0}
.battle-upcoming h3{margin:5px 0;color:#f3f8ff;font-size:20px;overflow-wrap:anywhere}
.battle-upcoming-card p{color:#cde1ef;line-height:1.6;margin:6px 0;overflow-wrap:anywhere}
.battle-upcoming-phase{font-size:11px;text-transform:uppercase;letter-spacing:.1em;color:#ffd39b;font-weight:700}
.battle-upcoming-timing{display:flex;flex-wrap:wrap;gap:4px 22px;margin:14px 0;padding:12px 0;border-top:1px solid #36556a;border-bottom:1px solid #36556a}
.battle-upcoming-timing strong{color:#ffe1a6;font-variant-numeric:tabular-nums}
.battle-upcoming-actions{display:flex;gap:8px;flex-wrap:wrap}
.battle-upcoming-actions a{display:inline-flex;align-items:center;min-height:44px;padding:10px 14px;color:#d9f1ff;border:1px solid #688fa8;background:#21465e;border-radius:6px;text-decoration:none}
.battle-upcoming-actions a:hover{border-color:#e5c888;background:#31566e}
.battle-upcoming-actions a:focus-visible{outline:3px solid #ffe0a0;outline-offset:3px}
.battle-incoming>p>a{display:block;padding-top:8px;min-height:36px}
@media(max-width:600px){.battle-upcoming{padding:14px}.battle-upcoming-card{padding:14px}.battle-upcoming-identity>img{width:72px;height:64px}.battle-upcoming h3{font-size:18px}.battle-upcoming-actions a{flex:1 1 130px;justify-content:center}.battle-upcoming-timing{display:block}}
@media(forced-colors:active){.battle-upcoming,.battle-upcoming-card{background:Canvas;color:CanvasText;border-color:CanvasText}.battle-upcoming-card[data-selected=true]{outline-color:Highlight}}

.battle-result-hero .battle-verdict-title{font-size:clamp(1.6rem,4vw,2.7rem)!important;text-transform:none;letter-spacing:0;line-height:1.2;overflow-wrap:anywhere}.battle-result-hero .battle-verdict-reason{font-size:15px;color:#f2e9d8}.battle-result .battle-resolution-note{margin:14px 0;padding:13px 15px;border-left:3px solid #aa9468;background:#eee6d3;color:#35493e;line-height:1.65;font-size:14px}
