* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #2a2a2a;
    color: #e0e0e0;
    line-height: 1.6;
    transition: background-color 0.05s ease, filter 0.05s ease;
    overflow-x: hidden;
}

body.fullscreen-flash {
    overflow: hidden;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999 !important;
    transition: none !important;
}

.app {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    background: #3a3a3a;
    min-height: 100vh;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

header {
    text-align: center;
    margin-bottom: 30px;
}

header h1 {
    color: #f0f0f0;
    font-size: 2rem;
    font-weight: 600;
}

.mode-toggle {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: #4a4a4a;
    padding: 4px;
    border-radius: 8px;
}

.mode-btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #c0c0c0;
}

.mode-btn.active {
    background: #007bff;
    color: white;
}

.mode-btn:not(.active):hover {
    background: rgba(0, 123, 255, 0.1);
}

.mode-content {
    display: block;
}

.hidden {
    display: none !important;
}

.input-section {
    margin-bottom: 20px;
}

#messageInput {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    border: 2px solid #555;
    border-radius: 8px;
    font-size: 16px;
    resize: vertical;
    font-family: inherit;
    background: #2a2a2a;
    color: #e0e0e0;
}

#messageInput:focus {
    outline: none;
    border-color: #007bff;
}

.char-counter {
    text-align: right;
    margin-top: 5px;
    font-size: 14px;
    color: #a0a0a0;
}

.morse-preview {
    margin-bottom: 20px;
    padding: 15px;
    background: #4a4a4a;
    border-radius: 8px;
}

.morse-preview label {
    font-weight: 600;
    margin-bottom: 10px;
    display: block;
}

#morseOutput {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    letter-spacing: 2px;
    min-height: 40px;
    padding: 10px;
    background: #2a2a2a;
    border: 1px solid #555;
    border-radius: 4px;
    color: #e0e0e0;
}

.action-btn {
    width: 100%;
    padding: 15px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.action-btn:hover {
    background: #218838;
}

.action-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
}

.status {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    padding: 15px;
    background: #3a5a3a;
    border: 1px solid #5a7a5a;
    border-radius: 8px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    background: #28a745;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status-indicator.loading {
    background: #007bff;
    animation: spin 1s linear infinite;
}

.status-indicator.error {
    background: #dc3545;
    animation: none;
}

.status-indicator.active {
    background: #28a745;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.camera-section {
    margin-bottom: 30px;
    text-align: center;
}

#cameraVideo {
    width: 100%;
    max-width: 400px;
    height: 300px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #555;
}

.received-section {
    margin-top: 20px;
}

.received-section label {
    font-weight: 600;
    margin-bottom: 5px;
    margin-top: 15px;
    display: block;
}

#receivedMorse, #decodedMessage {
    padding: 10px;
    background: #4a4a4a;
    border: 1px solid #555;
    border-radius: 4px;
    min-height: 40px;
    font-family: 'Courier New', monospace;
    color: #e0e0e0;
}

#decodedMessage {
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    color: #28a745;
}

@media (max-width: 480px) {
    body {
        margin: 0;
        padding: 10px;
    }
    
    .app {
        padding: 15px;
        margin: 0;
        border-radius: 0;
        min-height: calc(100vh - 20px);
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .mode-btn {
        padding: 10px 15px;
        font-size: 14px;
    }
    
    #messageInput {
        min-height: 80px;
        font-size: 14px;
    }
    
    #cameraVideo {
        height: 250px;
        max-width: 100%;
    }
    
    .morse-preview, .status, #receivedMorse, #decodedMessage {
        padding: 10px;
    }
}