/* ===========================================
   TACTICAL MODE - Shared Grid Demo
   Standalone styles for the tactical mode prototype
   =========================================== */

/* ---- Layout ---- */
.tactical-app {
    display: none;
    flex-direction: column;
    min-height: 100vh;
    color: var(--text-primary);
    font-family: 'Exo 2', sans-serif;
    position: relative;
    z-index: 1;
    overflow-x: hidden;
}

.tactical-app:has(.screen.active) {
    display: flex;
}

.tactical-header {
    text-align: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-secondary);
}

.tactical-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--faction-primary);
    text-shadow: 0 0 20px var(--faction-glow);
}

.tactical-header .subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-top: 2px;
}

.tactical-main {
    display: flex;
    flex: 1;
    gap: 12px;
    padding: 12px;
    justify-content: center;
    align-items: flex-start;
}

/* ---- Fleet Builder Screen ---- */
.fleet-builder {
    max-width: 800px;
    width: 100%;
    padding: 20px;
}

.fleet-builder h2 {
    text-align: center;
    font-size: 1.2rem;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 2px;
    color: var(--faction-primary);
    margin-bottom: 16px;
}

.budget-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.85rem;
}

.budget-bar .budget-value {
    font-size: 1.4rem;
    font-weight: bold;
    color: var(--faction-primary);
}

.budget-bar .budget-value.over-budget {
    color: var(--hit);
}

.budget-bar .fleet-count {
    color: var(--text-secondary);
}

.ship-class-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.ship-class-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    transition: border-color 0.2s;
}

.ship-class-card:hover {
    border-color: var(--faction-border);
}

.ship-class-info {
    flex: 1;
}

.ship-class-info .class-name {
    font-size: 0.95rem;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.ship-class-info .class-stats {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.ship-class-info .class-trait {
    font-size: 0.8rem;
    color: var(--ability-triggered);
    margin-top: 2px;
}

.ship-class-info .class-desc {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.ship-count-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ship-count-controls button {
    width: 30px;
    height: 30px;
    border: 1px solid var(--border-medium);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, border-color 0.2s;
}

.ship-count-controls button:hover:not(:disabled) {
    background: var(--faction-bg);
    border-color: var(--faction-primary);
}

.ship-count-controls button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.ship-count-controls .count {
    font-size: 1.2rem;
    width: 30px;
    text-align: center;
    color: var(--faction-primary);
}

.ship-class-cost {
    font-size: 0.9rem;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: right;
}

.fleet-presets {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.8rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    font-family: inherit;
    transition: all 0.2s;
}

.preset-btn:hover {
    border-color: var(--faction-primary);
    color: var(--faction-primary);
}

.fleet-validation {
    text-align: center;
    font-size: 0.85rem;
    min-height: 20px;
    margin-bottom: 12px;
}

.fleet-validation.error {
    color: var(--hit);
}

.fleet-validation.valid {
    color: var(--victory);
}

.fleet-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ---- Placement Screen ---- */
/* Uses standard .placement-container / .ship-dock / .ship-item styles from style.css.
   Only tactical-specific overrides below. */

/* Ghost cell size override — tactical cells are smaller than standard 30px */
#tactical-placement-screen .ghost-cell {
    width: var(--cell-size, 22px);
    height: var(--cell-size, 22px);
}

/* Random placement warning */
.tactical-random-warning {
    font-size: 0.7rem;
    color: var(--warning, #e8a33d);
    text-align: center;
    font-style: italic;
    margin-top: 6px;
}

/* Deployment zone hint */
.deployment-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    font-style: italic;
}

/* ---- Battle Screen ---- */
.battle-screen {
    width: 100%;
    max-width: 1200px;
}

.battle-layout {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: flex-start;
}

/* Side panels */
.side-panel {
    width: 200px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 22px; /* Align with grid (grid-container has margin-top: 22px for coord labels) */
}

.panel-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    padding: 10px;
}

.panel-section h3 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--faction-primary);
    margin: 0 0 8px 0;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border-subtle);
}

.ship-roster-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 6px;
    margin-bottom: 4px;
    border-radius: 3px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.15s;
}

.ship-roster-item:hover {
    background: var(--faction-bg);
}

.ship-roster-item.selected {
    background: var(--faction-bg);
    border-left: 2px solid var(--faction-primary);
}

/* Selected ship cells — pulsing glow */
@keyframes selectPulse {
    0%, 100% { box-shadow: inset 0 0 4px var(--faction-glow); }
    50% { box-shadow: inset 0 0 10px var(--faction-glow), 0 0 6px var(--faction-glow); }
}

.ship-outline.selected-ship {
    box-shadow: 0 0 8px var(--faction-glow);
    animation: selectPulse 1.8s ease-in-out infinite;
}

.ship-roster-item.sunk {
    opacity: 0.4;
    text-decoration: line-through;
    cursor: default;
}

.ship-roster-item .ship-class-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--faction-primary);
    flex-shrink: 0;
}

.ship-roster-item .ship-hp {
    margin-left: auto;
    color: var(--text-muted);
}

