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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 58%, #f59e0b 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #1d4ed8 0%, #0f766e 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header p {
    font-size: 1.2em;
    opacity: 0.9;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 20px;
    padding: 20px;
}

.canvas-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#canvas {
    border: 3px solid #1d4ed8;
    border-radius: 8px;
    background: white;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#status-bar {
    background: #f7f7f7;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 10px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

#status-bar span {
    background: white;
    padding: 8px 15px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.control-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    max-height: 680px;
}

.commands-section,
.generator-section,
.info-section,
.output-section {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

h3 {
    color: #1d4ed8;
    margin-bottom: 15px;
    font-size: 1.3em;
}

#command-input {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    margin-bottom: 10px;
}

#command-input:focus {
    outline: none;
    border-color: #1d4ed8;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.shortcut-hint,
.section-note {
    margin-top: 12px;
    color: #334155;
    font-size: 13px;
    line-height: 1.45;
}

.section-note {
    margin-top: -4px;
    margin-bottom: 14px;
}

kbd {
    display: inline-block;
    min-width: 24px;
    padding: 2px 6px;
    border: 1px solid #cbd5e1;
    border-bottom-width: 2px;
    border-radius: 5px;
    background: #ffffff;
    color: #0f172a;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #1d4ed8;
    color: white;
}

.btn-primary:hover {
    background: #1e40af;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(29, 78, 216, 0.28);
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.btn-secondary:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.btn-warning {
    background: #f97316;
    color: white;
}

.btn-warning:hover {
    background: #ea580c;
    transform: translateY(-2px);
}

.generator-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.generator-controls label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #475569;
    font-size: 13px;
    font-weight: 700;
}

.generator-controls select {
    width: 100%;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: white;
    color: #0f172a;
    font-size: 14px;
    padding: 9px 10px;
}

.challenge-card {
    margin-top: 14px;
    padding: 14px;
    border-radius: 8px;
    background: #ffffff;
    border: 1px solid #dbe4ef;
    border-left: 4px solid #0f766e;
}

.challenge-card-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.challenge-card-header span {
    color: #64748b;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.challenge-card-header strong {
    color: #0f172a;
    font-size: 15px;
    text-align: right;
}

#challenge-goal {
    color: #334155;
    font-size: 13px;
    line-height: 1.45;
    margin-bottom: 10px;
}

#challenge-meta {
    color: #0f766e;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    margin-bottom: 8px;
}

#challenge-hint {
    color: #7c2d12;
    background: #fffbeb;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    font-size: 12px;
    line-height: 1.45;
    padding: 9px;
}

.command-help {
    font-size: 14px;
    line-height: 1.5;
}

.help-category {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid #d8e0ea;
}

.help-category:last-child {
    border-bottom: none;
}

.help-category h4 {
    color: #0f766e;
    margin-bottom: 10px;
    font-size: 1.05em;
}

.command-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.command-row {
    display: grid;
    grid-template-columns: minmax(150px, 1.1fr) minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 10px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
}

.command-name {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.command-desc {
    color: #1e293b;
    font-size: 13px;
}

.mini-example {
    margin-top: 2px;
    padding: 10px;
    overflow-x: auto;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #0f172a;
}

.mini-example code {
    display: block;
    padding: 0;
    border: 0;
    background: transparent;
    color: #d1fae5;
    white-space: pre;
}

code {
    background: #f8fafc;
    padding: 4px 7px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    font-weight: 700;
    color: #9f1239;
}

.tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #94a3b8;
    background: #e0f2fe;
    color: #075985;
    font-size: 12px;
    font-weight: 800;
    cursor: help;
}

.tip::after {
    content: attr(data-tip);
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    z-index: 20;
    width: min(260px, 70vw);
    padding: 10px;
    border-radius: 8px;
    background: #0f172a;
    color: #ffffff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.4;
    text-align: left;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.tip:hover::after,
.tip:focus::after {
    opacity: 1;
}

#output {
    background: #1e1e1e;
    color: #00ff00;
    padding: 15px;
    border-radius: 6px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 12px;
    text-align: center;
    max-width: 500px;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h2 {
    color: #1d4ed8;
    font-size: 2.5em;
    margin-bottom: 20px;
}

.modal-content p {
    font-size: 1.2em;
    margin-bottom: 15px;
    color: #555;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    #canvas {
        width: 100%;
        height: auto;
    }

    .generator-controls {
        grid-template-columns: 1fr;
    }

    .command-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
