/* ============================================================
   JSOC OPS Warlords - Dark Theme
   ============================================================ */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --bg-surface: #1e2a3a;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0b0;
    --text-muted: #606070;
    --border: #2a3a4a;
    --accent: #008DF8;
    --color-west: #008DF8;
    --color-east: #FA4C58;
    --color-guer: #8CE10B;
    --color-civ: #FFD966;
    --color-neutral: #333333;
    --color-success: #8CE10B;
    --color-error: #FA4C58;
    --color-warning: #FFD966;
    --sidebar-width: 320px;
    --topbar-height: 44px;
    --timeline-height: 40px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ---- Top Bar ---- */

#topbar {
    height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 1000;
    flex-shrink: 0;
}

#topbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 6px;
}

#topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

#topbar-logo {
    height: 30px;
    width: auto;
    flex-shrink: 0;
}

#app-title {
    font-weight: 700;
    font-size: 14px;
    letter-spacing: 0.5px;
    color: #F1AE00;
}

/* ---- Help Button ---- */

.help-btn {
    height: 32px;
    border-radius: 16px;
    background: #F1AE00;
    color: #111;
    border: none;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 12px;
    transition: all 0.15s;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(241, 174, 0, 0.4);
    white-space: nowrap;
}

.help-btn:hover {
    background: #ffca28;
    transform: scale(1.05);
}

/* ---- Timeline Event Ticks ---- */

#timeline-ticks-overlay {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    pointer-events: none;
    overflow: visible;
}

.timeline-tick {
    position: absolute;
    transform: translateX(-50%);
    width: 6px;
    height: 12px;
    border-radius: 2px;
    cursor: pointer;
    pointer-events: auto;
    opacity: 0.85;
    transition: opacity 0.15s, height 0.15s;
}

.timeline-tick:hover {
    opacity: 1;
    height: 16px;
}

.timeline-tick.sector-captured {
    background: #FFD700;
    top: -14px;
}

.timeline-tick.objective-captured {
    background: #00BFFF;
    top: calc(100% + 2px);
}

#timeline-tick-tooltip {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 2000;
    white-space: nowrap;
    display: none;
}

/* ---- Help Accordion Sections ---- */

.help-accordion-header {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 6px 0 4px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}

.help-accordion-header::after {
    content: '▶';
    font-size: 9px;
    opacity: 0.5;
    transition: transform 0.15s;
}

.help-accordion-header.open::after {
    transform: rotate(90deg);
}

.help-accordion-header:hover {
    color: var(--text-primary);
}

.help-accordion-header.hidden,
.help-accordion-body.hidden {
    display: none !important;
}

.help-accordion-body {
    display: none;
    padding-top: 6px;
}

.help-accordion-body.open {
    display: block;
}

.help-mode-hint {
    font-size: 11px;
    color: #F1AE00;
    font-weight: 600;
    margin-bottom: 10px;
    padding: 4px 8px;
    background: rgba(241, 174, 0, 0.1);
    border-radius: 4px;
    border-left: 3px solid #F1AE00;
}

/* ---- Confirm Modal ---- */

.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.confirm-modal.hidden {
    display: none !important;
}

.confirm-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
}

.confirm-modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px 28px;
    max-width: 380px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.confirm-modal-content h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.confirm-modal-content p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

.confirm-modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.action-btn.danger {
    background: var(--color-error);
    border-color: var(--color-error);
    color: #fff;
}

.action-btn.danger:hover {
    background: #c0333e;
    border-color: #c0333e;
}

/* ---- Player Detail Modal ---- */

.player-detail-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3500;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-detail-modal.hidden {
    display: none !important;
}

.player-detail-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
}

.player-detail-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px 28px;
    max-width: 760px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.player-detail-content h4 {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 12px;
    padding-right: 28px;
}

/* ---- Objective List Icon ---- */

.obj-list-icon {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

.objective-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.obj-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

/* ---- Admin bulk-delete input ---- */

.bulk-n-input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 6px;
    font-size: 11px;
    border-radius: 4px;
    width: 48px;
    text-align: center;
}

/* ---- Help Modal ---- */

.help-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-modal.hidden {
    display: none !important;
}

.help-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
}

.help-modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 28px 32px;
    max-width: 520px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.help-modal-content h2 {
    font-size: 18px;
    font-weight: 700;
    color: #F1AE00;
    margin-bottom: 20px;
    letter-spacing: 0.5px;
}

