* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: Arial, sans-serif;
    background: #333;
    min-height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.container {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.text-display {
    background: #f5f5f5;
    padding: 15px;
    font-size: 28px;
    min-height: 100px;
    border-bottom: 3px solid #333;
    word-wrap: break-word;
    overflow-y: auto;
    flex-shrink: 0;
}

.keyboard-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.layout-switcher {
    display: flex;
    gap: 0;
    margin: 0;
    justify-content: stretch;
    flex-shrink: 0;
}

.layout-btn {
    flex: 1;
    padding: 20px;
    font-size: 24px;
    font-weight: bold;
    border: 3px solid #333;
    border-right: none;
    background: white;
    color: #2196F3;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 70px;
}

.layout-btn:last-child {
    border-right: 3px solid #333;
}

.layout-btn:hover {
    background: #2196F3;
    color: white;
}

.layout-btn.active {
    background: #2196F3;
    color: white;
}

.keyboard {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin: 0;
    flex: 1;
    border-top: 3px solid #333;
    overflow-y: auto;
}

.keyboard-row {
    display: flex;
    flex: 1;
    gap: 0;
    border-left: 3px solid #333;
}

.key {
    flex: 1;
    min-height: 0;
    font-size: 48px;
    font-weight: bold;
    border: 3px solid #333;
    border-top: none;
    border-left: none;
    background: linear-gradient(145deg, #ffffff, #e6e6e6);
    color: #333;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    padding: 0;
}

.key:active {
    background: linear-gradient(145deg, #d0d0d0, #b0b0b0);
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.3);
}

.key:hover {
    background: linear-gradient(145deg, #f0f0f0, #d0d0d0);
}

.control-buttons {
    display: flex;
    gap: 0;
    margin: 0;
    border-top: 3px solid #333;
    flex-shrink: 0;
}

.control-btn {
    flex: 1;
    padding: 0;
    font-size: 32px;
    font-weight: bold;
    border: 3px solid #333;
    border-top: none;
    border-left: none;
    background: linear-gradient(145deg, #4CAF50, #45a049);
    color: white;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.1s;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:last-child {
    border-right: none;
}

.control-btn.space {
    background: linear-gradient(145deg, #2196F3, #1976D2);
    flex: 2;
}

.control-btn.backspace {
    background: linear-gradient(145deg, #f44336, #d32f2f);
    flex: 1;
}

.control-btn.enter {
    background: linear-gradient(145deg, #FF9800, #F57C00);
    flex: 1;
}

.control-btn:active {
    background: linear-gradient(145deg, #2e7d32, #1b5e20);
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.4);
}

.control-btn.space:active {
    background: linear-gradient(145deg, #1565C0, #0d47a1);
}

.control-btn.backspace:active {
    background: linear-gradient(145deg, #c62828, #b71c1c);
}

.control-btn.enter:active {
    background: linear-gradient(145deg, #E65100, #BF360C);
}

.history-section {
    position: relative;
    flex-shrink: 0;
}

.history-btn {
    width: 100%;
    padding: 20px;
    font-size: 24px;
    font-weight: bold;
    border: none;
    border-top: 3px solid #333;
    background: #9C27B0;
    color: white;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 70px;
}

.history-btn:hover {
    background: #7B1FA2;
}

.history-panel {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 3px solid #333;
    border-bottom: none;
    border-radius: 0;
    max-height: 300px;
    overflow-y: auto;
    margin: 0;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.2);
}

.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 2px solid #ddd;
    background: #f5f5f5;
    position: sticky;
    top: 0;
    z-index: 10;
}

.history-header h3 {
    margin: 0;
    font-size: 18px;
}

.close-btn {
    background: #f44336;
    color: white;
    border: none;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-list {
    padding: 10px;
}

.history-item {
    padding: 15px;
    margin: 0;
    border-bottom: 2px solid #ddd;
    background: #f9f9f9;
    border-left: 4px solid #2196F3;
    border-radius: 0;
    cursor: pointer;
    transition: all 0.2s;
}

.history-item:hover {
    background: #e3f2fd;
    transform: translateX(5px);
}

.history-item-time {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

/* Адаптация для очень маленьких экранов */
@media (max-height: 600px) {
    .key {
        font-size: 36px;
    }
    
    .control-btn {
        font-size: 24px;
        min-height: 80px;
    }
    
    .text-display {
        font-size: 22px;
        padding: 12px;
        min-height: 80px;
    }
    
    .layout-btn {
        font-size: 20px;
        min-height: 60px;
    }
}

/* Для планшетов и больших экранов */
@media (min-width: 768px) {
    .keyboard {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .key {
        font-size: 64px;
    }
    
    .control-btn {
        font-size: 40px;
        min-height: 120px;
    }
    
    .text-display {
        font-size: 32px;
    }
}
