:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --bg-canvas: #252525;
    --primary: #3b82f6;
    /* Blue */
    --accent: #f59e0b;
    /* Amber for handles */
    --text-main: #e5e5e5;
    --text-muted: #a3a3a3;
    --border: #333;
    --grid-line: #333;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 60px 1fr 280px;
    height: 100%;
}

/* Toolbar */
.toolbar {
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0;
    gap: 2rem;
}

.logo span {
    color: var(--primary);
    font-weight: 700;
}

.logo {
    font-family: var(--font-heading);
    font-size: 0.65rem;
    font-weight: 500;
    opacity: 0.8;
}

.tool-group,
.action-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tool-btn,
.action-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-btn svg,
.action-btn svg {
    width: 24px;
    height: 24px;
}

.tool-btn:hover,
.action-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.tool-btn.active {
    background-color: var(--primary);
    color: white;
}

/* Workspace */
.workspace {
    flex: 1;
    background-color: #1e1e1e;
    position: relative;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.canvas-wrapper {
    position: relative;
    width: 1000px;
    height: 700px;
    background-color: #1a1a1a;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#grid-layer {
    z-index: 1;
    pointer-events: none;
}

#ref-layer {
    z-index: 2;
    pointer-events: none;
    opacity: 0.5;
}

#draw-layer {
    z-index: 3;
}

.feedback-overlay {
    position: absolute;
    bottom: 2rem;
    background-color: rgba(0, 0, 0, 0.8);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    pointer-events: none;
    transition: opacity 0.3s;
}

.instruction {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Sidebar */
.sidebar {
    background-color: var(--bg-panel);
    border-left: 1px solid var(--border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
    max-height: 100vh;
}

/* Reduce panel gaps */
.worlds-panel {
    max-height: 180px;
}

.panel {
    flex-shrink: 0;
}

.panel h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    margin-bottom: 1rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mode-selector {
    display: flex;
    background: #111;
    padding: 4px;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.mode-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-muted);
    padding: 6px;
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
}

.mode-btn.active {
    background-color: var(--bg-panel);
    color: var(--text-main);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.level-info h4 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.description {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
}

.stat-row span:last-child {
    font-weight: 600;
    font-family: monospace;
    font-size: 1rem;
}

#stat-best-stars {
    color: var(--accent);
    font-size: 1.1rem;
    letter-spacing: 1px;
}

.primary-btn {
    margin-top: auto;
    background-color: var(--primary);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-heading);
    letter-spacing: 0.5px;
    transition: background 0.2s;
}

.primary-btn:hover {
    filter: brightness(1.1);
}

/* Secondary Button */
.secondary-btn {
    background-color: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 0.8rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-heading);
    margin-top: 0.5rem;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

/* Bug Report Button */
.bug-report-btn {
    background-color: transparent;
    color: #ef4444;
    border: 1px solid #ef4444;
    padding: 0.6rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-heading);
    margin-top: 1rem;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.bug-report-btn:hover {
    background-color: rgba(239, 68, 68, 0.1);
}

/* Bug Modal Form */
.bug-modal {
    max-width: 450px;
}

.form-group {
    margin-bottom: 1rem;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.form-group select,
.form-group textarea {
    width: 100%;
    background: #111;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.6rem;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: var(--font-body);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
}

/* World/Level Selector */
.worlds-panel {
    max-height: 280px;
    overflow-y: auto;
}

.worlds-panel::-webkit-scrollbar {
    width: 4px;
}

.worlds-panel::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.world-group {
    margin-bottom: 1rem;
}

.world-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 0.5rem;
}

.world-header:hover {
    background: rgba(255, 255, 255, 0.06);
}

.world-icon {
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
}

.world-name {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 600;
}

.world-progress {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.level-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding-left: 0.5rem;
}

.level-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
}

.level-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.level-item.active {
    background: var(--primary);
    color: white;
}

.level-item.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.level-item .level-num {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    width: 24px;
}

.level-item.active .level-num {
    color: rgba(255, 255, 255, 0.7);
}

