* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
}

/* Header with wrapped images */
.page-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 10px;
}

.page-header h1 {
    margin: 0;
    color: #00d4ff;
    text-align: center;
}

.page-description {
    text-align: center;
    color: #aaa;
    max-width: 700px;
    margin: 0 auto 25px;
    line-height: 1.5;
    font-size: 15px;
}

.walker-avatar {
    flex-shrink: 0;
}

.walker-avatar-left {
    width: 100px;
    height: auto;
}

.walker-avatar-right {
    width: 60px;
    height: auto;
}

.controls {
    background: #16213e;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.control-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.control-row:last-child {
    margin-bottom: 0;
}

label {
    font-weight: 500;
    min-width: 120px;
}

input[type="file"] {
    flex: 1;
    min-width: 200px;
}

input[type="number"],
input[type="range"] {
    padding: 8px 12px;
    border: 1px solid #0f3460;
    border-radius: 6px;
    background: #0f3460;
    color: #fff;
    font-size: 14px;
}

input[type="number"] {
    width: 80px;
}

input[type="range"] {
    flex: 1;
    min-width: 150px;
    cursor: pointer;
}

.value-display {
    min-width: 60px;
    text-align: right;
    color: #00d4ff;
    font-weight: bold;
}

button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #00d4ff;
    color: #1a1a2e;
}

.btn-primary:hover {
    background: #00b8e6;
}

.btn-secondary {
    background: #e94560;
    color: #fff;
}

.btn-secondary:hover {
    background: #d63d56;
}

.btn-group {
    display: flex;
    gap: 10px;
}

.preview-section {
    background: #16213e;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.preview-section h2 {
    margin-top: 0;
    color: #00d4ff;
    font-size: 18px;
}

.preview-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 200px;
    background: repeating-conic-gradient(#333 0% 25%, #444 0% 50%) 50% / 20px 20px;
    border-radius: 8px;
    padding: 20px;
    position: relative;
    overflow: auto;
}

#spriteCanvas,
#builderCanvas {
    max-width: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.frame-info {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.sprite-strip {
    background: #16213e;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.sprite-strip h2 {
    margin-top: 0;
    color: #00d4ff;
    font-size: 18px;
}

.strip-container {
    overflow-x: auto;
    background: repeating-conic-gradient(#333 0% 25%, #444 0% 50%) 50% / 20px 20px;
    border-radius: 8px;
    padding: 10px;
}

.strip-frames {
    display: flex;
    gap: 2px;
}

.strip-frame {
    border: 2px solid transparent;
    cursor: pointer;
    transition: border-color 0.2s;
    flex-shrink: 0;
}

.strip-frame:hover {
    border-color: #00d4ff;
}

.strip-frame.active {
    border-color: #e94560;
}

.strip-frame canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.info-panel {
    background: #16213e;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 14px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.info-item {
    display: flex;
    justify-content: space-between;
}

.info-label {
    color: #888;
}

.info-value {
    color: #00d4ff;
    font-weight: bold;
}

.drop-zone {
    border: 3px dashed #0f3460;
    border-radius: 12px;
    padding: 4px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: #00d4ff;
    background: rgba(0, 212, 255, 0.1);
}

.drop-zone p {
    margin: 0;
    color: #888;
}

.drop-zone .icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.hidden {
    display: none !important;
}

.scale-preview {
    display: flex;
    align-items: center;
    gap: 10px;
}

#scaleInput {
    width: 60px;
}

/* Mode Toggle */
.mode-toggle {
    display: flex;
    justify-content: center;
    gap: 0;
    margin-bottom: 20px;
}

.mode-btn {
    padding: 12px 30px;
    border: 2px solid #0f3460;
    background: #16213e;
    color: #888;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mode-btn:first-child {
    border-radius: 8px 0 0 8px;
}

.mode-btn:last-child {
    border-radius: 0 8px 8px 0;
}

.mode-btn.active {
    background: #00d4ff;
    border-color: #00d4ff;
    color: #1a1a2e;
}

.mode-btn:not(.active):hover {
    border-color: #00d4ff;
    color: #00d4ff;
}

/* Builder Mode Styles */
.builder-sprites {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
    min-height: 100px;
    padding: 15px;
    background: repeating-conic-gradient(#333 0% 25%, #444 0% 50%) 50% / 20px 20px;
    border-radius: 8px;
}

.builder-sprite-item {
    position: relative;
    background: #16213e;
    border: 2px solid #0f3460;
    border-radius: 8px;
    padding: 5px;
    cursor: grab;
    transition: all 0.2s;
}

.builder-sprite-item:hover {
    border-color: #00d4ff;
}

.builder-sprite-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.builder-sprite-item canvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.builder-sprite-item .sprite-number {
    position: absolute;
    top: -8px;
    left: -8px;
    background: #00d4ff;
    color: #1a1a2e;
    font-size: 11px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.builder-sprite-item .remove-btn {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #e94560;
    color: #fff;
    font-size: 12px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
}

.builder-sprite-item:hover .remove-btn {
    opacity: 1;
}

.builder-empty-state {
    width: 100%;
    text-align: center;
    color: #666;
    padding: 20px;
}

.builder-controls {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.builder-info {
    margin-top: 15px;
    padding: 10px 15px;
    background: #0f3460;
    border-radius: 8px;
    font-size: 13px;
    color: #aaa;
}

.builder-info strong {
    color: #00d4ff;
}
