/* ============================================
   КП Компас — CSS Design System
   ============================================ */

:root {
    /* Colors — Light high-contrast outdoor theme */
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.8);
    --bg-glass-hover: rgba(255, 255, 255, 0.95);

    --text-primary: #0f172a;
    --text-secondary: #1e293b;
    --text-muted: #475569;

    --accent-primary: #4338ca;
    --accent-secondary: #7c3aed;
    --accent-glow: rgba(67, 56, 202, 0.2);

    --success: #059669;
    --success-glow: rgba(5, 150, 105, 0.2);
    --warning: #d97706;
    --danger: #dc2626;
    --danger-glow: rgba(220, 38, 38, 0.2);

    --border-subtle: rgba(0, 0, 0, 0.12);
    --border-accent: rgba(67, 56, 202, 0.4);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.12);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.2);
    --shadow-glow: 0 0 20px var(--accent-glow);

    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    position: relative;
}

/* ============================================
   Screens
   ============================================ */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 20px 20px;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Loading Screen
   ============================================ */
#loading-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, rgba(67, 56, 202, 0.06) 0%, transparent 70%),
        var(--bg-primary);
}

.loading-content {
    text-align: center;
    animation: fadeInUp 0.8s ease-out;
}

.compass-logo {
    margin-bottom: 24px;
}

.logo-svg {
    width: 100px;
    height: 100px;
    animation: spinSlow 8s linear infinite;
}

.app-title {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.app-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.loading-bar {
    width: 200px;
    height: 3px;
    background: var(--border-subtle);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin: 0 auto;
}

.loading-bar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-full);
    animation: loadProgress 2s ease-out forwards;
}

/* ============================================
   Screen Header
   ============================================ */
.screen-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 0;
    background: linear-gradient(to bottom, var(--bg-primary) 60%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.screen-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    flex: 1;
}

.header-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    position: absolute;
    bottom: 12px;
    left: 0;
}

/* ============================================
   Upload Screen
   ============================================ */
#upload-screen {
    padding-top: 0;
}

#upload-screen .screen-header {
    flex-direction: column;
    align-items: flex-start;
    padding-top: 60px;
    padding-bottom: 24px;
    background: transparent;
    position: relative;
}

#upload-screen .screen-header h1 {
    font-size: 2rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   Source Tabs (Server / Upload)
   ============================================ */
.source-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
}

.source-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.source-tab:hover {
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.04);
}

.source-tab.active {
    background: linear-gradient(135deg, rgba(67, 56, 202, 0.12), rgba(124, 58, 237, 0.12));
    color: var(--accent-primary);
    border: 1px solid var(--border-accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.source-tab svg {
    flex-shrink: 0;
}

/* ============================================
   Tab Panels
   ============================================ */
.tab-panel {
    display: none;
    animation: fadeInUp 0.3s ease-out;
}

.tab-panel.active {
    display: block;
}

/* ============================================
   Code Entry (6-digit PIN)
   ============================================ */
.code-entry {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 16px 24px;
    text-align: center;
}

.code-entry-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(139, 92, 246, 0.15));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    margin-bottom: 20px;
}

.code-entry-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.code-entry-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 28px;
}

.code-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    transition: transform 0.1s ease;
}

.code-separator {
    font-size: 1.2rem;
    color: var(--text-muted);
    margin: 0 2px;
    user-select: none;
}

.code-digit {
    width: 48px;
    height: 60px;
    border-radius: var(--radius-md);
    border: 2px solid var(--border-subtle);
    background: var(--bg-glass);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.6rem;
    font-weight: 700;
    text-align: center;
    outline: none;
    transition: all var(--transition-normal);
    -webkit-appearance: none;
    -moz-appearance: textfield;
    appearance: none;
    caret-color: var(--accent-primary);
}

.code-digit::-webkit-inner-spin-button,
.code-digit::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.code-digit:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow), inset 0 0 12px rgba(99, 102, 241, 0.05);
    background: rgba(99, 102, 241, 0.05);
}

.code-digit.loading {
    border-color: var(--accent-primary);
    opacity: 0.7;
}

.code-digit.success {
    border-color: var(--success);
    box-shadow: 0 0 0 3px var(--success-glow);
    color: var(--success);
}

.code-digit.error {
    border-color: var(--danger);
    box-shadow: 0 0 0 3px var(--danger-glow);
    color: var(--danger);
}

.code-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    animation: fadeInUp 0.2s ease-out;
    min-height: 40px;
}

.code-status.loading {
    color: var(--accent-primary);
}

.code-status.success {
    color: var(--success);
    background: rgba(16, 185, 129, 0.08);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.code-status.error {
    color: var(--danger);
    background: rgba(244, 63, 94, 0.08);
    border: 1px solid rgba(244, 63, 94, 0.2);
}

/* Shake animation for wrong code */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70%,
    90% {
        transform: translateX(-6px);
    }

    20%,
    40%,
    60%,
    80% {
        transform: translateX(6px);
    }
}

.code-inputs.shake {
    animation: shake 0.5s ease-in-out;
}


