:root{
    --bg: #0b0f14;
    --panel: #131922;
    --panel-2: #182029;
    --line: #2a3542;
    --accent: #7fb7d9;
    --ok: #7fd4a0;
    --danger: #d95a5a;
    --text: #e6e8ec;
    --text-dim: #8b96a3;
    --warn: #e6c878;
  }
  *{box-sizing:border-box;}
  html,body{
    margin:0; padding:0; height:100%;
    background: radial-gradient(circle at 30% 10%, #131a22 0%, #0b0f14 55%, #060809 100%);
    color: var(--text);
    font-family: 'Segoe UI', system-ui, sans-serif;
    overflow-x:hidden;
  }
  .wrap{
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 16px 40px;
  }
  h1{
    font-size: 1.6rem;
    letter-spacing: 0.5px;
    margin: 0 0 2px;
    color: var(--accent);
    font-weight: 600;
    text-shadow: 0 0 18px rgba(127,183,217,0.25);
  }
  .subtitle{
    color: var(--text-dim);
    font-size: 0.85rem;
    margin: 0 0 16px;
  }
  .hud{
    display:flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
  }
  .stat{
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 14px;
    display:flex;
    align-items:center;
    gap:8px;
    font-size: 0.95rem;
    min-width: 92px;
  }
  .stat .ico{ font-size: 1.1rem; color: var(--text-dim); }
  .stat .val{ font-family: 'Consolas', 'Courier New', monospace; font-weight:bold; }
  .stat.credits .val{ color: var(--accent); }
  .stat.life .val{ color: var(--danger); }
  .stat.wave .val{ color: var(--ok); }
  .stat.energy .val{ color: #f0d848; }
  .btn.small{ padding:4px 9px; font-size:0.72rem; }
  .energized-ok{ color: var(--ok) !important; }
  .energized-no{ color: var(--danger) !important; }
  .controls-top{
    margin-left:auto;
    display:flex; gap:8px;
  }
  button{
    font-family: inherit;
    cursor:pointer;
  }
  .btn{
    background: var(--panel-2);
    border: 1px solid var(--line);
    color: var(--text);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.85rem;
    transition: border-color .15s, transform .1s;
  }
  .btn:hover{ border-color: var(--accent); }
  .btn:active{ transform: scale(0.96); }
  .btn.active{ border-color: var(--ok); color: var(--ok); }
  .btn:disabled{ opacity:0.35; cursor:not-allowed; }

  .layout{
    display:flex;
    gap: 16px;
    align-items:flex-start;
    flex-wrap: wrap;
  }
  /* Antes o board-holder tinha largura fixa (flex:0 0 auto, do tamanho
     do canvas) — numa faixa de largura intermediária (~760-1150px, onde
     o preview normalmente roda) a sidebar não cabia mais do lado e caía
     pra baixo do tabuleiro, obrigando a rolar a página pra construir
     torre no meio do combate. Agora o board encolhe (o canvas escala
     via CSS, o clique já é convertido com base no tamanho real via
     getBoundingClientRect) e some espaço fica reservado pra sidebar
     nunca precisar quebrar linha até a tela ficar realmente estreita. */
  .board-holder{
    position:relative;
    border: 2px solid var(--line);
    border-radius: 10px;
    overflow:hidden;
    background: #090c10;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    flex: 3 1 300px;
    min-width: 280px;
    max-width: 816px;
  }
  canvas{ display:block; touch-action:none; width:100%; height:auto; }

  .prep-banner{
    position:absolute;
    top:0; left:0; right:0;
    background: linear-gradient(180deg, rgba(19,25,34,0.94), rgba(19,25,34,0.75) 70%, rgba(19,25,34,0));
    padding: 10px 12px 20px;
    pointer-events:none;
    font-size: 0.85rem;
    color: var(--text-dim);
  }
  .prep-banner b{ color: var(--accent); }
  .prep-top{ display:flex; justify-content:space-between; align-items:center; }
  .wave-preview{
    margin-top: 8px;
    line-height: 1.6;
    font-size: 0.82rem;
  }
  .wave-preview b{ color: var(--text); }
  .preview-notes{ color: var(--warn); font-style: italic; }

  .sidebar{
    flex: 1 1 270px;
    min-width: 270px;
    max-width: 380px;
    display:flex;
    flex-direction: column;
    gap: 12px;
  }
  .panel{
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
  }
  .panel h2{
    margin: 0 0 10px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    font-weight: normal;
  }

  .accordion summary{
    margin: 0 0 10px;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-dim);
    font-weight: normal;
    cursor: pointer;
    list-style: none;
    display: flex; justify-content:space-between; align-items:center;
  }
  .accordion summary::-webkit-details-marker{ display:none; }
  .accordion summary::after{ content:'▸'; font-size:0.7rem; transition: transform 0.15s; }
  .accordion[open] summary::after{ transform: rotate(90deg); }
  .accordion[open] summary{ margin-bottom:10px; }
  .tower-btn{
    width:100%;
    display:flex;
    align-items:center;
    gap:10px;
    text-align:left;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 9px 10px;
    margin-bottom: 8px;
    color: var(--text);
  }
  .tower-btn:last-child{ margin-bottom:0; }
  .tower-btn .ico{
    font-size: 1.5rem;
    width: 38px; height:38px;
    display:flex; align-items:center; justify-content:center;
    background: rgba(255,255,255,0.03);
    border-radius: 6px;
    flex-shrink:0;
  }
  .tower-btn .info{ flex:1; }
  .tower-btn .info .nm{ font-weight:bold; font-size:0.9rem; }
  .tower-btn .info .desc{ font-size:0.72rem; color: var(--text-dim); margin-top:2px; line-height:1.3; }
  .tower-btn .cost{ font-family:'Consolas','Courier New',monospace; color: var(--accent); font-size:0.85rem; white-space:nowrap; }
  .tower-btn.selected{ border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }
  .tower-btn:disabled{ opacity:0.4; cursor:not-allowed; }

  .empty-hint{ color: var(--text-dim); font-size: 0.85rem; line-height:1.5; }

  .sel-tower{ display:flex; flex-direction:column; gap:8px; }
  .hpbar-track{ height:6px; border-radius:3px; background:rgba(0,0,0,0.4); overflow:hidden; }
  .hpbar-fill{ height:100%; }
  .sel-head{ display:flex; align-items:center; gap:10px; }
  .sel-head .ico{ font-size:1.8rem; }
  .sel-head .nm{ font-weight:bold; }
  .sel-head .lvl{ font-size:0.75rem; color: var(--text-dim); }
  .stat-row{
    display:flex; justify-content:space-between;
    font-size: 0.82rem; color: var(--text-dim);
    border-bottom: 1px dashed var(--line);
    padding: 3px 0;
  }
  .stat-row span:last-child{ color: var(--text); font-family:'Consolas','Courier New',monospace; }
  .sel-actions{ display:flex; gap:8px; margin-top:6px; }
  .sel-actions button{ flex:1; }
  .btn-sell{ background: rgba(217,90,90,0.12); border-color: var(--danger); color:#f0b0ae; }

  .priority-row{ display:flex; flex-wrap:wrap; gap:5px; margin:6px 0 4px; }
  .priority-btn{ padding:5px 9px; font-size:0.72rem; }
  .priority-btn.active{ border-color: var(--accent); color: var(--accent); background: rgba(127,183,217,0.12); }

  /* 3 colunas lado a lado, uma por caminho, em vez de 3 blocos empilhados
     (redesign inspirado no BTD6) — cada nível vira um "pip" compacto, com
     o nome completo só no próximo nível a comprar (o resto fica no
     title/tooltip do pip, pra não competir por espaço). */
  .upgrade-paths{ display:flex; flex-direction:row; gap:6px; margin-top:6px; align-items:stretch; }
  .upgrade-path{
    flex: 1 1 0; min-width:0;
    display:flex; flex-direction:column;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 6px;
  }
  .upgrade-path-head{
    display:flex; justify-content:space-between; align-items:center;
    font-size: 0.7rem;
  }
  .path-ico{ font-size:1.1rem; }
  .upgrade-path-head .path-level{ font-family:'Consolas','Courier New',monospace; color: var(--text-dim); }
  .path-name{
    font-size:0.66rem; font-weight:bold; text-align:center; line-height:1.2;
    margin:3px 0 5px; min-height:1.9em;
    display:flex; align-items:center; justify-content:center;
  }
  .upgrade-pips{ display:flex; justify-content:center; gap:3px; margin-bottom:6px; flex-wrap:wrap; }
  .pip{ width:8px; height:8px; border-radius:50%; background: var(--line); flex-shrink:0; }
  .pip.owned{ background: var(--ok); }
  .pip.next{ background: var(--accent); box-shadow: 0 0 0 2px rgba(127,183,217,0.28); }
  .next-name{ font-size:0.66rem; font-weight:bold; text-align:center; margin-bottom:2px; }
  .next-desc{
    font-size:0.6rem; text-align:center; line-height:1.3; margin-bottom:6px;
  }
  .upgrade-buy-btn{ width:100%; font-size:0.68rem; padding:5px 3px; margin-top:auto; }

  .doctrine-list{ display:flex; flex-direction:column; gap:6px; margin:8px 0; }
  .doctrine-item{
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 7px 9px;
    display:flex; flex-direction:column; gap:3px;
  }
  .doctrine-item.owned{ border-color: var(--ok); }
  .doctrine-item .dh{ display:flex; justify-content:space-between; font-size:0.82rem; font-weight:bold; }
  .doctrine-item .dd{ font-size:0.72rem; color: var(--text-dim); line-height:1.3; }
  .doctrine-buy-btn{ width:100%; font-size:0.76rem; margin-top:2px; }
  .domain-badge{ display:inline-flex; align-items:center; gap:4px; font-size:0.78rem; margin:2px 6px 2px 0; color: var(--ok); }
  .go-rewards{ color: var(--accent); font-size:0.85rem; margin:0; }

  .log{
    font-size: 0.78rem;
    color: var(--text-dim);
    max-height: 90px;
    overflow-y:auto;
    line-height:1.5;
  }

  /* Telas (redesign de interface): Menu/Seleção e Resultado ocupam a
     página inteira (não mais presas dentro da caixa do tabuleiro), com
     um cartão central. Partida usa o próprio layout (.hud/.context-strip/
     .layout) e não precisa de centralização. */
  .screen{ display:block; }
  .screen-center{
    display:flex; flex-direction:column;
    align-items:center; justify-content:center;
    text-align:center;
    min-height: 480px;
    padding: 20px;
  }
  .menu-card{
    display:flex; flex-direction:column;
    align-items:center;
    gap: 14px;
    background: rgba(6,8,10,0.9);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 28px 24px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
  }
  .menu-card h2{ font-size:1.8rem; color: var(--accent); margin:0; }
  .menu-card p{ color: var(--text-dim); margin:0; max-width:420px; font-size:0.9rem; line-height:1.5;}
  .hidden{ display:none !important; }

  /* Assistente de 3 passos: o cartão tem altura fixa (em vez de crescer
     conforme o conteúdo do passo), então trocar de passo não empurra o
     resto da página nem pisca o layout — mais previsível, mais "tela de
     jogo" e menos "formulário rolando". */
  .menu-card-wizard{ width:700px; height:560px; justify-content:flex-start; }
  .wizard-steps{
    display:flex; gap:18px; font-size:0.78rem; color: var(--text-dim);
  }
  .wizard-step{ display:flex; align-items:center; gap:5px; opacity:0.5; }
  .wizard-step b{
    display:inline-flex; align-items:center; justify-content:center;
    width:18px; height:18px; border-radius:50%;
    border:1px solid var(--line); font-size:0.68rem;
  }
  .wizard-step.active{ opacity:1; color: var(--text); }
  .wizard-step.active b{ border-color: var(--ok); color: var(--ok); }
  .wizard-step.done{ opacity:0.85; }
  .wizard-step.done b{ border-color: var(--accent); color: var(--accent); }

  .wizard-body{
    flex:1; width:100%;
    display:flex; align-items:center; justify-content:center;
  }
  .wizard-page{
    width:100%; height:100%;
    display:flex; flex-direction:column; align-items:center; justify-content:center;
    gap:14px;
  }
  .wizard-nav{ display:flex; gap:10px; margin-top:4px; }

  .mode-choice{ display:flex; gap:16px; flex-wrap:wrap; justify-content:center; }
  .mode-choice-btn{
    display:flex; flex-direction:column; align-items:center; gap:6px;
    width:220px; padding:20px 16px;
  }
  .mode-choice-btn .ico{ font-size:2rem; }
  .mode-choice-btn .nm{ font-weight:bold; font-size:1.05rem; }
  .mode-choice-btn .desc{ font-size:0.74rem; color: var(--text-dim); line-height:1.4; }
  .mode-choice-btn.active{ border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }

  /* Faixa contextual (redesign de interface): uma linha de chips compactos
     em vez de várias caixas permanentes — nível 3 da hierarquia visual
     (contextual), não nível 1/2. */
  /* Sempre uma linha só (rola na horizontal em vez de quebrar) — deixar
     quebrar linha numa tela estreita empurrava o tabuleiro pra baixo
     bem mais do que essa faixa merece; assim o mapa nunca se move por
     causa dos chips, só a faixa em si ganha uma rolagem lateral. */
  .context-strip{
    display:flex; align-items:center; gap:8px; flex-wrap:nowrap;
    font-size:0.78rem; color: var(--text-dim);
    margin: -6px 0 12px;
    overflow-x:auto; overflow-y:hidden;
    padding-bottom:4px;
  }
  .chip{
    display:flex; align-items:center; gap:6px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 10px;
    flex-shrink:0;
    white-space:nowrap;
  }
  .chip .val, .chip #cmd-name, .chip #bridge-status, .chip #ep-order, .chip #director-adjust{
    color: var(--text); font-family:'Consolas','Courier New',monospace;
  }
  .chip-dim{ color: var(--text-dim); font-family:'Consolas','Courier New',monospace; }
  .chip .btn.small{ margin-left:2px; }

  /* Habilidades do comandante flutuam sobre o mapa (canto inferior
     esquerdo), em vez de ocupar uma faixa inteira no topo. */
  .cmd-abilities{
    position:absolute; left:10px; bottom:10px;
    display:flex; flex-direction:column; gap:5px;
    z-index:5;
  }
  .cmd-ability{
    white-space:nowrap; text-align:left;
    background: rgba(10,13,18,0.82);
    backdrop-filter: blur(2px);
  }

  .commander-picker{
    display:flex; gap:8px; flex-wrap:wrap; justify-content:center;
  }
  .picker-label{ font-size:0.72rem; color: var(--text-dim); text-transform:uppercase; letter-spacing:0.04em; }
  .cmd-pick-btn{
    display:flex; flex-direction:column; align-items:center; gap:2px;
    padding:8px 12px; width:110px;
  }
  .cmd-pick-btn .ico{ font-size:1.3rem; }
  .cmd-pick-btn .nm{ font-weight:bold; font-size:0.85rem; }
  .cmd-pick-btn .desc{ font-size:0.68rem; color: var(--text-dim); line-height:1.3; }
  .cmd-pick-btn.active{ border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }

  ::-webkit-scrollbar{ width:6px; }
  ::-webkit-scrollbar-thumb{ background: var(--line); border-radius:3px; }

