/* =============================================================
   ESTILO — cores e medidas principais ficam nas variáveis abaixo
   ============================================================= */
:root {
  --fundo: #0f1b2d;
  --fundo-2: #16263d;
  --fundo-3: #1f3352;
  --mar: #1b3150;
  --borda: #2c4468;
  --texto: #e9eef6;
  --texto-2: #9fb0c8;
  --ouro: #e8b04b;
  --ouro-2: #c98f2a;
  --perigo: #e5484d;
  --ok: #3fb950;
  --raio: 12px;
  --titulo: 'Cinzel', Georgia, serif;
  --corpo: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  --painel: 360px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--fundo); color: var(--texto); font-family: var(--corpo); font-size: 15px; }
body { overflow: hidden; -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; color: inherit; }
.oculto { display: none !important; }

/* ---------- telas ---------- */
.tela { display: none; height: 100%; }
.tela.ativa { display: flex; }
#tela-inicio, #tela-lobby {
  align-items: center; justify-content: center; padding: 20px; overflow-y: auto;
  background: radial-gradient(ellipse at top, #24406a 0%, var(--fundo) 60%);
}
#tela-jogo { flex-direction: column; }

.cartao-inicio {
  width: 100%; max-width: 400px; background: rgba(22, 38, 61, .92); border: 1px solid var(--borda);
  border-radius: 18px; padding: 28px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.45);
  display: flex; flex-direction: column; gap: 14px; margin: auto;
}
.cartao-inicio.largo { max-width: 480px; }
.logo { font-family: var(--titulo); font-weight: 800; font-size: 42px; letter-spacing: 6px; text-align: center; margin: 0;
  background: linear-gradient(180deg, #ffe3a3, var(--ouro) 55%, var(--ouro-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.subtitulo { text-align: center; color: var(--texto-2); margin: 0 0 6px; line-height: 1.5; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo span, .rotulo { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--texto-2); margin: 0; }
input, select { background: var(--fundo); border: 1px solid var(--borda); border-radius: 10px; padding: 12px 14px; outline: none; min-width: 0; }
input:focus, select:focus { border-color: var(--ouro); }
.linha { display: flex; gap: 8px; }
.linha input { flex: 1; }
input.codigo { text-transform: uppercase; letter-spacing: 6px; text-align: center; font-weight: 700; }
.divisor { display: flex; align-items: center; gap: 10px; color: var(--texto-2); font-size: 13px; }
.divisor::before, .divisor::after { content: ''; flex: 1; height: 1px; background: var(--borda); }
.erro { color: var(--perigo); min-height: 1em; margin: 0; text-align: center; font-size: 14px; }
.dica { color: var(--texto-2); text-align: center; }
h3 { margin: 8px 0 0; font-family: var(--titulo); }
.contador { color: var(--texto-2); font-family: var(--corpo); font-size: 14px; }
.codigo-grande { font-family: var(--titulo); font-size: 48px; letter-spacing: 12px; text-align: center; color: var(--ouro); }

/* ---------- botões ---------- */
.btn { background: var(--fundo-3); border: 1px solid var(--borda); border-radius: 10px; padding: 11px 16px; cursor: pointer; font-weight: 600; transition: transform .08s, filter .15s; white-space: nowrap; }
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ouro { background: linear-gradient(180deg, var(--ouro), var(--ouro-2)); border-color: #f3c46b; color: #2b1a00; }
.btn-perigo { background: linear-gradient(180deg, #ef5b5f, #c93a3f); border-color: #f17b7e; color: #fff; }
.btn-ok { background: linear-gradient(180deg, #4cc764, #2f9a47); border-color: #6fd685; color: #fff; }
.btn-fantasma { background: transparent; }
.btn.grande { padding: 14px; font-size: 16px; }
.btn.pequeno { padding: 6px 10px; font-size: 13px; align-self: center; }

/* ---------- lobby ---------- */
.lista-jogadores { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lista-jogadores li { display: flex; align-items: center; gap: 10px; background: var(--fundo); border: 1px solid var(--borda); border-radius: 10px; padding: 9px 12px; }
.lista-jogadores .nome { flex: 1; font-weight: 600; }
.lista-jogadores .tag { font-size: 12px; color: var(--texto-2); }
.lista-jogadores button { background: none; border: none; color: var(--texto-2); cursor: pointer; font-size: 16px; }
.ponto { width: 14px; height: 14px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px rgba(255,255,255,.15); }
.grade-config { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 6px 0; }
#lobby-host { display: flex; flex-direction: column; gap: 10px; }

/* ---------- barra superior ---------- */
.barra { display: flex; align-items: center; gap: 12px; padding: 8px 12px; background: var(--fundo-2); border-bottom: 1px solid var(--borda); flex-wrap: wrap; z-index: 5; }
.barra-recursos { display: flex; gap: 6px; flex-wrap: wrap; }
.recurso { display: flex; align-items: center; gap: 5px; background: var(--fundo); border: 1px solid var(--borda); border-radius: 999px; padding: 4px 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.recurso small { font-weight: 600; font-size: 11px; }
.recurso small.pos { color: var(--ok); } .recurso small.neg { color: var(--perigo); }
.barra-turno { flex: 1; display: flex; align-items: center; justify-content: center; gap: 12px; min-width: 0; }
.turno-info { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.etapas { display: flex; gap: 3px; }
.etapas span { font-size: 11px; padding: 3px 8px; border-radius: 999px; background: var(--fundo); color: var(--texto-2); border: 1px solid var(--borda); }
.etapas span.atual { background: var(--ouro); color: #2b1a00; border-color: var(--ouro); }
.turno-tempo { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--texto-2); }
.turno-tempo.urgente { color: var(--perigo); animation: pulsar 1s infinite; }

/* ---------- área do jogo ---------- */
.area-jogo { flex: 1; display: flex; min-height: 0; position: relative; }
.mapa-caixa { flex: 1; position: relative; overflow: hidden; background: var(--mar); touch-action: none; }
#mapa { width: 100%; height: 100%; display: block; cursor: grab; user-select: none; }
#mapa.arrastando { cursor: grabbing; }
.controles-mapa { position: absolute; left: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; }
.controles-mapa button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--borda); background: rgba(22,38,61,.9); cursor: pointer; font-size: 18px; }
.dica-etapa { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); background: rgba(15,27,45,.88); border: 1px solid var(--borda); padding: 8px 14px; border-radius: 999px; font-size: 13px; pointer-events: none; max-width: 92%; text-align: center; }
.dica-etapa:empty { display: none; }

/* ---------- mapa (SVG) ---------- */
.regiao { stroke: #0b1420; stroke-width: 1.2; stroke-linejoin: round; transition: filter .15s; cursor: pointer; }
.regiao:hover { filter: brightness(1.15); }
.regiao.selecionada { stroke: #fff; stroke-width: 4; }
.regiao.alvo-ataque { stroke: var(--perigo); stroke-width: 4; animation: brilho 1.2s infinite; }
.regiao.alvo-mover { stroke: var(--ok); stroke-width: 4; animation: brilho 1.2s infinite; }
.regiao.apagada { filter: brightness(.55) saturate(.6); }
.contorno-continente { fill: none; stroke: rgba(255,255,255,.18); stroke-width: 6; pointer-events: none; }
.rota { stroke: rgba(255,255,255,.45); stroke-width: 2; stroke-dasharray: 7 7; fill: none; pointer-events: none; }
.rotulo-regiao { font-size: 12px; font-weight: 600; fill: #0b1420; text-anchor: middle; pointer-events: none; paint-order: stroke; stroke: rgba(255,255,255,.55); stroke-width: 3px; }
.ficha { pointer-events: none; }
.ficha circle { stroke: #0b1420; stroke-width: 2; }
.ficha text { font-size: 13px; font-weight: 800; text-anchor: middle; dominant-baseline: central; fill: #fff; paint-order: stroke; stroke: rgba(0,0,0,.5); stroke-width: 2px; }
.ficha .icone { font-size: 13px; stroke: none; }
.nome-continente { font-family: var(--titulo); font-size: 22px; fill: rgba(255,255,255,.22); text-anchor: middle; pointer-events: none; letter-spacing: 3px; }

@keyframes brilho { 50% { stroke-opacity: .35; } }
@keyframes pulsar { 50% { opacity: .5; } }

/* ---------- painel lateral ---------- */
.painel { width: var(--painel); background: var(--fundo-2); border-left: 1px solid var(--borda); display: flex; flex-direction: column; min-height: 0; }
.alca { display: none; }
.abas { display: flex; border-bottom: 1px solid var(--borda); }
.abas button { flex: 1; background: none; border: none; padding: 12px 4px; cursor: pointer; color: var(--texto-2); font-weight: 600; border-bottom: 2px solid transparent; position: relative; }
.abas button.ativa { color: var(--ouro); border-bottom-color: var(--ouro); }
.bolinha { display: inline-block; width: 8px; height: 8px; background: var(--perigo); border-radius: 50%; }
.aba-conteudo { display: none; flex: 1; overflow-y: auto; padding: 14px; }
.aba-conteudo.ativa { display: flex; flex-direction: column; gap: 12px; }

.cab-regiao { display: flex; align-items: center; gap: 10px; }
.cab-regiao h2 { margin: 0; font-family: var(--titulo); font-size: 20px; }
.cab-regiao .sub { color: var(--texto-2); font-size: 13px; }
.caixa { background: var(--fundo); border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.caixa h4 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--texto-2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: var(--fundo-3); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; }
.vazio { color: var(--texto-2); font-size: 13px; }
.item-acao { display: flex; align-items: center; gap: 10px; }
.item-acao .info { flex: 1; min-width: 0; }
.item-acao .titulo { font-weight: 700; }
.item-acao .custo { font-size: 12px; color: var(--texto-2); }
.item-acao .custo .falta { color: var(--perigo); }
.item-acao .btn { padding: 8px 12px; }
.qtd { display: flex; align-items: center; gap: 4px; }
.qtd button { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--borda); background: var(--fundo-3); cursor: pointer; }
.qtd span { min-width: 22px; text-align: center; font-weight: 700; }

.jogador-linha { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: var(--fundo); border: 1px solid var(--borda); }
.jogador-linha.davez { border-color: var(--ouro); }
.jogador-linha.morto { opacity: .45; text-decoration: line-through; }
.jogador-linha .nome { flex: 1; font-weight: 700; }
.jogador-linha .stats { font-size: 12px; color: var(--texto-2); text-align: right; }

.log-item { font-size: 13px; line-height: 1.45; padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.05); }
.chat-msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.chat-msgs .msg b { margin-right: 4px; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(5,10,20,.7); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; }
.modal-caixa { position: relative; width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto; background: var(--fundo-2); border: 1px solid var(--borda); border-radius: 16px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.modal-caixa h2 { margin: 0 0 12px; font-family: var(--titulo); }
.modal-fechar { position: absolute; top: 10px; right: 10px; background: none; border: none; color: var(--texto-2); font-size: 18px; cursor: pointer; }
.seletor-unidade { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.seletor-unidade .nome { flex: 1; }
.seletor-unidade input[type=range] { flex: 2; accent-color: var(--ouro); padding: 0; }
.seletor-unidade .valor { width: 52px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: center; text-align: center; margin: 10px 0; }
.versus .lado { background: var(--fundo); border-radius: 10px; padding: 10px; }
.versus .num { font-size: 26px; font-weight: 800; }
.dados { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; font-variant-numeric: tabular-nums; font-size: 13px; }
.dados .rodada { display: flex; justify-content: space-between; gap: 6px; padding: 4px 8px; background: var(--fundo); border-radius: 6px; }
.resultado { font-size: 20px; font-weight: 800; text-align: center; margin: 8px 0; }
.resultado.vitoria { color: var(--ok); } .resultado.derrota { color: var(--perigo); }
.botoes-modal { display: flex; gap: 8px; margin-top: 12px; }
.botoes-modal .btn { flex: 1; }

.aviso { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--fundo-3); border: 1px solid var(--borda); padding: 12px 18px; border-radius: 12px; z-index: 60; transition: transform .25s; max-width: 90vw; text-align: center; }
.aviso.mostrar { transform: translateX(-50%) translateY(0); }
.aviso.erro-aviso { border-color: var(--perigo); }

/* ---------- celular ---------- */
@media (max-width: 820px) {
  body { font-size: 14px; }
  .barra { gap: 6px; padding: 6px 8px; }
  .barra-recursos { order: 2; width: 100%; justify-content: space-between; gap: 4px; }
  .recurso { padding: 3px 7px; font-size: 13px; }
  .barra-turno { order: 1; justify-content: flex-start; }
  #btn-avancar { order: 1; padding: 9px 12px; }
  .etapas span { padding: 2px 8px; font-size: 11px; }
  .etapas span:not(.atual) { display: none; }
  .turno-tempo { font-size: 13px; }
  .area-jogo { flex-direction: column; }
  .painel { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 44%; border-left: none; border-top: 1px solid var(--borda); border-radius: 16px 16px 0 0; transition: height .25s; box-shadow: 0 -10px 30px rgba(0,0,0,.4); }
  .painel.recolhido { height: 92px; }
  .painel.expandido { height: 80%; }
  .alca { display: block; height: 18px; background: none; border: none; cursor: pointer; position: relative; flex: none; }
  .alca::after { content: ''; position: absolute; left: 50%; top: 7px; width: 44px; height: 4px; border-radius: 4px; background: var(--borda); transform: translateX(-50%); }
  .controles-mapa { bottom: auto; top: 60px; left: auto; right: 8px; }
  .dica-etapa { font-size: 12px; padding: 6px 12px; }
  .controles-mapa button { width: 36px; height: 36px; }
  .grade-config { grid-template-columns: 1fr; }
  .codigo-grande { font-size: 40px; }
}

/* ---------- objetivos e rodadas ---------- */
.objetivo { border-color: var(--ouro); background: linear-gradient(180deg, rgba(232,176,75,.12), var(--fundo)); }
.titulo-objetivo { font-weight: 700; font-size: 16px; }
.barra-progresso { height: 8px; background: var(--fundo-3); border-radius: 999px; overflow: hidden; }
.barra-progresso span { display: block; height: 100%; background: linear-gradient(90deg, var(--ouro-2), var(--ouro)); }
.rodada { font-size: 12px; color: var(--texto-2); background: var(--fundo); border: 1px solid var(--borda); border-radius: 999px; padding: 2px 8px; }
.campo.check { flex-direction: row; align-items: center; gap: 8px; align-self: end; padding: 12px 0; }
.campo.check input { width: 18px; height: 18px; accent-color: var(--ouro); }
.campo.check span { text-transform: none; letter-spacing: 0; font-size: 14px; color: var(--texto); }
