:root {
    /* Theme Colors */
    --bg-main: #0a1419;
    --bg-panel: #11222a;
    --bg-darker: #050a0d;
    --primary: #00cec9;
    --secondary: #81ecec;
    --accent: #fdcb6e;
    --text-primary: #ffffff;
    --text-muted: #8b9eb0;
    --success: #00b894;
    --error: #d63031;
    --border-color: rgba(129, 236, 236, 0.2);
    --radius: 12px;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 30px;
    background: var(--bg-panel);
    border-bottom: 2px solid var(--border-color);
}

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo .accent {
    color: var(--primary);
}

.level-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.level-indicator {
    text-align: center;
    min-width: 150px;
}

#current-level {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

#level-title {
    display: block;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--accent);
}

.icon-btn, .action-btn, .menu-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s ease;
}

.icon-btn {
    color: var(--primary);
    font-size: 1.2rem;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(0, 206, 201, 0.1);
}

.icon-btn:hover:not(:disabled) {
    background: rgba(0, 206, 201, 0.2);
}

.icon-btn:disabled {
    color: var(--text-muted);
    background: transparent;
    cursor: not-allowed;
}

.menu-btn {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.action-btn {
    padding: 8px 20px;
    border-radius: 8px;
    font-weight: 600;
    color: #fff;
}

.action-btn.outline {
    border: 1px solid var(--primary);
    color: var(--primary);
}

.action-btn.outline:hover {
    background: rgba(0, 206, 201, 0.1);
}

/* Workspace */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
    padding: 20px;
    gap: 20px;
}

@media (max-width: 768px) {
    .workspace {
        flex-direction: column-reverse;
        overflow-y: auto;
    }
}

.panel {
    background: var(--bg-panel);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.editor-panel {
    flex: 1;
    max-width: 450px;
}

.views-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.view-box {
    flex: 1;
    background: var(--bg-panel);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.panel-header {
    background: rgba(0,0,0,0.2);
    padding: 12px 20px;
    border-radius: var(--radius) var(--radius) 0 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--secondary);
}

.tag {
    background: rgba(0, 206, 201, 0.2);
    color: var(--primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'Fira Code', monospace;
    font-size: 0.8rem;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    background: rgba(255,255,255,0.1);
}

.status-badge.success {
    background: rgba(0, 184, 148, 0.2);
    color: var(--success);
}
.status-badge.error {
    background: rgba(214, 48, 49, 0.2);
    color: var(--error);
}

/* Code Editor */
.code-area {
    flex: 1;
    padding: 20px;
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    background: var(--bg-darker);
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex;
    flex-direction: column;
}

.code-mockup {
    color: #ce9178;
}

.html-context {
    color: var(--text-muted);
    opacity: 0.5;
}

.indent {
    padding-left: 20px;
}

#css-input {
    width: 100%;
    min-height: 150px;
    background: transparent;
    border: none;
    color: var(--accent);
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.5;
    padding-left: 20px;
    resize: vertical;
    outline: none;
    flex: 1;
}

#css-input::placeholder {
    color: rgba(253, 203, 110, 0.3);
}

/* Grid Visuals */
.grid-wrapper {
    flex: 1;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-darker);
    border-radius: 0 0 var(--radius) var(--radius);
    position: relative;
    /* subtle grid background pattern */
    background-image: linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
                      linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center center;
}

.grid-container {
    width: 100%;
    height: 100%;
    max-width: 600px;
    max-height: 300px;
    display: grid; /* default */
    background: rgba(0, 206, 201, 0.05);
    border: 2px dashed rgba(0, 206, 201, 0.3);
    border-radius: 8px;
    transition: all 0.3s;
}

/* Individual Grid Items */
.grid-item {
    background: linear-gradient(135deg, var(--primary), #0984e3);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 1.5rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

/* Target View Variations */
#target-grid .grid-item {
    background: transparent;
    border: 2px solid var(--secondary);
    color: var(--secondary);
    box-shadow: none;
}

/* Modals */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(10, 20, 25, 0.85);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 1;
    transition: opacity 0.3s;
}

.modal.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.level-grid {
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
    gap: 15px;
    overflow-y: auto;
}

.level-box {
    aspect-ratio: 1;
    background: var(--bg-darker);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.level-box.completed {
    background: rgba(0, 184, 148, 0.2);
    border-color: var(--success);
    color: var(--success);
}

.level-box.locked {
    opacity: 0.3;
    cursor: not-allowed;
}

.level-box:hover:not(.locked) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 206, 201, 0.2);
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    text-align: right;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--primary);
    color: #000;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0, 206, 201, 0.4);
    transition: all 0.3s;
    z-index: 1000;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

/* Confetti */
#confetti-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    pointer-events: none;
    z-index: 99;
}
