/* === STATISTICS === */
.stats-container {
    margin-bottom: var(--space-6);
}

.stats-mode-selector {
    display: flex; gap: var(--space-1); margin-bottom: var(--space-3); justify-content: center;
}
.stats-mode-btn {
    flex: 1; max-width: 120px; border: 1px solid var(--border); background: var(--bg-card);
    color: var(--text-muted); font-size: 0.7rem; letter-spacing: 0.05em;
}
.stats-mode-btn.active {
    border-color: var(--gold); color: var(--gold); background: rgba(212,175,55,0.1);
}

.stats-overview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: var(--space-3);
}

.stats-record {
    text-align: center;
}

.stats-record-number {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 900;
    color: var(--gold);
}

.stats-record-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.stats-wld {
    display: flex;
    gap: var(--space-3);
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
}

.stats-w { color: var(--success); }
.stats-d { color: var(--gold); }
.stats-l { color: var(--danger); }

.stats-vp-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.stats-vp {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-3);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.stats-vp-value {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

.stats-breakdown {
    margin-bottom: var(--space-4);
}

.stats-breakdown-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.stat-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--space-2);
    align-items: center;
    margin-bottom: var(--space-2);
}

.stat-row-name {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
}

.stat-row-record {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-display);
    white-space: nowrap;
}

.stat-bar {
    grid-column: 1 / -1;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-input);
    display: flex;
    overflow: hidden;
    margin-bottom: var(--space-1);
}

.stat-bar-w { background: var(--success); }
.stat-bar-d { background: var(--gold); }
.stat-bar-l { background: var(--danger); }
.stat-bar-phase { background: var(--phase-shooting); }

.stats-positive { color: var(--success); }
.stats-negative { color: var(--danger); }

/* === STATS SUB-TAB BAR === */
.stats-subtab-bar {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--space-2);
    gap: 0;
    position: sticky;
    top: 0;
    z-index: 15;
    flex-shrink: 0;
    /* Fade hint on right edge to show scrollability */
    mask-image: linear-gradient(to right, black calc(100% - 20px), transparent);
    -webkit-mask-image: linear-gradient(to right, black calc(100% - 20px), transparent);
}
.stats-subtab-bar::-webkit-scrollbar { display: none; }
.stats-subtab-bar.scrolled-end {
    mask-image: none;
    -webkit-mask-image: none;
}

.stats-subtab {
    flex-shrink: 0;
    padding: var(--space-2) var(--space-3);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.stats-subtab:hover { color: var(--text-secondary); }
.stats-subtab.active {
    color: var(--gold);
    border-bottom-color: var(--gold);
}

.stats-subtab-panel { padding: var(--space-4); }
.stats-subtab-panel:not(.active) { display: none; }

/* === STATS HEATMAP === */
.stats-heatmap {
    display: grid;
    grid-template-columns: auto repeat(4, 1fr);
    gap: 4px;
    margin-bottom: var(--space-4);
}
.stats-heatmap-label {
    font-family: var(--font-display);
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    padding-right: var(--space-2);
}
.stats-heatmap-header {
    font-family: var(--font-display);
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    padding: var(--space-1) 0;
}
.stats-heatmap-cell {
    border-radius: 4px;
    padding: var(--space-2);
    text-align: center;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.heatmap-0 { background: var(--bg-input); }
.heatmap-1 { background: rgba(212, 175, 55, 0.15); }
.heatmap-2 { background: rgba(212, 175, 55, 0.3); }
.heatmap-3 { background: rgba(212, 175, 55, 0.5); }
.heatmap-4 { background: rgba(212, 175, 55, 0.7); color: var(--bg-root); }

/* === RP EFFICIENCY CARD === */
.stats-efficiency-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: var(--space-4);
}
.stats-efficiency-ring {
    position: relative;
    width: 80px;
    height: 80px;
}
.stats-efficiency-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}
.stats-efficiency-ring-bg {
    fill: none;
    stroke: var(--bg-input);
    stroke-width: 8;
}
.stats-efficiency-ring-fill {
    fill: none;
    stroke: var(--gold);
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}
.stats-efficiency-pct {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--gold);
}
.stats-efficiency-detail {
    flex: 1;
    padding-left: var(--space-4);
}

