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

:root {
    --primary-color: #6366f1;
    --secondary-color: #8b5cf6;
    --bg-dark: #0f172a;
    --bg-light: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --error-color: #ef4444;
    --success-color: #10b981;
    --border-color: #334155;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    padding: 1.5rem 2rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-secondary);
}

main {
    flex: 1;
    padding: 2rem;
}

.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.editor-section, .canvas-section {
    background: var(--bg-light);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.editor-header, .canvas-header {
    padding: 1rem 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-header h2, .canvas-header h2 {
    font-size: 1.2rem;
    font-weight: 600;
}

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

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #4f46e5;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--border-color);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #475569;
}

.template-select {
    padding: 0.5rem;
    background: var(--bg-dark);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
}

.editor-container {
    height: 400px;
    position: relative;
}

#codeEditor {
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    color: var(--text-primary);
    border: none;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    resize: none;
}

.CodeMirror {
    height: 100%;
    font-size: 14px;
}

.error-console {
    padding: 1rem;
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    font-family: monospace;
    font-size: 0.85rem;
    max-height: 100px;
    overflow-y: auto;
    display: none;
}

.error-console.show {
    display: block;
}

.canvas-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.canvas-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.canvas-container {
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    height: 400px;
}

#animationCanvas {
    background: white;
    max-width: 100%;
    max-height: 100%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.info-panel {
    padding: 1rem;
    background: var(--bg-dark);
    display: flex;
    gap: 2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.info-panel span {
    display: flex;
    gap: 0.5rem;
}

.help-section {
    max-width: 1400px;
    margin: 2rem auto 0;
    padding: 2rem;
    background: var(--bg-light);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.help-section h3 {
    margin-bottom: 1rem;
    color: var(--primary-color);
}

.help-section ul {
    list-style: none;
    padding-left: 1.5rem;
}

.help-section li {
    margin-bottom: 0.5rem;
    position: relative;
}

.help-section li::before {
    content: '▸';
    position: absolute;
    left: -1.5rem;
    color: var(--primary-color);
}

footer {
    padding: 2rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* レスポンシブデザイン */
@media (max-width: 1024px) {
    .workspace {
        grid-template-columns: 1fr;
    }
    
    .editor-container, .canvas-container {
        height: 300px;
    }
}

@media (max-width: 640px) {
    header h1 {
        font-size: 1.5rem;
    }
    
    main {
        padding: 1rem;
    }
    
    .controls {
        flex-wrap: wrap;
    }
    
    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}