/* =====================================================================
   Conquiste o Mundo — UX da partida no mobile (mobile-ux.js)
   Seletor de tropas, dicas, confirmação, foco no ataque, último combate,
   dados, tabela de trocas, rótulos no mapa e reforços compactos.
   Porte de match-ux.css (desktop) para o HUD de game-mobile.html.
   ===================================================================== */

.troop-picker[hidden],
.ux-dialog[hidden],
.last-combat[hidden],
.ux-dice[hidden],
.tp-input[hidden],
.tp-value[hidden],
.tp-extra[hidden],
.draft-income-howto[hidden] { display: none !important; }

/* ---------------- Seletor de tropas ---------------- */
.troop-picker {
    --tp-accent: #00e5ff;
    position: absolute;
    z-index: 210; /* acima da folha de cartas, que deixa o mapa tocável */
    width: min(282px, 46vw);
    max-height: calc(100% - 108px - var(--safe-bottom));
    overflow-y: auto;
    background: #080d1c;
    border: 1.5px solid var(--tp-accent);
    border-radius: 14px;
    box-shadow: 0 14px 44px rgba(0, 0, 0, 0.75), 0 0 22px color-mix(in srgb, var(--tp-accent) 25%, transparent);
    padding: 9px 10px 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: tpUp 0.18s ease-out;
    touch-action: manipulation;
}

/* Lado oposto ao território em jogo (a prévia fica à vista). À direita, ancorado
   no topo: o Confirmar fica longe de MANOBRAR / ENCERRAR TURNO da barra inferior. */
.troop-picker[data-side="right"] { right: calc(10px + var(--safe-right)); top: 50px; }
.troop-picker[data-side="left"] { left: calc(10px + var(--safe-left)); bottom: calc(58px + var(--safe-bottom)); }

