/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0a0a;
    --bg-card: #151515;
    --bg-card-hover: #1a1a1a;
    --text: #ffffff;
    --text-dim: #666666;
    --text-label: #888888;
    --accent: #ff3b3b;
    --accent-glow: rgba(255, 59, 59, 0.4);
    --success: #00ff88;
    --warning: #ffaa00;
    --gauge-track: #2a2a2a;
    --gauge-fill: #ff3b3b;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding-top: var(--safe-top);
    padding-bottom: var(--safe-bottom);
    overflow-y: auto;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* View Tabs */
.view-tabs {
    display: flex;
    gap: 4px;
    padding: 0 16px 8px;
}

.view-tab {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-card);
    border: none;
    border-radius: 8px;
    color: var(--text-dim);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    pointer-events: auto;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-tab.active {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 15px rgba(255, 59, 59, 0.3);
}

.view-tab:not(.active):active {
    background: var(--bg-card-hover);
}

/* View Content */
.view-content {
    display: none;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.view-content.active {
    display: flex;
}

.gps-indicator {
    font-size: 20px;
    opacity: 0.4;
    transition: none;
}

.gps-indicator.flash {
    opacity: 1;
    animation: flash 0.3s ease-out;
}

@keyframes flash {
    0% { transform: scale(1.3); filter: drop-shadow(0 0 10px var(--success)); }
    100% { transform: scale(1); filter: none; }
}

.btn-icon {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    opacity: 0.6;
    pointer-events: auto;
}

/* Toast */
.toast {
    position: fixed;
    top: 60px;
    left: 16px;
    right: 16px;
    padding: 14px 16px;
    background: rgba(255, 170, 0, 0.95);
    color: #000;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    transform: translateY(-100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Gauge Container */
.gauge-container {
    position: relative;
    width: 100%;
    max-width: 320px;
    margin: 0 auto;
    padding: 10px;
}

.gauge-svg {
    width: 100%;
    height: auto;
    transform: rotate(135deg);
}

.gauge-track {
    fill: none;
    stroke: var(--gauge-track);
    stroke-width: 12;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke: var(--gauge-fill);
    stroke-width: 12;
    stroke-linecap: round;
    filter: drop-shadow(0 0 10px var(--accent-glow));
    --rotation: 0deg;
    stroke-dashoffset: calc(400 - (var(--rotation) / 270 * 333));
    /* Animação controlada por JS spring - sem transition CSS */
    will-change: stroke-dashoffset;
}

.gauge-ticks {
    transform: rotate(-135deg);
    transform-origin: 100px 100px;
}

.tick {
    stroke: var(--text-dim);
    stroke-width: 2;
}

.tick-label {
    fill: var(--text-dim);
    font-size: 10px;
    font-weight: 600;
}

/* Speed Display */
.speed-display {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.speed-value {
    font-size: 80px;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    line-height: 1;
    display: block;
    /* Evita saltos no layout quando número muda */
    min-width: 3ch;
    text-align: center;
    /* GPU acceleration */
    will-change: contents;
    transform: translateZ(0);
}

.speed-unit {
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 2px;
}

/* GPS Signal */
.gps-signal {
    position: absolute;
    bottom: 40px;
    left: 30px;
    display: flex;
    align-items: flex-end;
    gap: 3px;
}

.signal-bar {
    width: 6px;
    background: var(--text-dim);
    border-radius: 2px;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.signal-bar.active {
    background: var(--success);
    box-shadow: 0 0 6px var(--success);
}

.signal-bar:nth-child(1) { height: 6px; }
.signal-bar:nth-child(2) { height: 10px; }
.signal-bar:nth-child(3) { height: 14px; }
.signal-bar:nth-child(4) { height: 18px; }
.signal-bar:nth-child(5) { height: 22px; }

.signal-label {
    font-size: 8px;
    color: var(--text-dim);
    margin-left: 6px;
    letter-spacing: 1px;
}

/* Motion Status */
.motion-status {
    position: absolute;
    bottom: 40px;
    right: 30px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 6px 12px;
    border-radius: 20px;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateZ(0);
}

.motion-status.stopped {
    background: rgba(102, 102, 102, 0.3);
    color: var(--text-dim);
}

.motion-status.moving {
    background: rgba(0, 255, 136, 0.2);
    color: var(--success);
    animation: pulse-glow 1.5s infinite;
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 5px var(--success); }
    50% { box-shadow: 0 0 15px var(--success); }
}

/* Alert */
.alert {
    text-align: center;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    max-height: 0;
    overflow: hidden;
    transition: all 0.3s;
}

.alert.show {
    padding: 10px;
    max-height: 50px;
}

.alert.warning {
    background: rgba(255, 170, 0, 0.2);
    color: var(--warning);
}

.alert.danger {
    background: rgba(255, 59, 59, 0.2);
    color: var(--accent);
    animation: alert-pulse 0.5s infinite;
}

@keyframes alert-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 16px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 14px;
    text-align: center;
    transition: background 0.2s ease, transform 0.2s ease;
    transform: translateZ(0);
}

.stat-card:active {
    background: var(--bg-card-hover);
    transform: scale(0.98);
}

.stat-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-label);
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    /* Estabiliza largura do número */
    display: inline-flex;
    align-items: baseline;
    justify-content: center;
}

