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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
}

header {
    text-align: center;
    margin-bottom: 40px;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    color: #666;
    opacity: 0.8;
}

.main-content {
    display: grid;
    gap: 30px;
}

section {
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 1.8rem;
    font-weight: 600;
    border-bottom: 3px solid #3498db;
    padding-bottom: 10px;
}

section h3 {
    color: #34495e;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.config-item {
    display: flex;
    flex-direction: column;
}

.config-item.full-width {
    grid-column: 1 / -1;
    margin-top: 20px;
}

.config-item label {
    font-weight: 600;
    margin-bottom: 8px;
    color: #2c3e50;
    font-size: 0.95rem;
}

.config-item input,
.config-item textarea {
    padding: 12px;
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.3s ease;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.config-item input:focus,
.config-item textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.config-item textarea {
    resize: vertical;
    min-height: 60px;
}

.config-item small {
    margin-top: 5px;
    color: #666;
    font-size: 0.85rem;
}

.button-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

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

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-primary {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, #ff0000, #ff0000);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #27ae60, #229954);
    color: white;
}

.status-bar {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 25px;
}

.status {
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
}

.tape-section {
    margin-bottom: 25px;
}

.tape-display {
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    padding: 20px;
    overflow-x: auto;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tape-rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    justify-content: center;
    min-width: 100%;
}

.tape-row {
    display: flex;
    gap: 2px;
    align-items: center;
    justify-content: center;
}

.tape-cell {
    width: 50px;
    height: 50px;
    border: 2px solid #dee2e6;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 18px;
    font-weight: bold;
    color: #2c3e50;
    border-radius: 8px;
    transition: all 0.3s ease;
    position: relative;
}

.tape-cell.head-position {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border-color: #c0392b;
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.4);
}

.tape-cell.head-position::after {
    content: '↑';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 20px;
    color: #e74c3c;
}

.tape-cell::before {
    content: attr(data-position);
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #666;
    opacity: 0.7;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 15px;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.speed-control label {
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
}

.speed-control #speed-slider {
    width: 200px;
    height: 6px;
    border-radius: 3px;
    background: #ddd;
    outline: none;
    appearance: none;
}

.speed-control #speed-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3498db;
    cursor: pointer;
    transition: all 0.3s ease;
}

.speed-control #speed-slider::-webkit-slider-thumb:hover {
    background: #2980b9;
    transform: scale(1.1);
}

.speed-control #speed-display {
    font-weight: 600;
    color: #34495e;
    min-width: 60px;
    text-align: center;
}

.control-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.instruction-item {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    padding: 25px;
    border-radius: 10px;
    border-left: 4px solid #3498db;
}

.instruction-item h4 {
    color: #2c3e50;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.instruction-item p {
    color: #666;
    line-height: 1.6;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .config-grid {
        grid-template-columns: 1fr;
    }
    
    .button-group {
        justify-content: center;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .tape-cell {
        width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .instruction-grid {
        grid-template-columns: 1fr;
    }
}

@keyframes cellUpdate {
    0% { background-color: #fff3cd; }
    100% { background-color: white; }
}

.tape-cell.updated {
    animation: cellUpdate 0.5s ease-in-out;
}

.btn.loading {
    position: relative;
    color: transparent;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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