/* Turn info */
.turn-indicator {
    text-align: center;
    padding: 8px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 0.85rem;
    letter-spacing: 1px;
    margin: 0 auto 10px;
    width: fit-content;
}

.battle-header .turn-indicator {
    margin: 0;
    width: auto;
}

.battle-header {
    position: relative;
}

.battle-header .phase-banner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    min-width: auto;
}

.battle-header .phase-banner.active {
    transform: translate(-50%, -50%) scaleX(1);
    animation: none;
}

.turn-indicator.your-turn {
    border-color: var(--faction-primary);
    color: var(--faction-primary);
    box-shadow: 0 0 10px var(--faction-glow);
}

.turn-indicator.enemy-turn {
    border-color: var(--opponent-primary);
    color: var(--opponent-primary);
}

.phase-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Phase-specific indicator styling */
.turn-indicator.indicator-move {
    background: rgba(60, 180, 60, 0.2);
    border: 2px solid rgba(60, 180, 60, 0.6);
    color: #3cb43c;
    box-shadow: 0 0 15px rgba(60, 180, 60, 0.4);
}

.turn-indicator.indicator-fire {
    background: rgba(245, 90, 90, 0.2);
    border: 2px solid rgba(245, 90, 90, 0.6);
    color: #f55a5a;
    box-shadow: 0 0 15px rgba(245, 90, 90, 0.4);
}

/* Phase banner — large text overlay that flashes on phase change */
.phase-banner {
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    padding: 8px 24px;
    margin: 0 auto 6px;
    border-radius: 4px;
    width: fit-content;
    min-width: 200px;
    transition: all 0.3s ease;
    opacity: 0;
    transform: scaleX(0.8);
    pointer-events: none;
}

.phase-banner.active {
    opacity: 1;
    transform: scaleX(1);
    animation: phaseBannerIn 0.35s ease-out;
}

@keyframes phaseBannerIn {
    0% { opacity: 0; transform: scaleX(0.7) translateY(-8px); }
    100% { opacity: 1; transform: scaleX(1) translateY(0); }
}

.phase-banner.move {
    background: rgba(60, 180, 60, 0.15);
    border: 2px solid rgba(60, 180, 60, 0.6);
    color: #3cb43c;
    box-shadow: 0 0 20px rgba(60, 180, 60, 0.3);
}

.phase-banner.fire {
    background: rgba(245, 90, 90, 0.15);
    border: 2px solid rgba(245, 90, 90, 0.6);
    color: #f55a5a;
    box-shadow: 0 0 20px rgba(245, 90, 90, 0.3);
}

.phase-banner.enemy {
    background: rgba(200, 200, 200, 0.08);
    border: 2px solid rgba(200, 200, 200, 0.2);
    color: var(--text-muted);
}

.phase-icon {
    display: inline-block;
    margin-right: 6px;
    font-size: 1em;
    vertical-align: middle;
}

