:root {
    --screen-size-warning-width: 550px;

    --primary-color: #2196F3;
    --error-color: #f44336;
    --success-color: #4CAF50;
    --warning-color: #ff9800;

    --primary-text: color-mix(in srgb, var(--primary-color) 88%, white);
    --primary-btn-bg: color-mix(in srgb, var(--primary-color) 12%, transparent);
    --primary-btn-border: solid 1px color-mix(in srgb, var(--primary-color) 32%, transparent);
    --primary-btn-bg-hover: color-mix(in srgb, var(--primary-color) 32%, transparent);

    --error-text: color-mix(in srgb, var(--error-color) 88%, white);
    --error-btn-bg: color-mix(in srgb, var(--error-color) 12%, transparent);
    --error-btn-border: solid 1px color-mix(in srgb, var(--error-color) 32%, transparent);
    --error-btn-bg-hover: color-mix(in srgb, var(--error-color) 32%, transparent);

}

.button {
    background: var(--primary-btn-bg);
    color: var(--primary-text);
    border: var(--primary-btn-border);
    cursor: pointer;
    font-size: 12px;
    text-align: center;
    padding: 8px;
    border-radius: 4px;
}
.button:hover {
    background: var(--primary-btn-bg-hover);
}

.negative-button {
    background: var(--error-btn-bg);
    color: var(--error-text);
    border: var(--error-btn-border);
}
.negative-button:hover {
    background: var(--error-btn-bg-hover);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1a1a1a;
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
}

.header {
    background: #2d2d2d;
    padding: 12px 20px;
    border-bottom: 1px solid #404040;
    text-align: center;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.main-container {
    display: flex;
    height: calc(100vh);
}

.sidebar {
    width: 200px;
    background: #252525;
    border-right: 1px solid #404040;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 20px 0;
}

.sidebar > div {
    padding: 0 20px;
}

.sidebar h3 {
    margin-bottom: 16px;
    font-size: 16px;
    color: #e0e0e0;
}

.canvas-container {
    flex: 1;
    background: #808080;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.controls {
    width: 200px;
    background: #252525;
    border-left: 1px solid #404040;
    padding: 20px;
    overflow-y: auto;
}

.sprite-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.sprite-gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: min-content;
    gap: 4px;
    margin-bottom: 16px;
    height: 150px;
    max-height: 150px;
    overflow-y: auto;
    padding-right: 4px;
}

.sprite-gallery::-webkit-scrollbar {
    width: 6px;
}

.sprite-gallery::-webkit-scrollbar-track {
    background: #333;
    border-radius: 3px;
}

.sprite-gallery::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.sprite-gallery::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.sprite-item {
    position: relative;
    aspect-ratio: 1;
    background: #333;
    border: 2px solid #444;
    border-radius: 4px;
    cursor: pointer;
    overflow: hidden;
}

.sprite-item:hover {
    border-color: #666;
}

.sprite-item.empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #666;
    border-style: dashed;
}

.sprite-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sprite-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0, 0, 0, 0.7);
    color: var(--error-color);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sprite-upload {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* .upload-button, .capture-button {
    background: var(--primary-btn-bg);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
} */

/* .capture-button {
    background: #2196F3;
} */

/* .upload-button:hover {
    background: color-mix(in srgb, var(--primary-color) 88%, black);
} */

/* .capture-button:hover {
    background: color-mix(in srgb, var(--primary-color) 88%, black);
} */

.control-group {
    margin-bottom: 24px;
}

.control-group h4 {
    margin-bottom: 12px;
    font-size: 14px;
    color: #e0e0e0;
}

.slider-container {
    margin-bottom: 12px;
}

.slider-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 12px;
    color: #ccc;
}

.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #444;
    outline: none;
    -webkit-appearance: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--primary-color);
    cursor: pointer;
    border: none;
}