.help-modal-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.help-modal-close:hover {
    color: var(--text-primary);
}

.help-section {
    margin-bottom: 18px;
}

.help-section h3 {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.help-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 4px 0;
    font-size: 13px;
    color: var(--text-primary);
}

.help-row kbd {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 12px;
    font-family: monospace;
    color: #F1AE00;
    white-space: nowrap;
    min-width: fit-content;
}

/* ---- Topbar Dropdowns ---- */

.topbar-select {
    background: var(--bg-surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    outline: none;
}

.topbar-select:hover {
    border-color: var(--accent);
}

.topbar-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.status-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--color-neutral);
    color: var(--text-secondary);
}

.status-badge.live {
    background: var(--color-success);
    color: #111;
}

#topbar-right {
    display: flex;
    gap: 4px;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.15s;
}

.tab-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--bg-tertiary);
    color: var(--accent);
}

/* ---- Map ---- */

#map {
    flex: 1;
    background: var(--bg-primary);
    z-index: 1;
}

.leaflet-container {
    background: var(--bg-primary) !important;
}

/* ---- Sidebar ---- */

#sidebar {
    position: fixed;
    top: var(--topbar-height);
    right: 0;
    bottom: var(--timeline-height);
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    z-index: 500;
    overflow-y: auto;
    transition: transform 0.2s ease;
}

#sidebar.sidebar-closed {
    transform: translateX(var(--sidebar-width));
}

#sidebar-toggle {
    position: absolute;
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 4px 0 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 12px;
}

#sidebar.sidebar-closed #sidebar-toggle {
    content: '\25B6';
}

.sidebar-panel {
    display: none;
    padding: 16px;
}

.sidebar-panel.active {
    display: block;
}

.sidebar-panel h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* ---- Sector List ---- */

.sector-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.sector-item:hover {
    border-color: var(--accent);
}

.sector-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}

.sector-status {
    font-size: 11px;
    color: var(--text-secondary);
}

.sector-status .captured {
    color: var(--color-success);
    font-weight: 600;
}

.sector-sides {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.side-tag {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.side-tag.WEST { background: var(--color-west); color: #fff; }
.side-tag.EAST { background: var(--color-east); color: #fff; }
.side-tag.GUER { background: var(--color-guer); color: #111; }
.side-tag.RESISTANCE { background: var(--color-guer); color: #111; }
.side-tag.CIV { background: var(--color-civ); color: #111; }

/* ---- Objective List ---- */

.objective-item {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.objective-item:hover {
    border-color: var(--accent);
}

.obj-title {
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.obj-sector {
    font-size: 11px;
    color: var(--text-muted);
}

/* ---- Detail Panel ---- */

.detail-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px;
    margin-top: 12px;
}

.detail-close {
    float: right;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.detail-close:hover {
    color: var(--text-primary);
}

.detail-row {
    margin: 8px 0;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-label {
    color: var(--text-secondary);
    min-width: 100px;
    flex-shrink: 0;
}

/* Progress bar */

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s;
}

/* Gauge */

.gauge {
    flex: 1;
    height: 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    overflow: hidden;
}

.gauge-fill {
    height: 100%;
    background: var(--color-success);
    border-radius: 4px;
    transition: width 0.3s;
}

/* ---- Drawings Panel ---- */

.panel-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.action-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.action-btn:hover {
    background: var(--bg-tertiary);
}

.action-btn.accent {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.action-btn.accent:hover {
    background: #0070d0;
}

.share-link {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.share-link input {
    flex: 1;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
}

.share-link button {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 4px;
    cursor: pointer;
}

/* ---- Scoreboard ---- */

.auth-prompt {
    text-align: center;
    padding: 20px 0;
}

.auth-prompt p {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.auth-prompt input {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 12px;
    font-size: 13px;
    border-radius: 4px;
    width: 100%;
    margin-bottom: 8px;
}

.error-text {
    color: var(--color-error) !important;
    font-size: 11px !important;
}

#scoreboard-awards {
    margin-bottom: 12px;
}

.award-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-right: 6px;
    margin-bottom: 4px;
}

.award-badge.mvp {
    background: var(--color-success);
    color: #111;
}

.award-badge.muvp {
    background: var(--color-error);
    color: #fff;
}

#scoreboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

#scoreboard-table th {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 11px;
}

#scoreboard-table th.num {
    text-align: right;
}

#scoreboard-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

#scoreboard-table td.num {
    text-align: right;
    font-family: monospace;
}

#scoreboard-table tr {
    cursor: pointer;
    transition: background 0.15s;
}

#scoreboard-table tbody tr:hover {
    background: var(--bg-surface);
}

.ff-highlight {
    color: var(--color-error) !important;
    font-weight: 700;
}

/* Player detail log table */

#player-log-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    margin-top: 10px;
}

#player-log-table th {
    text-align: left;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 10px;
}

#player-log-table td {
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
}

#player-log-table th.num {
    text-align: right;
}

#player-log-table td.num {
    text-align: right;
    font-family: monospace;
}

