* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 16px;
    max-width: 980px;
    margin-inline: auto;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text-main);
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--font-heading);
}

h1 {
    margin: 0 0 4px;
    font-size: 1.4rem;
}

p.subtitle {
    margin: 0 0 16px;
    font-size: 0.9rem;
    color: var(--text-sub);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.token-pill {
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--accent-soft, #fff3de);
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 1px solid var(--border);
}

.token-pill strong {
    font-weight: 700;
}

.layout {
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 2fr);
    gap: 16px;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    border: 1px solid var(--border);
}

.preview-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.avatar-preview {
    width: 164px;
    height: 164px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 64px;
    border: 4px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}

.avatar-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.12);
}

#avatarEmoji {
    width: 110px;
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#avatarEmoji img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.preview-label {
    font-size: 0.9rem;
    color: var(--text-sub);
}

.pixel-preview-card {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 12px;
    background: linear-gradient(180deg, #fffaf0, #fff4df);
}

.pixel-preview-stage {
    min-height: 180px;
    border-radius: 16px;
    border: 1px solid rgba(209, 162, 77, 0.25);
    background:
        radial-gradient(circle at 20% 20%, rgba(255, 216, 140, 0.35), transparent 28%),
        radial-gradient(circle at 75% 25%, rgba(141, 206, 255, 0.28), transparent 24%),
        linear-gradient(180deg, #fffdf7, #fff4de);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.pixel-preview-stage img {
    width: min(240px, 100%);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.pixel-preview-actions {
    margin-top: 10px;
    display: flex;
    justify-content: center;
}

.pixel-preview-actions .btn-outline {
    width: 100%;
    justify-content: center;
}

.section-title {
    font-size: 1rem;
    margin: 0 0 8px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.section-head-tools {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.genre-select {
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text-main);
    padding: 6px 10px;
    font-size: 0.8rem;
    max-width: 160px;
}

.option-group {
    margin-bottom: 16px;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
}

.option-btn {
    border-radius: 12px;
    border: 1px solid var(--border);
    padding: 8px;
    background: #f9fafb;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    transition: all 0.15s ease;
    position: relative;
    min-height: 128px;
}

.option-btn:hover {
    background: #f3f4ff;
    transform: translateY(-1px);
}

.option-btn.selected {
    border-color: var(--accent-dark);
    background: #fff7ed;
    box-shadow: 0 0 0 1px rgba(248, 113, 38, 0.3);
}

.option-btn.locked {
    opacity: 0.6;
}

.option-chip {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.option-emoji {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
}

.option-emoji img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 14px;
}

.badge-tag {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
}

.badge-meta {
    font-size: 0.65rem;
    color: var(--text-sub);
    line-height: 1.35;
}

.pixel-pack-meta {
    font-size: 0.74rem;
    color: var(--text-sub);
}

.pixel-catalog-panel {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px 14px;
    border: 1px solid rgba(209, 162, 77, 0.18);
    border-radius: 16px;
    background:
        radial-gradient(circle at top left, rgba(255, 219, 150, 0.18), transparent 38%),
        linear-gradient(180deg, #fffdf7, #fff5e6);
}

.pixel-catalog-headline {
    font-size: 0.86rem;
    font-weight: 800;
    color: var(--text-main);
}

.pixel-catalog-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.pixel-catalog-stats .badge-tag {
    background: rgba(255, 255, 255, 0.9);
}

.character-preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.character-preset-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 12px;
    background:
        radial-gradient(circle at top left, rgba(255, 219, 150, 0.22), transparent 38%),
        linear-gradient(180deg, #fffef9, #fff5e9);
    display: flex;
    flex-direction: column;
    gap: 10px;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
    min-height: 280px;
}

.character-preset-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 18px rgba(15, 23, 42, 0.08);
}

.character-preset-card.selected {
    border-color: #d18f2a;
    box-shadow: 0 0 0 1px rgba(209, 143, 42, 0.28), 0 10px 18px rgba(15, 23, 42, 0.08);
}

.character-preset-card.none-option {
    background:
        radial-gradient(circle at top left, rgba(191, 219, 254, 0.25), transparent 40%),
        linear-gradient(180deg, #f8fbff, #edf4ff);
}

.character-preset-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.character-preset-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.character-preset-card img {
    width: 100%;
    max-width: 152px;
    margin: 0 auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

.character-preset-title {
    font-size: 0.8rem;
    font-weight: 800;
    text-align: center;
    color: var(--text-main);
}

.character-preset-sub {
    font-size: 0.68rem;
    line-height: 1.4;
    color: var(--text-sub);
    text-align: center;
}

.character-preset-desc {
    font-size: 0.7rem;
    line-height: 1.45;
    color: var(--text-sub);
    text-align: left;
}

.character-preset-status {
    margin-top: auto;
    display: flex;
    justify-content: center;
}

.character-preset-action {
    width: 100%;
    border: 1px solid rgba(209, 143, 42, 0.18);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.88);
    padding: 8px 10px;
    text-align: center;
    font-size: 0.74rem;
    line-height: 1.35;
    color: var(--text-main);
}

.character-preset-action strong {
    display: block;
    font-size: 0.76rem;
}

.character-preset-action .badge-tag {
    display: inline-flex;
    margin-top: 4px;
}

.character-preset-note {
    font-size: 0.68rem;
    line-height: 1.45;
    color: var(--text-sub);
    text-align: left;
}

.character-preset-card.locked {
    opacity: 0.9;
}

.character-preset-card.sold-out {
    opacity: 0.72;
}

.character-preset-card .btn-primary,
.character-preset-card .btn-outline {
    width: 100%;
    justify-content: center;
}

.character-preset-actions {
    margin-top: auto;
    display: grid;
    gap: 8px;
}

.badge-owned {
    background: #dcfce7;
    color: #166534;
}

.badge-free {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-price {
    background: #fef3c7;
    color: #92400e;
}

.badge-muted {
    background: #e2e8f0;
    color: #475569;
}

.catalog-empty {
    grid-column: 1 / -1;
    border: 1px dashed var(--border);
    border-radius: 18px;
    padding: 18px;
    text-align: center;
    color: var(--text-sub);
    background: #fffdf8;
}

.auto-candidate-wrap {
    margin-top: 10px;
    border: 1px dashed var(--border);
    border-radius: 12px;
    padding: 10px;
    background: #fffdf8;
}

.auto-candidate-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.auto-candidate-hint {
    font-size: 0.75rem;
    color: var(--text-sub);
}

.auto-candidate-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 8px;
}

.auto-candidate-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.auto-candidate-preview {
    width: 72px;
    height: 72px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    background: #f8fafc;
    overflow: hidden;
}

.auto-candidate-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.auto-candidate-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-main);
}

.btn-row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 12px;
}

.btn-primary,
.btn-outline {
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--accent);
    border: 1px solid var(--accent-dark);
    color: #111827;
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--accent-dark);
    color: #fff;
}