/* === EVENT TIMELINE (battle detail) === */
.event-timeline {
    margin-bottom: var(--space-4);
}
.event-timeline-round {
    margin-bottom: var(--space-3);
}
.event-timeline-round-header {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--gold);
    letter-spacing: 0.08em;
    margin-bottom: var(--space-1);
    padding-bottom: var(--space-1);
    border-bottom: 1px solid var(--border);
}
.event-timeline-item {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.event-timeline-phase {
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    min-width: 65px;
}
.event-timeline-type {
    font-weight: 600;
    color: var(--text-primary);
}

/* === VP SOURCE BAR === */
.vp-source-bar {
    display: flex;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: var(--space-2);
}
.vp-source-primary { background: var(--phase-shooting); }
.vp-source-secondary { background: var(--phase-movement); }
.vp-source-manual { background: var(--steel); }

.vp-source-legend {
    display: flex;
    gap: var(--space-3);
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
}
.vp-source-legend-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}
.vp-source-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* === VP TREND CHART === */
.vp-trend-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 80px;
    padding: var(--space-2) 0;
    margin-bottom: var(--space-2);
}
.vp-trend-bar-group {
    flex: 1;
    display: flex;
    gap: 1px;
    align-items: flex-end;
    height: 100%;
    border-bottom: 2px solid transparent;
    padding-bottom: 2px;
}
.vp-trend-bar-group.trend-win { border-bottom-color: var(--success); }
.vp-trend-bar-group.trend-loss { border-bottom-color: var(--danger); }
.vp-trend-bar-group.trend-draw { border-bottom-color: var(--gold); }
.vp-trend-bar {
    flex: 1;
    border-radius: 2px 2px 0 0;
    min-width: 4px;
    transition: height 0.3s ease;
}
.vp-trend-p1 { background: var(--player-1); opacity: 0.8; }
.vp-trend-p2 { background: var(--player-2); opacity: 0.8; }

/* === UNIT SCORING STATS === */
.unit-stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-3);
    margin-bottom: var(--space-2);
}
.unit-stat-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: var(--space-2);
}
.unit-stat-name {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--gold);
}
.unit-stat-games {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.unit-stat-bar-track {
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    margin-bottom: var(--space-2);
    overflow: hidden;
}
.unit-stat-bar {
    height: 100%;
    background: var(--gold);
    border-radius: 2px;
    transition: width 0.3s ease;
}
.unit-stat-details {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
}
.unit-stat-detail {
    display: flex;
    flex-direction: column;
}
.unit-stat-detail-value {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary);
}
.unit-stat-detail-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.unit-stat-line { color: var(--success); }
.unit-stat-vanguard { color: #63b3ed; }

/* === BATTLE HISTORY RESULTS === */
.battle-item {
    background: var(--bg-elevated);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
}

.battle-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    /* Reserve room for the absolutely-positioned .battle-item-delete (28px + 8px right offset). */
    padding-right: 40px;
}

.battle-item-matchup {
    font-family: var(--font-display);
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 600;
}

.battle-item-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.battle-item-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    font-family: var(--font-display);
}

