/* ============================================
   In-Game HUD Overlay Styles
   ============================================ */

/* Game container */
.game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    background: #000;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Top bar */
.hud-top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: linear-gradient(180deg, rgba(10, 10, 20, 0.9), transparent);
    pointer-events: none;
    z-index: 10;
}

.hud-top > * {
    pointer-events: auto;
}

.hud-battle-name {
    font-family: var(--font-heading);
    color: var(--gold);
    font-size: 1.2rem;
}

.hud-unit-count {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
}

.hud-unit-count .friendly {
    color: var(--green);
}

.hud-unit-count .enemy {
    color: var(--blood-light);
}

.hud-controls {
    display: flex;
    gap: 0.5rem;
}

.hud-btn {
    background: rgba(10, 10, 20, 0.8);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.8rem;
    transition: all 0.2s;
}

.hud-btn:hover {
    border-color: var(--gold);
    background: rgba(212, 160, 23, 0.2);
}

/* Bottom bar — commands */
.hud-bottom {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: linear-gradient(0deg, rgba(10, 10, 20, 0.9), transparent);
    pointer-events: none;
    z-index: 10;
}

.hud-bottom > * {
    pointer-events: auto;
}

.command-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem 1rem;
    background: rgba(10, 10, 20, 0.8);
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    color: var(--text-primary);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.75rem;
    transition: all 0.2s;
    min-width: 70px;
}

.command-btn:hover {
    border-color: var(--gold);
    background: rgba(212, 160, 23, 0.15);
}

.command-btn .cmd-icon {
    font-size: 1.3rem;
}

.command-btn .cmd-key {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
}

/* Formation divider */
.formation-divider {
    width: 1px;
    background: var(--gold-dim);
    margin: 0 0.3rem;
    align-self: stretch;
    opacity: 0.5;
}

/* Active formation button highlight */
.formation-btn.active {
    border-color: var(--gold);
    background: rgba(212, 160, 23, 0.25);
    box-shadow: 0 0 8px rgba(212, 160, 23, 0.3);
}

/* Formation name flash */
.formation-flash {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-heading);
    font-size: 1.8rem;
    color: var(--gold);
    text-shadow: 0 0 20px rgba(212, 160, 23, 0.6), 0 2px 4px rgba(0,0,0,0.8);
    opacity: 0;
    pointer-events: none;
    z-index: 30;
    transition: opacity 0.3s ease;
    white-space: nowrap;
}

.formation-flash.show {
    opacity: 1;
}

/* Formation tooltip */
.formation-tooltip {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    max-width: 380px;
    width: 90%;
    background: rgba(10, 10, 20, 0.95);
    border: 2px solid var(--gold-dim);
    border-radius: var(--radius-lg);
    padding: 1rem 1.2rem;
    z-index: 25;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.formation-tooltip.visible {
    opacity: 1;
}

.formation-tooltip .ft-title {
    font-family: var(--font-heading);
    color: var(--gold);
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
}

.formation-tooltip .ft-history {
    font-size: 0.85rem;
    color: var(--parchment);
    line-height: 1.5;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid rgba(212, 160, 23, 0.2);
}

.formation-tooltip .ft-strategy {
    font-size: 0.8rem;
    color: var(--green);
    line-height: 1.5;
}

/* Minimap */
.hud-minimap {
    position: absolute;
    bottom: 60px;
    right: 10px;
    width: 180px;
    height: 120px;
    background: rgba(10, 10, 20, 0.85);
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    z-index: 10;
    overflow: hidden;
}

#minimapCanvas {
    width: 100%;
    height: 100%;
}

/* Advisor popup */
.advisor-popup {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    max-width: 500px;
    width: 90%;
    background: rgba(10, 10, 20, 0.95);
    border: 2px solid var(--gold-dim);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    z-index: 20;
    opacity: 0;
    pointer-events: none;
    transition: all 0.4s ease;
}

.advisor-popup.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
    cursor: pointer;
}

.advisor-popup .advisor-label {
    font-family: var(--font-heading);
    color: var(--gold);
    font-size: 0.85rem;
    margin-bottom: 0.3rem;
}

