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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    background: #1a1a1a;
    color: #ffffff;
}

#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: #2d2d2d;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    gap: 12px;
    z-index: 1000;
    border-bottom: 1px solid #1a1a1a;
    overflow-x: auto;
    overflow-y: hidden;
}

#toolbar::-webkit-scrollbar {
    height: 4px;
}

#toolbar::-webkit-scrollbar-track {
    background: #1a1a1a;
}

#toolbar::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 2px;
}

#toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

#toolbar-left label {
    font-size: 12px;
    color: #aaa;
    margin: 0;
    white-space: nowrap;
}

#toolbar-left select {
    padding: 6px 10px;
    background: #4a4a4a;
    color: white;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: border-color 0.2s ease;
}

#toolbar-left select:hover {
    border-color: #5a5a5a;
}

#toolbar-left select:focus {
    outline: none;
    border-color: #007acc;
}

#toolbar-title {
    font-size: 24px;
    font-weight: 600;
    white-space: nowrap;
    margin-left: auto;
    flex-shrink: 0;
}

button {
    padding: 8px 16px;
    background: #4a4a4a;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease, transform 0.1s ease;
    white-space: nowrap;
}

button:hover {
    background: #5a5a5a;
}

button:active {
    transform: scale(0.98);
}

button.active {
    background: #007acc;
}

button.active:hover {
    background: #0088dd;
}

#canvas-container {
    position: fixed;
    top: 50px;
    left: 0;
    right: 200px;
    bottom: 120px;
    overflow: hidden;
    background: #1a1a1a;
}

#metadata-panel {
    position: fixed;
    top: 50px;
    right: 0;
    width: 200px;
    bottom: 120px;
    background: #2d2d2d;
    border-left: 1px solid #1a1a1a;
    padding: 16px;
    overflow-y: auto;
    z-index: 100;
}

#metadata-panel h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 16px;
    color: #cccccc;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metadata-item {
    margin-bottom: 12px;
}

.metadata-item label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: #888;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metadata-item div {
    font-size: 13px;
    color: #ffffff;
    word-wrap: break-word;
    line-height: 1.4;
}

.metadata-item input,
.metadata-item textarea {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: white;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
}

.metadata-item input:focus,
.metadata-item textarea:focus {
    outline: none;
    border-color: #007acc;
}

.metadata-item textarea {
    resize: vertical;
    min-height: 60px;
}

.metadata-item select {
    width: 100%;
    padding: 8px;
    margin-top: 4px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: white;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
}

.metadata-item select:focus {
    outline: none;
    border-color: #007acc;
}

.metadata-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 2px solid #555;
    border-radius: 3px;
    background-color: #1a1a1a;
    position: relative;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.metadata-item input[type="checkbox"]:hover {
    border-color: #666;
}

.metadata-item input[type="checkbox"]:checked {
    background-color: #007acc;
    border-color: #007acc;
}

.metadata-item input[type="checkbox"]:checked::before {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
    line-height: 1;
}

#metadata-panel::-webkit-scrollbar {
    width: 6px;
}

#metadata-panel::-webkit-scrollbar-track {
    background: #1a1a1a;
}

#metadata-panel::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 3px;
}

#metadata-panel::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    cursor: crosshair;
}

input[type="file"] {
    display: none;
}

#tile-selector-container {
    position: fixed;
    bottom: 30px;
    left: 0;
    right: 0;
    background: #2d2d2d;
    border-top: 1px solid #1a1a1a;
}

#copyright-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: #1a1a1a;
    border-top: 1px solid #2d2d2d;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    z-index: 1000;
}

#copyright-text {
    font-size: 14px;
    color: #aaa;
    text-align: center;
}

#tile-search {
    width: 100%;
    padding: 8px 12px;
    background: #1a1a1a;
    border: none;
    border-bottom: 1px solid #1a1a1a;
    color: white;
    font-size: 14px;
    font-family: inherit;
}

#tile-search:focus {
    outline: none;
    background: #222;
}

#tile-search::placeholder {
    color: #666;
}

#tile-selector {
    height: 90px;
    padding: 12px;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
}

#tile-selector::-webkit-scrollbar {
    height: 6px;
}

#tile-selector::-webkit-scrollbar-track {
    background: #1a1a1a;
}

#tile-selector::-webkit-scrollbar-thumb {
    background: #4a4a4a;
    border-radius: 3px;
}

#tile-selector::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

.tile-preview {
    width: 64px;
    height: 64px;
    border: 2px solid #555;
    cursor: pointer;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    flex-shrink: 0;
    border-radius: 4px;
    transition: border-color 0.2s ease, transform 0.1s ease;
    background-color: #3a3a3a;
}

.tile-preview:hover {
    transform: scale(1.05);
    border-color: #666;
}

.tile-preview.selected {
    border-color: #007acc;
    border-width: 3px;
}

.tile-preview.selected:hover {
    border-color: #0088dd;
}

#modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}

#modal.active {
    display: flex;
}

#modal-content {
    background: #2d2d2d;
    padding: 24px;
    border-radius: 8px;
    min-width: 320px;
    max-width: 90vw;
    color: white;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid #3a3a3a;
}

#modal-content h2 {
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
}

#modal-content label {
    display: block;
    margin: 0 0 6px 0;
    font-size: 14px;
    font-weight: 500;
    color: #cccccc;
}

#modal-content input,
#modal-content input[type="text"],
#modal-content input[type="number"],
#modal-content textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 16px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: textfield;
}

#modal-content input[type="number"]::-webkit-inner-spin-button,
#modal-content input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#modal-content input:focus,
#modal-content textarea:focus {
    outline: none;
    border-color: #007acc;
}

#modal-content textarea {
    resize: vertical;
    min-height: 60px;
}

#modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

#modal-buttons button {
    flex: 1;
}

#modal-buttons #modal-cancel {
    background: #3a3a3a;
}

#modal-buttons #modal-cancel:hover {
    background: #4a4a4a;
}