.troop-picker[data-kind="attack"] { --tp-accent: #ff3d57; }
.troop-picker[data-kind="occupation"] { --tp-accent: #00e676; }
.troop-picker[data-kind="fortify"] { --tp-accent: #3399ff; }

@keyframes tpUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.tp-head { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.tp-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--tp-accent);
    letter-spacing: 0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tp-sub { font-size: 11px; color: var(--text-dim); line-height: 1.35; }
.tp-sub b { color: #fff; }

.tp-row {
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr) auto auto;
    align-items: center;
    gap: 4px;
}

.tp-btn {
    height: 42px;
    min-width: 40px;
    border-radius: 10px;
    border: 1px solid rgba(100, 120, 160, 0.55);
    background: rgba(28, 38, 60, 0.9);
    color: var(--text);
    font-family: var(--font);
    cursor: pointer;
    touch-action: manipulation;
    transition: background 0.15s, border-color 0.15s, transform 0.08s;
}

.tp-btn:active:not(:disabled) { transform: scale(0.94); background: rgba(45, 60, 92, 0.95); border-color: var(--tp-accent); }
.tp-btn:disabled { opacity: 0.32; cursor: default; }
.tp-step { font-size: 24px; line-height: 1; font-weight: 700; }
.tp-minmax { min-width: 36px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }

.tp-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
}

.tp-value {
    background: transparent;
    border: none;
    border-bottom: 1.5px dashed rgba(140, 156, 184, 0.5);
    color: #fff;
    font-family: var(--font);
    font-size: 26px;
    font-weight: 800;
    line-height: 1.1;
    min-width: 48px;
    padding: 0 6px;
    cursor: text;
    text-shadow: 0 0 12px color-mix(in srgb, var(--tp-accent) 60%, transparent);
}

.tp-input {
    width: 70px;
    text-align: center;
    font-family: var(--font);
    font-size: 21px;
    font-weight: 800;
    color: #fff;
    background: rgba(5, 10, 25, 0.9);
    border: 1.5px solid var(--tp-accent);
    border-radius: 8px;
    padding: 2px 4px;
    outline: none;
    -webkit-user-select: text;
    user-select: text;
}

.tp-unit { font-size: 9px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-top: 1px; }
.tp-range { text-align: center; font-size: 10px; color: var(--text-muted); margin-top: -3px; }

/* Pular animação: só no seletor de dados (no lugar da faixa "de 1 a 3", que Mín/Máx já dizem) */
.tp-skip { display: none !important; justify-content: center; margin-top: -2px; }
.troop-picker[data-kind="attack"] .tp-skip { display: flex !important; }
.troop-picker[data-kind="attack"] .tp-range { display: none; }

.tp-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: stretch; }

.tp-actions button {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 10px;
}

.tp-cancel { flex: 0 1 auto; }

/* Confirmar sempre na ponta direita do seletor */
.tp-confirm {
    flex: 1 1 auto;
    margin-left: auto;
    background: var(--tp-accent);
    color: #04070f;
    box-shadow: 0 0 14px color-mix(in srgb, var(--tp-accent) 45%, transparent);
}

.tp-extra {
    order: -1;
    flex: 1 1 100%;
    background: linear-gradient(135deg, #ff1744, #ff5252);
    border: 1.5px solid #ff1744;
    color: #fff;
    font-family: var(--font);
    cursor: pointer;
}

/* Com o seletor aberto, a faixa do objetivo sai da frente */
body.picker-open .objective-tip { visibility: hidden; }

/* ---------------- Prévia no mapa ---------------- */
#map-canvas .army-badge.preview-dest .army-badge-circle {
    stroke: #00e676 !important;
    stroke-width: 2.6px !important;
    filter: drop-shadow(0 0 6px #00e676) !important;
}

#map-canvas .army-badge.preview-src .army-badge-circle {
    stroke: #ffb300 !important;
    stroke-width: 2.4px !important;
    filter: drop-shadow(0 0 5px #ffb300) !important;
}

#map-canvas .army-badge.preview-dest,
#map-canvas .army-badge.preview-src { opacity: 1 !important; }

#map-canvas .badge-preview-tag {
    font-family: var(--font);
    font-size: 11px;
    font-weight: 900;
    fill: #00e676;
    paint-order: stroke;
    stroke: rgba(3, 6, 14, 0.9);
    stroke-width: 3px;
    pointer-events: none;
}

#map-canvas .preview-src .badge-preview-tag { fill: #ffb300; }

/* ---------------- Foco no ataque / manobra ---------------- */
#map-canvas .territory-bloc,
#map-canvas .army-badge,
#map-canvas .terr-name-label { transition: opacity 0.25s ease; }

#map-canvas.focus-mode .territory-bloc:not(.selected):not(.target-candidate):not(.attack-target) {
    opacity: 0.22;
    filter: grayscale(0.7) !important;
}

#map-canvas.focus-mode .army-badge:not(.focus-keep) { opacity: 0.3; }
#map-canvas.focus-mode .terr-name-label:not(.focus-keep) { opacity: 0.25; }
#map-canvas.focus-mode .continent-labels-layer { opacity: 0.35; }

/* Alvo escolhido: vermelho, sobre os demais alvos possíveis (amarelo) */
.territory-bloc.attack-target {
    stroke: #ff3d57 !important;
    stroke-width: 2.6 !important;
    filter: brightness(1.15) drop-shadow(0 0 7px rgba(255, 61, 87, 0.75)) !important;
}

/* ---------------- Rótulos no mapa ---------------- */
#map-canvas .terr-name-label {
    display: none;
    font-family: var(--font);
    font-size: var(--name-fs, 7px);
    font-weight: 700;
    fill: #e8eef9;
    paint-order: stroke;
    stroke: rgba(3, 6, 14, 0.92);
    stroke-width: 0.3em;
    stroke-linejoin: round;
    dominant-baseline: hanging;
    pointer-events: none;
}

#map-canvas.names-zoomed .terr-name-label { display: inline; }

/* Cartas abertas sem zoom: só os nomes dos territórios das cartas (sem poluir o mapa) */
#map-canvas.show-card-names .terr-name-label.card-terr { display: inline; }
#map-canvas.show-card-names:not(.names-zoomed) .terr-name-label { font-size: var(--name-fs-forced, 8px); }
#map-canvas .terr-name-label.card-terr { fill: #ffd54f; font-weight: 900; }