.checkbox-container {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.checkbox-container input[type="checkbox"] {
    accent-color: var(--primary-color);
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.radio-container input[type="radio"] {
    accent-color: var(--primary-color);
}

.canvas {
    max-width: 100%;
    max-height: 100%;
    background: #808080; /* Default solid background */
    border: 1px solid #444;
    display: block;
    margin: auto;
}

.status-bar {
    background: #2d2d2d;
    padding: 8px 20px;
    border-top: 1px solid #404040;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #ccc;
}

.webcam-preview {
    /* position: absolute;
    bottom: 0;
    right: 0; */
    /* transform: translate(-50%, -50%); */
    max-width: 100%;
    /* max-height: 20%; */
    border: 2px solid #444;
    border-radius: 8px;
}

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

.drop-zone {
    width: 100%;
    min-height: 80px;
    color: #BBB;
    background: #333333;
    border: 2px dashed #444;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
    font-size: 13px;
    cursor: pointer;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.drop-zone:hover {
    border-color: #666;
}

.drop-zone.active {
    background: color-mix(in srgb, var(--primary-color) 24%, transparent);
    border-color: var(--primary-color);
    transform: scale(1.02);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.drop-zone-icon {
    font-size: 24px;
    opacity: 0.7;
}

.drop-zone-text {
    font-weight: 500;
}

.drop-zone-subtext {
    font-size: 11px;
    opacity: 0.7;
}

.drop-zone-preview {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 6px;
    overflow: visible;
    border: 2px solid #444;
    background: rgba(0, 0, 0, 0.3);
    display: none;
    margin-top: 4px;
}

.drop-zone-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.drop-zone-preview.show {
    display: block;
}

.drop-zone-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.performance {
    font-size: 11px;
    color: #999;
}

.error-message {
    background: var(--error-color);
    color: white;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 12px;
}

.success-message {
    background: var(--primary-color);
    color: white;
    padding: 12px;
    border-radius: 4px;
    margin-bottom: 16px;
    font-size: 12px;
}

.hidden {
    display: none !important;
}

.number-input {
    background: #333;
    border: 1px solid #555;
    color: #fff;
    padding: 4px 8px;
    border-radius: 3px;
    width: 60px;
    font-size: 12px;
}

.text-input {
    background: #333;
    border: 1px solid #555;
    color: #fff;
    padding: 8px 12px;
    border-radius: 4px;
    width: 100%;
    font-size: 14px;
    margin-bottom: 8px;
}

.text-sprite-input {
    margin-bottom: 16px;
    position: relative;
}

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

.input-with-button .text-input {
    flex: 1;
    margin-bottom: 0;
}

/* .emoji-picker-btn {
    background: var(--primary-color);
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 16px;
    cursor: pointer;
    color: white;
    min-width: 44px;
} */

/* .emoji-picker-btn:hover {
    background: color-mix(in srgb, var(--primary-color) 85%, black);;
} */

.emoji-picker {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #333;
    border: 1px solid #555;
    border-radius: 4px;
    z-index: 1000;
    max-height: 250px;
    overflow: hidden;
    margin-top: 4px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.emoji-category-header {
    grid-column: 1 / -1;
    font-size: 12px;
    font-weight: bold;
    color: var(--primary-color);
    padding: 8px 4px 4px 4px;
    margin-top: 4px;
    border-top: 1px solid #555;
    text-align: left;
}

.emoji-category-header:first-child {
    margin-top: 0;
    border-top: none;
}

.emoji-item {
    padding: 4px;
    font-size: 18px;
    cursor: pointer;
    text-align: center;
    border-radius: 3px;
    transition: background 0.2s;
}

.emoji-item:hover {
    background: var(--primary-color);
}

.color-picker {
    width: 100%;
    height: 40px;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
}

.reset-button {
    /* background: var(--error-color);
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px; */
    margin-bottom: 12px;
}

/* .reset-button:hover {
    background: color-mix(in srgb, var(--error-color) 88%, black);
} */

.webcam-controls {
    padding: 16px 20px;
    border-bottom: 1px solid #404040;
}

.webcam-select {
    width: 100%;
    background: #333;
    border: 1px solid #555;
    color: #fff;
    padding: 6px;
    border-radius: 3px;
    font-size: 12px;
    margin-bottom: 8px;
}

.webcam-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.camera-permission-status {
    margin-top: 8px;
    padding: 8px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.3;
}

.camera-permission-status.info {
    background: rgba(33, 150, 243, 0.1);
    border: 1px solid rgba(33, 150, 243, 0.3);
    color: #64b5f6;
}

.camera-permission-status.requesting {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.3);
    color: #ffb74d;
}

.camera-permission-status.error {
    background: rgba(244, 67, 54, 0.1);
    border: 1px solid rgba(244, 67, 54, 0.3);
    color: #e57373;
}

.permission-message {
    margin-bottom: 6px;
}

/* .permission-retry-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    font-size: 10px;
    cursor: pointer;
    transition: background 0.2s;
} */

/* .permission-retry-btn:hover {
    background: color-mix(in srgb, var(--primary-color) 85%, black);
} */

.permission-spinner {
    width: 12px;
    height: 12px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 4px auto 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mobile Warning Overlay */
.mobile-warning {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

@media (max-width: 999px) {
    .mobile-warning {
        display: flex !important;
    }
    
    .mobile-warning.dismissed {
        display: none !important;
    }
}

.mobile-warning-content {
    background: #2d2d2d;
    border-radius: 12px;
    padding: 30px;
    max-width: 400px;
    text-align: center;
    border: 2px solid #444;
}

.mobile-warning-content h2 {
    color: #ffb74d;
    margin-bottom: 20px;
    font-size: 20px;
}

.mobile-warning-content p {
    color: #e0e0e0;
    margin-bottom: 15px;
    line-height: 1.5;
}

.mobile-warning-content ul {
    text-align: left;
    color: #e0e0e0;
    margin: 15px 0;
    padding-left: 20px;
}

.mobile-warning-content li {
    margin-bottom: 8px;
    line-height: 1.4;
}

.continue-mobile-btn {
    /* background: var(--primary-color);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer; */
    margin-top: 20px;
    /* transition: background 0.2s; */
}

/* .continue-mobile-btn:hover {
    background: color-mix(in srgb, var(--primary-color) 85%, black);
} */

.github-links {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}


.capture-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.capture-modal.active {
    display: flex;
}

.capture-content {
    background: #2d2d2d;
    border-radius: 8px;
    padding: 20px;
    max-width: 90vw;
    max-height: 90vh;
    text-align: center;
}

.capture-preview {
    max-width: 100%;
    max-height: 60vh;
    border: 2px solid #444;
    border-radius: 4px;
    margin-bottom: 16px;
}

.countdown {
    font-size: 48px;
    font-weight: bold;
    color: var(--error-color);
    margin: 20px 0;
}

.capture-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 16px;
}

/* .capture-controls button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
} */

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

/* .cancel-btn {
    background: #666;
    color: white;
} */

.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    color: white;
    z-index: 1001;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast.error {
    background: var(--error-color);
}

.toast.success {
    background: var(--primary-color);
}

.toast.warning {
    background: var(--warning-color);
}