/**
 * Risk 3D: Conquista mundial - Estilos visuales
 * Diseño de sala de operaciones militares (War Room), HUD táctico,
 * modales de combate, dados 3D y controles táctiles responsivos.
 */

:root {
    --font-main: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --bg-page: #0a0d14;
    --bg-surface: #121824;
    --bg-surface-elevated: #1a2334;
    --bg-card: rgba(26, 35, 52, 0.85);

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-gold: rgba(212, 175, 55, 0.35);

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --gold-primary: #d4af37;
    --gold-hover: #e5c158;
    --red-danger: #ef4444;
    --green-success: #10b981;
    --blue-accent: #3b82f6;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;

    --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.45);
    --shadow-gold: 0 0 15px rgba(212, 175, 55, 0.25);
}

/* Reset y base */
body {
    overflow-x: clip;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-family: var(--font-main);
    margin: 0;
    padding: 0;
}

.tool-layout {
    max-width: 1240px;
    margin: 1rem auto 2.5rem;
    padding: 0 1rem;
    width: 100%;
    box-sizing: border-box;
}

/* Encabezado de la herramienta */
.tool-header-block {
    text-align: center;
    margin-bottom: 1.25rem;
}

.tool-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    font-weight: 800;
    margin: 0 0 0.4rem;
    background: linear-gradient(135deg, #fef08a 0%, #d4af37 50%, #b45309 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.tool-subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin: 0 auto;
    max-width: 760px;
    line-height: 1.5;
}

/* Tablero y HUD principal */
.war-room-container {
    background: var(--bg-surface);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-soft), var(--shadow-gold);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Barra superior del HUD táctico */
.hud-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    background: rgba(18, 24, 36, 0.95);
    border-bottom: 1px solid var(--border-subtle);
    backdrop-filter: blur(10px);
    flex-wrap: wrap;
    gap: 0.75rem;
    z-index: 10;
}

.hud-turn-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.player-badge-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-surface-elevated);
    padding: 0.35rem 0.85rem;
    border-radius: 9999px;
    border: 1px solid var(--border-subtle);
    font-weight: 600;
    font-size: 0.95rem;
}

.color-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    box-shadow: 0 0 8px currentColor;
}

.phase-badge {
    padding: 0.35rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.04em;
}

.phase-reinforce {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.phase-attack {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.phase-fortify {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.phase-gameover {
    background: rgba(212, 175, 55, 0.2);
    color: #fde047;
    border: 1px solid rgba(212, 175, 55, 0.4);
}

.reinforcements-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    background: rgba(234, 179, 8, 0.15);
    color: #fde047;
    border: 1px solid rgba(234, 179, 8, 0.35);
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-family: var(--font-mono);
}

.hud-actions-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Botones del HUD */
.btn-hud {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 40px;
}

.btn-hud:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-gold);
}

.btn-hud-primary {
    background: linear-gradient(135deg, #d4af37, #b45309);
    color: #0b0f17;
    font-weight: 700;
    border: none;
    box-shadow: 0 2px 8px rgba(212, 175, 55, 0.35);
}

.btn-hud-primary:hover {
    background: linear-gradient(135deg, #e5c158, #d4af37);
    transform: translateY(-1px);
}

.badge-count {
    background: #ef4444;
    color: #ffffff;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    padding: 0.1rem 0.45rem;
    border-radius: 9999px;
    font-weight: bold;
}

.select-camera-preset {
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 0.45rem 2.2rem 0.45rem 0.85rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    font-size: 0.9rem;
    min-height: 40px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23d4af37'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    width: auto;
    max-width: 100%;
}

.select-camera-preset option {
    background: #121824;
    color: #f8fafc;
}

/* Franja de indicaciones tácticas */
.hud-prompt-bar {
    background: rgba(10, 14, 20, 0.85);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.hud-prompt-bar::before {
    content: "⚔️";
    font-size: 1rem;
}

/* Lienzo 3D */
.viewport-3d-wrapper {
    width: 100%;
    height: 65vh;
    min-height: 520px;
    max-height: 780px;
    position: relative;
    background: #0a0d14;
}

#risk-3d-viewport {
    width: 100%;
    height: 100%;
    outline: none;
}

/* Drawer / Cajón lateral de registro histórico */
.history-drawer {
    position: absolute;
    top: 0;
    right: -380px;
    width: 360px;
    height: 100%;
    background: rgba(15, 22, 34, 0.96);
    border-left: 1px solid var(--border-gold);
    backdrop-filter: blur(12px);
    z-index: 20;
    display: flex;
    flex-direction: column;
    transition: right 0.3s ease;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
}

.history-drawer.active {
    right: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-subtle);
}

.drawer-title {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    margin: 0;
    color: var(--gold-primary);
}

.btn-close-drawer {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.history-item {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-secondary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding-bottom: 0.5rem;
}

.history-time {
    font-family: var(--font-mono);
    color: var(--gold-primary);
    font-weight: bold;
    font-size: 0.78rem;
    margin-right: 0.4rem;
}

/* Modales canónicos */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    padding: 1rem;
    box-sizing: border-box;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
    color: var(--gold-primary);
}

.modal-body {
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background: rgba(0, 0, 0, 0.25);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Modal de combate */
.combat-front-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-surface-elevated);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    border: 1px solid var(--border-subtle);
}