.ff-row {
    background: rgba(250, 76, 88, 0.1);
}

/* ---- Timeline ---- */

#timeline {
    height: var(--timeline-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 10px;
    z-index: 1000;
    flex-shrink: 0;
}

.timeline-btn {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.timeline-btn.active {
    background: var(--color-error);
    border-color: var(--color-error);
    color: #fff;
}

#timeline-slider {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: var(--bg-surface);
    border-radius: 2px;
    outline: none;
}

#timeline-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--accent);
    cursor: pointer;
}

#timeline-info {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 120px;
    text-align: right;
}

#app-title-group {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

#footer-credit {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap;
}

/* ---- Game Map Markers ---- */

.game-marker-icon {
    background: none !important;
    border: none !important;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.game-marker-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 3px rgba(0,0,0,0.6);
}

.game-marker-text {
    font-size: 11px;
    font-weight: 600;
    text-shadow: 0 0 3px #000, 0 0 1px #000;
    margin-left: 4px;
}

.game-marker-label {
    background: none !important;
    border: none !important;
    text-align: center;
    white-space: nowrap;
}

.game-marker-label span {
    font-size: 10px;
    font-weight: 600;
    text-shadow: 0 0 3px #000, 0 0 1px #000;
}

/* ---- Draw Toolbar Text Button ---- */

.warlords-draw-text-btn {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: white !important;
}

/* ---- Drawing Comments & Text ---- */

.drawing-comment-tooltip {
    background: rgba(0, 0, 0, 0.8) !important;
    color: #fff !important;
    border: 1px solid var(--border) !important;
    font-size: 11px !important;
    padding: 2px 6px !important;
    border-radius: 3px !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4) !important;
}

.drawing-comment-tooltip::before {
    border-bottom-color: rgba(0, 0, 0, 0.8) !important;
}

.drawing-text-annotation {
    background: none !important;
    border: none !important;
    white-space: nowrap;
}

.drawing-text-annotation span {
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-shadow: 0 0 4px #000, 0 0 2px #000, 1px 1px 2px #000;
    pointer-events: auto;
}

/* ---- Measurement Tools ---- */

.measure-toolbar {
    margin-top: 4px !important;
}

.measure-btn {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border) !important;
    background-image: none !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    color: white !important;
}

.measure-icon {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 26px;
}

.measure-btn.active {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--accent) !important;
}

/* Measurement point-action popup */
.measure-point-popup {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 4px;
}

.measure-action-btn {
    height: 28px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0 8px;
    transition: all 0.15s;
    white-space: nowrap;
}

.measure-action-btn.btn-delete {
    border: 1px solid var(--color-error);
    background: rgba(250, 76, 88, 0.15);
    color: var(--color-error);
}

.measure-action-btn.btn-delete:hover {
    background: var(--color-error);
    color: #fff;
}

.measure-action-btn.btn-replace {
    border: 1px solid var(--accent);
    background: rgba(0, 141, 248, 0.15);
    color: var(--accent);
}

.measure-action-btn.btn-replace:hover {
    background: var(--accent);
    color: #fff;
}

.measure-action-btn.btn-remove {
    border: 1px solid var(--color-warning);
    background: rgba(255, 217, 102, 0.15);
    color: var(--color-warning);
}

.measure-action-btn.btn-remove:hover {
    background: var(--color-warning);
    color: #111;
}

.measure-action-btn .btn-icon {
    font-size: 14px;
    line-height: 1;
}

/* Replace-mode crosshair */
.measure-replace-active {
    cursor: crosshair !important;
}

.measure-delete-popup-container .leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    padding: 0;
}

.measure-delete-popup-container .leaflet-popup-content {
    margin: 4px;
}

.measure-delete-popup-container .leaflet-popup-tip {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
}

