* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background-color: #2c3e50;
    color: white;
    border-radius: 8px;
}

header h1 {
    margin-bottom: 10px;
}

.warning-message {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 20px;
    color: #856404;
    text-align: center;
}

.warning-message strong {
    color: #856404;
}

.display-section {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.display-section h2 {
    margin-bottom: 15px;
    color: #2c3e50;
    text-align: center;
}

.lcd-display-container {
    display: flex;
    align-items: center;
    gap: 20px;
}

.display-controls-left {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 100px;
}

.display-controls-left button {
    padding: 8px 12px;
    background-color: #9b59b6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s;
}

.display-controls-left button:hover {
    background-color: #8e44ad;
}

.lcd-display {
    background-color: #2c3e50;
    border: 3px solid #1a2530;
    border-radius: 8px;
    padding: 15px;
    flex: 1;
    max-width: 800px;
}

.lcd-row {
    display: flex;
    gap: 5px;
    margin-bottom: 5px;
}

.lcd-row:last-child {
    margin-bottom: 0;
}

.lcd-cell {
    flex: 1;
    background-color: #1a2530;
    border: 1px solid #34495e;
    border-radius: 3px;
    padding: 2px;
    cursor: pointer;
    transition: border-color 0.2s;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lcd-cell:hover {
    border-color: #3498db;
}

.lcd-cell.active-cell {
    border-color: #f39c12;
    box-shadow: 0 0 5px rgba(243, 156, 18, 0.5);
    background-color: #2c3e50;
}

.cell-grid {
    display: grid;
    grid-template-columns: repeat(5, 6px);
    grid-template-rows: repeat(8, 6px);
    gap: 1px;
    width: 35px;
    height: 55px;
}

.cell-grid .grid-pixel {
    width: 6px;
    height: 6px;
    background-color: #34495e;
    border-radius: 1px;
}

.cell-grid .grid-pixel.active {
    background-color: #2980b9;
}

.display-controls-right {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 150px;
}

.animation-controls-simple .control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.animation-controls-simple label {
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
}

.animation-controls-simple #animation-speed {
    width: 100%;
}

.animation-controls-simple #speed-value {
    font-weight: bold;
    color: #2c3e50;
    font-size: 14px;
    text-align: center;
}

.animation-controls-simple #animation-direction {
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.animation-controls-simple #apply-animation-checkbox {
    transform: scale(1.2);
    margin-right: 5px;
}

.animation-controls-simple .button-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.animation-controls-simple button {
    padding: 6px 10px;
    font-size: 14px;
    min-width: auto;
}

.display-info {
    text-align: center;
    margin-top: 15px;
    color: #7f8c8d;
    font-size: 14px;
}

.editor-section {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-bottom: 30px;
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.character-grid-container {
    flex: 1;
    min-width: 300px;
}

.character-grid-container h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(5, 40px);
    grid-template-rows: repeat(8, 40px);
    gap: 3px;
    margin: 0 auto;
    user-select: none; /* Prevent text selection during drag */
    touch-action: none; /* Prevent touch scrolling during drag */
    border: 2px solid #34495e;
    padding: 10px;
    background-color: #1a2530;
    border-radius: 4px;
    width: fit-content;
}

.grid-cell {
    width: 40px;
    height: 40px;
    border: 1px solid #2c3e50;
    background-color: #34495e;
    cursor: pointer;
    transition: background-color 0.1s;
    border-radius: 2px;
}

.grid-cell:hover {
    border-color: #3498db;
    box-shadow: 0 0 3px rgba(52, 152, 219, 0.5);
}

.grid-cell.active {
    background-color: #2980b9;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.3);
}

.grid-cell.drag-active {
    background-color: #3498db;
    transform: scale(0.95);
}

.grid-info {
    font-size: 14px;
    color: #7f8c8d;
    text-align: center;
    margin-top: 15px;
}

.controls {
    flex: 1;
    min-width: 300px;
}

.control-group {
    margin-bottom: 20px;
}

.control-group label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    color: #2c3e50;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    padding: 10px 15px;
    background-color: #3498db;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: background-color 0.3s;
    flex: 1;
    min-width: 100px;
}

button:hover {
    background-color: #2980b9;
}

#clear-btn {
    background-color: #e74c3c;
}

#clear-btn:hover {
    background-color: #c0392b;
}

#reset-display-btn {
    background-color: #f39c12;
}

#reset-display-btn:hover {
    background-color: #d35400;
}

#copy-code-btn {
    align-self: flex-end;
    background-color: #27ae60;
    width: 150px;
}

#copy-code-btn:hover {
    background-color: #229954;
}

.instructions {
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid #3498db;
}

.instructions h3 {
    margin-bottom: 10px;
    color: #2c3e50;
}

.instructions ul {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 5px;
}

.code-section {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.code-section h2 {
    margin-bottom: 15px;
    color: #2c3e50;
}

.transmission-options {
    margin-bottom: 15px;
    padding: 15px;
    background-color: #ecf0f1;
    border-radius: 4px;
}

.transmission-options label {
    margin-right: 20px;
    cursor: pointer;
    display: inline-block;
    margin-bottom: 10px;
}

.format-options {
    margin-bottom: 15px;
    padding: 15px;
    background-color: #ecf0f1;
    border-radius: 4px;
}

.format-options label {
    margin-right: 20px;
    cursor: pointer;
    display: inline-block;
    margin-bottom: 10px;
}

.animation-options {
    margin-bottom: 15px;
    padding: 15px;
    background-color: #ecf0f1;
    border-radius: 4px;
}

.animation-options label {
    cursor: pointer;
    display: inline-block;
    margin-bottom: 10px;
}

.animation-settings {
    margin-top: 10px;
    padding: 10px;
    background-color: #d5dbdb;
    border-radius: 4px;
}

.animation-settings .control-group {
    margin-bottom: 10px;
}

.animation-settings label {
    display: block;
    margin-bottom: 5px;
    font-weight: normal;
}

.animation-settings input, .animation-settings select {
    width: 100%;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid #ddd;
}

.code-output {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#code-output {
    width: 100%;
    height: 300px;
    font-family: 'Courier New', monospace;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    background-color: #2c3e50;
    color: #ecf0f1;
}

footer {
    text-align: center;
    margin-top: 30px;
    padding: 20px;
    color: #7f8c8d;
    font-size: 14px;
}

footer a {
    color: #3498db;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .editor-section {
        flex-direction: column;
    }
    
    .lcd-display-container {
        flex-direction: column;
    }
    
    .display-controls-left,
    .display-controls-right {
        flex-direction: row;
        justify-content: center;
        width: 100%;
    }
    
    .lcd-display {
        padding: 10px;
    }
    
    .lcd-cell {
        padding: 1px;
        min-height: 45px;
    }
    
    .cell-grid {
        grid-template-columns: repeat(5, 4px);
        grid-template-rows: repeat(8, 4px);
        width: 25px;
        height: 40px;
    }
    
    .cell-grid .grid-pixel {
        width: 4px;
        height: 4px;
    }
    
    .character-grid {
        grid-template-columns: repeat(5, 30px);
        grid-template-rows: repeat(8, 30px);
    }
    
    .grid-cell {
        width: 30px;
        height: 30px;
    }
}