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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    overflow: hidden;
    height: 100vh;
}

.app {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#canvas {
    display: block;
    background: white;
    cursor: crosshair;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.3);
}

#canvas.panning {
    cursor: grab;
}

#canvas.panning:active {
    cursor: grabbing;
}

#canvas.erasing {
    cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m7 21-4.3-4.3c-1-1-1-2.6 0-3.6l9.6-9.6c1-1 2.6-1 3.6 0l4.3 4.3c1 1 1 2.6 0 3.6l-9.6 9.6c-1 1-2.6 1-3.6 0z"/><path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"/><path d="M9 7 4 12l4 4m2-8 4-4 4 4"/></svg>') 12 12, crosshair;
}

.tool-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.tool-group label {
    font-weight: 600;
    color: #eee;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

input[type="range"] {
    flex-grow: 1;
    height: 8px;
    border-radius: 4px;
    background: #444;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #a29bfe;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #a29bfe;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

input[type="color"] {
    width: 100%;
    height: 40px;
    border: 2px solid #555;
    border-radius: 8px;
    cursor: pointer;
    padding: 0;
}

#brushSizeValue {
    font-weight: 600;
    color: #a29bfe;
    background-color: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 6px;
    text-align: center;
    font-size: 14px;
    width: 60px;
    padding: 4px;
    -moz-appearance: textfield; /* Hide arrows in Firefox */
}

#brushSizeValue::-webkit-outer-spin-button,
#brushSizeValue::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

button {
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    background: #4a5568;
    color: white;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

button:hover {
    background: #6a7384;
    transform: translateY(-1px);
}

button.active {
    background: #a29bfe;
    color: #1a202c;
    box-shadow: 0 4px 12px rgba(162, 155, 254, 0.4);
}

.button-group {
    display: flex;
    gap: 8px;
}

.button-group button {
    flex: 1;
}

.special-tools {
    display: flex;
    gap: 8px;
    justify-content: space-between;
}

.special-tools button {
    flex: 1;
}

.pixel-tool {
    background: #4a5568;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 600;
}

.pixel-tool:hover {
    background: linear-gradient(135deg, #9b59b6 0%, #8e44ad 100%);
    transform: translateY(-1px);
}

.pixel-tool.active {
    background: #2ecc71;
    color: white;
}

.eraser-tool {
    background: #4a5568;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 600;
}

.eraser-tool:hover {
    background: #e74c3c;
    transform: translateY(-1px);
}

.eraser-tool.active {
    background: linear-gradient(135deg, #8e44ad 0%, #732d91 100%);
    box-shadow: 0 4px 12px rgba(142, 68, 173, 0.4);
}

#clearBtn {
    background-color: #e74c3c;
    width: 100%;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
}

.modal {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
    display: none;
}

.modal.active {
    transform: translateY(0);
    opacity: 1;
    display: block;
}

.modal h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 24px;
}

.modal-content {
    text-align: left;
    margin-bottom: 25px;
}

.modal-content p {
    margin-bottom: 12px;
    color: #555;
    line-height: 1.5;
}

.modal-content a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.modal-content a:hover {
    text-decoration: underline;
}

.modal-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    padding: 15px 30px;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.artist-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    pointer-events: none;
    z-index: 2000;
    opacity: 0;
    transform: translateY(5px);
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.artist-tooltip #artistAvatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
}

.artist-tooltip.visible {
    opacity: 1;
    transform: translateY(0);
}

.rainbow-color {
    background: linear-gradient(45deg, #ff0000, #ff8000, #ffff00, #80ff00, #00ff00, #00ff80, #00ffff, #0080ff, #0000ff, #8000ff, #ff00ff, #ff0080);
    background-size: 400% 400%;
    animation: rainbow 2s ease infinite;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

@keyframes rainbow {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.ui-container {
    position: fixed;
    top: 20px;
    left: 20px;
    bottom: 20px;
    z-index: 1000;
    display: flex;
    gap: 10px;
    transition: transform 0.4s ease-in-out, opacity 0.3s ease-in-out;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(45, 55, 72, 0.8);
    backdrop-filter: blur(10px);
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.sidebar-btn {
    width: 48px;
    height: 48px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 2px solid transparent;
}
.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
.sidebar-btn.active {
    background: #a29bfe;
    color: #1a202c;
    border-color: rgba(255,255,255,0.5);
}

.toggle-switch {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-switch span {
    font-size: 14px;
    font-weight: 500;
    color: #cbd5e0;
}

.toggle-switch input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch .slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background-color: #4a5568;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.toggle-switch .slider:before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle-switch input:checked + .slider {
    background-color: #2ecc71;
}

.toggle-switch input:checked + .slider:before {
    transform: translateX(20px);
}

.main-panel {
    background: rgba(45, 55, 72, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    width: 280px;
    padding: 20px;
    color: #f7fafc;
    overflow-y: auto;
    position: relative;
    overflow-x: hidden;
}

.panel {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    opacity: 0;
    transform: translateX(20px);
    pointer-events: none;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
}
.panel.active {
    position: static;
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.1s;
}

.panel h3 {
    margin: 0 0 25px 0;
    color: #f7fafc;
    font-size: 20px;
    border-bottom: 2px solid #718096;
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.credits-info {
    background: rgba(0,0,0,0.2);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
}

.credits-info p {
    margin: 0;
    font-weight: 600;
    font-size: 16px;
    color: #f7fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.shop-item {
    border: 2px solid #718096;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    transition: all 0.2s ease;
}

.shop-item:hover {
    border-color: #f39c12;
    transform: translateY(-2px);
}

.shop-item.owned {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
}

.item-info h4 {
    margin: 0 0 8px 0;
    color: #f7fafc;
    font-size: 16px;
}

.item-info p {
    margin: 0 0 10px 0;
    color: #a0aec0;
    font-size: 14px;
    line-height: 1.4;
}

.item-price {
    font-weight: 700;
    color: #f39c12;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.buy-btn {
    width: 100%;
    background: #f39c12;
    color: white;
    border: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s ease;
}

.buy-btn:hover {
    background: #e67e22;
}

.buy-btn:disabled {
    background: #718096;
    cursor: not-allowed;
}

.buy-btn.owned {
    background: #27ae60;
    cursor: default;
}

.layer-controls {
    display: flex;
    flex-wrap: wrap; 
    gap: 5px;
}

.layer-controls button {
    flex: 0 1 calc(20% - 4px); 
    min-width: 40px;
    padding: 8px;
    font-size: 14px;
    text-align: center;
}

.danger-btn {
    background-color: #e74c3c;
    width: 100%;
}

.danger-btn:hover {
    background-color: #c0392b;
}

.admin-command {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.admin-command:last-child {
    margin-bottom: 0;
}

.admin-command label {
    font-weight: 600;
    color: #eee;
    font-size: 14px;
}

.admin-command input,
.admin-command select {
    padding: 8px 12px;
    border: 2px solid #718096;
    background: #2d3748;
    color: white;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 1em;
}

.admin-command input:focus,
.admin-command select:focus {
    border-color: #a29bfe;
}

.admin-command button {
    background: #e74c3c;
    padding: 10px 16px;
    font-size: 13px;
    margin-top: 5px;
}

.admin-command button:hover {
    background: #c0392b;
}

.drawing-effect {
    background: #4a5568;
    color: white;
}

.drawing-effect.active {
    background: #2ecc71;
}

.admin-context-menu {
    position: fixed;
    display: none;
    background: rgba(45, 55, 72, 0.9);
    color: white;
    border: 1px solid #718096;
    border-radius: 8px;
    padding: 10px;
    z-index: 3000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    backdrop-filter: blur(5px);
    flex-direction: column;
    gap: 8px;
}
.admin-context-menu.visible {
    display: flex;
}

.admin-context-menu #contextArtInfo {
    font-size: 14px;
    font-weight: 500;
    color: #cbd5e0;
    text-align: center;
}

.admin-context-menu button {
    width: 100%;
    background: #e74c3c;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.admin-context-menu button:hover {
    background: #c0392b;
}

#collapse-ui-btn {
    margin-top: auto;
}

.expand-ui-btn {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 999;
    width: 48px;
    height: 48px;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(45, 55, 72, 0.8);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    border: 2px solid rgba(255,255,255,0.5);
    opacity: 0;
    pointer-events: none;
    transform: translateX(-20px);
    transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out;
    transition-delay: 0.1s;
}

.ui-container.collapsed {
    transform: translateX(-110%);
    opacity: 0;
    pointer-events: none;
}

.ui-container.collapsed + .expand-ui-btn {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #1a202c;
    z-index: 20000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2em;
    transition: opacity 0.5s ease;
}

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

.spinner {
    border: 8px solid rgba(255, 255, 255, 0.3);
    border-top: 8px solid #a29bfe;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .ui-container {
        top: 0;
        left: 0;
        right: 0;
        bottom: auto;
        flex-direction: column;
        background: rgba(45, 55, 72, 0.9);
        backdrop-filter: blur(10px);
        border-radius: 0;
        gap: 0;
        padding: 5px;
    }

    .sidebar {
        flex-direction: row;
        justify-content: center;
        border-radius: 0;
        padding: 5px;
        background: transparent;
        box-shadow: none;
        backdrop-filter: none;
    }

    .main-panel {
        width: auto;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
        max-height: 50vh;
        padding: 10px 15px;
        overflow-x: visible;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        opacity: 0;
        transition: max-height 0.4s ease-out, padding 0.4s ease-out, opacity 0.3s ease-out;
    }
    .main-panel.active {
        max-height: 50vh;
        opacity: 1;
        padding-top: 10px;
        padding-bottom: 15px;
    }

    .sidebar-btn {
        width: 44px;
        height: 44px;
    }
}