.phase-icon-move { color: #3cb43c; }
.phase-icon-fire { color: #f55a5a; }

/* ---- Grid ---- */
.grid-container {
    position: relative;
    display: inline-block;
    margin-left: 24px;
    margin-top: 22px;
    transition: box-shadow 0.4s ease, border-color 0.4s ease;
}

/* Phase indicators on grid container — stronger glow */
.grid-container.phase-move {
    box-shadow: 0 0 20px rgba(60, 180, 60, 0.3), inset 0 0 15px rgba(60, 180, 60, 0.08);
    border: 1px solid rgba(60, 180, 60, 0.4);
}

.grid-container.phase-fire {
    box-shadow: 0 0 20px rgba(245, 90, 90, 0.3), inset 0 0 15px rgba(245, 90, 90, 0.08);
    border: 1px solid rgba(245, 90, 90, 0.4);
}

/* Match main game's enemy-turn dimming */
.grid-container.phase-enemy {
    opacity: 0.5;
    filter: grayscale(30%);
    pointer-events: none;
    transition: opacity 0.3s ease, filter 0.3s ease;
}

/* Phase transition flash (combines with phase-enemy grayscale) */
@keyframes phaseTransition {
    0% { filter: brightness(1.3) grayscale(0); }
    100% { filter: brightness(1); }
}
.grid-container.phase-transition {
    animation: phaseTransition 0.4s ease-out !important;
}

/* Phase-specific cursors */
.grid-container.phase-move .tactical-grid .cell:not(.fog-dense) {
    cursor: move;
}
.grid-container.phase-fire .tactical-grid .cell:not(.fog-dense) {
    cursor: crosshair;
}
.grid-container.phase-enemy .tactical-grid .cell {
    cursor: not-allowed;
}

.tactical-grid {
    display: grid;
    gap: var(--cell-gap, 2px);
    grid-template-columns: repeat(25, var(--cell-size, 22px));
    grid-template-rows: repeat(25, var(--cell-size, 22px));
    background: var(--bg-primary);
    border: 2px solid var(--faction-primary);
    border-radius: 6px;
    box-shadow: 0 0 15px var(--faction-glow), inset 0 0 15px rgba(0,0,0,0.2);
    position: relative;
}

.tactical-grid .cell {
    width: var(--cell-size, 22px);
    height: var(--cell-size, 22px);
    background: var(--bg-cell);
    border: 1px solid transparent;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease, box-shadow 0.3s ease;
    box-sizing: border-box;
}

/* Deployment zone tinting — faction-colored */
.tactical-grid .cell.deploy-player {
    background: var(--faction-bg);
}

.tactical-grid .cell.deploy-ai {
    background: var(--opponent-bg);
}

/* Fog states */
.tactical-grid .cell.fog-dense {
    background:
        repeating-linear-gradient(
            45deg,
            rgba(10, 12, 18, 0.85),
            rgba(10, 12, 18, 0.85) 2px,
            rgba(20, 24, 35, 0.75) 2px,
            rgba(20, 24, 35, 0.75) 4px
        );
    position: relative;
}

/* Subtle animated shimmer on dense fog */
.tactical-grid .cell.fog-dense::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(
        ellipse at 50% 50%,
        rgba(106, 173, 255, 0.04) 0%,
        transparent 70%
    );
    animation: fogShimmer 4s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes fogShimmer {
    0% { opacity: 0.3; }
    100% { opacity: 0.8; }
}

.tactical-grid .cell.fog-light {
    background: rgba(15, 18, 28, 0.5);
    position: relative;
}

.tactical-grid .cell.visible {
    background: var(--bg-cell);
}

/* Hover states */
.tactical-grid .cell:hover:not(.fog-dense) {
    background: var(--bg-cell-hover);
    border-color: var(--border-medium);
}

/* Ship cells — faction background, per-ship green/red friend-foe edge borders */
.tactical-grid .cell.has-player-ship {
    background: var(--faction-bg);
}

.tactical-grid .cell.has-enemy-ship {
    background: var(--opponent-bg);
}

/* Hit marker on ship — matches main game style */
.tactical-grid .cell.hit-marker {
    background: var(--hit-bg);
    box-shadow: inset 0 0 0 1px var(--hit-border);
    position: relative;
}

.tactical-grid .cell.hit-marker::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 10px; height: 10px;
    background: var(--hit);
    border-radius: 50%;
    opacity: 0.9;
}

/* Miss marker (fading) — matches main game style */
.tactical-grid .cell.miss-marker {
    background: var(--miss-bg);
    box-shadow: inset 0 0 0 1px var(--miss-border);
    position: relative;
}

.tactical-grid .cell.miss-marker::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 6px; height: 6px;
    background: transparent;
    border: 2px solid var(--faction-primary);
    border-radius: 50%;
    opacity: 0.7;
}

.tactical-grid .cell.miss-age-1::after { opacity: 0.7; }
.tactical-grid .cell.miss-age-2::after { opacity: 0.45; }
.tactical-grid .cell.miss-age-3::after { opacity: 0.2; }

/* Debris SVG container in tactical cells */
.tactical-grid .cell .ship-debris {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 3;
    pointer-events: none;
    background: var(--bg-cell);
    animation: debris-fade-in 0.4s ease-out forwards;
}

.tactical-grid .cell.has-debris {
    background: var(--bg-cell) !important;
}

/* Hide debris SVG when a living ship occupies the same cell.
   display:none defeats the debris-fade-in animation's forwards fill (which overrides opacity). */
.tactical-grid .cell.has-player-ship .ship-debris,
.tactical-grid .cell.has-enemy-ship .ship-debris {
    display: none !important;
}

/* Override has-debris background to show ship colors instead of bg-cell */
.tactical-grid .cell.has-player-ship.has-debris {
    background: var(--faction-bg) !important;
}

.tactical-grid .cell.has-enemy-ship.has-debris {
    background: var(--opponent-bg) !important;
}

/* When silhouettes are active, use the subtler silhouette background */
.tactical-grid .cell.has-player-ship.has-debris.has-silhouette {
    background: var(--faction-bg, rgba(50, 60, 80, 0.3)) !important;
    box-shadow: none;
}

.tactical-grid .cell.has-enemy-ship.has-debris.has-silhouette {
    background: var(--opponent-bg, rgba(80, 50, 50, 0.3)) !important;
    box-shadow: none;
}

/* Ensure hit markers render above debris on ship cells */
.tactical-grid .cell.has-player-ship.hit-marker::after,
.tactical-grid .cell.has-enemy-ship.hit-marker::after {
    z-index: 4;
}

.tactical-grid .cell.has-debris::before {
    display: none !important;  /* Hide fog shimmer / x marker when SVG debris present */
}

/* Destroyed cells in fog: show x marker instead of fog shimmer */
.tactical-grid .cell.destroyed.fog-dense::before,
.tactical-grid .cell.destroyed.fog-light::before {
    content: '\00d7';
    background: transparent;
    animation: none;
    inset: auto;
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1rem;
    font-weight: bold;
    color: rgba(150, 100, 100, 0.8);
}