.advisor-popup .advisor-text {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--parchment);
}

/* Selection box */
.selection-box {
    position: absolute;
    border: 1px solid var(--gold);
    background: rgba(212, 160, 23, 0.1);
    pointer-events: none;
    z-index: 5;
}

/* Briefing overlay */
.briefing-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(5, 5, 10, 0.95);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    z-index: 100;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.briefing-content {
    max-width: 700px;
    width: 90%;
    text-align: center;
    padding: var(--gap-lg);
    margin: auto 0;
    min-height: min-content;
}

.briefing-content h1 {
    font-size: 2.5rem;
    margin-bottom: 0.3rem;
}

.briefing-content .briefing-year {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

.briefing-content .briefing-text {
    text-align: left;
    line-height: 1.8;
    color: var(--parchment);
    margin-bottom: 1.5rem;
}

.briefing-content .science-focus-box {
    background: rgba(52, 152, 219, 0.1);
    border: 1px solid rgba(52, 152, 219, 0.3);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    text-align: left;
}

.briefing-content .science-focus-box h3 {
    color: var(--blue);
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.briefing-facts {
    text-align: left;
    margin-bottom: 1.5rem;
}

.briefing-facts h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.briefing-facts ul {
    list-style: none;
    padding: 0;
}

.briefing-facts li {
    padding: 0.3rem 0 0.3rem 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

.briefing-facts li::before {
    content: '📜';
    position: absolute;
    left: 0;
}

/* Post-battle screen */
.debrief-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--gap);
    margin: 1.5rem 0;
}

.debrief-stat {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1rem;
}

.debrief-stat .stat-value {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--gold);
}

.debrief-stat .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.debrief-history {
    background: rgba(212, 160, 23, 0.1);
    border: 1px solid var(--gold-dim);
    border-radius: var(--radius);
    padding: 1rem;
    margin: 1rem 0;
    text-align: left;
}

.debrief-retry {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(46, 204, 113, 0.1);
    border: 1px solid rgba(46, 204, 113, 0.3);
    border-radius: var(--radius);
    text-align: left;
}

.debrief-retry h3 {
    color: var(--green);
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

/* ============================================
   Mobile / touch — phones and small tablets
   Triggers below 768px (most phones in portrait).
   ============================================ */
@media (max-width: 768px) {
    /* Top HUD wraps onto two rows so all controls stay reachable */
    .hud-top {
        flex-wrap: wrap;
        gap: 0.4rem;
        padding: 0.4rem 0.6rem;
    }
    .hud-battle-name {
        font-size: 1rem;
        flex: 1 1 100%;
        text-align: center;
    }
    .hud-unit-count {
        gap: 0.6rem;
        font-size: 0.75rem;
    }
    .hud-controls {
        flex-wrap: wrap;
        gap: 0.3rem;
        justify-content: center;
        flex: 1 1 100%;
    }
    .hud-btn {
        padding: 0.45rem 0.6rem;
        font-size: 0.8rem;
        min-height: 40px;
    }

    /* Bottom HUD — horizontal scroll for the command strip
       (13 buttons can't fit a phone screen, so let users swipe through). */
    .hud-bottom {
        overflow-x: auto;
        flex-wrap: nowrap;
        justify-content: flex-start;
        padding: 0.5rem;
        gap: 0.4rem;
        -webkit-overflow-scrolling: touch;
    }
    .command-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.7rem;
        min-width: 64px;
        min-height: 44px;
        flex-shrink: 0;
    }
    .command-btn .cmd-key {
        display: none; /* hide keyboard hints — there's no keyboard */
    }

    /* Formation tooltip becomes a bottom sheet on phones, not a hover popup */
    .formation-tooltip {
        left: 0.5rem;
        right: 0.5rem;
        bottom: 6.5rem;
        max-width: none;
    }

    /* Help overlay: scrollable + fits the screen */
    .help-overlay-content {
        max-height: 90vh;
        overflow-y: auto;
        padding: 1rem;
    }
}