.level-item .level-name {
    flex: 1;
    font-size: 0.8rem;
}

.level-item .level-stars {
    font-size: 0.65rem;
    color: var(--accent);
    letter-spacing: -1px;
}

.level-item.locked .level-stars {
    color: var(--text-muted);
}

/* Level Panel */
.level-panel {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, transparent 100%);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    padding: 1rem !important;
}

.level-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.level-badge {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: monospace;
}

.level-panel h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.skill-tag {
    display: inline-block;
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent);
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-top: 0.75rem;
}

/* Completion Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-panel);
    border-radius: 16px;
    padding: 2.5rem;
    text-align: center;
    max-width: 400px;
    transform: scale(0.9);
    transition: transform 0.3s;
    border: 1px solid var(--border);
}

.modal-overlay.visible .modal {
    transform: scale(1);
}

.modal-stars {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--accent);
    text-shadow: 0 0 20px rgba(245, 158, 11, 0.5);
}

.modal h2 {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.modal p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.modal-buttons {
    display: flex;
    gap: 1rem;
}

.modal-btn {
    flex: 1;
    padding: 0.8rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font-heading);
    transition: all 0.2s;
    border: none;
}

.modal-btn.retry {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.modal-btn.retry:hover {
    background: rgba(255, 255, 255, 0.15);
}

.modal-btn.next {
    background: var(--primary);
    color: white;
}

.modal-btn.next:hover {
    filter: brightness(1.1);
}

/* Star colors */
.stars-3 {
    color: #fbbf24;
}

.stars-2 {
    color: #a3a3a3;
}

.stars-1 {
    color: #78716c;
}

.stars-0 {
    color: #52525b;
}

/* Appearance Panel */
.appearance-panel {
    background: var(--bg-panel);
}

.appearance-section {
    margin-bottom: 1rem;
}

.appearance-section>label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.appearance-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.appearance-row input[type="color"] {
    width: 40px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
}

.appearance-row input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.appearance-row input[type="color"]::-webkit-color-swatch {
    border-radius: 2px;
    border: none;
}

.appearance-row select {
    flex: 1;
    background: #111;
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
}

.appearance-row select:focus {
    outline: none;
    border-color: var(--primary);
}

.fill-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
}

.fill-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.appearance-row input[type="color"]:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Info Group */
.info-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Info Modals */
.info-modal {
    max-width: 500px;
    text-align: left;
}

.info-modal h2 {
    text-align: center;
    margin-bottom: 1rem;
}

/* Shortcuts Grid */
.shortcuts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
}

.shortcut-item kbd {
    background: var(--primary);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: monospace;
    min-width: 60px;
    text-align: center;
}

.shortcut-item span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* About Content */
.about-content {
    font-size: 0.9rem;
    line-height: 1.6;
}

.about-content p {
    margin-bottom: 0.75rem;
    color: var(--text-muted);
}

.about-content h4 {
    margin: 1rem 0 0.5rem;
    color: var(--text-main);
}

.about-content ul {
    margin-left: 1.5rem;
    color: var(--text-muted);
}

.about-content li {
    margin-bottom: 0.25rem;
}

.about-content .credits {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: center;
}

.about-content .credits a {
    color: var(--primary);
    text-decoration: none;
}

.about-content .credits a:hover {
    text-decoration: underline;
}

/* FAQ Content */
.faq-modal {
    max-width: 550px;
}

.faq-content {
    max-height: 350px;
    overflow-y: auto;
}

.faq-content details {
    margin-bottom: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    overflow: hidden;
}

.faq-content summary {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-main);
    list-style: none;
}

.faq-content summary::-webkit-details-marker {
    display: none;
}

.faq-content summary::before {
    content: '▶ ';
    font-size: 0.7rem;
    margin-right: 0.5rem;
    transition: transform 0.2s;
    display: inline-block;
}

.faq-content details[open] summary::before {
    transform: rotate(90deg);
}

.faq-content details p {
    padding: 0 1rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}