.battle-item-result-label {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.battle-item-score {
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: auto;
}

.result-win {
    background: rgba(56, 161, 105, 0.12);
    color: var(--success);
}

.result-loss {
    background: rgba(229, 62, 62, 0.12);
    color: var(--danger);
}

.result-draw {
    background: var(--gold-dim);
    color: var(--gold);
}

.result-active {
    background: rgba(66, 153, 225, 0.12);
    color: var(--info);
}

.battle-item-clickable {
    cursor: pointer;
    transition: border-color 0.15s;
}

.battle-item-clickable:hover {
    border-color: var(--gold-glow);
}

.battle-item {
    position: relative;
}

.battle-item-delete {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(229, 62, 62, 0.55);
    background: rgba(229, 62, 62, 0.12);
    color: var(--danger);
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
    z-index: 1;
}

.battle-item-delete:hover,
.battle-item-delete:focus-visible {
    background: rgba(229, 62, 62, 0.28);
    border-color: var(--danger);
    color: var(--danger);
    outline: none;
}

.battle-item-delete:disabled {
    opacity: 0.4;
    cursor: default;
}

/* === BATTLE DETAIL VIEW (Full-Screen) === */
.battle-detail-fullscreen {
    position: fixed;
    inset: 0;
    background: var(--bg-root);
    z-index: 200;
    display: flex;
    flex-direction: column;
    animation: slideInRight 250ms ease-out;
}

@keyframes slideInRight {
    from { transform: translateX(30px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.detail-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    padding-top: calc(var(--space-3) + env(safe-area-inset-top, 0px));
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
    background: var(--bg-surface);
}

.detail-back-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: var(--space-2) var(--space-3);
    border-radius: 6px;
    cursor: pointer;
    transition: all 150ms ease-out;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.detail-back-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

.detail-back-arrow {
    font-size: 1.1rem;
}

.detail-topbar-title {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.08em;
}

.detail-scroll-area {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

.detail-content {
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-4);
    padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom, 0px));
}

.detail-header {
    text-align: center;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.detail-matchup {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-4);
    margin-bottom: var(--space-3);
}

.detail-player {
    text-align: center;
    flex: 1;
}

.detail-player-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.detail-player-legion {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

.detail-player-vp {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 900;
    color: var(--gold);
}

.detail-vs {
    color: var(--text-muted);
    font-family: var(--font-display);
}

.detail-result {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    padding: var(--space-1) var(--space-4);
    border-radius: 4px;
    margin-bottom: var(--space-3);
}

.detail-meta {
    display: flex;
    justify-content: center;
    gap: var(--space-3);
    font-size: 0.75rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.detail-section {
    margin-bottom: var(--space-5);
}

.detail-section-title {
    font-family: var(--font-display);
    font-size: 0.8rem;
    color: var(--text-muted);
    letter-spacing: 0.1em;
    margin-bottom: var(--space-2);
}

.detail-section-header-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}

.detail-section-header-row .detail-section-title {
    margin-bottom: 0;
}

.detail-event-count {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.detail-toggle-btn {
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: var(--font-display);
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: var(--space-1) var(--space-2);
    border-radius: 4px;
    cursor: pointer;
    transition: all 150ms ease-out;
}

.detail-toggle-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
}

/* VP Progression */
.detail-vp-round {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
}

.detail-vp-round-label {
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    min-width: 28px;
}

.detail-vp-bars {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.detail-vp-bar-row {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.detail-vp-bar-name {
    font-size: 0.65rem;
    color: var(--text-muted);
    min-width: 70px;
    text-align: right;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-vp-bar-track {
    flex: 1;
    height: 14px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.detail-vp-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 300ms ease-out;
    min-width: 2px;
}

.detail-vp-bar-p1 {
    background: var(--gold);
}

.detail-vp-bar-p2 {
    background: var(--text-muted);
}

.detail-vp-bar-val {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 24px;
    text-align: right;
}

/* Scoring */
.detail-score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border-radius: 4px;
    margin-bottom: var(--space-1);
    gap: var(--space-2);
}

.detail-score-round {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 65px;
}

.detail-score-vp {
    font-family: var(--font-display);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.detail-score-cumulative {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.detail-score-delta {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    min-width: 40px;
    text-align: right;
}

.delta-ahead { color: var(--success); }
.delta-behind { color: var(--error); }
.delta-tied { color: var(--gold); }

.detail-score-notes {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0 var(--space-3) var(--space-1);
}

/* Reactions */
.detail-reaction-summary {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border-radius: 4px;
    border-left: 3px solid var(--gold);
}

.detail-reaction-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border-radius: 4px;
    margin-bottom: var(--space-1);
}

.detail-reaction-name {
    font-family: var(--font-display);
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 600;
}

.detail-reaction-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Journal */
.detail-journal-row {
    padding: var(--space-2) var(--space-3);
    background: var(--bg-elevated);
    border-radius: 4px;
    margin-bottom: var(--space-1);
}

.detail-journal-row.journal-mvp {
    border-left: 3px solid var(--gold);
    background: rgba(212, 175, 55, 0.05);
}

.detail-journal-row.journal-memorable {
    border-left: 3px solid var(--info);
    background: rgba(59, 130, 246, 0.05);
}

.detail-journal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1);
}

.detail-journal-type {
    font-family: var(--font-display);
    font-size: 0.7rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.detail-journal-time {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.detail-journal-content {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Mission Details */
.detail-mission-card {
    background: var(--bg-elevated);
    border-radius: 6px;
    padding: var(--space-3);
    border: 1px solid var(--border);
}

.detail-mission-name {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: var(--space-2);
}

.detail-mission-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
}

.detail-mission-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
    line-height: 1.4;
}

.detail-mission-objectives {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: var(--space-2);
}

.detail-mission-objectives strong {
    color: var(--text-primary);
}

.detail-mission-objectives ul {
    margin: var(--space-1) 0 0 var(--space-4);
    padding: 0;
}

.detail-mission-objectives li {
    margin-bottom: 2px;
}

/* Action Buttons */
.detail-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-4);
}

.detail-actions .btn {
    flex: 1;
}

/* Event timeline player label */
.event-timeline-player {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}
