/* ... (предыдущие стили body, .container, h1, .lang-selector, #morse-key, .history-container и т.д.) ... */
body {
    background-color: #1e1e1e;
    color: #e0e0e0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
                 Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    margin: 0;
    padding: 0;
    display: flex;
    /* Changed to flex-start to avoid vertical centering with dictionary */
    justify-content: center;
    align-items: flex-start; /* Align items to the top */
    min-height: 100vh;
    text-align: center;
    touch-action: manipulation;
    padding-top: 20px; /* Add some top padding */
    padding-bottom: 40px; /* Add bottom padding */
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    width: 90%;
    max-width: 700px; /* Slightly wider max-width */
}

h1 {
    margin-bottom: 15px;
    color: #cccccc;
}

/* Стили для блока выбора языка */
.lang-selector {
    margin-bottom: 25px;
}

.lang-selector button {
    background: none;
    border: 1px solid transparent;
    color: #a0a0a0;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 15px;
    border-radius: 4px;
    transition: color 0.2s ease, border-color 0.2s ease;
    margin: 0 5px;
}

.lang-selector button:hover {
    color: #e0e0e0;
}

.lang-selector button.active-lang {
    color: #ffffff;
    font-weight: bold;
    border-color: #555;
    cursor: default;
}

.lang-selector {
    color: #555;
}


/* Стили для кнопки ключа */
#morse-key {
    background-color: #4CAF50;
    border: none;
    color: white;
    padding: 40px 60px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 20px;
    margin: 20px 2px;
    cursor: pointer;
    border-radius: 12px;
    transition: background-color 0.1s ease, transform 0.1s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

#morse-key:active {
    background-color: #367c39;
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

/* Контейнер истории */
.history-container {
    margin-top: 30px;
    background-color: #2a2a2a;
    padding: 15px;
    border-radius: 8px;
    width: 100%;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

h2 { /* History Heading */
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 18px;
    color: #bbbbbb;
}

#history-display {
    min-height: 50px;
    background-color: #1a1a1a;
    padding: 10px;
    border-radius: 4px;
    word-wrap: break-word;
    font-size: 22px;
    font-family: 'Fira Code', monospace;
    color: #aaffaa;
    line-height: 1.4;
    text-align: left;
    margin-bottom: 15px;
}

#clear-history {
     background-color: #f44336;
     border: none;
     color: white;
     padding: 10px 20px;
     text-align: center;
     text-decoration: none;
     display: inline-block;
     font-size: 14px;
     margin-top: 10px;
     cursor: pointer;
     border-radius: 5px;
     transition: background-color 0.2s ease;
     -webkit-tap-highlight-color: transparent;
     outline: none;
}

#clear-history:hover, #clear-history:active {
    background-color: #d32f2f;
}

/* Стили для словаря Морзе */
#morse-dictionary {
    margin-top: 40px; /* Отступ сверху */
    width: 100%;
    background-color: #2a2a2a; /* Тот же фон, что и у истории */
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

#dictionary-heading {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 18px;
    color: #bbbbbb;
}

/* Используем CSS Grid для словаря */
.dictionary-grid {
    display: grid;
    /* 3 колонки с авто-шириной, минимум 100px */
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px 15px; /* Промежутки между строками и колонками */
    text-align: left; /* Выравнивание внутри ячеек */
}

.dict-entry {
    display: flex; /* Размещаем символ и код рядом */
    justify-content: space-between; /* Разносим по краям */
    padding: 4px 0; /* Небольшой вертикальный отступ */
    border-bottom: 1px solid #333; /* Разделитель */
}

.dict-entry span:first-child {
    font-weight: bold;
    color: #e0e0e0; /* Цвет символа */
    margin-right: 10px; /* Отступ справа от символа */
}

.dict-entry span:last-child {
    font-family: 'Fira Code', monospace; /* Шрифт для кода морзе */
    color: #aaffaa; /* Зеленый цвет для кода */
    letter-spacing: 1px; /* Небольшое разрежение */
}