* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    color: #333;
}

.container {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    padding: 30px;
    max-width: 1400px;
    width: 100%;
}

h1 {
    text-align: center;
    color: #4a5568;
    margin-bottom: 30px;
    font-size: 2.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.input-section {
    background: #f7fafc;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.text-input {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    font-size: 16px;
    border: 2px solid #4299e1;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    resize: vertical;
    letter-spacing: 1px;
}

.controls {
    text-align: center;
    margin: 20px 0;
}

button {
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #4299e1;
    color: white;
    margin: 0 5px;
}

button:hover {
    background: #3182ce;
    transform: translateY(-2px);
}

button.secondary {
    background: #68d391;
}

button.secondary:hover {
    background: #48bb78;
}

.analysis-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

.frequency-section {
    background: #f7fafc;
    padding: 20px;
    border-radius: 10px;
    width: 650px;
}

.frequency-section h3 {
    color: #4a5568;
    margin-bottom: 15px;
    text-align: center;
}

.chart-container {
    background: white;
    height: 250px;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.chart {
    display: flex;
    align-items: end;
    height: 200px;
    gap: 1px;
    padding: 30px;
    overflow-x: auto;
}

.bar {
    min-width: 18px;
    border-radius: 2px 2px 0 0;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
}

.bar.cipher {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.bar.reference {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
}

.bar:hover {
    filter: brightness(1.2);
    transform: scaleY(1.05);
}

.bar-label {
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 11px;
    font-weight: bold;
    color: #4a5568;
}

.bar-value {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 9px;
    color: #2d3748;
    background: rgba(255,255,255,0.9);
    padding: 1px 3px;
    border-radius: 2px;
    white-space: nowrap;
}

.mapping-section {
    background: #f7fafc;
    padding: 20px;
    border-radius: 10px;
    grid-column: 1 / -1;
}

.mapping-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.mapping-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    transition: all 0.3s ease;
}

.mapping-item:hover {
    border-color: #4299e1;
    box-shadow: 0 2px 8px rgba(66, 153, 225, 0.2);
}

.mapping-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 5px 0;
}

.cipher-char {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 18px;
    min-width: 40px;
    text-align: center;
}

.mapping-select {
    flex: 1;
    padding: 8px;
    border: 2px solid #4299e1;
    border-radius: 6px;
    font-size: 16px;
}

.frequency-info {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.comparison-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.comparison-table th,
.comparison-table td {
    padding: 8px 12px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.comparison-table th {
    background: #4299e1;
    color: white;
    font-weight: bold;
}

.comparison-table tr:nth-child(even) {
    background: #f8f9fa;
}

.decryption-section {
    background: #edf2f7;
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.decrypted-text {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #68d391;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    line-height: 1.6;
    min-height: 100px;
    letter-spacing: 1px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.stat-card {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 2px solid #e2e8f0;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: #4299e1;
}

.stat-label {
    font-size: 14px;
    color: #666;
    margin-top: 5px;
}

.message {
    text-align: center;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-weight: bold;
}

.info {
    background: #bee3f8;
    color: #2b6cb0;
}

.success {
    background: #c6f6d5;
    color: #2f855a;
}

.reference-info {
    background: #e6fffa;
    border: 1px solid #4fd1c7;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    font-size: 14px;
}

@media (max-width: 1024px) {
    .analysis-container {
        grid-template-columns: 1fr;
    }
    
    .mapping-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

@media (max-width: 768px) {
    .chart {
        height: 150px;
    }
    
    .bar {
        min-width: 12px;
    }
    
    .mapping-grid {
        grid-template-columns: 1fr;
    }
}