.stat-value.time {
    font-size: 22px;
}

.stat-unit {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    margin-left: 4px;
}

/* GPS Info */
.gps-info {
    padding: 0 16px;
    margin-bottom: 12px;
}

.gps-row {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    color: var(--text-dim);
}

#gps-quality {
    font-weight: 600;
    color: var(--success);
}

/* Debug Panel */
.debug-panel {
    margin: 0 16px 12px;
    background: var(--bg-card);
    border-radius: 10px;
    font-size: 11px;
}

.debug-panel summary {
    padding: 10px 14px;
    cursor: pointer;
    color: var(--text-dim);
}

.debug-info {
    padding: 0 14px 14px;
    color: var(--text-dim);
    font-family: 'SF Mono', monospace;
    line-height: 1.6;
}

/* Controls */
.controls {
    padding: 12px 16px;
    display: flex;
    gap: 10px;
    background: var(--bg);
    border-top: 1px solid #1a1a1a;
    margin-top: auto;
}

.btn {
    flex: 1;
    padding: 16px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                filter 0.15s ease;
    transform: translateZ(0);
}

.btn:active {
    transform: scale(0.96);
    filter: brightness(0.9);
}

.btn-start {
    background: var(--success);
    color: #000;
    box-shadow: 0 4px 15px rgba(0, 255, 136, 0.3);
}

.btn-start:active {
    box-shadow: 0 2px 8px rgba(0, 255, 136, 0.2);
}

.btn-stop {
    background: var(--warning);
    color: #000;
    box-shadow: 0 4px 15px rgba(255, 170, 0, 0.3);
}

.btn-stop:active {
    box-shadow: 0 2px 8px rgba(255, 170, 0, 0.2);
}

.btn-reset {
    background: var(--accent);
    color: #fff;
    flex: 0.5;
    box-shadow: 0 4px 15px rgba(255, 59, 59, 0.3);
}

.btn-reset:active {
    box-shadow: 0 2px 8px rgba(255, 59, 59, 0.2);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

/* Permission Error */
.permission-error {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    z-index: 100;
}

.permission-error.hidden {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    z-index: -1 !important;
}

.error-icon { font-size: 60px; margin-bottom: 20px; }
.error-title { font-size: 20px; font-weight: 600; color: var(--accent); margin-bottom: 12px; }
.error-text { color: var(--text-dim); margin-bottom: 20px; }
.error-instructions {
    background: var(--bg-card);
    padding: 16px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 24px;
    text-align: left;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-card);
    border-radius: 16px;
    width: 100%;
    max-width: 340px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #222;
}