.upload-area {
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--bg-glass);
    position: relative;
    overflow: hidden;
}

.upload-area::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at center, var(--accent-glow) 0%, transparent 70%);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--accent-primary);
    background: var(--bg-glass-hover);
}

.upload-area:hover::before,
.upload-area.drag-over::before {
    opacity: 1;
}

.upload-area.drag-over {
    transform: scale(1.02);
}

.upload-icon {
    margin-bottom: 16px;
    position: relative;
    z-index: 1;
}

.upload-area h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    position: relative;
    z-index: 1;
}

.upload-area p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    position: relative;
    z-index: 1;
}

.supported-formats {
    display: flex;
    gap: 8px;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.format-badge {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 12px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-full);
    color: var(--accent-primary);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-top: 16px;
    animation: slideIn 0.3s ease-out;
}

.file-icon {
    font-size: 2rem;
}

.file-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.file-name {
    font-weight: 600;
    font-size: 0.875rem;
    word-break: break-all;
}

.file-size {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-remove-file {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.btn-remove-file:hover {
    background: rgba(244, 63, 94, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

.parse-status {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    animation: slideIn 0.3s ease-out;
}

.parse-status.success {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.parse-status.error {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: var(--danger);
}

.parse-status.loading {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--accent-primary);
}

/* File checklist (3-file upload) */
.file-checklist {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    gap: 10px;
    animation: slideIn 0.3s ease-out;
}

.file-check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, 0.02);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.file-check.loaded {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.file-check-icon {
    font-size: 1.2rem;
    flex-shrink: 0;
}

.file-check-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.file-check.loaded .file-check-label {
    color: var(--success);
}

.file-check-name {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    text-align: right;
}

/* ============================================
   Buttons
   ============================================ */
.btn-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px 24px;
    margin-top: 24px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    box-shadow: var(--shadow-glow);
    font-family: inherit;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 30px var(--accent-glow);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-secondary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 24px;
    margin-top: 12px;
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-normal);
    font-family: inherit;
}

.btn-secondary:hover {
    background: var(--bg-glass-hover);
    border-color: var(--accent-primary);
}

.btn-back {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-back:hover {
    background: var(--bg-glass-hover);
    border-color: var(--accent-primary);
}

.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-glass);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--bg-glass-hover);
    color: var(--text-primary);
}

/* ============================================
   CP Selection Screen
   ============================================ */
.cp-count {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-full);
    color: var(--accent-primary);
    white-space: nowrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    margin-bottom: 16px;
    transition: border-color var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--accent-primary);
}

.search-box svg {
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

.cp-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 24px;
}

.cp-card {
    padding: 16px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-normal);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.cp-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(67, 56, 202, 0.08), transparent);
    opacity: 0;
    transition: opacity var(--transition-normal);
}

.cp-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.cp-card:hover::before {
    opacity: 1;
}

.cp-card:active {
    transform: translateY(0);
}

.cp-card.found {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.15);
}

.cp-card.found::before {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), transparent);
    opacity: 1;
}

.cp-found-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 0.75rem;
    font-weight: 800;
    color: #10b981;
    z-index: 2;
}

.cp-number {
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    z-index: 1;
}

.cp-code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
    position: relative;
    z-index: 1;
}

.cp-alt {
    font-size: 0.6rem;
    color: var(--text-muted);
    margin-top: 4px;
    opacity: 0.6;
    position: relative;
    z-index: 1;
}

.manual-input {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
}

.manual-input h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.coord-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.input-group label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-group input {
    padding: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    outline: none;
    transition: border-color var(--transition-fast);
}

.input-group input:focus {
    border-color: var(--accent-primary);
}

.input-group input::placeholder {
    color: var(--text-muted);
}

/* ============================================
   Compass Screen
   ============================================ */
#compass-screen {
    padding-bottom: 24px;
}

.compass-header {
    position: relative;
    background: transparent !important;
}

.cp-badge {
    font-size: 0.875rem;
    font-weight: 700;
    padding: 6px 16px;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    border-radius: var(--radius-full);
    flex: 1;
    text-align: center;
}

.compass-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
    min-height: 300px;
}

.compass-ring-outer {
    width: min(320px, 80vw);
    height: min(320px, 80vw);
    border-radius: 50%;
    background: conic-gradient(from 0deg,
            rgba(99, 102, 241, 0.05) 0deg,
            rgba(139, 92, 246, 0.05) 90deg,
            rgba(99, 102, 241, 0.05) 180deg,
            rgba(139, 92, 246, 0.05) 270deg,
            rgba(99, 102, 241, 0.05) 360deg);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 6px;
}

.compass-ring-outer::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid var(--border-subtle);
}

.compass-ring-middle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 8px;
    border: 1px solid var(--border-subtle);
}

.compass-ring-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(17, 24, 39, 0.5) 0%, var(--bg-primary) 100%);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: transform 0.1s linear;
}

.compass-marks {
    position: absolute;
    inset: 0;
}

.compass-mark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform-origin: 0 0;
    color: var(--text-muted);
    font-size: 0.6rem;
    font-weight: 500;
}

