  * { box-sizing: border-box; }
  body {
    margin: 0; background: #111318; color: #eee; font-family: Arial, sans-serif;
    display: flex; justify-content: center; min-height: 100vh;
  }
  #app { width: min(1440px, 100%); padding: 16px 20px; }
  .top-bar {
    margin-bottom: 12px;
  }
  .top-turn-order {
    display: block;
    width: 100%;
  }
  .top-turn-order .panel { padding: 4px 8px; }
  .top-turn-order .section-title { margin: 0 0 2px; font-size: 11px; }
  .turn-badge {
    font-size: 38px; font-weight: bold; letter-spacing: 0.5px;
    background: transparent; border: none; color: #7aa2f7;
    border-radius: 0; padding: 2px 0; text-align: center;
    text-transform: uppercase; display: block; line-height: 1.15;
  }
  .meta-badges {
    display: flex; flex-direction: column; gap: 4px;
    text-align: center;
  }
  .sub { color: #aaa; margin-bottom: 14px; display: none; }
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 14px;
    align-items: start;
  }
  .col-left { display: none !important; }


  body.deployment-active .col-left {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
  }
  body.deployment-active .layout {
    grid-template-columns: 260px minmax(0, 1fr) 280px;
  }
  body.deployment-active .col-right .buttons,
  body.deployment-active .col-right .actions-title,
  body.deployment-active #actionPicker {
    display: none !important;
  }
  .cell.deploy-slot {
    outline: 2px solid #5b9fff;
    box-shadow: inset 0 0 0 999px rgba(60,120,255,.28);
  }
  .cell.deploy-slot.deploy-hover {
    outline: 3px solid #8ec0ff;
    box-shadow: inset 0 0 0 999px rgba(80,140,255,.42);
  }
  .cell.deploy-slot.deploy-filled {
    outline: 2px solid #7aa2f7;
    box-shadow: inset 0 0 0 999px rgba(45,108,223,.2);
  }
  .deploy-panel .section-title { margin-bottom: 8px; }
  .deploy-card {
    display: grid; grid-template-columns: 48px 1fr; gap: 8px; align-items: center;
    background: #252933; border: 1px solid #3b4454; border-radius: 10px;
    padding: 8px; margin-bottom: 8px; cursor: pointer; text-align: left; color: #fff;
    width: 100%;
  }
  .deploy-card:hover { border-color: #69758a; }
  .deploy-card.selected { outline: 2px solid #fff; border-color: #7aa2f7; }
  .deploy-card.placed { opacity: .55; border-color: #2f7650; }
  .deploy-card-avatar { width: 48px; height: 48px; display:flex; align-items:center; justify-content:center; }
  .deploy-card-avatar svg, .deploy-card-avatar img { width:100%; height:100%; object-fit:contain; }
  .deploy-card-name { font-weight: 900; font-size: 13px; }
  .deploy-card-sub { font-size: 10px; color: #8e99aa; margin-top: 2px; }
  .deploy-hint { font-size: 11px; color: #9aa6b8; margin-bottom: 10px; line-height: 1.4; }
  .deploy-confirm-btn {
    width: 100%; margin-top: 8px; padding: 12px; font-weight: 900;
    background: #2a3348; border: 1px solid #5a6a88; border-radius: 8px; color: #fff; cursor: pointer;
  }
  .deploy-confirm-btn:disabled { opacity: .35; cursor: not-allowed; }
  .deploy-confirm-btn:not(:disabled):hover { background: #354260; }
  #deployOkModal {
    display: none; position: fixed; inset: 0; z-index: 1005;
    background: rgba(0,0,0,.72); align-items: center; justify-content: center;
  }
  #deployOkModal.show { display: flex; }
  .deploy-ok-box {
    background: #1b1e26; border: 1px solid #4a5568; border-radius: 14px;
    padding: 28px 32px; text-align: center; min-width: 280px;
    box-shadow: 0 16px 40px rgba(0,0,0,.55);
  }
  .deploy-ok-title { font-size: 20px; font-weight: 900; margin-bottom: 8px; }
  .deploy-ok-sub { font-size: 13px; color: #9aa6b8; margin-bottom: 18px; }
  .deploy-ok-box button {
    background: #2a3348; color: #fff; border: 1px solid #5a6a88;
    border-radius: 8px; padding: 10px 22px; font-weight: 900; cursor: pointer; margin: 0 4px;
  }


  .col-right { display: flex; flex-direction: column; gap: 12px; }
  .panel { background: #1b1e26; border: 1px solid #343844; border-radius: 10px; padding: 14px; }
  #battlefield {
    display: grid; grid-template-columns: repeat(12, 1fr); gap: 3px;
    aspect-ratio: 1/1;
    width: 100%;
    max-width: min(900px, 70vh);
    margin: 0 auto;
  }
  .cell {
    position: relative; border: 1px solid #353945; background: #252933;
    cursor: pointer; min-width: 0;
  }
  .cell.road { background: #6b6e75; }
  .cell.bridge { background: #5a4a3a; }
  .cell.sand { background: #6a5a38; }
  .cell.dirt { background: #4a3f32; }
  .cell.water { background: #344f63; }
  .cell.wall { background: #16181d; border-color:#08090c; cursor:not-allowed; }
  .cell.moveable { outline: 2px solid #7ee787; box-shadow: inset 0 0 0 2px rgba(126,231,135,.25); }
  .cell.move-path {
    outline: 2px solid #9ef0a6;
    box-shadow: inset 0 0 0 999px rgba(126,231,135,.28);
  }
  .cell.move-dest {
    outline: 3px solid #7ee787;
    box-shadow: inset 0 0 0 999px rgba(126,231,135,.4), 0 0 8px rgba(126,231,135,.5);
    z-index: 2;
  }
  /* Full attack range footprint (LOS + range) — translucent red wash */
  .cell.attack-range {
    outline: 1px solid rgba(255,100,100,.55);
    box-shadow: inset 0 0 0 999px rgba(255,60,60,.14);
  }
  /* Enemy in attack range — stronger red target marker */
  .cell.attackable {
    outline: 2px solid #ff6b6b;
    box-shadow: inset 0 0 0 999px rgba(255,60,60,.28), 0 0 10px rgba(255,80,80,.45);
    z-index: 2;
  }
  /* Hover on an attackable enemy — brighter translucent red */
  .cell.attackable.attack-hover,
  .cell.attack-range.attack-hover {
    outline: 3px solid #ff4d4d;
    box-shadow: inset 0 0 0 999px rgba(255,50,50,.42), 0 0 14px rgba(255,80,80,.7);
    z-index: 3;
  }
  .cell.abilityable { outline: 2px solid #ff6b6b; box-shadow: inset 0 0 0 2px rgba(255,107,107,.25); }
  .cell:hover { outline: 2px solid #888; z-index: 2; }
  .cell.attackable:hover, .cell.attack-range:hover { outline: 3px solid #ff4d4d; }
  .terrain-label { position:absolute; left:3px; top:2px; font-size:8px; color:#aaa; }
  .obstacle { width:72%; height:72%; border-radius:8px; position:absolute; left:14%; top:14%;
    display:flex; align-items:center; justify-content:center; font-size:10px; font-weight:bold; color:#bbb;
    background:#30333b; border:2px solid #555; }
  .unit {
    width: 72%; height: 72%; border-radius: 50%; position: absolute;
    left: 14%; top: 14%; display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 13px; border: 2px solid #ddd;
  }
  .player { background: #2d6cdf; }
  .enemy { background: #a13a3a; }
  .unit.ranged { border-style: dashed; }
  .selected { box-shadow: 0 0 0 3px #fff, 0 0 12px #fff; }


  .unit img.unit-art, .char-avatar img.unit-art, .queue-avatar img.unit-art {
    width: 100%; height: 100%; object-fit: contain; pointer-events: none;
    border-radius: 0; background: transparent;
  }
  .unit.has-art {
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    overflow: visible;
  }


  .dead { opacity: .25; }
  .hp-bar-wrap { position:absolute; left:9%; bottom:2px; width:82%; height:5px; background:rgba(0,0,0,.55); border-radius:3px; overflow:hidden; z-index:3; }
  .hp-bar-fill { height:100%; border-radius:3px; transition:width .25s ease; }
  .facing-arrow {
    position:absolute; font-size:11px; line-height:1; z-index:5;
    color:#fff; text-shadow:0 0 3px #000, 0 1px 2px #000;
    pointer-events:none; font-weight:bold;
  }
  .facing-arrow.N { top:-2px; left:50%; transform:translateX(-50%); }
  .facing-arrow.S { bottom:6px; left:50%; transform:translateX(-50%); }
  .facing-arrow.W { left:0; top:42%; }
  .facing-arrow.E { right:0; top:42%; }
  .ability-badge {
    position:absolute; top:-4px; right:-4px; min-width:15px; height:15px; padding:0 3px;
    border-radius:50%; font-size:9px; font-weight:bold; display:flex; align-items:center; justify-content:center;
    z-index:4; border:1px solid #111318; line-height:1;
  }
  .ability-badge.ready {
    background:#7ee787; color:#12261a;
    box-shadow:0 0 6px rgba(126,231,135,.9);
    animation: cd-ready-pulse 1.6s ease-in-out infinite;
  }
  .ability-badge.cooldown {
    background:#3a2a2a; color:#ff9b9b; border-color:#5a3030;
  }
  @keyframes cd-ready-pulse {
    0%, 100% { box-shadow:0 0 4px rgba(126,231,135,.6); }
    50% { box-shadow:0 0 10px rgba(126,231,135,1); }
  }
  .cell-label { position:absolute; bottom:1px; right:3px; font-size:8px; color:#777; }
  .section-title { font-weight:bold; margin: 0 0 8px; }
  #queue {
    display: flex; flex-direction: row; flex-wrap: nowrap;
    gap: 6px; align-items: center; overflow: hidden;
  }
  .queue-card {
    display: flex; align-items: center; justify-content: center;
    background: #252933; border: 1px solid #343844; border-radius: 6px;
    padding: 3px; min-width: 52px; height: 52px; flex: 1 1 0;
    position: relative; overflow: hidden;
  }
  .queue-card.current { outline: 2px solid #fff; }
  .queue-card.player-row { border-bottom: 3px solid #2d6cdf; }
  .queue-card.enemy-row { border-bottom: 3px solid #a13a3a; }
  .queue-avatar {
    width: 46px; height: 46px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 10px; border: 2px solid #ddd; color: #fff;
    overflow: hidden; background: #171a16; padding: 0;
  }
  .queue-avatar.player { background: #2d6cdf; }
  .queue-avatar.enemy { background: #a13a3a; }
  .queue-avatar.ranged { border-style: dashed; }
  .queue-name, .queue-ord { display: none; }
  .queue-avatar .character-card-portrait { width: 100%; height: 100%; object-fit: cover; display: block; }
  .queue-avatar .queue-enemy-portrait { width: 100%; height: 100%; object-fit: cover; display: block; }
  .queue-caption { font-size:10px; color:#777; margin-top: 6px; }
  .meter { color:#bbb; font-family:monospace; }
  .stats { display:grid; grid-template-columns:1fr 1fr; gap:6px; }
  .stat { background:#252933; padding:7px; border-radius:6px; }
  .stat span { color:#aaa; display:block; font-size:11px; }
  #log { height:220px; overflow:auto; background:#111318; padding:8px; border-radius:6px; font-size:12px; line-height:1.45; }
  button {
    background:#2a2e39; color:#fff; border:1px solid #505665; border-radius:6px;
    padding:9px 10px; cursor:pointer; font-weight:bold; font-size:11px;
  }
  button:hover:not(:disabled) { background:#3a3f4d; }
  button:disabled { opacity:.35; cursor:not-allowed; }
  .buttons { display:grid; grid-template-columns:1fr 1fr; gap:7px; }
  #message { min-height:38px; padding:9px; background:#252933; border-radius:6px; font-size:13px; }
  .legend { font-size:11px; color:#aaa; margin-top:10px; }
  .ability-line { color:#ff6b6b; }
  /* Character panel */
  .char-header {
    display: flex; gap: 12px; align-items: center; margin-bottom: 12px;
  }
  .char-avatar {
    width: 64px; height: 64px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; font-size: 20px; border: 3px solid #ddd;
    flex-shrink: 0; position: relative;
  }
  .char-avatar.player { background: #2d6cdf; }
  .char-avatar.enemy { background: #a13a3a; }
  .char-avatar.ranged { border-style: dashed; }
  .char-avatar.empty {
    background: #252933; border-color: #505665; color: #555; font-size: 14px;
  }
  .char-name-block { flex: 1; min-width: 0; }
  .char-name { font-size: 18px; font-weight: bold; margin: 0 0 2px; }
  .char-team {
    font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
    color: #aaa; margin-bottom: 6px;
  }
  .char-team.player { color: #7aa2f7; }
  .char-team.enemy { color: #f07178; }
  .char-hp-row { display: flex; align-items: center; gap: 8px; }
  .char-hp-bar {
    flex: 1; height: 18px; background: rgba(0,0,0,.45); border-radius: 6px; overflow: hidden;
  }
  .char-hp-fill { height: 100%; border-radius: 4px; transition: width .25s ease; }
  .char-hp-text { font-size: 12px; font-family: monospace; color: #ccc; white-space: nowrap; }
  .char-chips {
    display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px;
  }
  .chip {
    background: #252933; border: 1px solid #343844; border-radius: 4px;
    padding: 2px 6px; font-size: 10px; color: #bbb;
    display: inline-flex; align-items: center; gap: 3px;
  }
  .chip strong { color: #eee; }
  .char-stats {
    display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px;
  }
  .char-stat {
    background: #252933; border: 1px solid #2f3542; border-radius: 5px;
    padding: 4px 7px; font-size: 11px;
    display: inline-flex; align-items: center; gap: 4px;
    min-width: 0;
  }
  .char-stat .stat-ico {
    font-size: 12px; line-height: 1; opacity: .95;
  }
  .char-stat .stat-label {
    color: #7a8496; font-size: 9px; text-transform: uppercase; letter-spacing: .3px;
  }
  .char-stat .stat-val { color: #eee; font-weight: bold; font-size: 11px; }
  .status-icons {
    display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; min-height: 0;
  }
  .status-ico {
    display: inline-flex; align-items: center; gap: 4px;
    border-radius: 6px; padding: 3px 7px;
    font-size: 10px; font-weight: bold; line-height: 1.2;
    border: 1px solid transparent;
    animation: status-pop .25s ease;
  }
  .status-ico .si-glyph { font-size: 13px; line-height: 1; }
  .status-ico.defend { background: #1e2a44; border-color: #3d5a9a; color: #7aa2f7; }
  .status-ico.haste { background: #1a3324; border-color: #3d7a52; color: #7ee787; }
  .status-ico.slow { background: #3a2222; border-color: #7a3a3a; color: #ff8a8a; }
  .status-ico.retreat { background: #3a3220; border-color: #7a6540; color: #f0c674; }
  .status-ico.buff { background: #2a2440; border-color: #5a4a8a; color: #c4b5fd; }
  @keyframes status-pop {
    0% { transform: scale(.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
  }
  .char-ability {
    background: #252933; border-left: 3px solid #ff6b6b;
    padding: 8px 10px; border-radius: 0 6px 6px 0; font-size: 12px;
  }
  .char-ability.on-cooldown { border-left-color: #a13a3a; opacity: .85; }
  .char-ability .ability-name {
    color: #ff6b6b; font-weight: bold; margin: 0 6px 0 0; display: inline;
  }
  .char-ability.on-cooldown .ability-name { color: #ff9b9b; }
  .char-ability .ability-desc { color: #aaa; display: inline; }
  .cd-row {
    display: flex; align-items: center; gap: 8px; margin-top: 7px;
  }
  .cd-bar {
    flex: 1; height: 7px; background: rgba(0,0,0,.45); border-radius: 4px; overflow: hidden;
  }
  .cd-bar-fill {
    height: 100%; border-radius: 4px; transition: width .3s ease;
    background: linear-gradient(90deg, #ff6b6b, #c44);
  }
  .cd-bar-fill.cooling {
    background: linear-gradient(90deg, #ff6b6b, #c44);
  }
  .cd-label {
    font-size: 11px; font-family: monospace; white-space: nowrap;
  }
  .cd-label.ready { color: #7ee787; }
  .cd-label.cooling { color: #ff9b9b; }
  .char-empty {
    color: #666; text-align: center; padding: 24px 8px; font-size: 13px;
  }
  .actions-title { font-weight: bold; margin: 0 0 8px; font-size: 13px; color: #ccc; }


  /* Action picker (Abilities / Items window) */
  #actionPicker {
    display: none;
    position: fixed; inset: 0; z-index: 900;
    background: rgba(0,0,0,.55);
    align-items: center; justify-content: center;
  }
  #actionPicker.show { display: flex; }
  .picker-box {
    background: #1b1e26;
    border: 1px solid #505665;
    border-radius: 12px;
    width: min(360px, 92vw);
    max-height: 70vh;
    overflow: auto;
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
  }
  .picker-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 16px; border-bottom: 1px solid #343844;
  }
  .picker-header h3 { margin: 0; font-size: 16px; }
  .picker-close {
    background: transparent; border: none; color: #aaa; font-size: 20px;
    cursor: pointer; padding: 0 6px; line-height: 1;
  }
  .picker-close:hover { color: #fff; }
  .picker-list { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
  .picker-item {
    background: #252933; border: 1px solid #343844; border-radius: 8px;
    padding: 12px 14px; cursor: pointer; text-align: left; width: 100%;
    color: #eee; font-weight: normal;
  }
  .picker-item:hover:not(:disabled) { background: #2f3440; border-color: #5a6270; }
  .picker-item:disabled { opacity: .4; cursor: not-allowed; }
  .picker-item-name { font-weight: bold; font-size: 14px; margin-bottom: 3px; }
  .picker-item-name.ability { color: #ff6b6b; }
  .picker-item-name.item { color: #7ee787; }
  .picker-item-desc { font-size: 12px; color: #aaa; }
  .picker-item-meta { font-size: 11px; color: #888; margin-top: 4px; }
  .picker-cd {
    margin-top: 8px; display: flex; align-items: center; gap: 8px;
  }
  .picker-cd .cd-bar { flex: 1; height: 6px; background: rgba(0,0,0,.45); border-radius: 3px; overflow: hidden; }
  .picker-cd .cd-bar-fill { height: 100%; border-radius: 3px; background: linear-gradient(90deg, #ff6b6b, #c44); }
  .picker-cd .cd-label { font-size: 11px; color: #ff9b9b; font-family: monospace; }
  .picker-item.on-cooldown { border-color: #5a3030; }
  .picker-empty { color: #666; text-align: center; padding: 20px; font-size: 13px; }
  #abilityBtn.on-cooldown {
    border-color: #505665; color: #fff;
  }
  #abilityBtn { color: #fff; }
  .facing-picker {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; padding: 12px; max-width: 200px; margin: 0 auto;
  }
  .facing-picker .fp-spacer { visibility: hidden; }
  .facing-picker button {
    padding: 14px 10px; font-size: 18px; font-weight: bold;
  }
  .facing-picker button.selected-facing {
    outline: 2px solid #7ee787; background: #2a3d2e;
  }
  .facing-hint {
    text-align: center; font-size: 12px; color: #888; padding: 0 14px 12px;
  }
  .cell.ally-target {
    outline: 2px solid #7ee787;
    box-shadow: inset 0 0 0 999px rgba(126,231,135,.2);
  }
  .cell.support-range { background:rgba(126,231,135,.16) !important; outline:2px solid rgba(126,231,135,.55); }
  .cell.supportable { outline:3px solid #7ee787 !important; box-shadow:inset 0 0 0 2px rgba(126,231,135,.35); }
  .cell.supportable:hover,.cell.support-range:hover { outline:3px solid #b6f7bd !important; }
  .cell.ally-target:hover {
    outline: 3px solid #9ef0a6;
    box-shadow: inset 0 0 0 999px rgba(126,231,135,.35);
  }


  /* Floating combat text */
  .combat-float {
    position: absolute;
    left: 50%; top: 18%;
    transform: translateX(-50%);
    font-weight: bold; font-size: 16px;
    pointer-events: none; z-index: 20;
    text-shadow: 0 1px 3px #000, 0 0 6px rgba(0,0,0,.85);
    animation: combat-float-up 1.15s ease-out forwards;
    white-space: nowrap;
  }
  .combat-float.dmg { color: #ff6b6b; font-size: 18px; }
  .combat-float.crit { color: #ffd166; font-size: 20px; }
  .combat-float.miss { color: #bbb; font-size: 14px; font-style: italic; }
  .combat-float.heal { color: #7ee787; font-size: 17px; }
  @keyframes combat-float-up {
    0%   { opacity: 0; transform: translateX(-50%) translateY(10px) scale(.85); }
    12%  { opacity: 1; transform: translateX(-50%) translateY(0) scale(1.08); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-40px) scale(1); }
  }


  /* Screen shake on the battlefield */
  #battlefield.shake-light {
    animation: bf-shake-light 0.28s ease-out;
  }
  #battlefield.shake-heavy {
    animation: bf-shake-heavy 0.4s ease-out;
  }
  @keyframes bf-shake-light {
    0%, 100% { transform: translate(0, 0); }
    20% { transform: translate(-3px, 1px); }
    40% { transform: translate(3px, -2px); }
    60% { transform: translate(-2px, 2px); }
    80% { transform: translate(2px, -1px); }
  }
  @keyframes bf-shake-heavy {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-6px, 2px); }
    20% { transform: translate(6px, -3px); }
    30% { transform: translate(-5px, -2px); }
    40% { transform: translate(5px, 3px); }
    50% { transform: translate(-4px, 1px); }
    60% { transform: translate(4px, -2px); }
    70% { transform: translate(-2px, 2px); }
    80% { transform: translate(2px, -1px); }
  }


  @media(max-width: 1200px) {
    .layout { grid-template-columns: 1fr; }
    .col-left, .col-right { order: 2; }
    #battlefield { max-width: min(720px, 80vw); }
  }
  /* Start / loading screen */
  #startScreen {
    position: fixed; inset: 0; z-index: 2000;
    background: #0d0f14;
    display: flex; align-items: center; justify-content: center;
  }
  #startScreen.hidden { display: none; }
  .start-box {
    text-align: center;
    padding: 48px 56px;
    background: #1b1e26;
    border: 1px solid #343844;
    border-radius: 16px;
    box-shadow: 0 16px 48px rgba(0,0,0,.55);
    min-width: 320px;
  }
  .start-title {
    font-size: 36px; font-weight: bold; margin: 0 0 8px;
    letter-spacing: 1px; color: #eee;
  }
  .start-sub {
    color: #888; font-size: 14px; margin-bottom: 28px;
  }
  .start-box button#startNewBtn {
    background: #2d6cdf; color: #fff; border: 1px solid #4a8af0;
    border-radius: 8px; padding: 14px 36px; font-size: 15px;
    font-weight: bold; cursor: pointer; letter-spacing: 0.5px;
  }
  .start-box button#startNewBtn:hover { background: #3d7cef; }


  /* End-of-battle modal */
  #endModal {
    display: none;
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,.72);
    align-items: center; justify-content: center;
  }
  #endModal.show { display: flex; }
  .end-modal-box {
    background: #1b1e26;
    border: 2px solid #505665;
    border-radius: 14px;
    padding: 36px 48px;
    text-align: center;
    min-width: 280px;
    box-shadow: 0 12px 40px rgba(0,0,0,.55);
  }
  .end-modal-box.victory { border-color: #7ee787; }
  .end-modal-box.fallen { border-color: #ff6b6b; }
  .end-modal-title {
    font-size: 32px; font-weight: bold; margin: 0 0 8px;
    letter-spacing: 1px;
  }
  .end-modal-box.victory .end-modal-title { color: #7ee787; }
  .end-modal-box.fallen .end-modal-title { color: #ff6b6b; }
  .end-modal-sub {
    color: #aaa; font-size: 14px; margin-bottom: 24px;
  }
  .end-modal-box button {
    background: #2a2e39; color: #fff; border: 1px solid #505665;
    border-radius: 8px; padding: 12px 28px; font-size: 14px;
    font-weight: bold; cursor: pointer;
  }
  .end-modal-box button:hover { background: #3a3f4d; }
  /* ================= BATTLE DIALOG ================= */
  .battle-dialog-modal{display:none;position:fixed;inset:0;z-index:1150;background:rgba(0,0,0,.72);align-items:center;justify-content:center;padding:18px;}
  .battle-dialog-modal.show{display:flex;animation:dialogFadeIn .22s ease forwards;}
  .battle-dialog-box{width:min(560px,88vw);background:linear-gradient(160deg,#1b2029,#101319);border:1px solid #596477;border-radius:12px;box-shadow:0 20px 60px rgba(0,0,0,.78);padding:12px;}
  .battle-dialog-inner{display:grid;grid-template-columns:92px 1fr;gap:13px;align-items:center;}
  .battle-dialog-avatar-wrap{width:92px;height:92px;border:1px solid #4f6078;border-radius:9px;overflow:hidden;background:#0b0f14;box-shadow:0 5px 18px rgba(0,0,0,.5);}
  .battle-dialog-avatar{width:100%;height:100%;display:block;object-fit:cover;}
  .battle-dialog-content{min-width:0;}
  .battle-dialog-speaker{font-size:10px;letter-spacing:1.6px;text-transform:uppercase;color:#7aa2f7;font-weight:900;margin:0 0 5px;}
  .battle-dialog-text{min-height:50px;color:#fff;font-size:14px;line-height:1.38;font-weight:600;text-shadow:0 1px 2px #000;}
  .battle-dialog-next{display:block;margin:9px 0 0 auto;min-width:82px;padding:7px 13px;background:#252b36;border:1px solid #69758a;border-radius:7px;color:#fff;font-size:11px;font-weight:900;letter-spacing:.8px;cursor:pointer;}
  .battle-dialog-next:hover{background:#313947;}
  @media(max-width:520px){
    .battle-dialog-box{width:min(430px,92vw);padding:10px;}
    .battle-dialog-inner{grid-template-columns:72px 1fr;gap:10px;}
    .battle-dialog-avatar-wrap{width:72px;height:72px;}
    .battle-dialog-text{font-size:12px;min-height:42px;}
  }
  @keyframes dialogFadeIn{from{opacity:0;transform:scale(.98)}to{opacity:1;transform:scale(1)}}


  .battle-entrance-modal {
    display:none;
    position:fixed; inset:0; z-index:1100;
    background:rgba(0,0,0,.70);
    align-items:center; justify-content:center;
    pointer-events:none;
  }
  .battle-entrance-modal.show { display:flex; animation:entranceFade 4s ease forwards; }
  .battle-entrance-title {
    color:#fff;
    font-size:clamp(46px,8vw,92px);
    font-weight:1000;
    letter-spacing:8px;
    text-transform:uppercase;
    text-shadow:0 4px 18px rgba(0,0,0,.9), 0 0 28px rgba(122,162,247,.45);
    transform:scale(1.08);
    animation:entranceTitle 2s ease forwards;
  }
  .battle-commence-title {
    display:none;
    position:absolute;
    color:#fff;
    font-size:clamp(42px,7vw,82px);
    font-weight:1000;
    letter-spacing:6px;
    text-transform:uppercase;
    text-shadow:0 4px 18px rgba(0,0,0,.9), 0 0 34px rgba(126,231,135,.65);
    opacity:0;
  }
  .battle-entrance-modal.commence .battle-entrance-title { display:none; }
  .battle-entrance-modal.commence .battle-commence-title {
    display:block;
    animation:commenceTitle 2s ease forwards;
  }
  @keyframes entranceTitle {
    0%{opacity:0;transform:scale(1.18)}
    18%{opacity:1;transform:scale(1)}
    72%{opacity:1;transform:scale(1)}
    100%{opacity:0;transform:scale(.96)}
  }
  @keyframes commenceTitle {
    0%{opacity:0;transform:scale(.82)}
    18%{opacity:1;transform:scale(1.05)}
    38%{opacity:1;transform:scale(1)}
    78%{opacity:1;transform:scale(1)}
    100%{opacity:0;transform:scale(1.12)}
  }
  @keyframes entranceFade {
    0%{opacity:1} 88%{opacity:1} 100%{opacity:0}
  }
  .battle-badge { color:#f6e58d; }
  .meta-badges { gap:2px; }


  /* Level-up modal */
  #levelUpModal {
    display: none;
    position: fixed; inset: 0; z-index: 1001;
    background: rgba(0,0,0,.72);
    align-items: center; justify-content: center;
  }
  #levelUpModal.show { display: flex; }
  .level-up-modal-box {
    background: #1b1e26;
    border: 2px solid #f6e58d;
    border-radius: 14px;
    padding: 36px 48px;
    text-align: center;
    min-width: 280px;
    max-width: 380px;
    box-shadow: 0 12px 40px rgba(0,0,0,.55), 0 0 24px rgba(246,229,141,.25);
  }
  .level-up-modal-title {
    font-size: 22px; font-weight: 900; margin: 0 0 24px;
    letter-spacing: 0.5px; color: #f6e58d;
    text-shadow: 0 1px 4px #000;
  }
  .level-up-modal-box button {
    background: #4a4326; color: #f6e58d; border: 1px solid #f6e58d;
    border-radius: 8px; padding: 12px 28px; font-size: 14px;
    font-weight: bold; cursor: pointer; letter-spacing: 0.5px;
  }
  .level-up-modal-box button:hover { background: #5c5330; }


  .level-up-modal-box.choice-mode {
    max-width: 520px; min-width: min(520px, 94vw); text-align: left;
  }
  .level-up-kicker {
    font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase;
    color: #9ec1ff; font-weight: 900; margin-bottom: 4px;
  }
  .level-up-arch {
    font-size: 12px; color: #8e99aa; margin-bottom: 12px;
  }
  .level-choice-row {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px;
  }
  .level-choice-btn {
    background: #252933; border: 1px solid #3d4658; border-radius: 10px;
    padding: 14px 12px; cursor: pointer; text-align: left; color: #eee;
    transition: border-color .15s, transform .12s, background .15s;
  }
  .level-choice-btn:hover {
    border-color: #7aa2f7; background: #2a3348; transform: translateY(-2px);
  }
  .level-choice-letter {
    font-size: 11px; font-weight: 900; letter-spacing: 1px; color: #f6e58d; margin-bottom: 4px;
  }
  .level-choice-name {
    font-size: 15px; font-weight: 900; margin-bottom: 8px; color: #fff;
  }
  .level-choice-list {
    margin: 0; padding-left: 16px; font-size: 12px; color: #b0b8c8; line-height: 1.45;
  }
  .level-ability-grant {
    background: #1a2430; border: 1px solid #3a5068; border-radius: 10px;
    padding: 14px; margin-top: 10px;
  }
  .level-ability-grant strong { color: #ff8a8a; }




  /* Character unlock modal */
  #unlockModal {
    display: none; position: fixed; inset: 0; z-index: 1002;
    background: rgba(0,0,0,.78);
    align-items: center; justify-content: center;
  }
  #unlockModal.show { display: flex; }
  .unlock-box {
    background: linear-gradient(180deg,#1e2330,#141820);
    border: 1px solid #4a5568; border-radius: 14px;
    padding: 28px 28px 22px; width: min(720px, 94vw);
    box-shadow: 0 18px 50px rgba(0,0,0,.6);
  }
  .unlock-kicker {
    font-size: 11px; letter-spacing: 2px; text-transform: uppercase;
    color: #7aa2f7; font-weight: 900; margin-bottom: 6px; text-align: center;
  }
  .unlock-title {
    font-size: 26px; font-weight: 900; text-align: center; margin: 0 0 8px; color: #f0f3fa;
  }
  .unlock-sub {
    text-align: center; color: #9aa6b8; font-size: 13px; margin: 0 0 20px;
  }
  .unlock-cards {
    display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; margin-bottom: 18px;
  }
  .unlock-card {
    width: 160px; background: #252933; border: 1px solid #3d4658; border-radius: 12px;
    padding: 14px 12px 12px; cursor: pointer; text-align: center;
    transition: transform .12s ease, border-color .15s ease, box-shadow .15s ease;
  }
  .unlock-card:hover:not(.claimed) {
    transform: translateY(-3px); border-color: #7aa2f7;
    box-shadow: 0 8px 20px rgba(0,0,0,.35);
  }
  .unlock-card.claimed {
    opacity: .55; cursor: default; border-color: #2f7650;
  }


  .unlock-box.pack-mode { max-width: 640px; }
  .unlock-pack-grid {
    display: flex; flex-wrap: wrap; gap: 20px; justify-content: center;
    margin: 12px 0 20px; min-height: 220px; align-items: center;
  }
  
  .pack-slot { position: relative; overflow: visible; }
  .pack-particles {
    position: absolute; left: 50%; top: 50%;
    width: 0; height: 0; pointer-events: none; z-index: 20;
  }
  .pack-particle {
    position: absolute; left: 0; top: 0;
    border-radius: 50%;
    pointer-events: none;
    animation: pack-particle-fly var(--dur, 700ms) ease-out forwards;
    opacity: 0;
  }
  .pack-particle.spark {
    width: var(--size, 6px); height: var(--size, 6px);
    background: radial-gradient(circle, #fff6c8 0%, #f0d56a 45%, #c9a227 100%);
    box-shadow: 0 0 6px rgba(255, 220, 120, .9);
  }
  .pack-particle.mote {
    width: var(--size, 4px); height: var(--size, 4px);
    background: radial-gradient(circle, #fff 0%, #ffe9a0 70%, transparent 100%);
    box-shadow: 0 0 8px rgba(255, 240, 180, .8);
  }
  .pack-particle.shard {
    width: var(--size, 10px); height: var(--size, 3px);
    border-radius: 1px;
    background: linear-gradient(90deg, transparent, #f6e58d, #fff8d0, #f6e58d, transparent);
    box-shadow: 0 0 4px rgba(240, 213, 106, .7);
  }
  @keyframes pack-particle-fly {
    0% {
      opacity: 1;
      transform: translate(-50%, -50%) rotate(var(--rot, 0deg)) scale(1);
    }
    15% { opacity: 1; }
    100% {
      opacity: 0;
      transform:
        translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -40px)))
        rotate(calc(var(--rot, 0deg) + var(--spin, 120deg)))
        scale(var(--scale-end, 0.2));
    }
  }
  .pack-slot.burst .pack-back {
    animation: pack-flash 0.35s ease-out;
  }
  @keyframes pack-flash {
    0% { filter: brightness(1); box-shadow: 0 12px 28px rgba(0,0,0,.45); }
    30% { filter: brightness(1.8); box-shadow: 0 0 40px rgba(255, 220, 120, .85), 0 12px 28px rgba(0,0,0,.45); }
    100% { filter: brightness(1); box-shadow: 0 12px 28px rgba(0,0,0,.45); }
  }
  .pack-slot.opened .pack-front {
    animation: pack-reveal-glow 0.8s ease-out;
  }
  @keyframes pack-reveal-glow {
    0% { box-shadow: 0 0 0 rgba(240, 213, 106, 0); }
    40% { box-shadow: 0 0 28px rgba(240, 213, 106, .75), 0 12px 28px rgba(0,0,0,.45); }
    100% { box-shadow: 0 12px 28px rgba(0,0,0,.45); }
  }


  .pack-slot {
    width: 170px; height: 240px; perspective: 900px;
    cursor: pointer; border: none; background: transparent; padding: 0;
  }
  .pack-slot:disabled { cursor: default; }
  .pack-inner {
    position: relative; width: 100%; height: 100%;
    transform-style: preserve-3d; transition: transform .65s ease;
  }
  .pack-slot.opened .pack-inner { transform: rotateY(180deg); }
  .pack-face {
    position: absolute; inset: 0; backface-visibility: hidden;
    border-radius: 14px; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    box-shadow: 0 12px 28px rgba(0,0,0,.45);
  }
  .pack-back {
    background:
      radial-gradient(circle at 50% 30%, rgba(255,230,150,.35), transparent 55%),
      linear-gradient(160deg, #c9a227 0%, #8a6a12 40%, #5c480a 100%);
    border: 3px solid #f0d56a;
    color: #1a1408;
  }
  .pack-back::before {
    content: '';
    position: absolute; inset: 10px;
    border: 1px solid rgba(255,240,180,.45);
    border-radius: 10px;
    pointer-events: none;
  }
  .pack-seal {
    width: 54px; height: 54px; border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffe9a0, #b8860b);
    border: 2px solid #fff3c4;
    margin-bottom: 12px;
    box-shadow: 0 0 16px rgba(255,210,100,.5);
  }
  .pack-brand {
    font-weight: 900; font-size: 13px; letter-spacing: 1.5px;
    text-transform: uppercase; text-align: center;
    color: #1a1408; text-shadow: 0 1px 0 rgba(255,255,200,.35);
    line-height: 1.3; padding: 0 12px;
  }
  .pack-brand small {
    display: block; font-size: 10px; letter-spacing: 3px;
    margin-top: 4px; opacity: .85;
  }
  .pack-hint {
    position: absolute; bottom: 16px; font-size: 10px;
    letter-spacing: 1px; text-transform: uppercase; opacity: .75;
  }
  .pack-front {
    background:
      radial-gradient(circle at 50% 20%, rgba(255,236,170,.25), transparent 50%),
      linear-gradient(165deg, #2a2410 0%, #1a160c 100%);
    border: 3px solid #e8c547;
    transform: rotateY(180deg);
    color: #f6e58d;
    padding: 12px 10px;
  }
  .pack-front .unlock-card-avatar {
    width: 88px; height: 88px; margin: 6px auto 8px;
    background: rgba(0,0,0,.25); border-radius: 12px;
    border: 1px solid rgba(240,213,106,.4);
    display: flex; align-items: center; justify-content: center;
  }
  .pack-front .unlock-card-avatar svg,
  .pack-front .unlock-card-avatar img { width: 100%; height: 100%; object-fit: contain; }
  .pack-front .unlock-card-name {
    font-size: 16px; font-weight: 900; color: #ffe9a0;
  }
  .pack-front .unlock-card-arch {
    font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
    color: #c9b56a; margin-top: 4px;
  }
  .pack-front .unlock-card-blurb {
    font-size: 10px; color: #b8a878; margin-top: 8px; line-height: 1.35;
    max-height: 48px; overflow: hidden;
  }
  .pack-front .pack-unlocked-tag {
    margin-top: auto; font-size: 10px; font-weight: 900;
    letter-spacing: 1.5px; text-transform: uppercase;
    color: #1a1408; background: linear-gradient(90deg,#f0d56a,#c9a227);
    padding: 5px 10px; border-radius: 999px;
  }
  .pack-slot.opened { cursor: default; }


  .unlock-card-avatar {
    width: 64px; height: 64px; margin: 0 auto 10px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: #2d6cdf; border: 2px solid #ddd; overflow: hidden;
  }
  .unlock-card-avatar svg { width: 58px; height: 58px; }
  .unlock-card-name { font-weight: 900; font-size: 15px; margin-bottom: 4px; }
  .unlock-card-arch {
    font-size: 10px; letter-spacing: .6px; text-transform: uppercase;
    color: #9ec1ff; font-weight: 800; margin-bottom: 6px;
  }
  .unlock-card-blurb { font-size: 11px; color: #8b95a8; line-height: 1.35; min-height: 34px; }
  .unlock-card-status {
    margin-top: 8px; font-size: 10px; font-weight: 800; letter-spacing: .5px;
    text-transform: uppercase; color: #7ee787;
  }
  .unlock-card:not(.claimed) .unlock-card-status { color: #7aa2f7; }
  .unlock-actions { display: flex; justify-content: center; gap: 10px; }
  .unlock-continue {
    background: #2a3348; color: #fff; border: 1px solid #5a6a88;
    border-radius: 8px; padding: 12px 28px; font-weight: 900; font-size: 13px;
    cursor: pointer; letter-spacing: .5px;
  }
  .unlock-continue:disabled { opacity: .35; cursor: not-allowed; }
  .unlock-continue:not(:disabled):hover { background: #354260; }
  #unlockToast {
    display: none; position: fixed; inset: 0; z-index: 1003;
    background: rgba(0,0,0,.55); align-items: center; justify-content: center;
  }
  #unlockToast.show { display: flex; }
  .unlock-toast-box {
    background: #1b1e26; border: 2px solid #7ee787; border-radius: 12px;
    padding: 28px 36px; text-align: center; min-width: 260px;
    box-shadow: 0 12px 40px rgba(0,0,0,.5);
  }
  .unlock-toast-title { font-size: 20px; font-weight: 900; color: #7ee787; margin-bottom: 8px; }
  .unlock-toast-name { font-size: 18px; font-weight: 900; margin-bottom: 6px; }
  .unlock-toast-sub { font-size: 12px; color: #9aa6b8; margin-bottom: 16px; }
  .unlock-toast-box button {
    background: #173d2a; color: #7ee787; border: 1px solid #2f7650;
    border-radius: 8px; padding: 10px 22px; font-weight: 900; cursor: pointer;
  }


  img {
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 40%; 
}


.combat-float.xp{color:#8be9fd;text-shadow:0 1px 3px #000;font-size:12px;}
.combat-float.levelup{color:#f6e58d;text-shadow:0 1px 4px #000;font-size:15px;font-weight:900;}




  /* ========================================================================
     COVENSMARCH v0.9.1 — VISUAL BATTLEFIELD LAYER
     Graphics-only pass: sprites, terrain textures, environment dressing.
     Combat rules and campaign logic remain unchanged.
     ======================================================================== */
  body {
    background:
      radial-gradient(circle at 50% -10%, rgba(91,112,82,.28), transparent 42%),
      linear-gradient(180deg, #141912 0%, #0d100d 52%, #080a08 100%);
  }
  #app { position:relative; }
  #app::before {
    content:""; position:fixed; inset:0; pointer-events:none; opacity:.17;
    background-image:
      linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px),
      linear-gradient(rgba(255,255,255,.014) 1px, transparent 1px);
    background-size:32px 32px;
  }
  .battle-stage {
    position:relative;
    padding:22px;
    border:1px solid #4a4938;
    border-radius:14px;
    background:
      linear-gradient(rgba(12,16,11,.64), rgba(12,16,11,.72)),
      repeating-linear-gradient(135deg,#38432f 0 18px,#303a2a 18px 36px);
    box-shadow:0 18px 44px rgba(0,0,0,.38), inset 0 0 0 1px rgba(255,255,255,.035);
    overflow:hidden;
  }
  .battle-stage::before,
  .battle-stage::after {
    content:""; position:absolute; pointer-events:none; z-index:0;
    width:180px; height:180px; border-radius:50%; filter:blur(2px); opacity:.28;
    background:radial-gradient(circle, #577143 0 12%, #405535 13% 30%, transparent 31%);
  }
  .battle-stage::before { left:-86px; top:-72px; }
  .battle-stage::after { right:-92px; bottom:-80px; transform:scale(1.2); }
  #battlefield {
    position:relative; z-index:1;
    gap:2px;
    padding:5px;
    border:2px solid #24281f;
    border-radius:8px;
    background:#151912;
    box-shadow:0 8px 22px rgba(0,0,0,.45), inset 0 0 20px rgba(0,0,0,.45);
  }
  .cell {
    overflow:visible;
    border-color:rgba(31,36,28,.48);
    transition:filter .12s ease, transform .12s ease, box-shadow .12s ease;
  }
  .cell.road {
    background-color:#777469;
    background-image:
      radial-gradient(circle at 22% 28%, rgba(255,255,255,.08) 0 2px, transparent 2.5px),
      radial-gradient(circle at 72% 66%, rgba(0,0,0,.14) 0 2px, transparent 2.5px),
      linear-gradient(140deg, rgba(255,255,255,.04), transparent 38%);
    background-size:21px 19px, 27px 23px, 100% 100%;
  }
  .cell.sand {
    background-color:#9a8352;
    background-image:
      radial-gradient(circle, rgba(70,51,25,.23) 0 1px, transparent 1.3px),
      radial-gradient(circle, rgba(255,238,184,.16) 0 1px, transparent 1.4px),
      linear-gradient(155deg, rgba(255,255,255,.09), transparent 45%);
    background-size:8px 8px, 13px 13px, 100% 100%;
    background-position:0 0, 4px 5px, 0 0;
  }
  .cell.water {
    background-color:#315d72;
    background-image:
      repeating-linear-gradient(165deg, rgba(139,211,232,.14) 0 2px, transparent 2px 11px),
      linear-gradient(180deg, rgba(93,179,211,.14), rgba(14,64,88,.18));
    animation:water-shimmer 4.5s linear infinite;
  }
  .cell.bridge {
    background-color:#70543a;
    background-image:
      repeating-linear-gradient(90deg, rgba(25,14,8,.36) 0 2px, transparent 2px 14px),
      repeating-linear-gradient(0deg, transparent 0 45%, rgba(31,18,9,.28) 46% 50%, transparent 51% 100%);
    box-shadow:inset 0 3px 0 rgba(185,139,82,.18), inset 0 -3px 0 rgba(35,19,9,.34);
  }
  .cell.treasure {
    /* walkable interactable tile — soft gold wash under the chest sprite */
  }
  .treasure-box {
    position:absolute; left:10%; top:8%; width:80%; height:80%;
    z-index:5; pointer-events:none;
    filter:drop-shadow(0 4px 3px rgba(0,0,0,.45));
  }
  .treasure-box.looted { opacity:.55; filter:grayscale(.35) drop-shadow(0 3px 2px rgba(0,0,0,.35)); }
  .cell.treasure-adj {
    outline:2px solid #f6e58d;
    box-shadow:inset 0 0 0 999px rgba(246,229,141,.18);
  }
  .cell.treasure-adj.supportable {
    outline:3px solid #f6e58d !important;
    box-shadow:inset 0 0 0 999px rgba(246,229,141,.28), 0 0 10px rgba(246,229,141,.35);
  }
  .cell.wall {
    background-color:#2a2b28;
    background-image:
      linear-gradient(45deg, rgba(255,255,255,.035) 25%, transparent 25% 75%, rgba(0,0,0,.13) 75%),
      linear-gradient(-45deg, rgba(255,255,255,.025) 25%, transparent 25% 75%, rgba(0,0,0,.12) 75%);
    background-size:16px 16px;
  }
  @keyframes water-shimmer { from{background-position:0 0,0 0} to{background-position:44px 0,0 0} }


  .terrain-label { display:none; }
  .cell-label { color:rgba(255,255,255,.20); text-shadow:0 1px 2px #000; font-size:7px; z-index:2; }
  .obstacle {
    width:82%; height:82%; left:9%; top:5%; border:none; background:transparent; color:transparent;
    filter:drop-shadow(0 5px 3px rgba(0,0,0,.42));
  }
  .obstacle::before {
    content:""; width:78%; height:78%; border-radius:45% 52% 42% 48%;
    background:
      radial-gradient(circle at 36% 31%, #747970 0 16%, transparent 17%),
      radial-gradient(circle at 58% 48%, #5c625a 0 24%, transparent 25%),
      radial-gradient(circle at 45% 64%, #3f4540 0 34%, #2b302c 35% 55%, transparent 56%);
    transform:rotate(-8deg);
    border:1px solid rgba(0,0,0,.35);
  }


  .unit {
    width:88%; height:96%; left:6%; top:-7%; border:none; border-radius:0; background:transparent !important;
    color:#fff; z-index:6; overflow:visible;
    filter:drop-shadow(0 6px 3px rgba(0,0,0,.55));
    transform-origin:50% 78%;
  }
  .unit.selected {
    box-shadow:none;
    filter:drop-shadow(0 0 5px #fff) drop-shadow(0 7px 3px rgba(0,0,0,.62));
  }
  .unit.selected::after {
    content:""; position:absolute; left:17%; right:17%; bottom:2%; height:14%; border-radius:50%;
    background:rgba(255,233,112,.38); border:2px solid #ffe66d; z-index:-1;
    box-shadow:0 0 10px rgba(255,230,109,.75);
  }
  .unit-sprite { width:100%; height:100%; display:block; overflow:visible; pointer-events:none; }
  .unit .sprite-name {
    position:absolute; left:50%; top:-10px; transform:translateX(-50%); white-space:nowrap;
    font-size:8px; font-weight:800; letter-spacing:.15px; color:#f4f1df;
    text-shadow:0 1px 2px #000,0 0 3px #000;
    background:rgba(11,13,10,.56); border-radius:3px; padding:1px 3px;
    opacity:.9;
  }
  .unit.enemy .sprite-name { color:#ffd0cc; }
  .unit.player .sprite-name { color:#d8e7ff; }
  .unit.dead .unit-sprite { filter:grayscale(1); transform:rotate(90deg) scale(.82); opacity:.55; }
  .unit.ranged { border:none; }
  .unit.wolf-sprite { filter:drop-shadow(0 7px 3px rgba(0,0,0,.65)); }
  .unit.enemy:has(.wolf-sprite) .sprite-name { color:#ffb0b0; letter-spacing:.4px; }
  .facing-arrow {
    display: block;
    position: absolute;
    font-size: 12px;
    line-height: 1;
    z-index: 9;
    color: #fff;
    text-shadow: 0 0 3px #000, 0 1px 2px #000, 0 0 6px rgba(0,0,0,.8);
    pointer-events: none;
    font-weight: bold;
  }
  .ability-badge { top:7%; right:4%; }
  .hp-bar-wrap { left:12%; bottom:2px; width:76%; height:5px; z-index:8; border:1px solid rgba(0,0,0,.55); }


  .queue-avatar { border-radius:6px; overflow:hidden; background:#171a16 !important; padding:0; }
  .queue-avatar .unit-sprite { width:100%; height:100%; }


  @media(max-width:900px){
    .battle-stage{padding:10px;}
    .unit .sprite-name{display:none;}
  }




/* v0.9.2 animation/effects layer */
.unit-sprite{transition:transform .22s ease,filter .18s ease,opacity .25s ease;animation:idle-bob 2.6s ease-in-out infinite}
@keyframes idle-bob{0%,100%{transform:translateY(0)}50%{transform:translateY(-2px)}}
.unit.dead .unit-sprite{animation:none}
.unit.ranged{border:none !important;outline:none !important;box-shadow:none !important}
  .unit.npc::after{content:'NPC';position:absolute;top:-18px;left:50%;transform:translateX(-50%);font-size:8px;font-weight:900;letter-spacing:1px;color:#ffd27a;text-shadow:0 1px 3px #000;pointer-events:none;}


.unit.dead .unit-sprite.anim-death{animation:unitDeath .65s ease forwards}
.unit-sprite.anim-move{animation:unitMove .28s ease}
.unit-sprite.anim-attack{animation:unitAttack .34s ease}
.unit-sprite.anim-hit{animation:unitHit .30s ease}
.unit-sprite.anim-death{animation:unitDeath .65s ease forwards}


  /* Formation Wall — bright orange visual marker for allied 3-unit lines */
  .unit.formation-wall-active{
    outline:2px solid #ff8a00;
    outline-offset:2px;
    box-shadow:0 0 0 2px rgba(255,138,0,.18), 0 0 18px rgba(255,138,0,.42);
  }
  .formation-wall-marker{
    position:absolute;
    top:-17px;
    left:50%;
    transform:translateX(-50%);
    z-index:12;
    white-space:nowrap;
    padding:2px 6px;
    border:1px solid #ffb347;
    border-radius:4px;
    background:#ff8a00;
    color:#1a0d00;
    font-size:7px;
    line-height:1.1;
    font-weight:1000;
    letter-spacing:.7px;
    text-shadow:none;
    box-shadow:0 2px 7px rgba(0,0,0,.45);
    pointer-events:none;
  }
  .formation-wall-marker::after{
    content:'';
    position:absolute;
    left:50%;
    bottom:-4px;
    transform:translateX(-50%);
    width:0;height:0;
    border-left:4px solid transparent;
    border-right:4px solid transparent;
    border-top:4px solid #ff8a00;
  }


.unit-sprite.anim-evade{animation:unitEvade .38s ease}
.unit-sprite.anim-defend{animation:unitDefend .32s ease}
.combat-fx{position:absolute;pointer-events:none;z-index:30;transform:translate(-50%,-50%);font-weight:900;text-shadow:0 2px 5px #000;animation:fxFloat .7s ease forwards}
.combat-fx.damage{font-size:22px;color:#ffd6d6}.combat-fx.crit{font-size:28px;color:#ffe36b}.combat-fx.heal{font-size:22px;color:#b9ffca}.combat-fx.evade{font-size:18px;color:#bfe4ff}.combat-fx.xp{font-size:17px;color:#e9c8ff}
.projectile{position:absolute;width:18px;height:5px;border-radius:4px;background:#f2dfad;box-shadow:0 0 10px #fff,0 0 16px rgba(242,223,173,.8);z-index:25;pointer-events:none;transform-origin:center center;will-change:left,top,transform,opacity}.projectile:after{content:'';position:absolute;right:-7px;top:-4px;border-left:9px solid #f2dfad;border-top:6px solid transparent;border-bottom:6px solid transparent;filter:drop-shadow(0 0 4px #fff)}
.slash-fx{position:absolute;width:58px;height:8px;border-radius:50%;border-top:4px solid #fff2b0;border-bottom:2px solid rgba(255,255,255,.5);z-index:26;pointer-events:none;animation:slash .3s ease-out forwards}
.flash-fx{position:absolute;inset:0;background:rgba(255,245,190,.45);z-index:20;pointer-events:none;animation:flash .18s ease-out forwards}
.flash-fx.pierce{background:rgba(180,225,255,.45)}
.flash-fx.slow{background:rgba(170,220,255,.45)}
.flash-fx.stun{background:rgba(255,240,120,.5)}
.flash-fx.cleave{background:rgba(255,150,110,.45)}
.flash-fx.aimed{background:rgba(255,214,120,.45)}
/* Hit-stop: briefly freeze all running sprite/board animations on a crit for impact */
#battlefield.hitstop, #battlefield.hitstop * { animation-play-state: paused !important; }
@keyframes unitMove{0%{transform:translateY(0)}45%{transform:translateY(-7px) scale(1.04)}100%{transform:translateY(0)}}
@keyframes unitAttack{0%{transform:translateX(0) scale(1)}35%{transform:translateX(9px) scale(1.08)}70%{transform:translateX(-3px) scale(1.02)}100%{transform:translateX(0) scale(1)}}
@keyframes unitHit{0%,100%{transform:translateX(0)}20%{transform:translateX(-7px)}40%{transform:translateX(7px)}60%{transform:translateX(-4px)}}
@keyframes unitDeath{0%{transform:translateY(0) rotate(0);opacity:1}100%{transform:translateY(12px) rotate(22deg);opacity:.35;filter:grayscale(1)}}
@keyframes unitEvade{0%,100%{transform:translateX(0);opacity:1}45%{transform:translateX(-13px);opacity:.65}75%{transform:translateX(6px);opacity:1}}
@keyframes unitDefend{0%,100%{transform:scale(1)}45%{transform:scale(.94) translateY(2px)}70%{transform:scale(1.06)}}
@keyframes fxFloat{0%{opacity:0;transform:translate(-50%,0) scale(.7)}15%{opacity:1}100%{opacity:0;transform:translate(-50%,-42px) scale(1.05)}}
@keyframes projectileFly{from{opacity:1}to{opacity:0}}
@keyframes slash{0%{opacity:0;transform:rotate(-35deg) scale(.2)}35%{opacity:1}100%{opacity:0;transform:rotate(-35deg) scale(1.25)}}
@keyframes flash{from{opacity:1}to{opacity:0}}
  /* ========================================================================
     COVENSMARCH v0.9.3 — RPG PRESENTATION LAYER
     UI hierarchy, battle HUD, active-unit presentation, and combat feedback.
     ======================================================================== */
  body{background:radial-gradient(circle at 50% -15%,rgba(67,86,120,.25),transparent 40%),linear-gradient(180deg,#10131a 0%,#0b0d12 58%,#07090d 100%)}
  #app{padding:18px 20px 28px}
  .game-header{display:flex;align-items:flex-end;justify-content:space-between;gap:18px;margin-bottom:14px}
  .game-kicker{font-size:10px;letter-spacing:2px;text-transform:uppercase;color:#7d8799;font-weight:800;margin-bottom:3px}
  .game-title{font-size:27px;font-weight:1000;letter-spacing:.4px;color:#f3f5f8}.game-subtitle{font-size:11px;color:#778196;margin-top:3px}
  .hud-strip{display:grid;grid-template-columns:150px 150px minmax(220px,1fr);gap:9px;margin-bottom:12px}
  .hud-card{position:relative;background:linear-gradient(180deg,#202531,#181b23);border:1px solid #363c4a;border-radius:10px;padding:9px 13px;min-height:66px;overflow:hidden;box-shadow:0 8px 22px rgba(0,0,0,.18)}
  .hud-card:after{content:'';position:absolute;inset:auto 0 0;height:2px;background:linear-gradient(90deg,transparent,#53617b,transparent);opacity:.7}
  .hud-label{font-size:9px;text-transform:uppercase;letter-spacing:1.5px;color:#788397;font-weight:800}.hud-value{font-size:26px;font-weight:1000;line-height:1.05;margin-top:3px;color:#f4f6fa}.hud-value.battle{color:#f6e58d}.hud-value.turn{color:#7aa2f7}
  .progress-wrap{margin-top:7px;height:6px;background:#0e1117;border-radius:999px;overflow:hidden;border:1px solid #303644}.progress-fill{height:100%;width:33.333%;background:linear-gradient(90deg,#7aa2f7,#bd93f9);border-radius:999px;transition:width .35s ease}.progress-caption{display:flex;justify-content:space-between;margin-top:4px;font-size:9px;color:#70798b}
  .top-bar{margin-bottom:12px}.top-turn-order .panel{padding:9px 11px;background:linear-gradient(180deg,#1c2029,#171a21);border-color:#343a48}.top-turn-order .section-title{font-size:10px;letter-spacing:1.3px;text-transform:uppercase;color:#7f899c;margin:0 0 6px}.turn-order-caption{float:right;font-size:9px;color:#596275;text-transform:none;letter-spacing:0}
  .layout{grid-template-columns:minmax(0,1fr) 300px;gap:14px}.col-left{display:none!important}.panel{background:linear-gradient(180deg,#1b1f28,#171a21);border-color:#343a48;box-shadow:0 7px 18px rgba(0,0,0,.13)}.battle-stage{position:relative}
  .battle-overlay{position:absolute;top:12px;left:12px;z-index:40;pointer-events:none;display:flex;flex-direction:column;gap:3px}.battle-overlay .ov-battle{font-size:10px;letter-spacing:1.5px;text-transform:uppercase;color:#f6e58d;font-weight:900;text-shadow:0 2px 5px #000}.battle-overlay .ov-turn{font-size:16px;font-weight:1000;color:#fff;text-shadow:0 2px 6px #000}.battle-overlay .ov-unit{font-size:10px;color:#d1d7e2;text-shadow:0 2px 5px #000}
  .active-ribbon{display:flex;align-items:center;justify-content:space-between;gap:10px;background:#202530;border:1px solid #3b4352;border-radius:7px;padding:7px 9px;margin-bottom:9px}.active-ribbon-label{font-size:9px;letter-spacing:1.2px;text-transform:uppercase;color:#778296;font-weight:900}.active-ribbon-name{font-size:13px;font-weight:900;color:#fff}.active-ribbon.player{border-color:#315aa8}.active-ribbon.enemy{border-color:#78383d}
  .actions-title{letter-spacing:1px;text-transform:uppercase;color:#8791a4;margin:0 0 8px}.buttons button{min-height:40px;position:relative;transition:transform .12s ease,border-color .15s ease,background .15s ease,box-shadow .15s ease}.buttons button:hover:not(:disabled){transform:translateY(-1px);box-shadow:0 5px 12px rgba(0,0,0,.2)}#endBtn{grid-column:1 / -1;background:#252b36;border-color:#606a7d;width:100%;justify-self:stretch}#retreatBtn{display:none!important}#abilityBtn{border-color:#505665;color:#fff}
  #defendBtn{min-height:32px;font-size:11px;padding:6px 8px;opacity:.95}
  .actions-sub-header{display:flex;align-items:center;gap:8px;margin-bottom:10px}
  .actions-sub-header .actions-title{margin:0;flex:1}
  .actions-back{background:#2a2e39;border:1px solid #505665;border-radius:6px;color:#eee;width:36px;height:36px;padding:0;cursor:pointer;font-size:14px;flex-shrink:0}
  .actions-back:hover{background:#3a3f4d}
  .actions-sub-list{display:flex;flex-direction:column;gap:8px}
  .actions-sub-list .picker-item{width:100%}
  .actions-sub-list .facing-picker{max-width:100%;padding:4px 0}
  #message{border:1px solid #303746;background:#12161e;box-shadow:inset 0 1px 0 rgba(255,255,255,.025)}#log{background:#0f131a;border:1px solid #2d3340;height:238px}.log-title-row{display:flex;align-items:center;justify-content:space-between}.log-live{font-size:9px;color:#7ee787;text-transform:uppercase;letter-spacing:1px}.legend{padding:7px 2px 0;color:#778196;line-height:1.4}
  .queue-card{background:#20242d;border-color:#353c4a;transition:transform .15s ease,opacity .15s ease}.queue-card.current{outline:2px solid #f6e58d;box-shadow:0 0 13px rgba(246,229,141,.18);transform:translateY(-2px)}.queue-ord{color:#70798b}
  .char-header{background:linear-gradient(135deg,#202531,#181b22);border:1px solid #303746;border-radius:9px;padding:9px;margin-bottom:10px}.char-avatar{width:58px;height:58px}.char-name{font-size:19px}.char-stats .char-stat{border:1px solid #2f3542}.char-ability{border:1px solid #343a48;border-left:3px solid #ff6b6b}.combat-float{font-size:18px;filter:drop-shadow(0 2px 5px rgba(0,0,0,.45))}
  .battle-entrance-modal{background:radial-gradient(circle,rgba(21,29,45,.35),rgba(0,0,0,.84))}.battle-entrance-title{font-size:clamp(52px,9vw,104px);letter-spacing:10px}.end-modal-box{min-width:340px;padding:30px 38px;background:linear-gradient(180deg,#202530,#171a21);box-shadow:0 18px 55px rgba(0,0,0,.7)}.end-modal-kicker{font-size:10px;letter-spacing:2px;text-transform:uppercase;color:#7f899c;font-weight:900;margin-bottom:6px}.end-modal-statline{display:flex;justify-content:center;gap:18px;margin:0 0 22px;color:#aeb7c7;font-size:11px}.end-modal-statline strong{color:#fff;font-size:13px}
  @media(max-width:900px){.hud-strip{grid-template-columns:1fr 1fr}.hud-strip .hud-card:last-child{grid-column:1/-1}.game-header{align-items:flex-start;flex-direction:column}.layout{grid-template-columns:1fr}.col-left,.col-right{order:2}}






  /* ========================================================================
     CHARACTER CARD ART SYSTEM
     Portrait art is intentionally distinct from battlefield sprite art.
     ======================================================================== */
  .character-card-portrait{display:block;width:100%;height:100%;object-fit:cover;border-radius:8px;background:#0b0f14;}
  .character-roster-card{display:flex;align-items:center;gap:10px;min-height:78px;}
  .character-roster-portrait{width:64px;height:64px;flex:0 0 64px;border:1px solid #465064;border-radius:8px;overflow:hidden;background:#0b0f14;box-shadow:0 4px 12px rgba(0,0,0,.3);}
  .character-roster-info{min-width:0;flex:1;}
  #selected .char-header .char-avatar{overflow:hidden;border-radius:8px;}
  #selected .char-header .char-avatar .character-card-portrait{border-radius:8px;object-fit:cover;}
  .level-up-character-head{display:grid;grid-template-columns:76px minmax(0,1fr);gap:12px;align-items:center;margin-bottom:12px;}
  .level-up-portrait{width:76px;height:76px;border:1px solid #596477;border-radius:9px;overflow:hidden;background:#0b0f14;box-shadow:0 6px 18px rgba(0,0,0,.45);}
  .level-up-character-portrait{display:block;width:100%;height:100%;object-fit:cover;}
  .level-up-character-copy{min-width:0;}
  .level-up-character-copy .level-up-modal-title{margin-top:1px;}
  @media(max-width:520px){
    .level-up-character-head{grid-template-columns:60px minmax(0,1fr);gap:9px;}
    .level-up-portrait{width:60px;height:60px;}
  }


  /* v0.9.3 active-unit consolidation */
  #charPanel{padding:10px}
  #selected .char-header{display:grid;grid-template-columns:62px minmax(0,1fr);gap:10px;align-items:center;margin-bottom:10px}
  #selected .char-header .char-avatar{width:62px;height:62px;display:flex;align-items:center;justify-content:center;background:transparent;border:0}
  #selected .char-header .char-avatar svg{width:62px;height:62px}
  #selected .char-name-block{min-width:0}
  #selected .char-ready-label{font-size:9px;letter-spacing:1.4px;text-transform:uppercase;color:#7ee787;font-weight:900;margin-bottom:2px}
  #selected .char-name{font-size:18px}
  #selected .char-team{font-size:10px}
  #selected .char-hp-row{margin-top:6px}
  #selected .char-xp-row{display:flex;align-items:center;gap:7px;margin:5px 0 2px}
  #selected .char-xp-row .xp-bar{flex:1;height:7px;background:#222a38;border-radius:999px;overflow:hidden}
  #selected .char-xp-row .xp-fill{height:100%;background:linear-gradient(90deg,#8be9fd,#bd93f9);border-radius:999px}
  #selected .char-xp-row .xp-text{font-size:9px;color:#b8c1d1;white-space:nowrap}
  .turn-message-panel #message{font-size:13px;font-weight:800;color:#f6e58d;padding:7px 8px}
  .last-message-panel #lastMessage{font-size:11px;color:#aeb7c7;min-height:18px}


  .active-ribbon{align-items:center}.active-ribbon-avatar{width:42px;height:42px;flex:0 0 42px;display:flex;align-items:center;justify-content:center}.active-ribbon-avatar svg{width:42px;height:42px}.active-ribbon-info{flex:1;min-width:0}.active-ribbon-state{white-space:nowrap}
  .char-hp-bar{height:18px;border-radius:6px}.char-hp-fill{border-radius:6px}.char-team.player{color:#aaa}
  .char-title-row{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}
  .char-title-text{min-width:0;flex:1}
  .level-badge{
    flex-shrink:0;min-width:42px;height:42px;border-radius:10px;
    display:flex;flex-direction:column;align-items:center;justify-content:center;
    background:linear-gradient(145deg,#3d4a6a 0%,#252b3c 55%,#1a1f2c 100%);
    border:1px solid #6b7a9a;box-shadow:0 2px 8px rgba(0,0,0,.35),inset 0 1px 0 rgba(255,255,255,.12);
    color:#f6e58d;line-height:1;
  }
  .level-badge .lb-label{font-size:8px;letter-spacing:1px;text-transform:uppercase;color:#9aa6c0;font-weight:800;margin-bottom:2px}
  .level-badge .lb-num{font-size:18px;font-weight:900;color:#f6e58d;text-shadow:0 1px 2px #000}
  .level-badge.enemy-badge{border-color:#8a4a4a;background:linear-gradient(145deg,#5a3038,#2a1a1e);color:#ffb0b0}
  .level-badge.enemy-badge .lb-num{color:#ffb0b0}
  .level-badge.maxed{border-color:#f6e58d;box-shadow:0 0 10px rgba(246,229,141,.25),inset 0 1px 0 rgba(255,255,255,.15)}
  .char-identity{
    display:flex; flex-wrap:wrap; gap:5px; align-items:center;
    margin:0 0 8px;
  }
  .arch-badge{
    display:inline-block; font-size:10px; font-weight:900; letter-spacing:.6px;
    text-transform:uppercase; padding:3px 8px; border-radius:5px;
    background:linear-gradient(145deg,#2a3348,#1a2030);
    border:1px solid #4a5a78; color:#9ec1ff;
  }
  .trad-badge{
    display:inline-block; font-size:10px; font-weight:800; letter-spacing:.4px;
    text-transform:uppercase; padding:3px 8px; border-radius:5px;
    background:linear-gradient(145deg,#3a2a48,#241830);
    border:1px solid #6a4a88; color:#d4b5ff;
  }
  .trad-locked{
    display:inline-block; font-size:9px; font-weight:700; letter-spacing:.3px;
    text-transform:uppercase; padding:3px 7px; border-radius:5px;
    background:#1a1e26; border:1px dashed #3a4250; color:#6a7384;
  }
  .job-badge{
    display:inline-block; font-size:10px; font-weight:800;
    padding:3px 8px; border-radius:5px;
    background:#252933; border:1px solid #505665; color:#e0e4ec;
  }
  .buttons button{font-size:13px;letter-spacing:.3px;font-family:Arial,"Segoe UI Emoji","Apple Color Emoji","Noto Color Emoji",sans-serif}
  .hud-strip{display:none}.game-header{display:none}


  /* ================= GAME MENU SYSTEM ================= */
  .game-menu-overlay{position:fixed;inset:0;z-index:2000;background:radial-gradient(circle at center,#202633 0%,#0c0e12 72%);display:flex;align-items:center;justify-content:center;padding:24px;}
  .game-menu-box{width:min(560px,94vw);max-height:92vh;overflow:auto;background:linear-gradient(160deg,#1b2029,#101319);border:1px solid #4d5668;border-radius:18px;padding:26px;box-shadow:0 24px 80px rgba(0,0,0,.7),inset 0 1px 0 rgba(255,255,255,.06);}
  .game-menu-logo-wrap{text-align:center;margin:0 auto 14px;width:min(360px,90%);}
  .game-menu-logo{display:block;width:100%;max-height:180px;object-fit:contain;margin:0 auto;border-radius:10px;}
  .game-menu-title{display:none;}
  .game-menu-title{
    font-size:clamp(36px,6vw,52px); font-weight:900; letter-spacing:3px;
    text-transform:none; color:#e8ecf4;
    text-shadow:0 2px 12px rgba(0,0,0,.55), 0 0 24px rgba(122,162,247,.25);
    line-height:1.1; margin:8px 0 4px;
  }
  .game-menu-sub{text-align:center;color:#8e99aa;text-transform:uppercase;letter-spacing:4px;font-size:11px;margin:5px 0 20px;}
  .game-menu-list{display:grid;grid-template-columns:1fr 1fr;gap:9px;}
  .game-menu-item{display:grid;grid-template-columns:36px 1fr auto;align-items:center;text-align:left;gap:9px;width:100%;padding:14px 14px;background:#202631;border:1px solid #3b4454;border-radius:10px;color:#fff;cursor:pointer;transition:.15s ease;}
  .game-menu-item.full{grid-column:1 / -1;}
  .game-menu-item:hover{background:#293140;border-color:#69758a;transform:translateX(3px);}
  .game-menu-item span{font-size:20px;text-align:center;}
  .game-menu-item strong{font-size:13px;letter-spacing:1.2px;}
  .game-menu-item small{font-size:10px;color:#8994a5;}
  .game-menu-footer{text-align:center;color:#667184;font-size:10px;letter-spacing:2px;text-transform:uppercase;margin-top:18px;}
  .menu-sub-overlay{display:none;position:fixed;inset:0;z-index:2100;background:rgba(5,7,10,.82);align-items:center;justify-content:center;padding:20px;}
  .menu-sub-overlay.show{display:flex;}
  .menu-sub-box{width:min(620px,94vw);max-height:88vh;overflow:auto;background:#171b22;border:1px solid #4e5869;border-radius:15px;box-shadow:0 20px 70px rgba(0,0,0,.7);padding:18px;}
  .menu-sub-header{display:grid;grid-template-columns:42px 1fr 42px;align-items:center;border-bottom:1px solid #303744;padding-bottom:12px;margin-bottom:15px;color:#fff;font-size:18px;font-weight:800;text-align:center;}
  .menu-sub-header button{border:0;background:#252b36;color:#dce2ed;border-radius:7px;font-size:25px;height:34px;cursor:pointer;}
  .menu-card{background:#202631;border:1px solid #374050;border-radius:10px;padding:14px;margin-bottom:9px;}
  .menu-card-title{font-weight:800;color:#fff;font-size:14px;}
  .menu-card-sub{color:#8d98a9;font-size:11px;margin-top:4px;}
  .menu-section-title{font-size:10px;letter-spacing:2px;text-transform:uppercase;color:#7aa2f7;font-weight:900;margin:18px 2px 8px;padding-bottom:6px;border-bottom:1px solid #343b48;}
  .menu-back{width:100%;padding:12px;margin-top:10px;background:#252b36;border:1px solid #4b5668;border-radius:9px;color:#fff;font-weight:800;letter-spacing:1px;cursor:pointer;}
  
  
  .cache-badge{
    display:inline-flex;align-items:center;gap:6px;padding:6px 12px;margin:0 auto 12px;
    background:#1a2030;border:1px solid #3d4a66;border-radius:999px;color:#f6e58d;
    font-weight:900;font-size:13px;letter-spacing:.5px;
  }
  .cache-badge .cp-ico{font-size:14px}


  .menu-season-option{
    display:flex;align-items:center;justify-content:space-between;width:100%;
    padding:16px 16px;margin-bottom:10px;background:#202631;border:1px solid #3b4454;
    border-radius:10px;color:#fff;cursor:pointer;text-align:left;transition:.15s ease;
  }
  .menu-season-option:hover:not(:disabled){background:#293140;border-color:#69758a;transform:translateX(3px);}
  .menu-season-option:disabled{opacity:.45;cursor:not-allowed;transform:none;}
  .menu-season-option .season-title{font-size:15px;font-weight:900;letter-spacing:.5px;display:block;}
  .menu-season-option .season-tag{font-size:11px;color:#8e99aa;font-style:italic;margin-top:3px;display:block;}
  .menu-season-option .season-soon{font-size:10px;letter-spacing:1px;text-transform:uppercase;color:#f6e58d;}
  .menu-sub-header.no-nav{grid-template-columns:1fr;padding-bottom:12px;}


  .menu-battle-option{display:flex;align-items:center;justify-content:space-between;width:100%;padding:14px 16px;margin-bottom:9px;background:#202631;border:1px solid #3b4454;border-radius:10px;color:#fff;cursor:pointer;text-align:left;}
  .menu-battle-option:hover{background:#293140;border-color:#69758a;}
  .menu-battle-option strong{font-size:14px;letter-spacing:1px;}
  .menu-battle-option small{font-size:10px;color:#8994a5;}
  .menu-empty{text-align:center;padding:30px 12px;color:#8d98a9;}
  .menu-soon{text-align:center;padding:38px 20px;}
  .menu-soon-title{font-size:28px;font-weight:900;color:#fff;margin-bottom:8px;}
  .menu-soon-sub{color:#929cad;font-size:13px;}
  .roster-status{float:right;font-size:9px;letter-spacing:1px;padding:4px 7px;border-radius:5px;text-transform:uppercase;}
  .roster-status.active{background:#173d2a;color:#7ee787;border:1px solid #2f7650;}
  .roster-status.inactive{background:#292e38;color:#9ba5b5;border:1px solid #4a5362;}
  .roster-status.fallen{background:#421f25;color:#ff8f8f;border:1px solid #86404a;}


  .coven-active-grid{
    display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-bottom:8px;
  }
  .coven-unit-card{
    background:#202631; border:1px solid #374050; border-radius:10px;
    padding:12px 10px; cursor:pointer; text-align:center; color:#fff;
    transition:border-color .15s ease, transform .12s ease, background .15s ease;
    display:flex; flex-direction:column; align-items:center; gap:6px;
  }
  .coven-unit-card:hover{
    background:#293140; border-color:#7aa2f7; transform:translateY(-2px);
  }
  .coven-unit-card .character-roster-portrait{
    width:72px; height:72px; flex:0 0 72px; margin:0 auto;
    border:1px solid #465064; border-radius:8px; overflow:hidden; background:#0b0f14;
  }
  .coven-unit-card .menu-card-title{font-size:13px; font-weight:900;}
  .coven-unit-card .menu-card-sub{font-size:10px; color:#8d98a9; line-height:1.35;}
  .coven-fallen-list .character-roster-card{cursor:default;}
  #unitInfoModal{
    display:none; position:fixed; inset:0; z-index:2100;
    background:rgba(0,0,0,.72); align-items:center; justify-content:center; padding:18px;
  }
  #unitInfoModal.show{display:flex;}
  .unit-info-box{
    position:relative; width:min(420px,94vw); max-height:88vh; overflow:auto;
    background:linear-gradient(160deg,#1b2029,#101319);
    border:1px solid #4d5668; border-radius:16px; padding:22px 20px 20px;
    box-shadow:0 24px 70px rgba(0,0,0,.75);
  }
  .unit-info-close{
    position:absolute; top:10px; right:12px; width:34px; height:34px;
    border:1px solid #505665; border-radius:8px; background:#252b36; color:#eee;
    font-size:18px; font-weight:900; cursor:pointer; line-height:1;
  }
  .unit-info-close:hover{background:#3a3f4d; color:#fff;}
  .unit-info-header{
    display:flex; gap:14px; align-items:center; margin:4px 28px 14px 0;
  }
  .unit-info-portrait{
    width:88px; height:88px; flex:0 0 88px; border-radius:10px; overflow:hidden;
    border:1px solid #596477; background:#0b0f14;
  }
  .unit-info-portrait img, .unit-info-portrait svg{width:100%; height:100%; object-fit:cover; display:block;}
  .unit-info-name{font-size:22px; font-weight:1000; margin:0 0 4px; color:#fff;}
  .unit-info-meta{font-size:11px; color:#8e99aa; line-height:1.4;}
  .unit-info-level{color:#f6e58d; font-weight:900;}
  .unit-info-section{
    font-size:10px; letter-spacing:1.6px; text-transform:uppercase; color:#7aa2f7;
    font-weight:900; margin:16px 0 8px; padding-bottom:5px; border-bottom:1px solid #343b48;
  }
  .unit-info-stats{
    display:grid; grid-template-columns:1fr 1fr; gap:6px;
  }
  .unit-info-stat{
    background:#202631; border:1px solid #343b48; border-radius:8px;
    padding:7px 9px; font-size:11px; display:flex; justify-content:space-between; gap:8px;
  }
  .unit-info-stat span{color:#8a95a8;}
  .unit-info-stat strong{color:#eee;}
  .unit-info-ability{
    background:#202631; border-left:3px solid #ff6b6b; border-radius:0 8px 8px 0;
    padding:10px 12px; margin-bottom:8px;
  }
  .unit-info-ability .ain{color:#ff6b6b; font-weight:900; font-size:13px;}
  .unit-info-ability .aid{color:#9aa6b8; font-size:11px; margin-top:3px;}
  .unit-info-ability .aim{color:#7a8496; font-size:10px; margin-top:4px;}
  .unit-info-traits{display:flex; flex-wrap:wrap; gap:5px;}
  .unit-info-trait{
    background:#252b36; border:1px solid #3b4454; border-radius:5px;
    padding:3px 8px; font-size:10px; color:#c4b5fd;
  }


  #app.menu-hidden{display:none!important;}




  /* v0.9.3 layout: Battle Log lives beneath the Action panel in the right column. */
  .battle-log-panel{margin-top:0;}
  .battle-log-panel .section-title{margin-bottom:6px;}
  .battle-log-panel #log{height:180px;overflow:auto;background:#0f131a;border:1px solid #2d3340;border-radius:6px;padding:8px;font-size:11px;line-height:1.4;}
