:root {
    --primary-color: #ff6b6b;
    --secondary-color: #4ecdc4;
    --accent-color: #ffe66d;
    --bg-color: #f7fff7;
    --text-color: #2f2f2f;
    --card-bg: #ffffff;
    --editor-bg: #2d3436;
    --editor-text: #dfe6e9;
    --font-family: 'Quicksand', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    z-index: 10;
}

header h1 {
    font-size: 1.8rem;
    letter-spacing: 2px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.main-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1rem;
    padding: 1rem;
}

.left-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 400px;
}

.right-panel {
    flex: 1.5;
    background-color: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card {
    background-color: var(--card-bg);
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.05);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
}

/* Editor Styles */
.editor-container {
    position: relative;
    flex: 1;
    min-height: 300px;
    background-color: var(--editor-bg);
    border-radius: 15px;
    overflow: hidden;
}

#logo-editor,
#editor-highlight {
    width: 100%;
    height: 100%;
    padding: 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.1rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    tab-size: 4;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    border: none;
    box-sizing: border-box;
    overflow-y: scroll;
    /* Force scrollbar on both to match width */
}

#logo-editor {
    background: transparent;
    color: transparent;
    /* Text is transparent, only caret shows */
    caret-color: white;
    resize: none;
    outline: none;
    z-index: 2;
}

#editor-highlight {
    background: transparent;
    color: var(--editor-text);
    pointer-events: none;
    z-index: 1;
    scrollbar-width: none;
    /* Hide for Firefox */
    -ms-overflow-style: none;
    /* Hide for IE/Edge */
}

#editor-highlight::-webkit-scrollbar {
    display: none;
    /* Hide for Chrome/Safari */
}

.hidden {
    display: none !important;
}

/* Controls */
.controls {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 50px;
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.btn-run {
    background-color: var(--secondary-color);
    color: white;
}

.btn-save {
    background-color: var(--accent-color);
    color: var(--text-color);
}

.btn-reset {
    background-color: #dfe6e9;
    color: var(--text-color);
}

/* Canvas */
#turtle-canvas {
    width: 100%;
    height: 100%;
}

#turtle-overlay {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    width: 100%;
    height: 100%;
}

.canvas-container {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.canvas-header {
    padding: 1rem 1.5rem;
    border-bottom: 2px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.turtle-customizer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.turtle-options {
    display: flex;
    gap: 0.5rem;
}

.turtle-opt {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-color: transparent;
    padding: 2px;
    object-fit: contain;
}

.turtle-opt:hover {
    transform: translateY(-3px) scale(1.1);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.turtle-opt.active {
    border-color: var(--secondary-color);
    background-color: rgba(78, 205, 196, 0.15);
    box-shadow: 0 0 15px rgba(78, 205, 196, 0.3);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.btn-help {
    background-color: var(--accent-color);
    color: var(--text-color);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--card-bg);
    margin: 5% auto;
    padding: 2rem;
    border-radius: 25px;
    width: 80%;
    max-width: 800px;
    position: relative;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.close-modal {
    position: absolute;
    right: 25px;
    top: 15px;
    font-size: 2rem;
    font-weight: bold;
    color: #999;
    cursor: pointer;
}

.close-modal:hover {
    color: var(--primary-color);
}

.modal-content-small {
    max-width: 450px;
    margin: 15% auto;
    text-align: center;
}

.modal-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    border-radius: 12px;
    border: 2px solid #eee;
    margin: 1.5rem 0;
    font-family: var(--font-family);
    outline: none;
    transition: border-color 0.2s;
}

.modal-input:focus {
    border-color: var(--secondary-color);
}

.modal-actions {
    display: flex;
    justify-content: center;
}

.modal-header h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
    text-align: center;
}

.modal-body section {
    margin-bottom: 2rem;
}

.modal-body h3 {
    margin-bottom: 1rem;
    color: var(--secondary-color);
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

.command-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.8rem;
}

.command-item {
    background: #fdfdfd;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    border: 1px solid #eee;
    transition: background 0.2s;
}

.command-item code {
    font-weight: bold;
    color: var(--primary-color);
    display: block;
    margin-bottom: 0.2rem;
}

/* Samples Grid */
.samples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.sample-card {
    background: #f9f9f9;
    padding: 1.2rem;
    border-radius: 18px;
    border: 2px dashed #ddd;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.sample-card:hover {
    transform: translateY(-5px);
    border-color: var(--secondary-color);
    background: #f0fdfa;
}

.sample-card h4 {
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.sample-card p {
    font-size: 0.85rem;
    color: #666;
}

/* Saved Programs */
.saved-programs-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

select {
    padding: 0.5rem 1rem;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-family: var(--font-family);
    background: white;
}

/* Syntax Highlighting */
.hl-kw {
    color: #ff6b6b;
    font-weight: bold;
}

.hl-num {
    color: #4ecdc4;
}

.hl-bracket {
    color: #f9ca24;
    font-weight: bold;
}

.hl-var {
    color: #ff9f43;
}

/* Status */
#status-display {
    font-weight: bold;
    color: var(--secondary-color);
}