/* Ghost outline */
.tactical-grid .cell.ghost-marker {
    position: relative;
}

.tactical-grid .cell.ghost-marker::after {
    content: '';
    position: absolute;
    inset: 8%;
    border: 1px dashed var(--opponent-primary, rgba(245, 90, 90, 0.5));
    border-radius: 2px;
    opacity: 0.5;
    animation: ghostDrift 3s ease-in-out infinite alternate;
}

@keyframes ghostDrift {
    0% { opacity: 0.3; transform: translate(0, 0); }
    50% { opacity: 0.6; }
    100% { opacity: 0.3; transform: translate(1px, -1px); }
}

/* Movement highlights */
.tactical-grid .cell.move-target {
    background: rgba(60, 180, 60, 0.15);
    border-color: rgba(60, 180, 60, 0.4);
    cursor: pointer;
}

.tactical-grid .cell.move-target:hover {
    background: rgba(60, 180, 60, 0.3);
}

/* Fire target highlight */
.tactical-grid .cell.fire-target {
    background: rgba(245, 90, 90, 0.12);
    border-color: rgba(245, 90, 90, 0.35);
    cursor: crosshair;
}

.tactical-grid .cell.fire-target:hover {
    background: rgba(245, 90, 90, 0.25);
}

/* Fire pattern preview */
.tactical-grid .cell.fire-preview {
    box-shadow: inset 0 0 0 2px rgba(245, 90, 90, 0.6);
}

/* Fire range boundary (edge borders only, drawn on perimeter of reachable area) */
.tactical-grid .cell.fire-edge-top    { border-top: 1px dashed rgba(245, 90, 90, 0.55); }
.tactical-grid .cell.fire-edge-bottom { border-bottom: 1px dashed rgba(245, 90, 90, 0.55); }
.tactical-grid .cell.fire-edge-left   { border-left: 1px dashed rgba(245, 90, 90, 0.55); }
.tactical-grid .cell.fire-edge-right  { border-right: 1px dashed rgba(245, 90, 90, 0.55); }

/* Dim out-of-range cells when firing ship selected */
.tactical-grid .cell.out-of-range {
    opacity: 0.25;
    filter: saturate(0.3);
}

/* Keep player ships clickable when out of range (to switch firing ship) */
.tactical-grid .cell.out-of-range.has-player-ship {
    opacity: 0.6;
    filter: none;
    cursor: pointer;
}

/* Sensor range border visualization */
.tactical-grid .cell.sensor-edge {
    box-shadow: inset 0 0 4px 1px rgba(106, 173, 255, 0.12);
}

/* Ship outline overlays — single border per ship spanning inter-cell gaps */
.ship-outline {
    position: absolute;
    pointer-events: none;
    border: 1px solid transparent;
    border-radius: 2px;
    z-index: 2;
}
.ship-outline.player { border-color: var(--friendly-border); }
.ship-outline.enemy  { border-color: var(--hostile-border); }

/* Fire Coordinator range aura — radial gradient overlay per Transport (amber) */
.fire-coordinator-aura-overlay {
    position: absolute;
    pointer-events: none;
    border-radius: 4px;
    z-index: 1;
}

/* Spotter Relay reveal flash (Frigate trait) */
.tactical-grid .cell.spotter-relay-reveal {
    animation: spotterRevealFlash 0.6s ease-out;
}

/* Fire Coordinator bonus shot animation */
.tactical-grid .cell.fire-support-shot {
    animation: fireSupportFlash 0.8s ease-out;
}

/* Placement mode highlights */
.tactical-grid .cell.placement-valid {
    background: rgba(60, 180, 60, 0.15);
    border-color: rgba(60, 180, 60, 0.3);
    cursor: pointer;
}

.tactical-grid .cell.placement-invalid {
    background: rgba(245, 90, 90, 0.15);
    cursor: not-allowed;
}

.tactical-grid .cell.placement-preview {
    background: var(--faction-bg);
    border-color: var(--faction-border);
    opacity: 0.6;
}

/* Row/column labels */
.grid-labels-left {
    position: absolute;
    left: -24px;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: var(--cell-gap, 2px);
}

.grid-labels-top {
    position: absolute;
    top: -22px;
    left: 0;
    display: flex;
    gap: var(--cell-gap, 2px);
}

.grid-label {
    width: var(--cell-size, 22px);
    height: var(--cell-size, 22px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: max(8px, calc(var(--cell-size, 22px) * 0.35));
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-secondary);
}

/* ---- Buttons (tactical-specific size variant only; base .btn styles from style.css) ---- */
.tactical-app .btn-small {
    padding: 6px 14px;
    font-size: 0.8rem;
}

/* ---- Game Over Screen ---- */
.gameover-screen {
    text-align: center;
    padding: 40px;
}

.gameover-screen h2 {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}

.gameover-screen.victory h2 {
    color: var(--victory);
    text-shadow: 0 0 40px var(--victory-glow);
}

.gameover-screen.defeat h2 {
    color: var(--hit);
    text-shadow: 0 0 40px var(--hit-glow);
}

