:root {
    --bg-dark: #0f172a;
    --panel-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(16, 185, 129, 0.15) 0px, transparent 50%);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    height: 100vh;
    max-height: 100vh;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-header {
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px;
}

.logo h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    display: inline-block;
}

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

.badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    vertical-align: top;
    margin-left: 8px;
    font-weight: bold;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.credits {
    font-size: 0.9rem;
    color: #fcd34d;
    font-weight: 600;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #a855f7);
}

/* Main Layout */
.main-content {
    display: flex;
    gap: 20px;
    flex: 1;
    min-height: 0; /* Important for flex children to shrink */
}

.canvas-panel {
    flex: 1;
    padding: 15px;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.canvas-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
}

.canvas-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 1/1;
    margin: 0 auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

#canvas-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    transition: transform 0.05s ease-out; /* Fast transition for smooth zoom */
}

#canvas-wrapper canvas {
    position: absolute;
    top: 0;
    left: 0;
}

#grid-canvas {
    cursor: crosshair;
}

/* Right Panel */
.tools-panel {
    width: 320px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 5px; /* for scrollbar */
}

.tool-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.flex-grow {
    flex: 1;
}

.tool-section h3 {
    font-size: 0.95rem;
    font-family: 'Outfit', sans-serif;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 4px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', sans-serif;
}

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

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.glow-effect {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
    padding: 10px;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 5px;
}
.glow-effect:hover {
    box-shadow: 0 0 25px rgba(59, 130, 246, 0.6);
}
.glow-effect:disabled {
    background: #475569;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* Brush Tools */
.brush-group {
    display: flex;
    gap: 8px;
}

.tool-btn {
    flex: 1;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 8px 0px;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

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

.tool-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.8);
    transform: scale(1.1);
    z-index: 10;
}

.color-swatch {
    width: 18px;
    height: 18px;
    border-radius: 4px;
}

.checkerboard {
    background-image: linear-gradient(45deg, #ccc 25%, transparent 25%), 
                      linear-gradient(-45deg, #ccc 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #ccc 75%), 
                      linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 8px 8px;
    background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
    background-color: #eee;
}

/* Console */
#console-box {
    background: #0f172a;
    font-family: monospace;
    font-size: 0.8rem;
    padding: 10px;
    height: 120px;
    overflow-y: auto;
    overflow-x: hidden;
    word-wrap: break-word;
    word-break: break-all;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.1);
    color: #a7f3d0;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s;
}

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

.modal-content {
    width: 90%;
    max-width: 500px;
    padding: 30px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.success-text {
    color: var(--success);
    font-family: 'Outfit', sans-serif;
}

.result-data {
    background: rgba(0, 0, 0, 0.5);
    padding: 20px;
    border-radius: 8px;
    font-size: 1.2rem;
    word-break: break-all;
    border: 1px solid rgba(255,255,255,0.1);
}

.hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 8px;
}
