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

:root {
    --primary-color: #0052CC;
    --primary-hover: #0747A6;
    --secondary-color: #42526E;
    --background: #FAFBFC;
    --surface: #FFFFFF;
    --border: #DFE1E6;
    --text-primary: #172B4D;
    --text-secondary: #6B778C;
    --success: #00875A;
    --error: #DE350B;
    --warning: #FFAB00;
    --flash-color: #FFD700;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-hover) 100%);
    color: white;
    padding: 2rem;
    text-align: center;
    position: relative;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.95;
    font-weight: 400;
}

.language-selector {
    position: absolute;
    top: 1rem;
    right: 1rem;
}

.language-selector select {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 14px;
    cursor: pointer;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.language-selector select:hover {
    background: rgba(255,255,255,0.3);
}

.language-selector select option {
    background: var(--primary-color);
    color: white;
}

main {
    padding: 2rem;
}

.mode-tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
}

.tab-button {
    padding: 12px 24px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    position: relative;
    transition: all 0.3s ease;
}

.tab-button:hover {
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
}

.tab-button.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.mode-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.input-section {
    background: var(--background);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.input-section label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

textarea {
    width: 100%;
    min-height: 120px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-family: 'Courier New', monospace;
    resize: vertical;
    transition: all 0.3s ease;
    background: var(--surface);
}

textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,82,204,0.1);
}

.convert-btn {
    margin-top: 1rem;
    padding: 12px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.convert-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.convert-btn:active {
    transform: translateY(0);
}

.divider {
    text-align: center;
    font-size: 2rem;
    color: var(--text-secondary);
    margin: 1rem 0;
    opacity: 0.5;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--background);
    border-radius: var(--radius-md);
}

.control-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.control-group label {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    min-width: 100px;
}

input[type="range"] {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    transition: all 0.3s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: var(--shadow-md);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.control-group span {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
}

.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.action-btn {
    padding: 12px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.action-btn:hover {
    background: var(--background);
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-btn .icon {
    font-size: 1.2rem;
}

.flash-display {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--text-secondary);
    z-index: 1000;
    transition: background 0.1s ease;
}

.flash-display.flash-on {
    background: var(--flash-color);
    box-shadow: 0 0 100px var(--flash-color);
}

.learn-section {
    padding: 1rem;
}

.learn-section h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
    text-align: center;
    font-size: 2rem;
}

.quiz-container {
    background: var(--background);
    padding: 2rem;
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
}

.quiz-display {
    text-align: center;
    margin-bottom: 2rem;
}

.quiz-question {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 500;
}

.quiz-morse {
    font-size: 2rem;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    padding: 1rem;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#quizAnswer {
    width: 100%;
    padding: 12px;
    font-size: 1.2rem;
    text-align: center;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
}

.quiz-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 1rem;
}

.quiz-feedback {
    text-align: center;
    font-size: 1.1rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    min-height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.quiz-feedback.correct {
    background: rgba(0,135,90,0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.quiz-feedback.incorrect {
    background: rgba(222,53,11,0.1);
    color: var(--error);
    border: 1px solid var(--error);
}

.score-display {
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--primary-color);
}

.reference-table {
    margin-top: 3rem;
}

.reference-table h3 {
    color: var(--text-primary);
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    text-align: center;
}

.table-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
}

.table-item {
    background: var(--background);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
}

.table-item:hover {
    background: var(--surface);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.table-item .char {
    display: block;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.table-item .morse {
    display: block;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    font-size: 0.9rem;
}

footer {
    background: var(--background);
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
}

.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--primary-color);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    z-index: 2000;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

@media (max-width: 768px) {
    .container {
        border-radius: 0;
    }
    
    body {
        padding: 0;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
    
    .action-buttons {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .controls {
        grid-template-columns: 1fr;
    }
    
    .quiz-buttons {
        flex-direction: column;
    }
    
    .table-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
}