.gameover-stats {
    display: flex;
    gap: 24px;
    justify-content: center;
    margin: 20px 0;
}

.stat-box {
    text-align: center;
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

.stat-box .stat-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.6rem;
    color: var(--faction-primary);
    font-weight: bold;
}

.stat-box .stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 2px;
}

/* ---- Kill Feed ---- */
.kill-feed {
    max-height: 200px;
    overflow-y: auto;
    font-size: 0.75rem;
}

@keyframes killFeedSlideIn {
    0% { opacity: 0; transform: translateX(-10px); }
    100% { opacity: 1; transform: translateX(0); }
}

.kill-feed-entry {
    padding: 3px 6px;
    border-bottom: 1px solid var(--border-subtle);
    border-left: 2px solid transparent;
    color: var(--text-secondary);
    animation: killFeedSlideIn 0.25s ease-out;
}

.kill-feed-entry.hit {
    color: var(--hit);
    border-left-color: var(--hit);
}

.kill-feed-entry.sunk {
    color: var(--ability-triggered);
    font-weight: bold;
    border-left-color: var(--ability-triggered);
}

.kill-feed-entry.miss {
    color: var(--text-muted);
    border-left-color: var(--text-muted);
}

.kill-feed-entry.move {
    color: var(--ability-active);
    border-left-color: var(--ability-active);
}

.kill-feed-entry.scan {
    border-left-color: rgba(100, 200, 255, 0.6);
}

/* ---- Action Buttons ---- */
.action-bar {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 8px;
    margin-top: 8px;
}

/* ---- Ability Panels Row (below grid) ---- */
.ability-panels-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: stretch;
    margin-top: 12px;
    padding: 0 12px;
}

.ability-panels-row > * {
    flex: 1;
    max-width: 524px;
    width: auto;
}

/* Override base .enemy-abilities.opponent-abilities-tracker margin/width from style.css */
.ability-panels-row > .opponent-abilities-tracker {
    margin-top: 0;
    width: auto;
}

/* Player abilities tracker — faction-colored variant of opponent-abilities-tracker */
.player-abilities-tracker {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    background: var(--faction-bg);
    border: 1px solid var(--faction-border);
    border-radius: 6px;
}

.player-abilities-tracker .opp-tracker-header {
    border-bottom-color: var(--faction-border);
}

.player-abilities-tracker .opp-tracker-header h5 {
    color: var(--faction-primary);
}

.player-abilities-tracker .opp-ability-icon {
    color: var(--faction-primary);
}

/* Interactive states for player abilities */
.player-abilities-tracker .opp-tracker-ability.available {
    border-color: var(--faction-border);
    cursor: pointer;
}

.player-abilities-tracker .opp-tracker-ability.available:hover {
    border-color: var(--faction-primary);
    background: var(--faction-bg);
    box-shadow: 0 0 8px var(--faction-glow);
}

.player-abilities-tracker .opp-tracker-ability.targeting {
    border-color: var(--faction-primary);
    background: var(--faction-bg);
    box-shadow: 0 0 12px var(--faction-glow);
}

/* Ship silhouettes - reduce cell background when silhouette is overlaid */
.tactical-grid .cell.has-player-ship.has-silhouette {
    background: var(--faction-bg, rgba(50, 60, 80, 0.3));
    box-shadow: none;
}

.tactical-grid .cell.has-enemy-ship.has-silhouette {
    background: var(--opponent-bg, rgba(80, 50, 50, 0.3));
    box-shadow: none;
}

/* Scan reveal overlay */
.cell.scan-reveal {
    box-shadow: inset 0 0 8px rgba(68, 170, 255, 0.6);
}

/* Armor absorbed indicator */
.tactical-grid .cell.armor-absorbed::after {
    content: '';
    position: absolute;
    inset: 15%;
    border: 2px solid #f0c040;
    border-radius: 50%;
    opacity: 0.9;
    box-shadow: 0 0 6px rgba(240, 192, 64, 0.6);
}

/* ---- Hints Panel ---- */
.hint-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.hint-item kbd {
    display: inline-block;
    min-width: 20px;
    padding: 1px 5px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    text-align: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-medium);
    border-radius: 3px;
    color: var(--text-primary);
    flex-shrink: 0;
}

/* ---- Responsive ---- */
:root {
    --cell-size: 24px;
    --cell-gap: 2px;
}

@media (min-width: 1400px) {
    :root {
        --cell-size: 28px;
    }
}

@media (max-width: 900px) {
    :root {
        --cell-size: 20px;
    }

    .battle-layout {
        flex-direction: column;
        align-items: center;
    }

    .side-panel {
        width: 100%;
        max-width: 500px;
        flex-direction: row;
        flex-wrap: wrap;
        margin-top: 0;
    }

    .panel-section {
        flex: 1;
        min-width: 150px;
    }

    .ability-panels-row {
        flex-direction: column;
        align-items: center;
    }

    .ability-panels-row > * {
        width: 100%;
        max-width: 500px;
    }
}