.btn-outline {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-outline:hover {
    background: #f9fafb;
}

.btn-mini {
    padding: 6px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
}

.status {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--text-sub);
    min-height: 1.2rem;
    text-align: center;
    padding: 8px;
    border-radius: 8px;
}

.status.error {
    color: var(--danger);
    background: #fef2f2;
}

.status.success {
    color: #059669;
    background: #ecfdf5;
}

.avatar-walk-preview-modal[hidden] {
    display: none;
}

.avatar-walk-preview-modal {
    position: fixed;
    inset: 0;
    z-index: 9200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.avatar-walk-preview-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.56);
    backdrop-filter: blur(10px);
}

.avatar-walk-preview-dialog {
    position: relative;
    width: min(1080px, 100%);
    max-height: min(88vh, 860px);
    overflow: auto;
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.22);
    background:
        radial-gradient(circle at top left, rgba(255, 232, 167, 0.24), transparent 28%),
        linear-gradient(180deg, #fffdf7, #fff6e8);
    box-shadow: 0 28px 70px rgba(15, 23, 42, 0.28);
    padding: 18px;
}

.avatar-walk-preview-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.avatar-walk-preview-copy {
    margin: 4px 0 0;
    color: var(--text-sub);
    font-size: 0.84rem;
    line-height: 1.5;
}

.avatar-walk-preview-stage-shell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 14px;
    align-items: stretch;
}

.avatar-walk-preview-stage {
    min-height: min(62vh, 560px);
    border-radius: 22px;
    border: 1px solid rgba(209, 162, 77, 0.24);
    background:
        radial-gradient(circle at top left, rgba(255, 234, 170, 0.32), transparent 24%),
        linear-gradient(180deg, #fffef9, #edf7eb 52%, #e6f0ff);
    overflow: hidden;
    position: relative;
}

.avatar-walk-preview-stage canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.avatar-walk-preview-side {
    display: grid;
    gap: 12px;
    align-content: start;
}

.avatar-walk-preview-hint {
    display: grid;
    gap: 6px;
    border: 1px solid rgba(209, 162, 77, 0.18);
    border-radius: 18px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.86);
    color: var(--text-sub);
    font-size: 0.78rem;
    line-height: 1.55;
}

.avatar-walk-preview-hint strong {
    color: var(--text-main);
    font-size: 0.84rem;
}

.avatar-walk-preview-pad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.avatar-pad-btn {
    min-height: 56px;
    border-radius: 16px;
    border: 1px solid rgba(209, 162, 77, 0.3);
    background: linear-gradient(180deg, #fffdf9, #fff1d3);
    font-size: 1.1rem;
    font-weight: 800;
    color: #7c5212;
    cursor: pointer;
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.avatar-pad-btn:hover,
.avatar-pad-btn:focus-visible {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(209, 143, 42, 0.18);
    background: linear-gradient(180deg, #fffefc, #ffe7b0);
}

.avatar-pad-btn:active,
.avatar-pad-btn.is-active {
    transform: translateY(0);
    background: linear-gradient(180deg, #ffe9bd, #ffd67b);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.avatar-pad-btn-up {
    grid-column: 2;
}

.avatar-pad-btn-left {
    grid-column: 1;
    grid-row: 2;
}

.avatar-pad-btn-right {
    grid-column: 3;
    grid-row: 2;
}

.avatar-pad-btn-down {
    grid-column: 2;
    grid-row: 3;
}

.avatar-walk-preview-tools {
    display: grid;
}

.avatar-walk-preview-tools .btn-outline {
    width: 100%;
    justify-content: center;
}

@media (max-width: 720px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .avatar-walk-preview-modal {
        padding: 10px;
    }

    .avatar-walk-preview-dialog {
        padding: 14px;
        border-radius: 20px;
    }

    .avatar-walk-preview-header {
        flex-direction: column;
    }

    .avatar-walk-preview-stage-shell {
        grid-template-columns: 1fr;
    }

    .avatar-walk-preview-stage {
        min-height: 380px;
    }
}