#map-canvas .army-badge.card-terr .army-badge-circle {
    stroke: #ffd54f !important;
    stroke-width: 2.4px !important;
    stroke-dasharray: 3 2;
    filter: drop-shadow(0 0 5px #ffd54f) !important;
}

#map-canvas .continent-label {
    font-family: var(--font);
    font-size: var(--cont-fs, 12px);
    fill: var(--cc, #8c9cb8);
    opacity: 0.8;
    paint-order: stroke;
    stroke: rgba(3, 6, 14, 0.88);
    stroke-width: 0.22em;
    stroke-linejoin: round;
    letter-spacing: 0.06em;
    pointer-events: none;
}

#map-canvas .continent-label.controlled { opacity: 1; }
#map-canvas .continent-label .cl-name { font-size: 0.62em; font-weight: 700; }
#map-canvas .continent-label .cl-bonus { font-size: 1.15em; font-weight: 900; }
#map-canvas .continent-label .cl-owner { font-size: 0.6em; font-weight: 800; letter-spacing: 0; }

/* A tooltip do território vira uma etiqueta abaixo do placar central */
#territory-tooltip {
    top: 52px;
    left: 50%;
    transform: translateX(-50%);
    padding: 5px 12px;
    text-align: center;
    max-width: min(320px, 50vw);
}

#territory-tooltip #tt-name { font-size: 12px; }
#territory-tooltip #tt-details { font-size: 10px; }

/* ---------------- Dados (animação curta no centro inferior) ----------------
   Fora do caminho do seletor (laterais), do placar e do último combate (topo). */