.measure-label {
    background: none !important;
    border: none !important;
    white-space: nowrap;
}

.measure-label span {
    background: rgba(0, 0, 0, 0.75);
    color: #E87722;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
    text-shadow: none;
}

.measure-total-label span {
    background: rgba(0, 0, 0, 0.85);
    color: #FFF;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid #E87722;
}

.measure-angle-label span {
    background: rgba(0, 0, 0, 0.75);
    color: #FF6B6B;
    font-size: 12px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 3px;
}

/* ---- Scale Ruler ---- */

.game-scale-control {
    background: rgba(0, 0, 0, 0.7);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 8px;
    pointer-events: none;
}

.game-scale-bar {
    height: 4px;
    background: #FFD700;
    border-left: 2px solid #FFD700;
    border-right: 2px solid #FFD700;
    min-width: 20px;
}

.game-scale-label {
    color: var(--text-primary);
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    margin-top: 2px;
}

/* ---- Toast Notification ---- */

.warlords-toast {
    position: fixed;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 8px 20px;
    border-radius: 6px;
    font-size: 13px;
    z-index: 2000;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4);
    border: 1px solid var(--border);
    transition: opacity 0.4s;
}

.warlords-toast.fade-out {
    opacity: 0;
}

/* ---- Locations Panel ---- */

.locations-search {
    width: 100%;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 8px 10px;
    font-size: 12px;
    border-radius: 4px;
    margin-bottom: 10px;
    outline: none;
}

.locations-search:focus {
    border-color: var(--accent);
}

.location-item {
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s;
}

.location-item:hover {
    background: var(--bg-surface);
}

.location-item-type {
    font-size: 10px;
    color: var(--text-muted);
}

/* ---- Grid Coordinate Display ---- */

.grid-coord-control {
    background: rgba(0, 0, 0, 0.75);
    color: #FFD700;
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 4px;
    border: 1px solid var(--border);
    pointer-events: none;
    margin-bottom: 8px !important;
}

/* ---- Grid Edge Labels ---- */

.grid-label {
    position: absolute;
    font-family: monospace;
    font-size: 10px;
    font-weight: 600;
    color: #e0e0e0;
    background: rgba(22, 33, 62, 0.85);
    padding: 1px 4px;
    border-radius: 2px;
    pointer-events: none;
    z-index: 450;
    white-space: nowrap;
}

.grid-label-top {
    top: 2px;
    transform: translateX(-50%);
}

.grid-label-left {
    left: 2px;
    transform: translateY(-50%);
}

/* ---- Map Tools (Ruler, Compass, Grid Scale) ---- */

.tool-screen-overlay {
    position: absolute;
    z-index: 800;
    cursor: move;
    pointer-events: auto;
    user-select: none;
}

.tools-toolbar {
    margin-top: 4px !important;
}

.tool-btn {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border) !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    color: white !important;
}

.tool-btn.active {
    background-color: var(--bg-tertiary) !important;
    border-color: var(--accent) !important;
}

.tool-icon {
    font-size: 14px;
    color: var(--text-primary);
    line-height: 26px;
}

/* ---- Sector Label ---- */

.sector-label-text {
    font-size: 11px;
    font-weight: 700;
    text-shadow: 0 0 4px #000, 0 0 2px #000;
    background: rgba(0, 0, 0, 0.7);
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ---- Objective Popup ---- */

.objective-popup .leaflet-popup-content-wrapper {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.objective-popup .leaflet-popup-tip {
    background: var(--bg-secondary);
}

.obj-popup-title {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 2px;
}

.obj-popup-sector {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 6px;
}

.obj-popup-desc {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 260px;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    margin-bottom: 6px;
}

.obj-popup-row {
    font-size: 11px;
    margin: 2px 0;
}

.obj-popup-label {
    color: var(--text-secondary);
}

/* ---- Objective Inline Accordion ---- */

.obj-accordion {
    display: none;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px 12px;
    margin-top: 6px;
    font-size: 12px;
}

.obj-accordion.open {
    display: block;
}

.obj-accordion-desc {
    color: var(--text-secondary);
    margin-bottom: 8px;
    word-wrap: break-word;
}

.obj-accordion-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
}

.obj-accordion-label {
    color: var(--text-muted);
    min-width: 90px;
    flex-shrink: 0;
    font-size: 11px;
}

/* ---- Objective Detail Description ---- */

#obj-detail-description {
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    max-height: 200px;
    overflow-y: auto;
}

