:root {
    --toolbar: #0033a0;
    --accent: #ffd700;
}

body {
    margin: 0;
    height: 100vh;
    display: flex;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f4f4f4;
}

#sidebar {
    width: 350px;
    min-width: 350px; /* Prevent shrinking */
    display: flex;
    flex-direction: column;
    border-right: 2px solid #ddd;
    background: #fff;
}

#toolbar {
    background: var(--toolbar);
    color: #fff;
    padding: 8px;
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    align-items: center;
}

#speedControl {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto; /* Pushes to the right */
    white-space: nowrap; /* Prevents wrapping */
}

#speedSlider {
    width: 80px;
    vertical-align: middle;
}

#speedLabel {
    font-size: 11px;
    color: #fff;
    vertical-align: middle;
}

#speedValue {
    font-size: 11px;
    vertical-align: middle;
    width: 12px; /* Give it a fixed width */
    text-align: center;
}

#toolbar button {
    border: none;
    padding: 6px 12px;
    background: var(--accent);
    cursor: pointer;
    border-radius: 4px;
    color: #000;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0; /* Prevent buttons from shrinking */
}

#toolbar button:hover {
    background: #ffed4e;
}

#toolbar button:disabled {
    background: #999;
    color: #eee;
    cursor: not-allowed;
}

#editor {
    flex: 1;
    overflow: hidden;
    background: #282c34;
    color: #abb2bf;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    position: relative;
}

#codeDisplay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 10px;
    box-sizing: border-box;
    background: #282c34;
    color: #abb2bf;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow: auto;
    display: none;
    z-index: 10;
}

.code-line {
    padding: 2px 0;
    border-left: 3px solid transparent;
    padding-left: 8px;
}

#codeArea {
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    background: #282c34;
    color: #abb2bf;
    border: none;
    padding: 10px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    resize: none;
    outline: none;
    line-height: 1.4;
    white-space: pre-wrap;
    overflow-wrap: break-word;
}

.highlight-line {
    background-color: #3a4a5c !important;
    border-left: 3px solid #ffd700 !important;
    animation: pulse 0.3s ease-in-out;
}

@keyframes pulse {
    0% { background-color: #4a5a7c; }
    50% { background-color: #5a6a8c; }
    100% { background-color: #3a4a5c; }
}

#log {
    height: 120px;
    overflow: auto;
    font-size: 12px;
    padding: 8px;
    background: #1a1a1a;
    color: #00ff00;
    font-family: 'Consolas', 'Monaco', monospace;
    border-top: 1px solid #ddd;
}

#canvasWrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    background: #f8f8f8;
}

#canvas {
    border: 2px solid #ccc;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

#turtle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: #00ff00;
    border-radius: 50%;
    transform: translate(-10px, -10px);
    pointer-events: none;
    z-index: 10;
    box-shadow: 0 0 10px rgba(0,255,0,0.5);
    transition: none;
    --triangle-color: #333333;
    --rotation: 0deg;
}

#turtle::after {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1;
}

#turtle::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 3px solid transparent;
    border-right: 3px solid transparent;
    border-bottom: 6px solid var(--triangle-color);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(var(--rotation));
    z-index: 2;
    transform-origin: center;
}

/* Modal Styles */
#instructions, #examplesModal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    display: none;
    z-index: 1000;
    overflow: auto;
    padding: 20px;
    box-sizing: border-box;
}

#instructionsContent, #examplesContent {
    background: #fff;
    margin: 40px auto;
    padding: 30px;
    max-width: 800px;
    border-radius: 8px;
    font-family: system-ui;
    line-height: 1.6;
}

#instructionsContent h2, #examplesContent h2 {
    color: var(--toolbar);
    margin-top: 0;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 10px;
}

.close-modal-btn {
    float: right;
    background: var(--toolbar);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
}

.close-modal-btn:hover {
    background: #002080;
}

.example-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 20px;
    padding: 15px;
}

.example-item h4 {
    margin-top: 0;
}

.example-item pre {
    background: #f8f8f8;
    padding: 15px;
    border-radius: 4px;
    overflow-x: auto;
    border-left: 4px solid var(--toolbar);
    white-space: pre-wrap;
}

.try-it-btn {
    display: block;
    margin-left: auto;
}