.modal-header h2 { font-size: 18px; font-weight: 600; }

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-dim);
    cursor: pointer;
    pointer-events: auto;
}

.modal-body { padding: 20px; }

.setting-group { margin-bottom: 20px; }

.setting-group label {
    display: block;
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.setting-group input {
    width: 100%;
    padding: 14px;
    border: 1px solid #333;
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
}

.setting-group input:focus {
    outline: none;
    border-color: var(--accent);
}

.modal-footer {
    padding: 16px;
    border-top: 1px solid #222;
}

.modal-footer .btn { width: 100%; }

/* Utilities */
.hidden { 
    display: none !important; 
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
}

/* Garantir que modais ocultos não bloqueiem cliques */
.modal.hidden {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    z-index: -1 !important;
}

/* ============================================
   MAP VIEW
   ============================================ */

#map-view {
    position: relative;
    flex: 1;
    min-height: 300px;
}

.map-container {
    width: 100%;
    height: 100%;
    min-height: 300px;
    background: #1a1a1a;
    z-index: 1;
}

/* Leaflet dark theme override */
.leaflet-container {
    background: #1a1a1a;
    font-family: inherit;
}

.leaflet-tile-pane {
    filter: brightness(0.85) contrast(1.1) saturate(0.8);
}

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5) !important;
}

.leaflet-control-zoom a {
    background: var(--bg-card) !important;
    color: var(--text) !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    line-height: 36px !important;
    font-size: 18px !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-card-hover) !important;
}

.leaflet-control-attribution {
    background: rgba(0,0,0,0.7) !important;
    color: var(--text-dim) !important;
    font-size: 9px !important;
}

.leaflet-control-attribution a {
    color: var(--text-dim) !important;
}

/* Speed Overlay on Map */
.map-speed-overlay {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 16px 24px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.map-speed-main {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 6px;
    margin-bottom: 8px;
}

.map-speed-value {
    font-size: 56px;
    font-weight: 200;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--text);
}

.map-speed-unit {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 1px;
}

.map-speed-stats {
    display: flex;
    gap: 20px;
    justify-content: center;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.map-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.map-stat-label {
    font-size: 9px;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 1px;
}

.map-stat-value {
    font-size: 18px;
    font-weight: 300;
    font-variant-numeric: tabular-nums;
    color: var(--text);
}

/* Map Controls */
.map-controls {
    position: absolute;
    bottom: 20px;
    right: 16px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: rgba(10, 10, 10, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-btn:active {
    transform: scale(0.95);
}

.map-btn.active {
    background: var(--accent);
    box-shadow: 0 4px 15px rgba(255, 59, 59, 0.4);
}

/* User location marker - iOS Style */
.user-marker-container {
    z-index: 1000 !important;
}

.user-marker-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
}

.user-marker-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 122, 255, 0.25);
    border-radius: 50%;
    animation: ios-pulse 2s ease-out infinite;
}

.user-marker {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 22px;
    height: 22px;
    background: linear-gradient(145deg, #1E90FF 0%, #007AFF 50%, #0051D4 100%);
    border: 3.5px solid #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.6),
                0 0 0 1px rgba(0, 0, 0, 0.1),
                inset 0 1px 2px rgba(255,255,255,0.3);
}

.user-marker::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 4px;
    width: 8px;
    height: 5px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    transform: rotate(-40deg);
}

@keyframes ios-pulse {
    0% { 
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% { 
        transform: translate(-50%, -50%) scale(2.5);
        opacity: 0;
    }
}

.accuracy-circle {
    background: rgba(0, 122, 255, 0.1);
    border: 2px solid rgba(0, 122, 255, 0.3);
    border-radius: 50%;
}

/* Map layer toggle */
.map-layer-btn {
    font-size: 16px !important;
}

.map-layer-btn.satellite {
    background: rgba(0, 122, 255, 0.9);
}

/* iOS fixes */
@supports (-webkit-touch-callout: none) {
    body { position: fixed; width: 100%; }
    #app { overflow-y: scroll; -webkit-overflow-scrolling: touch; }
}

/* ============================================ */
/* RADAR INFO BADGE */
/* ============================================ */
.radar-info-badge {
    position: absolute;
    bottom: 85px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 59, 59, 0.4);
    border-radius: 20px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    z-index: 500;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.radar-info-badge span:first-child {
    font-size: 16px;
}

.radar-info-badge small {
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    font-size: 10px;
}

/* ============================================ */
/* SETTINGS EXTRAS */
/* ============================================ */
.setting-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 20px 0;
}