/* ---- Utility ---- */

.hidden {
    display: none !important;
}

/* ---- Leaflet overrides ---- */

.leaflet-control-zoom a {
    background: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

.leaflet-control-attribution {
    background: rgba(26, 26, 46, 0.8) !important;
    color: var(--text-muted) !important;
}

.leaflet-control-attribution a {
    color: var(--text-secondary) !important;
}

/* Leaflet Draw overrides */
.leaflet-draw-toolbar a {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border) !important;
    background-image: none !important;
    color: var(--text-primary);
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.leaflet-draw-actions a {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

/* ---- Map Only mode: extend sidebar to bottom (no timeline bar) ---- */

body.mode-maponly #sidebar {
    bottom: 0;
}

/* ---- Drawing Color Picker ---- */

.drawing-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.drawing-color-row label {
    font-size: 12px;
    color: var(--text-secondary);
    min-width: 36px;
}

#drawing-color-picker {
    width: 36px;
    height: 28px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    padding: 1px;
    background: var(--bg-surface);
}

.color-presets {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.color-preset {
    width: 22px;
    height: 22px;
    border-radius: 3px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.1s;
    flex-shrink: 0;
}

.color-preset:hover {
    border-color: var(--text-primary);
    transform: scale(1.15);
}

/* ---- Capture Event Log ---- */

#capture-event-log {
    margin-top: 16px;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.event-log-header {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.event-log-entry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}

.event-log-entry:last-child {
    border-bottom: none;
}

.event-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
}

.event-dot.captured {
    background: var(--color-success);
}

.event-dot.failed {
    background: var(--color-error);
}

.event-dot.objective-captured {
    background: #00BFFF;
}

.event-log-text {
    flex: 1;
    color: var(--text-primary);
    line-height: 1.4;
}

.event-log-time {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    font-family: monospace;
}

/* ---- Admin Sessions Table ---- */
#admin-sessions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

#admin-sessions-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.05em;
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

#admin-sessions-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

#admin-sessions-table tbody tr:nth-child(even) {
    background: var(--bg-surface);
}

#admin-sessions-table tbody tr:hover {
    background: var(--bg-secondary);
}

#admin-sessions-table .action-btn {
    padding: 2px 8px;
    font-size: 11px;
}

.admin-tabs {
    display: flex;
    gap: 4px;
    margin: 8px 0;
}

.admin-tabs .tab-btn {
    padding: 4px 12px;
    font-size: 12px;
}

#admin-audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

#admin-audit-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 10px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

#admin-audit-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

#admin-audit-table tbody tr:nth-child(even) {
    background: var(--bg-surface);
}

#admin-codes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

#admin-codes-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 10px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
}

#admin-codes-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    font-size: 11px;
}

#admin-codes-table tbody tr:nth-child(even) {
    background: var(--bg-surface);
}

/* ---- Objective Marker Size Slider ---- */
.obj-size-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0 10px 0;
    font-size: 11px;
    color: var(--text-secondary);
}
.obj-size-row label { white-space: nowrap; }
.obj-size-row input[type=range] { flex: 1; }
#obj-marker-size-label { width: 36px; text-align: right; font-size: 10px; }

/* ---- Victory Conditions Panel ---- */

.vc-condition {
    border-bottom: 1px solid var(--border);
    padding: 10px 0;
}

.vc-condition:last-child {
    border-bottom: none;
}

.vc-name {
    font-weight: bold;
    margin-bottom: 2px;
}

.vc-example {
    font-size: 11px;
    color: var(--text-muted);
}

.vc-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.vc-score-tag {
    padding: 2px 8px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 12px;
    font-family: monospace;
}

/* ---- Admin Cash Panel ---- */

#admin-cash-summary .cash-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

#admin-cash-summary .cash-row:last-child {
    border-bottom: none;
}

#cash-detail-modal table {
    width: 100%;
    border-collapse: collapse;
}

#cash-detail-modal td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-primary);
}

#cash-detail-modal td:first-child {
    width: 52px;
    font-size: 10px;
    color: var(--text-muted);
    font-family: monospace;
    white-space: nowrap;
}

#cash-detail-modal td:last-child {
    text-align: right;
    font-family: monospace;
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 280px;
    }
    #topbar-right {
        gap: 2px;
    }
    .tab-btn {
        padding: 6px 8px;
        font-size: 11px;
    }
}