.ux-dice {
    position: absolute;
    z-index: 40;
    bottom: calc(60px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    border-radius: 14px;
    background: rgba(6, 12, 26, 0.94);
    border: 1px solid rgba(0, 229, 255, 0.35);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    animation: uxdIn 0.16s ease-out;
}

@keyframes uxdIn {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.uxd-side { display: flex; align-items: center; gap: 6px; }
.uxd-side:last-child { flex-direction: row-reverse; }
.uxd-dice { display: flex; gap: 4px; }

.uxd-die {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 800;
    color: #fff;
    background: var(--dc, #1b2540);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.uxd-die.rolling { animation: uxdShake 0.14s linear infinite; }

@keyframes uxdShake {
    0%, 100% { transform: rotate(-6deg); }
    50% { transform: rotate(6deg); }
}

.uxd-die.win { background: #00c853; color: #03130a; border-color: #69f0ae; box-shadow: 0 0 10px rgba(0, 230, 118, 0.7); }
.uxd-die.lose { background: #3a1018; color: #ff8a95; border-color: rgba(255, 51, 68, 0.55); opacity: 0.75; text-decoration: line-through; }
.uxd-die.idle { opacity: 0.35; }

.uxd-loss { font-size: 13px; font-weight: 800; color: #ff8a95; min-width: 18px; text-align: center; visibility: hidden; }
.ux-dice.revealed .uxd-loss { visibility: visible; }
.uxd-vs { color: var(--text-muted); font-weight: 900; }
.uxd-blitz { font-size: 13px; font-weight: 800; color: #fff; }

/* ---------------- Último combate ---------------- */
.last-combat {
    position: absolute;
    z-index: 15; /* expandido, fica sobre o botão Bônus (14) */
    top: 54px;
    left: calc(10px + var(--safe-left));
    width: 232px;
    background: rgba(6, 12, 26, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    padding: 6px 9px 7px;
    font-size: 11px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

.last-combat.flash { animation: lcFlash 0.7s ease-out; }

@keyframes lcFlash {
    0% { border-color: #ffb300; box-shadow: 0 0 18px rgba(255, 179, 0, 0.55); }
    100% { border-color: rgba(255, 255, 255, 0.14); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
}

.lc-head { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.lc-title { flex: 1; font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); white-space: nowrap; }
.lc-summary { display: none; font-weight: 800; font-size: 11px; white-space: nowrap; }
.last-combat.collapsed .lc-summary { display: inline; }
.last-combat.collapsed .lc-content,
.last-combat.collapsed .lc-skip { display: none !important; }
.last-combat.collapsed { width: auto; padding: 5px 8px; }

.lc-toggle {
    width: 22px;
    height: 22px;
    border-radius: 5px;
    border: 1px solid rgba(100, 120, 160, 0.5);
    background: rgba(28, 38, 60, 0.9);
    color: var(--text);
    font-family: var(--font);
    cursor: pointer;
    line-height: 1;
    flex: none;
}

.lc-fight {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 6px;
    margin-top: 5px;
    align-items: start;
}

.lc-side {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    border-left: 3px solid var(--pc);
    padding-left: 6px;
}

.lc-side:last-child {
    border-left: none;
    border-right: 3px solid var(--pc);
    padding: 0 6px 0 0;
    align-items: flex-end;
    text-align: right;
}

.lc-who { color: var(--pc); font-weight: 800; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-terr { color: var(--text-dim); font-size: 10px; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lc-dice { display: flex; gap: 3px; margin: 3px 0 2px; }

.lc-die {
    width: 19px;
    height: 19px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 11px;
    background: #1b2540;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.lc-die.win { background: #00c853; color: #03130a; border-color: #69f0ae; }
.lc-die.lose { background: #3a1018; color: #ff8a95; border-color: rgba(255, 51, 68, 0.55); text-decoration: line-through; }
.lc-die.idle { opacity: 0.35; }

.lc-loss { font-weight: 800; font-size: 12px; color: var(--text-dim); }
.lc-loss.hit { color: #ff5c6c; }
.lc-vs { align-self: center; color: var(--text-muted); font-weight: 900; }

.lc-result {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-weight: 600;
}

.lc-result.conquered { color: #69f0ae; }
.lc-skip { margin-top: 5px; }

/* ---------------- Interruptores ---------------- */
.ux-toggle {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 11px;
    color: var(--text-dim);
    cursor: pointer;
}

.ux-toggle input { accent-color: #00e5ff; width: 16px; height: 16px; cursor: pointer; flex: none; }

/* ---------------- Dicas e confirmação ---------------- */
.ux-dialog {
    position: fixed;
    inset: 0;
    z-index: 260;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: rgba(4, 6, 12, 0.6);
    backdrop-filter: blur(3px);
}

.ux-dialog-card {
    width: min(460px, 100%);
    max-height: calc(100dvh - 20px);
    overflow-y: auto;
    background: var(--bg-panel-solid);
    border: 1.5px solid rgba(0, 229, 255, 0.45);
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7), 0 0 26px rgba(0, 229, 255, 0.12);
    animation: tpUp 0.2s ease-out;
}

.ux-dialog-card h3 { font-size: 16px; color: #fff; margin-bottom: 8px; line-height: 1.3; }
.ux-dialog-body { font-size: 13px; line-height: 1.45; color: var(--text); }
.ux-dialog-body p + p { margin-top: 6px; }
.ux-dialog-body b { color: #fff; }

.ux-dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.ux-dialog-actions button { min-height: 44px; padding: 10px 16px; font-size: 13px; }

.ux-tip-kicker {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #00e5ff;
    margin-bottom: 4px;
}

#ux-confirm .ux-dialog-card { border-color: rgba(255, 143, 0, 0.65); box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7), 0 0 26px rgba(255, 143, 0, 0.15); }
#ux-confirm-yes { border: 1.5px solid rgba(255, 143, 0, 0.7); color: #ffb74d; background: transparent; }

/* ---------------- Reforços do turno (cabe em celular deitado) ---------------- */
#draft-income-modal .modal-draft-income {
    max-width: min(560px, 94vw);
    max-height: calc(100dvh - 16px);
    padding: 12px 14px;
}

#draft-income-modal h3 { margin-bottom: 6px; font-size: 15px; }

.draft-income-sentence { font-size: 12px; line-height: 1.4; color: var(--text); margin-bottom: 8px; }
.draft-income-sentence b { color: #fff; }

#draft-income-modal .draft-income-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 6px;
    margin-bottom: 8px;
    max-height: none;
}

#draft-income-modal .draft-income-row { padding: 6px 10px; border-radius: 8px; }
#draft-income-modal .draft-income-label strong { font-size: 12px; }
#draft-income-modal .draft-income-label span { font-size: 10px; }
#draft-income-modal .draft-income-amt { font-size: 15px; }
#draft-income-modal .draft-income-total { font-size: 22px; margin-bottom: 4px; }
#draft-income-modal .draft-income-hint { margin-bottom: 8px; font-size: 11px; }

.draft-income-howto { text-align: left; font-size: 12px; line-height: 1.4; color: var(--text); margin-bottom: 8px; padding: 8px 10px; border-radius: 8px; background: rgba(0, 229, 255, 0.06); border: 1px solid rgba(0, 229, 255, 0.2); }
.draft-income-howto p + p { margin-top: 4px; }
.draft-income-howto:not([hidden]) + .draft-income-hint { display: none; } /* a explicação longa já diz isso */
.draft-income-howto b { color: #fff; }

.draft-income-actions { display: flex; align-items: center; gap: 12px; }
.draft-income-actions .btn-primary { flex: 1; min-height: 44px; padding: 10px 16px; }

/* ---------------- Cartas: folha à direita, mapa (e nomes) à vista ---------------- */
#cards-modal {
    justify-content: flex-end;
    align-items: stretch;
    background: rgba(0, 0, 0, 0.18);
    backdrop-filter: none;
    pointer-events: none; /* o mapa continua com pan/zoom para achar os territórios das cartas */
}

#cards-modal .modal-cards {
    pointer-events: auto;
    width: min(330px, 46vw);
    max-width: none;
    max-height: none;
    height: 100%;
    border-radius: 14px 0 0 14px;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    padding-right: calc(12px + var(--safe-right));
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow-y: auto;
    animation: cardsIn 0.2s ease-out;
}

@keyframes cardsIn {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

#cards-modal .panel-header { margin-bottom: 0; font-size: 14px; }
#cards-modal #cards-hand { margin-bottom: 0; }
#cards-modal #cards-exchange-info { font-size: 11px; color: var(--text-dim); text-align: center; }
#cards-modal #btn-exchange { min-height: 42px; padding: 10px 14px; font-size: 13px; }

.card-figures-rule {
    border: 1px solid rgba(176, 38, 255, 0.35);
    background: rgba(176, 38, 255, 0.06);
    border-radius: 8px;
    padding: 6px 8px;
}

.cfr-title { font-size: 9px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #d9a6ff; margin-bottom: 4px; text-align: center; }
.cfr-options { display: flex; align-items: center; justify-content: space-around; gap: 6px; }
.cfr-opt { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 10px; font-weight: 700; color: var(--text); }
.cfr-figs { font-size: 15px; letter-spacing: 2px; }
.cfr-or { font-size: 9px; color: var(--text-muted); text-transform: uppercase; }
.cfr-note { margin-top: 4px; font-size: 10px; color: var(--text-dim); text-align: center; line-height: 1.35; }

.trade-table {
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 8px;
    padding: 6px 8px 8px;
    background: rgba(0, 229, 255, 0.04);
}

.tt-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 2px 8px;
    margin-bottom: 6px;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-dim);
}

.tt-next { color: #00e5ff; }
.tt-next b { color: #fff; font-size: 13px; }

.tt-row { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px; }

.tt-cell {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 3px 0 4px;
    border-radius: 5px;
    background: rgba(22, 31, 51, 0.5);
    border: 1px solid rgba(56, 75, 112, 0.35);
}

.tt-n { font-size: 8px; color: var(--text-dim); }
.tt-v { font-weight: 800; font-size: 13px; color: var(--text); }
.tt-cell.done { opacity: 0.4; }
.tt-cell.done .tt-v { text-decoration: line-through; }
.tt-cell.next { background: rgba(0, 229, 255, 0.18); border-color: #00e5ff; box-shadow: 0 0 10px rgba(0, 229, 255, 0.45); }
.tt-cell.next .tt-v { color: #fff; }

.tt-arrow {
    position: absolute;
    bottom: -12px;
    font-size: 9px;
    color: #00e5ff;
    animation: ttBounce 1s ease-in-out infinite;
}

@keyframes ttBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.tt-foot { margin-top: 12px; font-size: 10px; line-height: 1.35; color: var(--text-dim); }