.setting-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.setting-hint {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: -10px;
    margin-bottom: 10px;
    padding-left: 2px;
}

.setting-group select {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 16px;
    font-family: inherit;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.setting-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.setting-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-toggle label {
    margin-bottom: 0;
}

.setting-toggle input[type="checkbox"] {
    width: 50px;
    height: 28px;
    appearance: none;
    -webkit-appearance: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
}

.setting-toggle input[type="checkbox"]::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 24px;
    height: 24px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.setting-toggle input[type="checkbox"]:checked {
    background: var(--accent);
}

.setting-toggle input[type="checkbox"]:checked::before {
    transform: translateX(22px);
}

/* Test Voice Button */
.btn-test-voice {
    width: 100%;
    background: linear-gradient(135deg, #32d74b 0%, #28a745 100%);
    border: none;
    color: #fff;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-test-voice:active {
    transform: scale(0.98);
    opacity: 0.9;
}

/* ============================================ */
/* HELP MODAL */
/* ============================================ */
.modal-help {
    max-height: 85vh;
}

.help-body {
    padding: 0 !important;
}

.help-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(0, 0, 0, 0.3);
    padding: 0 10px;
}

.help-tab {
    flex: 1;
    padding: 14px 8px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
}

.help-tab.active {
    color: var(--accent);
}

.help-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 10%;
    right: 10%;
    height: 3px;
    background: var(--accent);
    border-radius: 3px 3px 0 0;
}

.help-content {
    display: none;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(85vh - 150px);
}

.help-content.active {
    display: block;
}

.help-content h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #fff;
}

.help-content p {
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.6;
    margin-bottom: 15px;
}

.help-steps {
    list-style: none;
    counter-reset: step;
    margin-bottom: 20px;
}

.help-steps li {
    counter-increment: step;
    padding: 12px 12px 12px 45px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    margin-bottom: 8px;
    position: relative;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
}

.help-steps li::before {
    content: counter(step);
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
}

.help-tip {
    background: linear-gradient(135deg, rgba(255, 170, 0, 0.15) 0%, rgba(255, 170, 0, 0.05) 100%);
    border-left: 4px solid var(--warning);
    border-radius: 8px;
    padding: 12px 15px;
    margin: 15px 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
}

.help-info-box {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 20px;
}

.help-info-item {
    display: flex;
    gap: 12px;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.help-info-item:last-child {
    border-bottom: none;
}

.help-icon {
    font-size: 24px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.help-info-item div {
    flex: 1;
}

.help-info-item strong {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 3px;
    color: #fff;
}

.help-info-item p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
    line-height: 1.4;
}

/* ============================================ */
/* WELCOME MODAL */
/* ============================================ */
.modal-welcome {
    text-align: center;
    padding: 30px 25px;
    max-width: 340px;
}

.welcome-icon {
    font-size: 60px;
    margin-bottom: 15px;
    animation: welcomeBounce 1s ease-in-out;
}

@keyframes welcomeBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.modal-welcome h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
    color: #fff;
}

.modal-welcome > p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 14px;
    margin-bottom: 25px;
}

.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.welcome-feature {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 12px;
    text-align: left;
}

.welcome-feature span:first-child {
    font-size: 22px;
    width: 32px;
    text-align: center;
}