.compass-mark.major {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
}

.compass-mark-line {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 1px;
    height: 8px;
    background: var(--text-muted);
    transform: translateX(-50%);
    opacity: 0.3;
}

.compass-mark-line.major {
    height: 14px;
    width: 2px;
    opacity: 0.6;
    background: var(--text-secondary);
}

.direction-arrow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    transition: transform 0.15s ease-out;
    filter: drop-shadow(0 0 12px var(--danger-glow));
}

.north-indicator {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.85rem;
    font-weight: 800;
    color: var(--danger);
    z-index: 3;
    text-shadow: 0 0 10px var(--danger-glow);
}

.bearing-display {
    display: flex;
    align-items: baseline;
    gap: 2px;
    margin-top: 16px;
}

.bearing-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.bearing-unit {
    font-size: 1.2rem;
    color: var(--text-muted);
    font-weight: 600;
}

.info-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 16px;
}

.info-card {
    padding: 14px 10px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    text-align: center;
}

.info-label {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.info-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.info-unit {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.alignment-indicator {
    margin-top: 16px;
    padding: 14px 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    text-align: center;
}

.alignment-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 8px;
}

.alignment-fill {
    height: 100%;
    width: 0;
    border-radius: var(--radius-full);
    transition: width 0.2s ease, background 0.3s ease;
    background: var(--danger);
}

.alignment-fill.close {
    background: var(--warning);
}

.alignment-fill.aligned {
    background: var(--success);
    box-shadow: 0 0 10px var(--success-glow);
}

.alignment-text {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.alignment-text.aligned {
    color: var(--success);
}

.compass-error {
    margin-top: 12px;
    padding: 12px 16px;
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.2);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--danger);
    font-size: 0.85rem;
    animation: slideIn 0.3s ease-out;
}

/* ============================================
   Modal
   ============================================ */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: all var(--transition-normal);
}

.modal.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 70vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-subtle);
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.btn-close-modal {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-subtle);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.875rem;
}

.modal-body {
    padding: 20px;
}

.modal-body .info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-body .info-row:last-child {
    border-bottom: none;
}

.modal-body .info-row .label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.modal-body .info-row .value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   Utility Classes
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   Animations
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
    }

    to {
        transform: translateY(0);
    }
}

@keyframes spinSlow {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes loadProgress {
    0% {
        width: 0;
    }

    50% {
        width: 70%;
    }

    100% {
        width: 100%;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes glow {

    0%,
    100% {
        box-shadow: 0 0 10px var(--success-glow);
    }

    50% {
        box-shadow: 0 0 25px var(--success-glow);
    }
}

/* ============================================
   Scrollbar
   ============================================ */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-subtle);
    border-radius: var(--radius-full);
}

/* ============================================
   Mobile Adjustments
   ============================================ */
@media (max-height: 700px) {
    .compass-ring-outer {
        width: min(250px, 65vw);
        height: min(250px, 65vw);
    }

    .bearing-value {
        font-size: 2rem;
    }

    .info-value {
        font-size: 1.1rem;
    }
}

@media (max-height: 600px) {
    .compass-ring-outer {
        width: min(200px, 55vw);
        height: min(200px, 55vw);
    }

    .bearing-display {
        margin-top: 8px;
    }

    .info-cards {
        margin-top: 8px;
        gap: 6px;
    }

    .info-card {
        padding: 8px 6px;
    }
}

/* ============================================
   Map Screen
   ============================================ */
#map-screen {
    padding: 0;
    overflow: hidden;
    position: absolute;
    inset: 0;
    height: 100vh;
    height: 100dvh;
}

.map-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: linear-gradient(to bottom, rgba(240, 242, 245, 0.92) 60%, transparent);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.map-cp-badge {
    flex: 1;
    padding: 8px 16px;
    background: rgba(67, 56, 202, 0.1);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-pill);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.5px;
}

.map-cp-dist {
    padding: 6px 12px;
    background: rgba(37, 99, 235, 0.1);
    border: 1px solid rgba(37, 99, 235, 0.3);
    border-radius: var(--radius-pill);
    color: #1d4ed8;
    font-size: 0.8rem;
    font-weight: 700;
    white-space: nowrap;
    min-width: 48px;
    text-align: center;
}

.map-cp-dist:empty {
    display: none;
}

.btn-found {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.8);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-found.active {
    background: rgba(5, 150, 105, 0.15);
    border-color: var(--success);
    color: var(--success);
}

.map-canvas-container {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.map-canvas-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.map-zoom-controls {
    position: absolute;
    bottom: 24px;
    right: 16px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.btn-zoom {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.btn-zoom:hover {
    background: rgba(67, 56, 202, 0.15);
    border-color: var(--accent-primary);
}

.btn-zoom:active {
    transform: scale(0.9);
}

.btn-zoom.active {
    background: rgba(67, 56, 202, 0.2);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.map-loading {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: opacity 0.4s ease;
}

.map-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.map-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spinSlow 1s linear infinite;
}