@media (max-width: 650px) {
    :root {
        --cell-size: 13px;
    }

    .tactical-header h1 {
        font-size: 1.1rem;
    }

    .ship-class-card {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* ---- Ship Movement Animation ---- */
.ship-move-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 10;
    border-radius: 2px;
    transition: transform 400ms ease-in-out;
    will-change: transform;
}

.ship-move-overlay.rotating {
    transition: opacity 250ms ease-in-out;
}

/* Hide real ship visuals while movement overlay is animating */
.move-anim-hide {
    opacity: 0 !important;
    transition: none !important;
}

/* Departure dust — brief radial fade on vacated cells */
@keyframes departureDust {
    0% { background: radial-gradient(circle, rgba(150, 180, 220, 0.4) 0%, transparent 70%); }
    100% { background: transparent; }
}
.cell.departure-dust {
    animation: departureDust 0.5s ease-out;
}

/* Arrival glow — brief glow on destination cells */
@keyframes arrivalGlow {
    0% { box-shadow: inset 0 0 10px rgba(100, 200, 255, 0.5); }
    100% { box-shadow: none; }
}
.cell.arrival-glow {
    animation: arrivalGlow 0.4s ease-out;
}

/* Move hover preview — ghost ship at hovered move target */
.ship-move-ghost {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    opacity: 0.35;
    border: 1px dashed var(--faction-primary);
    border-radius: 2px;
}

/* ---- Animations ---- */

/* Fog reveal — cells newly emerging from fog */
@keyframes fogReveal {
    0% { box-shadow: inset 0 0 12px rgba(100, 200, 255, 0.6); background: rgba(100, 200, 255, 0.15); }
    100% { box-shadow: none; background: transparent; }
}

.cell.fog-reveal {
    animation: fogReveal 0.6s ease-out;
}

.cell.reveal-flash {
    animation: fogReveal 0.3s ease-out;
}

/* Hit animation — reuses pulse-hit and ripple-out-hit from animations.css */
.tactical-grid .cell.hit-anim {
    animation: pulse-hit 0.6s ease-out forwards;
}
.tactical-grid .cell.hit-anim::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 10px; height: 10px;
    background: transparent;
    border: 3px solid var(--hit);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: ripple-out-hit 0.6s ease-out forwards;
    z-index: 100;
    pointer-events: none;
}

/* Miss animation — reuses pulse-miss and ripple-out-miss from animations.css */
.tactical-grid .cell.miss-anim {
    animation: pulse-miss 0.6s ease-out forwards;
}
.tactical-grid .cell.miss-anim::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    width: 10px; height: 10px;
    background: transparent;
    border: 3px solid var(--faction-primary);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: ripple-out-miss 0.6s ease-out forwards;
    z-index: 100;
    pointer-events: none;
}

/* Grid shake for tactical */
.grid-container.shake {
    animation: shake 0.3s ease-out;
}

/* ---- Trait activation indicators ---- */

/* Shared trait label base — floats above cell, pointer-events none */
.trait-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: 'JetBrains Mono', monospace;
    font-size: max(9px, calc(var(--cell-size, 22px) * 0.45));
    font-weight: 700;
    letter-spacing: 1px;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
}

/* --- Evasion Dodge (Fighter) --- */
@keyframes evasionDodge {
    0%   { transform: translateX(0); background: rgba(100, 180, 255, 0.3); }
    20%  { transform: translateX(-3px); }
    40%  { transform: translateX(3px); }
    60%  { transform: translateX(-2px); }
    80%  { transform: translateX(1px); }
    100% { transform: translateX(0); background: transparent; }
}

.tactical-grid .cell.evasion-dodge {
    animation: evasionDodge 0.6s ease-out;
}

@keyframes evasionLabelFloat {
    0%   { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -180%); }
}

.evasion-label {
    color: #6ab4ff;
    text-shadow: 0 0 6px rgba(106, 180, 255, 0.8);
    animation: evasionLabelFloat 0.8s ease-out forwards;
}

/* --- Fire Support (Transport) --- */
@keyframes fireSupportFlash {
    0%   { box-shadow: inset 0 0 8px rgba(255, 200, 60, 0.7); }
    50%  { box-shadow: inset 0 0 14px rgba(255, 200, 60, 0.4); }
    100% { box-shadow: none; }
}

@keyframes fireSupportLabelPop {
    0%   { opacity: 1; transform: translate(-50%, -50%) scale(0.5); }
    30%  { transform: translate(-50%, -50%) scale(1.3); }
    100% { opacity: 0; transform: translate(-50%, -120%) scale(1); }
}

.fire-support-label {
    color: #ffc83c;
    font-size: max(10px, calc(var(--cell-size, 22px) * 0.45));
    text-shadow: 0 0 6px rgba(255, 200, 60, 0.8);
    animation: fireSupportLabelPop 0.8s ease-out forwards;
}

/* Fire Support source flash (firing ship) */
.tactical-grid .cell.fire-support-source {
    animation: fireSupportFlash 0.6s ease-out;
}