.combat-combatant {
    text-align: center;
    flex: 1;
}

.combatant-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.combatant-name {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0.2rem 0;
    color: var(--text-primary);
}

.combatant-troops {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 800;
}

.troops-attacker { color: #f87171; }
.troops-defender { color: #60a5fa; }

.combat-vs {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--gold-primary);
    padding: 0 1rem;
}

.dice-results-row {
    display: flex;
    justify-content: space-around;
    background: rgba(0, 0, 0, 0.35);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
}

.dice-group {
    text-align: center;
}

.dice-flex {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.4rem;
}

.die-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 1.2rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.die-red {
    background: #b91c1c;
    color: #ffffff;
    border: 1px solid #ef4444;
}

.die-white {
    background: #f8fafc;
    color: #0f172a;
    border: 1px solid #cbd5e1;
}

.losses-summary {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.95rem;
    color: var(--gold-primary);
    font-weight: bold;
    margin-top: 0.5rem;
}

.combat-banner {
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    text-align: center;
    margin-top: 1rem;
    font-weight: 600;
}

.banner-loss {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Galería de cartas de territorio */
.cards-grid-wrapper {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 0.75rem;
    max-height: 280px;
    overflow-y: auto;
    margin: 1rem 0;
    padding: 0.25rem;
}

.card-item {
    cursor: pointer;
    position: relative;
}

.card-checkbox {
    position: absolute;
    opacity: 0;
}

.card-inner {
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 0.85rem 0.6rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    transition: all 0.2s ease;
}

.card-checkbox:checked + .card-inner {
    border-color: var(--gold-primary);
    background: rgba(212, 175, 55, 0.15);
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.card-symbol {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--gold-primary);
}

.card-territory {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.2;
}

.card-owns-badge {
    background: #059669;
    color: #ffffff;
    font-size: 0.7rem;
    font-family: var(--font-mono);
    border-radius: 4px;
    padding: 0.1rem 0.3rem;
}

/* Slider de traslado de tropas */
.slider-control-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1.5rem 0;
}

.slider-val-display {
    text-align: center;
    font-family: var(--font-mono);
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--gold-primary);
}

.custom-range {
    width: 100%;
    accent-color: var(--gold-primary);
    height: 8px;
    background: var(--bg-surface-elevated);
    border-radius: 4px;
    cursor: pointer;
}

/* Botones de acción generales */
.btn-primary {
    background: linear-gradient(135deg, #d4af37, #b45309);
    color: #0b0f17;
    font-weight: 700;
    border: none;
    padding: 0.65rem 1.4rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    cursor: pointer;
    min-height: 40px;
    transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #e5c158, #d4af37);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
    padding: 0.65rem 1.2rem;
    border-radius: var(--radius-sm);
    font-family: var(--font-main);
    cursor: pointer;
    min-height: 40px;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

/* Formularios de configuración */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    background: var(--bg-surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 0.6rem 2.2rem 0.6rem 0.85rem;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    min-height: 40px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23d4af37'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

.form-select option {
    background: #121824;
    color: #f8fafc;
}

/* Pantalla de Game Over */
.title-victory {
    color: #fde047;
    font-size: 1.8rem;
    text-align: center;
}

.title-defeat {
    color: #f87171;
    font-size: 1.8rem;
    text-align: center;
}

/* Guía de reglas y SEO */
.rules-accordion-section {
    margin-top: 2.5rem;
}

.accordion-details {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    margin-bottom: 0.85rem;
    overflow: hidden;
}

.accordion-summary {
    padding: 1rem 1.25rem;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    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: 1.4rem;
    color: var(--gold-primary);
    transition: transform 0.2s ease;
}

.accordion-details[open] .accordion-summary::after {
    content: "−";
}

.accordion-content {
    padding: 0 1.25rem 1.25rem;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 0.95rem;
}

.accordion-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.accordion-content th,
.accordion-content td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--border-subtle);
    text-align: left;
}

.accordion-content th {
    color: var(--gold-primary);
    font-family: var(--font-heading);
    font-weight: 700;
}

/* Responsividad móvil */
@media (max-width: 768px) {
    .tool-title {
        font-size: 1.7rem;
    }

    .tool-subtitle {
        font-size: 0.95rem;
    }

    .viewport-3d-wrapper {
        height: 55vh;
        min-height: 420px;
    }

    .hud-top-bar {
        padding: 0.6rem 0.85rem;
    }

    .hud-turn-info {
        width: 100%;
        justify-content: space-between;
    }

    .hud-actions-group {
        width: 100%;
        justify-content: space-between;
    }

    .select-camera-preset {
        flex: 1 1 100%;
    }

    .btn-hud {
        flex: 1 1 auto;
        justify-content: center;
    }

    .history-drawer {
        width: 100%;
        right: -100%;
    }
}