.welcome-feature span:last-child {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.welcome-tip {
    background: linear-gradient(135deg, rgba(255, 170, 0, 0.15) 0%, rgba(255, 170, 0, 0.05) 100%);
    border-left: 4px solid var(--warning);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 25px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
    text-align: left;
}

.welcome-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.welcome-buttons .btn {
    flex: 1;
    padding: 14px 16px;
    font-size: 14px;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-secondary:active {
    background: rgba(255, 255, 255, 0.15);
}

.welcome-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
}

.welcome-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

/* ============================================ */
/* PROFILE BUTTON (HEADER) */
/* ============================================ */
.profile-btn {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 2px solid rgba(255, 59, 59, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
}

.profile-btn:active .profile-avatar {
    transform: scale(0.95);
    border-color: var(--accent);
}

/* ============================================ */
/* PROFILE MODAL */
/* ============================================ */
.modal-profile {
    max-height: 85vh;
    overflow-y: auto;
}

.profile-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 25px;
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    background: linear-gradient(145deg, #2a2a2a 0%, #1a1a1a 100%);
    border: 3px solid var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 45px;
    margin-bottom: 15px;
}

.profile-avatar-options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.avatar-option {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 50%;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-option:hover,
.avatar-option.selected {
    border-color: var(--accent);
    background: rgba(255, 59, 59, 0.1);
}

.avatar-option:active {
    transform: scale(0.95);
}

/* Profile Stats */
.profile-stats-section {
    margin: 25px 0;
}

.profile-stats-section h3,
.profile-achievements h3 {
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.profile-stat {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    padding: 15px;
    text-align: center;
}

.profile-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 4px;
}

.profile-stat-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Achievements */
.profile-achievements {
    margin-top: 25px;
}

.achievements-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.achievement {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 12px;
}

.achievement.locked {
    opacity: 0.4;
    filter: grayscale(1);
}

.achievement-icon {
    font-size: 18px;
}

.achievement-name {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
}

/* Profile Footer */
.profile-footer {
    display: flex;
    gap: 10px;
}

.profile-footer .btn {
    flex: 1;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid rgba(255, 59, 59, 0.5);
    color: var(--accent);
    font-size: 12px;
}

.btn-danger-outline:active {
    background: rgba(255, 59, 59, 0.1);
}

/* ============================================
   CLOUD SYNC SECTION
   ============================================ */

.profile-cloud-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.profile-cloud-section h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #fff;
}

.cloud-description {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 12px;
}

.cloud-buttons {
    display: flex;
    gap: 10px;
}

.btn-cloud {
    flex: 1;
    background: rgba(100, 210, 255, 0.15);
    border: 1px solid rgba(100, 210, 255, 0.3);
    color: #64d2ff;
    font-size: 13px;
    padding: 10px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-cloud:active {
    background: rgba(100, 210, 255, 0.25);
    transform: scale(0.98);
}

/* ============================================
   BACKUP MODAL
   ============================================ */

.modal-backup {
    max-width: 380px;
}

.backup-step.hidden {
    display: none;
}

.backup-instruction {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 15px;
    line-height: 1.5;
}

.backup-step .auth-field {
    margin-bottom: 14px;
}

.backup-step .auth-field label {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;
}

.backup-step .auth-field input {
    width: 100%;
    padding: 12px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
}

.backup-step .auth-field input:focus {
    border-color: #64d2ff;
    outline: none;
}

.backup-step .btn-primary {
    width: 100%;
    margin-top: 10px;
}

.backup-code-container {
    position: relative;
    margin-bottom: 15px;
}

.backup-code {
    width: 100%;
    height: 100px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(100, 210, 255, 0.3);
    border-radius: 8px;
    color: #64d2ff;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    padding: 12px;
    resize: none;
    word-break: break-all;
}

.btn-copy {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(100, 210, 255, 0.2);
    border: none;
    color: #64d2ff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
}

.btn-copy:active {
    background: rgba(100, 210, 255, 0.4);
}

.btn-copy.copied {
    background: rgba(50, 215, 75, 0.3);
    color: #32d74b;
}

.backup-tips {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.backup-tip {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ============================================
   RESTORE MODAL
   ============================================ */

.modal-restore {
    max-width: 380px;
}

.restore-instruction {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 12px;
}

.restore-code {
    width: 100%;
    height: 120px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    padding: 12px;
    resize: none;
    word-break: break-all;
}

.restore-code:focus {
    border-color: rgba(100, 210, 255, 0.5);
    outline: none;
}

.restore-error {
    margin-top: 10px;
    padding: 10px;
    background: rgba(255, 59, 59, 0.15);
    border: 1px solid rgba(255, 59, 59, 0.3);
    border-radius: 8px;
    color: #ff3b3b;
    font-size: 12px;
    text-align: center;
}

.restore-error.hidden {
    display: none;
}

/* ============================================
   AUTH MODAL
   ============================================ */

.modal-auth {
    max-width: 380px;
}

.auth-form-container {
    padding: 0;
}

.auth-tabs {
    display: flex;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 14px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.auth-tab.active {
    color: #64d2ff;
    border-bottom-color: #64d2ff;
}

.auth-error {
    background: rgba(255, 59, 59, 0.15);
    border: 1px solid rgba(255, 59, 59, 0.3);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 15px;
    color: #ff6b6b;
    font-size: 13px;
    text-align: center;
}

.auth-error.hidden {
    display: none;
}

.auth-form {
    padding: 0 20px 20px;
}

.auth-form.hidden {
    display: none;
}

.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.auth-field input {
    width: 100%;
    padding: 14px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    color: #fff;
    font-size: 16px;
    transition: all 0.2s;
}

.auth-field input:focus {
    border-color: #64d2ff;
    outline: none;
    background: rgba(255, 255, 255, 0.12);
}

.auth-field input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.btn-auth {
    width: 100%;
    padding: 16px;
    font-size: 16px;
    font-weight: 700;
    margin-top: 10px;
}

.auth-link {
    display: block;
    text-align: center;
    margin-top: 15px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    text-decoration: none;
}

.auth-link:hover {
    color: #64d2ff;
}

/* Auth Confirmation Screen */
.auth-confirmation {
    text-align: center;
    padding: 30px 20px;
}

.auth-confirmation-icon {
    font-size: 60px;
    margin-bottom: 20px;
}

.auth-confirmation h3 {
    font-size: 20px;
    margin-bottom: 15px;
    color: #fff;
}

.auth-confirmation p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin-bottom: 10px;
}

.auth-email-sent {
    background: rgba(100, 210, 255, 0.1);
    padding: 10px 15px;
    border-radius: 8px;
    margin: 15px 0;
}

.auth-instructions {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13px;
    margin-bottom: 20px;
}

/* Auth Status in Profile */
.auth-status {
    margin-bottom: 12px;
}

.auth-status-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
}

.auth-status-logged {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #32d74b;
    font-size: 13px;
}

.auth-status-email {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-top: 4px;
}

.btn-auth-login {
    background: linear-gradient(135deg, #64d2ff 0%, #5ac8fa 100%) !important;
    border-color: #64d2ff !important;
    color: #000 !important;
    font-weight: 700;
}

.btn-auth-logout {
    background: rgba(255, 59, 59, 0.15) !important;
    border-color: rgba(255, 59, 59, 0.3) !important;
    color: #ff6b6b !important;
}

.cloud-divider {
    display: flex;
    align-items: center;
    margin: 15px 0;
    gap: 10px;
}

.cloud-divider::before,
.cloud-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.cloud-divider span {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    text-transform: uppercase;
}

.btn-cloud-secondary {
    flex: 1;
    background: rgba(255, 255, 255, 0.08) !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    color: rgba(255, 255, 255, 0.7) !important;
    font-size: 12px !important;
    padding: 10px !important;
}

/* Profile logged in indicator */
.profile-btn.logged-in::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #32d74b;
    border-radius: 50%;
    border: 2px solid var(--bg-primary);
}