/* --- Spotter Relay (Frigate) --- */
@keyframes spotterRevealFlash {
    0%   { box-shadow: inset 0 0 10px rgba(60, 180, 220, 0.6); background: rgba(60, 180, 220, 0.15); }
    100% { box-shadow: none; background: transparent; }
}

/* --- Electronic Warfare (Corvette) --- */
@keyframes sensorJam {
    0%   { box-shadow: inset 0 0 12px rgba(0, 200, 255, 0.7); }
    50%  { box-shadow: inset 0 0 6px rgba(0, 200, 255, 0.3); }
    100% { box-shadow: none; }
}

.tactical-grid .cell.sensor-jam {
    animation: sensorJam 1s ease-out;
}

@keyframes jamLabelFloat {
    0%   { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -180%); }
}

.jam-label {
    color: #00c8ff;
    text-shadow: 0 0 6px rgba(0, 200, 255, 0.8);
    animation: jamLabelFloat 1s ease-out forwards;
}

/* --- Blaster Bolts --- */
.blaster-bolt {
    position: absolute;
    width: 14px;   /* overridden by JS per ship class */
    height: 4px;   /* overridden by JS per ship class */
    border-radius: 2px;
    pointer-events: none;
    z-index: 100;
    opacity: 0.95;
}

/* ---- Faction Picker ---- */
.faction-picker-section {
    margin-bottom: 20px;
}

.faction-picker-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin: 0 0 10px 0;
}

.faction-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 8px;
}

.faction-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-subtle);
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-family: inherit;
}

.faction-btn:hover {
    border-color: var(--faction-border);
    box-shadow: 0 0 20px var(--faction-glow);
    transform: translateY(-3px);
}

.faction-btn.selected {
    border-color: var(--faction-primary);
    background: var(--faction-bg);
    box-shadow: 0 0 25px var(--faction-glow);
}

.faction-btn .faction-name {
    font-size: 0.85rem;
    font-weight: bold;
    margin-bottom: 4px;
}

.faction-btn .faction-abilities {
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.3;
}

.faction-btn.selected .faction-abilities {
    color: var(--text-secondary);
}

/* ---- Decoy cell ---- */
.cell.has-decoy {
    background: var(--bg-tertiary);
    border: 1px dashed var(--faction-primary);
}

/* ---- Sweep line preview ---- */
.cell.sweep-line {
    box-shadow: inset 0 0 8px rgba(100, 200, 255, 0.4);
    border-color: rgba(100, 200, 255, 0.6);
}

/* ---- Decoy placement preview ---- */
.cell.decoy-preview {
    box-shadow: inset 0 0 8px rgba(200, 200, 100, 0.4);
    border-color: rgba(200, 200, 100, 0.6);
}

.cell.probe-preview {
    box-shadow: inset 0 0 8px rgba(59, 111, 160, 0.5);
    border-color: rgba(59, 111, 160, 0.7);
}

/* ---- Scan flash (area reveal, mandate, sweep) ---- */
@keyframes scanFlash {
    0% { background: rgba(100, 200, 255, 0.6); }
    100% { background: transparent; }
}
.cell.scan-flash {
    animation: scanFlash 0.6s ease-out;
}

/* ---- Deflect flash ---- */
@keyframes deflectFlash {
    0% { background: rgba(180, 180, 255, 0.7); }
    50% { background: rgba(180, 180, 255, 0.3); }
    100% { background: transparent; }
}
.cell.deflect-flash {
    animation: deflectFlash 0.5s ease-out;
}

/* ---- Repair flash ---- */
@keyframes repairFlash {
    0% { background: rgba(100, 255, 140, 0.6); }
    100% { background: transparent; }
}
.cell.repair-flash {
    animation: repairFlash 0.5s ease-out;
}

/* ---- Sweep flash (sector sweep / orbital bombardment) ---- */
@keyframes sweepFlash {
    0% { background: rgba(100, 200, 255, 0.5); }
    40% { background: rgba(100, 200, 255, 0.2); }
    100% { background: transparent; }
}
.cell.sweep-flash {
    animation: sweepFlash 0.8s ease-out;
}

/* ---- Decoy deploy flash ---- */
@keyframes decoyFlash {
    0% { background: rgba(200, 200, 100, 0.6); }
    100% { background: transparent; }
}
.cell.decoy-flash {
    animation: decoyFlash 0.6s ease-out;
}

/* ---- Armor absorb flash (gold shield) ---- */
@keyframes armorFlash {
    0%   { background: rgba(240, 192, 64, 0.6); box-shadow: inset 0 0 10px rgba(240, 192, 64, 0.8); }
    50%  { background: rgba(240, 192, 64, 0.3); box-shadow: inset 0 0 6px rgba(240, 192, 64, 0.4); }
    100% { background: transparent; box-shadow: none; }
}
.cell.armor-flash {
    animation: armorFlash 0.5s ease-out;
}

