/* Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-color: #000000;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent-color: #3b82f6;
    --panel-bg: rgba(255, 255, 255, 0.05);
    --header-bg: rgba(0, 0, 0, 0.75);
    --border-color: rgba(255, 255, 255, 0.1);
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Times New Roman', Times, serif;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

.customizer-container {
    max-width: 400px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 2rem;
}

.header {
    display: flex;
    align-items: center;
    padding: 1rem;
    background-color: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 9999;
}

.back-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.back-button:hover {
    color: var(--accent-color);
}

.header h1 {
    font-size: 1.25rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
    font-family: 'Times New Roman', Times, serif;
}

.character-preview {
    flex: 1;
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 320px;
    margin: 2rem auto;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: #1a1a1a;
    border-radius: 12px;
}

.character-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    image-rendering: pixelated; /* Ensures pixel art is crisp */
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s linear 0.3s;
    /* Hide initially until a src is set */
    opacity: 0;
    visibility: hidden;
    transform: scale(0.95);
}

.character-layer.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
    transition: opacity 0.3s ease, transform 0.3s ease, visibility 0s linear 0s;
}

/* Layer stacking order */
#layer-body { z-index: 1; }
#layer-face { z-index: 2; }
#layer-acc1 { z-index: 3; }
#layer-acc2 { z-index: 4; }
#layer-hat  { z-index: 5; }


.controls-container {
    padding: 1.5rem;
    background: var(--panel-bg);
    border-radius: 20px 20px 0 0;
    border-top: 1px solid var(--border-color);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    margin-top: auto; /* Push to bottom if space is available */
}

.control-group {
    display: grid;
    grid-template-columns: 28px 1fr 28px;
    align-items: center;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.control-group:last-child {
    border-bottom: none;
}

.list-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: bold;
    color: var(--text-secondary);
}

.selector-arrows {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.refresh-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    transition: color 0.2s, transform 0.2s, background 0.2s;
}

.refresh-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
    transform: rotate(90deg);
}

.refresh-btn:active {
    transform: rotate(90deg) scale(0.9);
}


.control-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
    min-width: 100px;
    text-align: center;
}

.arrow-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.1s;
}

.arrow-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.arrow-btn:active {
    transform: scale(0.9);
}

/* Animations for popping images */
@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); opacity: 1; }
}

.pop-animation {
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