@keyframes armorLabelFloat {
    0%   { opacity: 1; transform: translate(-50%, -50%); }
    100% { opacity: 0; transform: translate(-50%, -180%); }
}

.armor-label {
    color: #f0c040;
    text-shadow: 0 0 6px rgba(240, 192, 64, 0.8);
    animation: armorLabelFloat 0.8s ease-out forwards;
}

/* ---- Roster armor indicator ---- */
.ship-roster-item .ship-armor {
    margin-left: 4px;
    color: #f0c040;
    font-size: 0.7rem;
    font-weight: 700;
}
.ship-roster-item .ship-armor.depleted {
    color: var(--text-muted);
    opacity: 0.5;
}

/* ---- Armor-active ship outline glow ---- */
.ship-outline.armor-active {
    border-color: rgba(240, 192, 64, 0.7);
    box-shadow: 0 0 6px rgba(240, 192, 64, 0.4), inset 0 0 4px rgba(240, 192, 64, 0.2);
}

/* ===========================================
   BOARD-LEVEL ANIMATION ALIASES
   Duplicate .board-section effects from animations.css
   for .grid-container used in tactical mode
   =========================================== */

/* Multi-Shot / Double Shot Activation */
.grid-container.double-shot-active {
    animation: power-charge 0.5s ease-out;
}

.grid-container.double-shot-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 40%, rgba(0, 212, 255, 0.5) 50%, transparent 60%);
    animation: power-sweep 0.5s ease-out;
    pointer-events: none;
    z-index: 5;
}

.grid-container .multi-shot-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 212, 255, 0.9);
    color: #000;
    font-size: 18px;
    font-weight: 700;
    padding: 4px 16px;
    border-radius: 6px;
    z-index: 20;
    pointer-events: none;
    animation: multi-shot-pop 0.5s ease-out;
}

.grid-container .multi-shot-label.fade-out {
    opacity: 0;
    transition: opacity 0.5s ease-out;
}

/* Splash Damage Activation - red pulse */
.grid-container.splash-damage-activated {
    animation: splash-pulse 0.6s ease-out;
}

/* Relentless Assault - orange power charge effect */
.grid-container.relentless-active {
    animation: relentless-charge 0.6s ease-out;
}

.grid-container.relentless-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 40%, rgba(255, 100, 0, 0.6) 50%, transparent 60%);
    animation: relentless-sweep 0.5s ease-out;
    pointer-events: none;
    z-index: 5;
}

/* Guerrilla Tactics - digital scanline glitch */
.grid-container.guerrilla-active {
    position: relative;
}

.grid-container.guerrilla-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(34, 197, 94, 0.05) 2px,
        rgba(34, 197, 94, 0.05) 4px
    );
    animation: guerrilla-glitch 0.6s steps(4) forwards;
    pointer-events: none;
    z-index: 20;
}

/* Iron Might - golden gradient sweep */
.grid-container.iron-surge {
    position: relative;
}

.grid-container.iron-surge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.15), transparent);
    animation: iron-surge-bg 0.6s ease-out forwards;
    pointer-events: none;
    z-index: 20;
}

/* ===========================================
   LIGHT MODE FOG ADJUSTMENTS
   =========================================== */
[data-theme="light"] .tactical-grid .cell.fog-dense {
    background:
        repeating-linear-gradient(
            45deg,
            rgba(180, 185, 200, 0.7),
            rgba(180, 185, 200, 0.7) 2px,
            rgba(195, 200, 215, 0.6) 2px,
            rgba(195, 200, 215, 0.6) 4px
        );
}

[data-theme="light"] .tactical-grid .cell.fog-dense::before {
    background: radial-gradient(
        ellipse at 50% 50%,
        rgba(100, 120, 180, 0.06) 0%,
        transparent 70%
    );
}

[data-theme="light"] .tactical-grid .cell.fog-light {
    background: rgba(200, 205, 220, 0.5);
}

[data-theme="light"] .tactical-grid .cell.fire-edge-top    { border-top: 1px dashed rgba(200, 50, 50, 0.45); }
[data-theme="light"] .tactical-grid .cell.fire-edge-bottom { border-bottom: 1px dashed rgba(200, 50, 50, 0.45); }
[data-theme="light"] .tactical-grid .cell.fire-edge-left   { border-left: 1px dashed rgba(200, 50, 50, 0.45); }
[data-theme="light"] .tactical-grid .cell.fire-edge-right  { border-right: 1px dashed rgba(200, 50, 50, 0.45); }

[data-theme="light"] .tactical-grid .cell.out-of-range {
    opacity: 0.3;
    filter: saturate(0.4);
}

/* ---- Tactical ability tooltips ---- */
.opp-tracker-ability {
    position: relative;
}

.opp-tracker-ability .tactical-tooltip {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: 4px;
    font-size: 0.8rem;
    line-height: 1.4;
    color: var(--text-secondary);
    white-space: normal;
    width: max-content;
    max-width: 280px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

.opp-tracker-ability .tactical-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--border-subtle);
}

.opp-tracker-ability:hover .tactical-tooltip {
    display: block;
}

