/* ===== Hood Monkes Studio – Amazon Jungle Theme ===== */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-deep: #0a1f0a;
    --bg: #0d2b0d;
    --card: #143314;
    --card-hover: #1a401a;
    --border: #2d5a2d;
    --border-light: #3d7a3d;
    --primary: #3ecf3e;
    --primary-hover: #2db82d;
    --accent: #c4a035;
    --accent-glow: #e8c84a;
    --text: #e8f5e8;
    --muted: #8fbc8f;
    --danger: #e74c3c;
    --success: #2ecc71;
    --wood: #5c4033;
    --leaf: #228b22;
    --radius: 4px;
    --pixel: 'Press Start 2P', cursive;
    --pixel-body: 'VT323', monospace;
}

body {
    font-family: var(--pixel-body);
    font-size: 20px;
    background: var(--bg-deep);
    color: var(--text);
    line-height: 1.4;
    min-height: 100vh;
    overflow-x: hidden;
    /* subtle jungle gradient */
    background-image:
        radial-gradient(ellipse at 20% 80%, rgba(34, 139, 34, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(60, 179, 113, 0.1) 0%, transparent 45%),
        linear-gradient(180deg, #0a1f0a 0%, #0d2b0d 40%, #0a1a0a 100%);
}

a { color: inherit; text-decoration: none; }

/* ===== Pixel font headings ===== */
h1, h2, h3, .logo h1, .nav-item, .btn, .tool-card h3, .preset-btn {
    font-family: var(--pixel);
    letter-spacing: 1px;
}

h2 { font-size: 1.1rem; margin-bottom: 1rem; color: var(--accent-glow); text-shadow: 2px 2px 0 #000; }
h3 { font-size: 0.75rem; }

/* ===== Header ===== */
.header {
    background: linear-gradient(180deg, #1a3a1a 0%, #0f280f 100%);
    border-bottom: 4px solid var(--border);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    position: relative;
    z-index: 10;
    box-shadow: 0 4px 0 rgba(0,0,0,0.4);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    font-size: 2rem;
    animation: bounce-monkey 2s ease-in-out infinite;
}

@keyframes bounce-monkey {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.logo h1 {
    font-size: 0.95rem;
    color: var(--primary);
    text-shadow: 3px 3px 0 #000, -1px -1px 0 #1a5c1a;
}

.tagline {
    font-family: var(--pixel-body);
    font-size: 1.1rem;
    color: var(--muted);
}

/* ===== Navigation ===== */
.nav {
    background: #0f280f;
    border-bottom: 3px solid var(--border);
    padding: 0.6rem 1.5rem;
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    overflow-x: auto;
    position: relative;
    z-index: 10;
}

.nav-item {
    padding: 0.55rem 0.9rem;
    border-radius: 0;
    font-size: 0.55rem;
    color: var(--muted);
    border: 2px solid transparent;
    transition: all 0.15s steps(3);
    white-space: nowrap;
    image-rendering: pixelated;
}

.nav-item:hover {
    color: var(--text);
    border-color: var(--border-light);
    background: rgba(62, 207, 62, 0.1);
}

.nav-item.active {
    background: var(--primary);
    color: #0a1f0a;
    border-color: var(--accent);
    text-shadow: none;
    box-shadow: 0 0 12px rgba(62, 207, 62, 0.4);
}

/* ===== Main ===== */
.main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.25rem;
    position: relative;
    z-index: 5;
}

.hero {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background: rgba(20, 51, 20, 0.6);
    border: 3px solid var(--border);
    box-shadow: inset 0 0 30px rgba(0,0,0,0.3), 0 4px 0 #0a1a0a;
}

.hero h2 {
    font-size: 1.15rem;
    margin-bottom: 0.75rem;
}

.hero p {
    font-family: var(--pixel-body);
    font-size: 1.25rem;
    color: var(--muted);
    max-width: 560px;
    margin: 0 auto;
}

/* ===== Tools grid ===== */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

.tool-card {
    background: var(--card);
    border: 3px solid var(--border);
    border-radius: 0;
    padding: 1.4rem;
    transition: all 0.2s steps(4);
    display: block;
    position: relative;
    box-shadow: 4px 4px 0 #0a1a0a;
}

.tool-card:hover {
    border-color: var(--primary);
    background: var(--card-hover);
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #0a1a0a, 0 0 20px rgba(62, 207, 62, 0.25);
}

.tool-icon {
    font-size: 2.2rem;
    margin-bottom: 0.75rem;
    filter: drop-shadow(2px 2px 0 #000);
}

.tool-card h3 {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
    color: var(--accent-glow);
}

.tool-card p {
    font-family: var(--pixel-body);
    font-size: 1.1rem;
    color: var(--muted);
}

/* ===== Footer ===== */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--muted);
    font-family: var(--pixel-body);
    font-size: 1.1rem;
    border-top: 3px solid var(--border);
    margin-top: 3rem;
    position: relative;
    z-index: 5;
}

/* ===== Tool layout ===== */
.tool-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 1.5rem;
    min-height: 70vh;
}

@media (max-width: 900px) {
    .tool-layout { grid-template-columns: 1fr; }
}

.sidebar {
    background: var(--card);
    border: 3px solid var(--border);
    border-radius: 0;
    padding: 1.25rem;
    height: fit-content;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 4px 4px 0 #0a1a0a;
}

.sidebar h3 {
    font-size: 0.65rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
    color: var(--primary);
}

.canvas-area {
    background: var(--card);
    border: 3px solid var(--border);
    border-radius: 0;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    box-shadow: 4px 4px 0 #0a1a0a;
}

.canvas-wrapper {
    background: #0a1a0a;
    border: 3px solid var(--border);
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0,0,0,0.5);
}

canvas {
    display: block;
    max-width: 100%;
    image-rendering: pixelated;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.7rem 1.1rem;
    border: 3px solid var(--border-light);
    border-radius: 0;
    font-size: 0.55rem;
    font-weight: normal;
    cursor: pointer;
    transition: all 0.15s steps(3);
    background: var(--primary);
    color: #0a1f0a;
    text-shadow: none;
    box-shadow: 3px 3px 0 #0a1a0a;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0 #0a1a0a;
}

.btn:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0 #0a1a0a;
}

.btn-secondary {
    background: var(--wood);
    color: var(--text);
    border-color: #7a5c45;
}

.btn-secondary:hover {
    background: #6b4a38;
}

.btn-success {
    background: var(--success);
    color: #0a1f0a;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: #c0392b;
}

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
}

.btn-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-family: var(--pixel);
    font-size: 0.5rem;
    color: var(--muted);
    margin-bottom: 0.4rem;
}

.form-control {
    width: 100%;
    padding: 0.55rem 0.7rem;
    background: #0a1a0a;
    border: 2px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font-family: var(--pixel-body);
    font-size: 1.15rem;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(62, 207, 62, 0.3);
}

select.form-control {
    cursor: pointer;
}

/* ===== Trait options ===== */
.trait-select-group {
    margin-bottom: 1.1rem;
}

.trait-select-group label {
    font-family: var(--pixel);
    font-size: 0.55rem;
    font-weight: normal;
    color: var(--accent-glow);
    margin-bottom: 0.4rem;
    display: block;
}

.trait-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.4rem;
    max-height: 140px;
    overflow-y: auto;
}

.trait-option {
    background: #0a1a0a;
    border: 2px solid var(--border);
    border-radius: 0;
    padding: 0.3rem;
    cursor: pointer;
    text-align: center;
    font-family: var(--pixel-body);
    font-size: 0.9rem;
    transition: all 0.12s steps(2);
}

.trait-option:hover,
.trait-option.selected {
    border-color: var(--primary);
    background: rgba(62, 207, 62, 0.15);
    box-shadow: 0 0 8px rgba(62, 207, 62, 0.25);
}

.trait-option img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: contain;
    border-radius: 0;
    background: #111;
    margin-bottom: 0.15rem;
    image-rendering: pixelated;
}

/* ===== Gallery ===== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.gallery-item {
    background: var(--card);
    border: 3px solid var(--border);
    border-radius: 0;
    overflow: hidden;
    transition: all 0.15s steps(3);
    box-shadow: 3px 3px 0 #0a1a0a;
}

.gallery-item:hover {
    border-color: var(--primary);
    transform: translate(-2px, -2px);
    box-shadow: 5px 5px 0 #0a1a0a;
}

.gallery-item img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: #0a1a0a;
    image-rendering: pixelated;
}

.gallery-item .meta {
    padding: 0.55rem;
    font-family: var(--pixel-body);
    font-size: 1rem;
}

.gallery-item .meta strong {
    display: block;
    font-family: var(--pixel);
    font-size: 0.5rem;
    margin-bottom: 0.2rem;
    color: var(--accent-glow);
}

.gallery-item .meta span {
    color: var(--muted);
    font-size: 0.95rem;
}

.gallery-empty {
    text-align: center;
    padding: 3rem;
    color: var(--muted);
    font-family: var(--pixel-body);
    font-size: 1.3rem;
}

/* ===== Filters / stats ===== */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    align-items: end;
}

.filters .form-group {
    margin-bottom: 0;
    min-width: 130px;
}

.stats-bar {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    font-family: var(--pixel-body);
    font-size: 1.15rem;
    color: var(--muted);
}

.stats-bar strong {
    color: var(--primary);
    font-family: var(--pixel);
    font-size: 0.65rem;
}

/* ===== Status ===== */
.status {
    padding: 0.65rem 1rem;
    border-radius: 0;
    font-family: var(--pixel-body);
    font-size: 1.15rem;
    margin-top: 0.75rem;
    display: none;
    border: 2px solid;
}

.status.success {
    background: rgba(46, 204, 113, 0.15);
    color: var(--success);
    border-color: var(--success);
    display: block;
}

.status.error {
    background: rgba(231, 76, 60, 0.15);
    color: var(--danger);
    border-color: var(--danger);
    display: block;
}

/* ===== Presets ===== */
.presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.preset-btn {
    padding: 0.4rem 0.7rem;
    font-size: 0.5rem;
    background: #0a1a0a;
    border: 2px solid var(--border);
    border-radius: 0;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.12s steps(2);
}

.preset-btn.active,
.preset-btn:hover {
    border-color: var(--primary);
    color: var(--text);
    background: rgba(62, 207, 62, 0.12);
}

/* ===== Grid slots ===== */
.grid-slots {
    display: grid;
    gap: 8px;
    background: #0a1a0a;
    padding: 12px;
    border: 2px solid var(--border);
}

.grid-slot {
    background: #143314;
    border: 2px dashed var(--border);
    border-radius: 0;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-family: var(--pixel);
    font-size: 0.5rem;
    overflow: hidden;
    cursor: pointer;
}

.grid-slot img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    image-rendering: pixelated;
}

.grid-slot.has-image {
    border-style: solid;
    border-color: var(--primary);
}

/* ===== NFT picker ===== */
.nft-picker {
    max-height: 220px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.nft-picker img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 0;
    cursor: pointer;
    border: 2px solid transparent;
    image-rendering: pixelated;
    transition: border-color 0.12s steps(2);
}

.nft-picker img:hover,
.nft-picker img.selected {
    border-color: var(--primary);
    box-shadow: 0 0 8px rgba(62, 207, 62, 0.35);
}

/* ===== Scrollbar jungle style ===== */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: #0a1a0a;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border: 2px solid #0a1a0a;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ===== INTRO MONKEY ANIMATION ===== */
.jungle-monkey-intro {
    position: fixed;
    bottom: -220px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    pointer-events: none;
    font-size: 7rem;
    line-height: 1;
    filter: drop-shadow(0 8px 16px rgba(0,0,0,0.6));
    animation: monkeyRise 2s ease-out forwards;
}

@keyframes monkeyRise {
    0% {
        bottom: -220px;
        opacity: 0;
        transform: translateX(-50%) scale(0.6) rotate(-8deg);
    }
    40% {
        opacity: 1;
    }
    70% {
        bottom: 40px;
        transform: translateX(-50%) scale(1.05) rotate(4deg);
    }
    100% {
        bottom: 24px;
        opacity: 1;
        transform: translateX(-50%) scale(1) rotate(0deg);
    }
}

/* Fade out the monkey after it settles */
.jungle-monkey-intro.fade-away {
    animation: monkeyFade 1.2s ease-in 2.5s forwards;
}

@keyframes monkeyFade {
    to {
        opacity: 0;
        bottom: -100px;
        transform: translateX(-50%) scale(0.8);
    }
}

/* Soft vines / leaf overlay on edges */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 1;
    background:
        radial-gradient(circle at 0% 0%, rgba(34, 139, 34, 0.12) 0%, transparent 35%),
        radial-gradient(circle at 100% 0%, rgba(34, 139, 34, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 0% 100%, rgba(46, 139, 87, 0.1) 0%, transparent 30%),
        radial-gradient(circle at 100% 100%, rgba(34, 139, 34, 0.08) 0%, transparent 28%);
}

/* Pixel-style selection */
::selection {
    background: var(--primary);
    color: #0a1f0a;
}

/* ===== LIGHT MODE (sand jungle) ===== */
body.light-mode {
    --bg-deep: #e8dcc8;
    --bg: #f0e6d4;
    --card: #f5ebda;
    --card-hover: #faf3e6;
    --border: #c4a574;
    --border-light: #a88b5a;
    --primary: #2d6a2d;
    --primary-hover: #1e4d1e;
    --accent: #b8860b;
    --accent-glow: #d4a017;
    --text: #2a2218;
    --muted: #7a6a50;
    --danger: #c0392b;
    --success: #2e7d32;
    --wood: #8b6914;
    --leaf: #3d7a3d;
    --sand: #e8d4b0;
    --sand-deep: #d4bc94;
    --sand-light: #f2e6d0;
    background-image:
        radial-gradient(ellipse at 20% 80%, rgba(180, 150, 90, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(120, 160, 80, 0.08) 0%, transparent 45%),
        linear-gradient(180deg, #e8dcc8 0%, #f0e6d4 40%, #e0d4bc 100%);
}

body.light-mode .header {
    background: linear-gradient(180deg, #e0d0b0 0%, #d4c09a 100%);
    box-shadow: 0 4px 0 rgba(0,0,0,0.1);
}

body.light-mode .nav {
    background: #d8c8a8;
}

body.light-mode .nav-item.active {
    color: #fff;
}

body.light-mode .logo h1 {
    color: var(--primary);
    text-shadow: 2px 2px 0 rgba(0,0,0,0.08);
}

body.light-mode .hero {
    background: var(--sand-light);
    box-shadow: inset 0 0 20px rgba(0,0,0,0.04), 0 4px 0 #c4b090;
}

body.light-mode .tool-card,
body.light-mode .sidebar,
body.light-mode .canvas-area,
body.light-mode .selected-tray,
body.light-mode .panel {
    background: var(--card);
    box-shadow: 4px 4px 0 rgba(90, 70, 40, 0.15);
}

/* Preview / canvas boxes – sand */
body.light-mode .canvas-wrapper {
    background: var(--sand) !important;
    border-color: var(--border);
    box-shadow: inset 0 0 24px rgba(120, 90, 50, 0.12);
}

body.light-mode .canvas-area {
    background: var(--sand-light);
}

body.light-mode canvas {
    background: var(--sand);
}

body.light-mode .btn {
    box-shadow: 3px 3px 0 rgba(90, 70, 40, 0.18);
}

body.light-mode .form-control {
    background: var(--sand-light);
    color: var(--text);
    border-color: var(--border);
}

body.light-mode .trait-card,
body.light-mode .tray-slot,
body.light-mode .cat-tab,
body.light-mode .preset-btn,
body.light-mode .grid-slot {
    background: var(--sand);
    border-color: var(--border);
}

body.light-mode .trait-card .card-thumb,
body.light-mode .grid-slot {
    background: var(--sand-deep);
}

body.light-mode .trait-card.selected,
body.light-mode .tray-slot.has-trait {
    background: #e8f0d8;
    border-color: var(--primary);
}

body.light-mode .gallery-item {
    background: var(--card);
    box-shadow: 3px 3px 0 rgba(90, 70, 40, 0.12);
}

body.light-mode .gallery-item img {
    background: var(--sand);
}

body.light-mode .nft-picker img {
    background: var(--sand);
    border-color: transparent;
}

body.light-mode .upload-preview {
    background: var(--sand) !important;
    border-color: var(--border) !important;
}

body.light-mode .grid-slots {
    background: var(--sand-deep);
}

body.light-mode ::-webkit-scrollbar-track {
    background: var(--sand);
}
body.light-mode ::-webkit-scrollbar-thumb {
    background: var(--border);
    border-color: var(--sand);
}

/* ===== FLOATING THEME PANEL ===== */
.theme-float {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    font-family: var(--pixel);
}

.theme-float-btn {
    width: 52px;
    height: 52px;
    border: 3px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 4px 4px 0 rgba(0,0,0,0.25);
    transition: all 0.15s steps(3);
    padding: 0;
}

.theme-float-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 rgba(0,0,0,0.25);
    border-color: var(--primary);
}

.theme-float-panel {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 220px;
    background: var(--card);
    border: 3px solid var(--border);
    box-shadow: 6px 6px 0 rgba(0,0,0,0.3);
    padding: 1rem;
    display: none;
    animation: panelPop 0.2s steps(4);
}

.theme-float-panel.open {
    display: block;
}

@keyframes panelPop {
    from { opacity: 0; transform: translateY(8px) scale(0.95); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.theme-float-panel h4 {
    font-size: 0.5rem;
    color: var(--primary);
    margin-bottom: 0.75rem;
    letter-spacing: 1px;
}

.theme-opt {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.65rem;
    border: 2px solid var(--border);
    margin-bottom: 0.4rem;
    cursor: pointer;
    transition: all 0.12s steps(2);
    font-family: var(--pixel-body);
    font-size: 1.1rem;
    color: var(--text);
    background: transparent;
    width: 100%;
    text-align: left;
}

.theme-opt:hover {
    border-color: var(--primary);
    background: rgba(62, 207, 62, 0.08);
}

.theme-opt.active {
    border-color: var(--primary);
    background: rgba(62, 207, 62, 0.15);
    box-shadow: 0 0 8px rgba(62, 207, 62, 0.2);
}

.theme-opt .opt-icon {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
}

.theme-opt .opt-label {
    font-family: var(--pixel);
    font-size: 0.45rem;
}

.theme-float-panel .panel-hint {
    font-family: var(--pixel-body);
    font-size: 0.95rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

body.light-mode .theme-float-btn,
body.light-mode .theme-float-panel {
    box-shadow: 4px 4px 0 rgba(0,0,0,0.12);
}

/* ===== PREMIUM FINISH – animations & micro-interactions ===== */

/* Smooth theme switch */
body {
    transition: background-color 0.35s ease, color 0.35s ease;
}
body, body * {
    /* don't slow pixel step animations on every element */
}
.header, .nav, .tool-card, .sidebar, .canvas-area, .selected-tray,
.gallery-item, .btn, .form-control, .cat-tab, .trait-card, .tray-slot,
.theme-float-btn, .theme-float-panel, .nav-item {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease, box-shadow 0.25s ease, transform 0.2s ease;
}

/* Page enter */
.app {
    animation: pageIn 0.45s ease-out both;
}
@keyframes pageIn {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.main > h2 {
    animation: fadeSlide 0.5s ease-out 0.05s both;
}
.main > p, .hero, .stats-bar {
    animation: fadeSlide 0.5s ease-out 0.12s both;
}
@keyframes fadeSlide {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Stagger tool cards */
.tools-grid .tool-card {
    animation: cardPop 0.4s ease-out both;
}
.tools-grid .tool-card:nth-child(1) { animation-delay: 0.08s; }
.tools-grid .tool-card:nth-child(2) { animation-delay: 0.14s; }
.tools-grid .tool-card:nth-child(3) { animation-delay: 0.2s; }
.tools-grid .tool-card:nth-child(4) { animation-delay: 0.26s; }
.tools-grid .tool-card:nth-child(5) { animation-delay: 0.32s; }
.tools-grid .tool-card:nth-child(6) { animation-delay: 0.38s; }
.tools-grid .tool-card:nth-child(7) { animation-delay: 0.44s; }
.tools-grid .tool-card:nth-child(8) { animation-delay: 0.5s; }
@keyframes cardPop {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Premium card hover */
.tool-card {
    position: relative;
    overflow: hidden;
}
.tool-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(62, 207, 62, 0.08) 0%, transparent 50%);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}
.tool-card:hover::after {
    opacity: 1;
}
.tool-card:hover .tool-icon {
    transform: scale(1.12) rotate(-4deg);
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.tool-icon {
    transition: transform 0.25s ease;
    display: inline-block;
}

/* Gallery hover lift */
.gallery-item {
    position: relative;
}
.gallery-item:hover {
    z-index: 2;
}
.gallery-item img {
    transition: transform 0.3s ease;
}
.gallery-item:hover img {
    transform: scale(1.04);
}

/* ===== BUTTON CLICK EFFECTS ===== */
.btn {
    position: relative;
    overflow: hidden;
    user-select: none;
}
.btn:active {
    transform: translate(2px, 2px) scale(0.97);
    box-shadow: 1px 1px 0 rgba(0,0,0,0.3) !important;
}
.btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: ripple 0.55s ease-out;
    pointer-events: none;
}
body.light-mode .btn .ripple {
    background: rgba(45, 106, 45, 0.25);
}
@keyframes ripple {
    to { transform: scale(2.8); opacity: 0; }
}

/* Nav item press */
.nav-item {
    position: relative;
}
.nav-item:active {
    transform: scale(0.96);
}
.nav-item.active {
    animation: navGlow 2s ease-in-out infinite alternate;
}
@keyframes navGlow {
    from { box-shadow: 0 0 8px rgba(62, 207, 62, 0.3); }
    to { box-shadow: 0 0 16px rgba(62, 207, 62, 0.55); }
}
body.light-mode .nav-item.active {
    animation: navGlowLight 2s ease-in-out infinite alternate;
}
@keyframes navGlowLight {
    from { box-shadow: 0 0 6px rgba(45, 106, 45, 0.25); }
    to { box-shadow: 0 0 14px rgba(45, 106, 45, 0.45); }
}

/* Trait cards / tabs click */
.trait-card:active,
.cat-tab:active,
.preset-btn:active,
.theme-opt:active {
    transform: scale(0.95);
}
.trait-card.selected {
    animation: selectPulse 0.4s ease-out;
}
@keyframes selectPulse {
    0% { box-shadow: 0 0 0 0 rgba(62, 207, 62, 0.5); }
    100% { box-shadow: 0 0 12px rgba(62, 207, 62, 0.3); }
}

/* Tray slot pop when filled */
.tray-slot.has-trait {
    animation: slotFill 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes slotFill {
    from { transform: scale(0.9); opacity: 0.6; }
    to { transform: scale(1); opacity: 1; }
}

/* Canvas area subtle breathe */
.canvas-wrapper {
    transition: box-shadow 0.3s ease, background-color 0.3s ease;
}
.canvas-area:hover .canvas-wrapper {
    box-shadow: inset 0 0 24px rgba(62, 207, 62, 0.08), 0 0 0 1px var(--border-light);
}
body.light-mode .canvas-area:hover .canvas-wrapper {
    box-shadow: inset 0 0 24px rgba(120, 90, 50, 0.12), 0 0 0 1px var(--border);
}

/* Form focus glow */
.form-control:focus {
    animation: inputFocus 0.3s ease;
}
@keyframes inputFocus {
    from { box-shadow: 0 0 0 0 rgba(62, 207, 62, 0.4); }
    to { box-shadow: 0 0 10px rgba(62, 207, 62, 0.25); }
}

/* Status toast slide */
.status {
    animation: statusIn 0.3s ease-out;
}
@keyframes statusIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Scrollbar fade feel */
::-webkit-scrollbar-thumb {
    transition: background 0.2s ease;
}

/* Floating theme button pulse once on load */
.theme-float-btn {
    animation: floatIn 0.5s ease-out 0.6s both;
}
@keyframes floatIn {
    from { opacity: 0; transform: translateY(20px) scale(0.8); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.theme-float-btn:active {
    transform: scale(0.9);
}

/* Header logo shine */
.logo h1 {
    position: relative;
}
.logo:hover .logo-icon {
    animation: bounce-monkey 0.6s ease;
}

/* Premium selected tray */
.selected-tray {
    animation: fadeSlide 0.4s ease-out 0.1s both;
}

/* Sidebar / layout enter */
.tool-layout .sidebar {
    animation: slideFromLeft 0.4s ease-out 0.15s both;
}
.tool-layout .canvas-area {
    animation: slideFromRight 0.4s ease-out 0.2s both;
}
@keyframes slideFromLeft {
    from { opacity: 0; transform: translateX(-16px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slideFromRight {
    from { opacity: 0; transform: translateX(16px); }
    to { opacity: 1; transform: translateX(0); }
}

/* NFT picker image click */
.nft-picker img {
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.2s ease;
}
.nft-picker img:active {
    transform: scale(0.9);
}
.nft-picker img.selected {
    animation: selectPulse 0.35s ease-out;
}

/* Grid slot drop feel */
.grid-slot {
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}
.grid-slot:active {
    transform: scale(0.97);
}
.grid-slot.has-image {
    animation: slotFill 0.3s ease-out;
}

/* Loading shimmer for empty grids */
.loading-msg {
    position: relative;
}
.loading-msg::after {
    content: '';
    display: inline-block;
    width: 4px;
    height: 1em;
    background: var(--primary);
    margin-left: 4px;
    animation: blink 0.8s step-end infinite;
    vertical-align: text-bottom;
}
@keyframes blink {
    50% { opacity: 0; }
}

/* Disable motion for reduced-preference users */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}


/* Full-bleed project homepage */
.main.site-home,
main.site-home {
    max-width: none;
    padding: 0;
    margin: 0;
}

/* ===== Page load / scroll fade ===== */
.fx-fade {
    opacity: 0;
    transform: translateY(32px);
    transition: opacity 0.9s cubic-bezier(0.22, 1, 0.36, 1), transform 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.fx-fade.is-in {
    opacity: 1;
    transform: translateY(0);
}
.fx-stagger > .fx-fade:nth-child(1) { transition-delay: 0.04s; }
.fx-stagger > .fx-fade:nth-child(2) { transition-delay: 0.1s; }
.fx-stagger > .fx-fade:nth-child(3) { transition-delay: 0.16s; }
.fx-stagger > .fx-fade:nth-child(4) { transition-delay: 0.22s; }
.fx-stagger > .fx-fade:nth-child(5) { transition-delay: 0.28s; }
.fx-stagger > .fx-fade:nth-child(6) { transition-delay: 0.34s; }
.fx-stagger > .fx-fade:nth-child(7) { transition-delay: 0.4s; }
.fx-stagger > .fx-fade:nth-child(8) { transition-delay: 0.46s; }

@media (prefers-reduced-motion: reduce) {
    .fx-fade { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* Soft page sheen on main sections */
.main > h2,
.main > p,
.tool-layout,
.sidebar,
.canvas-area,
.tools-grid,
.land-section,
.hm-section,
.rg-section {
    /* enhanced by JS fx-fade when present */
}

/* ===== Music player ===== */
.hm-music {
    position: fixed;
    right: 1.1rem;
    bottom: 5.2rem;
    z-index: 9990;
    font-family: var(--pixel-body);
}
.hm-music-toggle {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border);
    background: var(--card);
    color: var(--primary);
    box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, border-color 0.2s ease;
}
.hm-music-toggle:hover {
    border-color: var(--primary);
    transform: translate(-1px, -1px);
}
.hm-music-toggle.is-playing {
    animation: musicPulse 1.6s ease-in-out infinite;
}
@keyframes musicPulse {
    0%, 100% { box-shadow: 3px 3px 0 rgba(0,0,0,0.3), 0 0 0 0 rgba(62,207,62,0.35); }
    50% { box-shadow: 3px 3px 0 rgba(0,0,0,0.3), 0 0 0 8px rgba(62,207,62,0); }
}
.hm-music-panel {
    position: absolute;
    right: 0;
    bottom: 58px;
    width: min(320px, calc(100vw - 2rem));
    background: var(--card);
    border: 3px solid var(--border);
    box-shadow: 6px 6px 0 rgba(0,0,0,0.3);
    padding: 0.85rem;
    display: none;
    flex-direction: column;
    gap: 0.65rem;
}
.hm-music-panel.open { display: flex; animation: musicPanelIn 0.25s ease; }
@keyframes musicPanelIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.hm-music-now {
    font-family: var(--pixel);
    font-size: 0.42rem;
    color: var(--accent-glow);
    line-height: 1.4;
}
.hm-music-now small {
    display: block;
    font-family: var(--pixel-body);
    font-size: 1rem;
    color: var(--muted);
    margin-top: 0.25rem;
    font-weight: normal;
}
.hm-music-progress {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--pixel-body);
    font-size: 0.9rem;
    color: var(--muted);
}
.hm-music-progress input[type="range"] {
    flex: 1;
    accent-color: var(--primary);
    height: 4px;
}
.hm-music-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: center;
}
.hm-music-controls button {
    border: 2px solid var(--border);
    background: var(--bg-deep);
    color: var(--text);
    font-family: var(--pixel);
    font-size: 0.38rem;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
    min-width: 2.2rem;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}
body.light-mode .hm-music-controls button { background: var(--sand, #e8d4b0); }
.hm-music-controls button:hover,
.hm-music-controls button.is-on {
    border-color: var(--primary);
    color: var(--primary);
}
.hm-music-vol {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: var(--pixel);
    font-size: 0.38rem;
    color: var(--muted);
}
.hm-music-vol input { flex: 1; accent-color: var(--primary); }
.hm-music-list-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--pixel);
    font-size: 0.4rem;
    color: var(--muted);
}
.hm-music-list-head select {
    font-family: var(--pixel-body);
    font-size: 0.95rem;
    background: var(--bg-deep);
    color: var(--text);
    border: 2px solid var(--border);
    padding: 0.15rem 0.3rem;
}
body.light-mode .hm-music-list-head select { background: var(--sand, #e8d4b0); }
.hm-music-list {
    max-height: 140px;
    overflow-y: auto;
    border: 2px solid var(--border);
    background: var(--bg-deep);
}
body.light-mode .hm-music-list { background: var(--sand, #e8d4b0); }
.hm-music-list button {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    border-bottom: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    font-family: var(--pixel-body);
    font-size: 1.05rem;
    padding: 0.4rem 0.5rem;
    cursor: pointer;
}
.hm-music-list button:hover { background: rgba(62,207,62,0.12); }
.hm-music-list button.is-current {
    color: var(--primary);
    background: rgba(62,207,62,0.1);
}
.hm-music-status {
    font-family: var(--pixel-body);
    font-size: 0.95rem;
    color: var(--muted);
    min-height: 1.2em;
}


/* Platform footer */
.site-footer, .footer.site-footer {
    border-top: 2px solid var(--border);
    padding: 1.75rem 1.25rem 2rem;
    margin-top: 1rem;
}
.site-footer-inner {
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    align-items: center;
    justify-content: space-between;
}
.site-footer-brand {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.site-footer-brand strong {
    font-family: var(--pixel);
    font-size: 0.5rem;
    color: var(--accent-glow);
}
.site-footer-brand span,
.site-footer-copy {
    font-family: var(--pixel-body);
    font-size: 1rem;
    color: var(--muted);
}
.site-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
}
.site-footer-links a {
    font-family: var(--pixel);
    font-size: 0.4rem;
    color: var(--muted);
    transition: color 0.2s;
}
.site-footer-links a:hover { color: var(--primary); }

/* ===== Responsive platform (all pages) ===== */
@media (max-width: 960px) {
  .nav {
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 0.25rem;
    padding-bottom: 0.35rem;
  }
  .nav-item {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.4rem;
    padding: 0.45rem 0.55rem;
  }
  .header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .tool-layout {
    grid-template-columns: 1fr !important;
  }
  .sidebar {
    max-height: none;
  }
  .canvas-wrapper canvas {
    max-width: 100%;
    height: auto !important;
  }
}
@media (max-width: 600px) {
  .logo h1 { font-size: 0.7rem; }
  .tagline { font-size: 0.85rem; }
  .btn { font-size: 0.42rem; padding: 0.55rem 0.7rem; }
  .hm-music { right: 0.75rem; bottom: 4.6rem; }
  .theme-float { right: 0.75rem; bottom: 1rem; }
}

/* ===== Header: desktop inline / mobile hamburger ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--card);
    border-bottom: 3px solid var(--border);
    padding: 0 !important;
    flex-direction: column !important;
    align-items: stretch !important;
}
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem clamp(0.75rem, 3vw, 1.5rem);
    position: relative;
}
.site-header .logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: inherit;
    min-width: 0;
}
.site-header .logo h1 {
    font-size: clamp(0.55rem, 2vw, 0.75rem);
    margin: 0;
}
.site-header .tagline {
    margin: 0.2rem 0 0;
    font-size: 0.9rem;
}
.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    border: 2px solid var(--border);
    background: var(--bg-deep);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
body.light-mode .nav-toggle { background: var(--sand, #e8d4b0); }
.nav-toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--primary);
    transition: transform 0.25s ease, opacity 0.2s ease;
}
body.nav-open .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
body.nav-open .nav-toggle-bar:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}
.site-header .nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
}
.nav-backdrop {
    display: none;
}

@media (max-width: 900px) {
    .nav-toggle { display: flex; }
    .site-header .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0;
        background: var(--card);
        border-bottom: 3px solid var(--border);
        box-shadow: 0 12px 24px rgba(0,0,0,0.35);
        padding: 0.5rem;
        max-height: min(70vh, 480px);
        overflow-y: auto;
        z-index: 1001;
    }
    body.nav-open .site-header .nav { display: flex; }
    .site-header .nav-item {
        width: 100%;
        text-align: left;
        padding: 0.75rem 0.85rem;
        border-width: 2px;
    }
    .nav-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        z-index: 999;
        border: none;
    }
    .nav-backdrop[hidden] { display: none; }
}

@media (min-width: 901px) {
    .header-bar {
        flex-wrap: wrap;
    }
    .site-header .nav {
        width: 100%;
        margin-top: 0.35rem;
        padding-top: 0.5rem;
        border-top: 1px solid var(--border);
    }
}

/* Wallet sign-in modal */
.hm-wallet-modal {
    position: fixed;
    inset: 0;
    z-index: 10050;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.hm-wallet-modal.open { display: flex; }
.hm-wallet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.6);
}
.hm-wallet-dialog {
    position: relative;
    z-index: 1;
    width: min(400px, 100%);
    background: var(--card);
    border: 3px solid var(--border);
    box-shadow: 8px 8px 0 rgba(0,0,0,0.35);
    padding: 1.25rem;
}
.hm-wallet-dialog h3 {
    font-family: var(--pixel);
    font-size: 0.6rem;
    color: var(--accent-glow);
    margin-bottom: 0.75rem;
}
.hm-wallet-dialog p {
    font-family: var(--pixel-body);
    font-size: 1.1rem;
    color: var(--muted);
    margin-bottom: 0.75rem;
    line-height: 1.35;
}
.hm-wallet-steps {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    font-family: var(--pixel-body);
    font-size: 1.05rem;
    color: var(--text);
}
.hm-wallet-steps li {
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--border);
}
.hm-wallet-steps li.is-done { color: var(--primary); }
.hm-wallet-steps li.is-active { color: var(--accent-glow); }
.hm-wallet-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.hm-wallet-status {
    min-height: 1.3em;
    margin-top: 0.75rem;
    font-family: var(--pixel-body);
    font-size: 1rem;
    color: var(--muted);
}
.hm-wallet-status.is-error { color: var(--danger, #e85d5d); }

/* Nav wallet button */
.nav-wallet {
    cursor: pointer;
    font-family: inherit;
    appearance: none;
    background: var(--bg-deep);
    border: 2px solid var(--primary) !important;
    color: var(--primary) !important;
}
body.light-mode .nav-wallet { background: var(--sand, #e8d4b0); }
.nav-wallet.is-signed {
    border-color: var(--border) !important;
    color: var(--muted) !important;
    cursor: default;
}
.grid-source-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}
.grid-source-tabs button {
    font-family: var(--pixel);
    font-size: 0.38rem;
    padding: 0.45rem 0.55rem;
    border: 2px solid var(--border);
    background: var(--card);
    color: var(--text);
    cursor: pointer;
}
.grid-source-tabs button.is-active {
    border-color: var(--primary);
    color: var(--primary);
}
.staking-soon {
    max-width: 560px;
    margin: 2rem auto;
    text-align: center;
    border: 3px solid var(--border);
    background: var(--card);
    padding: 2rem 1.5rem;
}
.staking-soon h2 {
    font-family: var(--pixel);
    font-size: 0.85rem;
    color: var(--accent-glow);
    margin-bottom: 0.75rem;
}
.staking-soon .joke {
    font-family: var(--pixel-body);
    font-size: 1.25rem;
    color: var(--primary);
    margin: 1rem 0;
}
.staking-soon p {
    font-family: var(--pixel-body);
    font-size: 1.15rem;
    color: var(--muted);
}

.nav-item.nav-wallet {
    cursor: pointer;
    background: var(--bg-deep);
    border: 2px solid var(--border);
    color: var(--primary);
    font-family: var(--pixel);
    font-size: 0.4rem;
}
.nav-item.nav-wallet.is-signed {
    color: var(--accent-glow);
    cursor: default;
}


/* ===== Collector Card Modal ===== */
body.hmc-open { overflow: hidden; }
#hmCollectorRoot {
  display: none;
  position: fixed; inset: 0; z-index: 10050;
  align-items: center; justify-content: center;
  padding: 1rem;
}
#hmCollectorRoot.is-open { display: flex; }
.hmc-backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 10, 4, 0.82);
  backdrop-filter: blur(4px);
}
.hmc-dialog {
  position: relative; z-index: 1;
  width: min(420px, 100%);
  max-height: min(88vh, 900px);
  overflow: auto;
}
.hmc-close {
  position: absolute; top: 0.35rem; right: 0.35rem; z-index: 3;
  width: 36px; height: 36px; border: 2px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
  font-size: 1.25rem; line-height: 1;
}
.hmc-close:hover { border-color: var(--primary); color: var(--primary); }
.hmc-loading {
  text-align: center; font-family: var(--pixel); font-size: 0.45rem;
  color: var(--muted); padding: 1rem;
}
.hmc-card {
  position: relative;
  border: 3px solid var(--border);
  background: var(--card);
  --hmc-glow: #6b8e6b;
  animation: hmcBorderPulse 2.4s ease-in-out infinite;
}
.hmc-card-inner { padding: 0 0 0.75rem; position: relative; z-index: 1; }

/* Outer pulse rings */
.hmc-card::before,
.hmc-card::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 2px solid var(--hmc-glow);
  pointer-events: none;
  opacity: 0;
  z-index: 0;
  animation: hmcRingPulse 2.4s ease-out infinite;
}
.hmc-card::after {
  animation-delay: 1.2s;
}
@keyframes hmcBorderPulse {
  0%, 100% {
    box-shadow:
      0 0 0 0 color-mix(in srgb, var(--hmc-glow) 0%, transparent),
      0 0 12px color-mix(in srgb, var(--hmc-glow) 35%, transparent),
      inset 0 0 12px color-mix(in srgb, var(--hmc-glow) 12%, transparent);
  }
  50% {
    box-shadow:
      0 0 0 4px color-mix(in srgb, var(--hmc-glow) 18%, transparent),
      0 0 28px color-mix(in srgb, var(--hmc-glow) 55%, transparent),
      inset 0 0 18px color-mix(in srgb, var(--hmc-glow) 22%, transparent);
  }
}
@keyframes hmcRingPulse {
  0% { inset: -2px; opacity: 0.7; }
  100% { inset: -18px; opacity: 0; }
}

/* Tier bar — electric */
.hmc-tier-bar {
  position: relative;
  overflow: hidden;
  font-family: var(--pixel); font-size: 0.42rem; letter-spacing: 0.14em;
  text-align: center; padding: 0.65rem 0.5rem; color: #0a120a;
  background: var(--muted);
  text-shadow: 0 0 8px rgba(255,255,255,0.35);
  isolation: isolate;
}
.hmc-tier-bar::before {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    90deg,
    transparent 0,
    transparent 3px,
    rgba(255,255,255,0.07) 3px,
    rgba(255,255,255,0.07) 4px
  );
  opacity: 0.5;
  pointer-events: none;
  z-index: 0;
}
.hmc-tier-bar::after {
  content: '';
  position: absolute;
  top: 0; left: -40%;
  width: 40%; height: 100%;
  background: linear-gradient(
    100deg,
    transparent 0%,
    rgba(255,255,255,0.15) 40%,
    rgba(255,255,255,0.85) 50%,
    rgba(255,255,255,0.15) 60%,
    transparent 100%
  );
  animation: hmcElectricSweep 2.2s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}
@keyframes hmcElectricSweep {
  0% { left: -45%; opacity: 0; }
  15% { opacity: 1; }
  50% { left: 110%; opacity: 1; }
  51%, 100% { left: 110%; opacity: 0; }
}

/* Flicker spark on tier text */
.hmc-tier-bar {
  animation: hmcElectricFlicker 3.5s steps(2, end) infinite;
}
@keyframes hmcElectricFlicker {
  0%, 92%, 100% { filter: brightness(1); }
  93% { filter: brightness(1.35) saturate(1.4); }
  94% { filter: brightness(0.92); }
  96% { filter: brightness(1.25); }
}

.hmc-art-wrap {
  margin: 0.75rem auto 0; width: min(280px, 72%);
  aspect-ratio: 1; border: 2px solid var(--border);
  background: var(--bg-deep); overflow: hidden;
}
body.light-mode .hmc-art-wrap { background: #e8d4b0; }
.hmc-art-wrap img {
  width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated; display: block;
}
.hmc-meta { text-align: center; padding: 0.75rem 1rem 0.35rem; }
.hmc-meta h3 {
  font-family: var(--pixel); font-size: 0.62rem; color: var(--accent-glow);
  margin: 0 0 0.45rem; line-height: 1.35;
}
.hmc-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; justify-content: center; margin-bottom: 0.35rem; }
.hmc-badge {
  font-family: var(--pixel); font-size: 0.38rem;
  padding: 0.3rem 0.5rem; border: 2px solid currentColor;
}
.hmc-badge-muted { color: var(--muted); border-color: var(--border); }
.hmc-sub {
  font-family: var(--pixel-body); font-size: 1rem; color: var(--muted); margin: 0;
}
.hmc-traits {
  margin: 0.5rem 0.85rem 0;
  border-top: 1px solid var(--border);
}
.hmc-trait-row {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr 0.85fr;
  gap: 0.35rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  font-family: var(--pixel-body); font-size: 1.05rem;
  color: var(--text);
}
.hmc-t-layer { color: var(--muted); }
.hmc-t-val { color: var(--text); font-weight: 600; }
.hmc-t-stat { text-align: right; color: var(--primary); font-variant-numeric: tabular-nums; }
.hmc-trait-row.is-rarest .hmc-t-val { color: var(--accent-glow); }
.hmc-trait-row.is-rarest .hmc-t-stat { color: var(--accent-glow); }
.hmc-foot {
  text-align: center; margin-top: 0.65rem;
  font-family: var(--pixel); font-size: 0.36rem; color: var(--muted);
}
.hmc-actions {
  display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center;
  margin-top: 0.85rem;
}

/* Tier skins + glow color */
.hmc-card[data-tier="common"] {
  --hmc-glow: #6b8e6b;
  border-color: #5a7a5a;
}
.hmc-card[data-tier="common"] .hmc-tier-bar {
  background: linear-gradient(90deg, #4a6a4a, #7aaa7a, #4a6a4a);
  background-size: 200% 100%;
  animation: hmcElectricFlicker 3.5s steps(2, end) infinite, hmcBarShift 4s linear infinite;
}
.hmc-card[data-tier="common"] #hmcTier { color: #8fbc8f; }

.hmc-card[data-tier="uncommon"] {
  --hmc-glow: #4a9eb8;
  border-color: #3a8aa0;
}
.hmc-card[data-tier="uncommon"] .hmc-tier-bar {
  background: linear-gradient(90deg, #2a6a80, #5ec0d8, #2a6a80);
  background-size: 200% 100%;
  animation: hmcElectricFlicker 3.2s steps(2, end) infinite, hmcBarShift 3.5s linear infinite;
}
.hmc-card[data-tier="uncommon"] #hmcTier { color: #6ec8e0; }

.hmc-card[data-tier="rare"] {
  --hmc-glow: #9b6bff;
  border-color: #8a5cff;
}
.hmc-card[data-tier="rare"] .hmc-tier-bar {
  background: linear-gradient(90deg, #5a30b0, #b08cff, #5a30b0);
  background-size: 200% 100%;
  animation: hmcElectricFlicker 2.8s steps(2, end) infinite, hmcBarShift 3s linear infinite;
}
.hmc-card[data-tier="rare"] #hmcTier { color: #c4a8ff; }

.hmc-card[data-tier="legendary"] {
  --hmc-glow: #e8c84a;
  border-color: #e8c84a;
}
.hmc-card[data-tier="legendary"] .hmc-tier-bar {
  background: linear-gradient(90deg, #8a6a10, #ffe08a, #e8c84a, #8a6a10);
  background-size: 220% 100%;
  animation: hmcElectricFlicker 2.4s steps(2, end) infinite, hmcBarShift 2.5s linear infinite;
  color: #1a1200;
}
.hmc-card[data-tier="legendary"] #hmcTier { color: #e8c84a; }

@keyframes hmcBarShift {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .hmc-card,
  .hmc-card::before,
  .hmc-card::after,
  .hmc-tier-bar,
  .hmc-tier-bar::after {
    animation: none !important;
  }
}

/* =========================================================
   UX / Responsive system — toolbars, sticky actions, density
   ========================================================= */

.page-title {
  margin-bottom: 0.75rem;
}

/* Compact filter / control toolbar (gallery + reusable) */
.ux-toolbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border: 2px solid var(--border);
  background: var(--card);
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}
body.light-mode .ux-toolbar {
  box-shadow: 0 8px 20px rgba(90,70,40,0.12);
}
.ux-toolbar-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.55rem 0.65rem;
}
.ux-toolbar-traits {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem 0.65rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}
.ux-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 120px;
}
.ux-field-grow {
  flex: 1 1 180px;
  min-width: min(100%, 180px);
}
.ux-field label {
  font-family: var(--pixel);
  font-size: 0.36rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}
.ux-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
}
.ux-results {
  margin-bottom: 0.85rem;
}

/* Legacy .filters also densified if still used elsewhere */
.filters {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem 0.65rem;
  align-items: end;
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--card);
  border: 2px solid var(--border);
  padding: 0.65rem;
  margin-bottom: 0.85rem;
}
.filters .form-group {
  margin: 0 !important;
}
.filters .btn,
.filters .btn-secondary {
  width: auto;
  align-self: end;
}

/* Tool pages: sticky action footer on mobile, sticky sidebar controls on desktop */
.tool-layout {
  align-items: start;
}
.tool-layout .sidebar {
  position: sticky;
  top: 0.75rem;
  max-height: calc(100vh - 1.5rem);
  overflow-y: auto;
  padding-bottom: 0.5rem;
}
.tool-layout .canvas-area {
  min-width: 0;
}

/* Sticky primary actions inside sidebars */
.sidebar .btn-group,
.gm-btn-stack,
.np-btn-stack,
.tray-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
  background: linear-gradient(to top, var(--card) 70%, transparent);
}

/* Main content breathing room under fixed header */
.main {
  padding-bottom: 5.5rem;
}
@media (min-width: 901px) {
  .main { padding-bottom: 2rem; }
}

/* Mobile floating action dock for tools with a primary CTA */
.ux-mobile-dock {
  display: none;
}
@media (max-width: 900px) {
  .tool-layout {
    grid-template-columns: 1fr !important;
  }
  .tool-layout .sidebar {
    position: relative;
    top: auto;
    max-height: none;
    order: 2;
  }
  .tool-layout .canvas-area {
    order: 1;
  }
  /* Preview first, controls second — less scroll for result-focused tasks */
  .ux-mobile-dock {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    gap: 0.4rem;
    padding: 0.55rem 0.75rem calc(0.55rem + env(safe-area-inset-bottom, 0px));
    background: var(--card);
    border-top: 2px solid var(--border);
    box-shadow: 0 -6px 20px rgba(0,0,0,0.25);
  }
  .ux-mobile-dock .btn {
    flex: 1;
    text-align: center;
  }
}

/* Gallery grid density */
.gallery-grid {
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 0.65rem;
}
@media (min-width: 700px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}
@media (max-width: 480px) {
  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.45rem;
  }
  .ux-toolbar-actions {
    margin-left: 0;
    width: 100%;
  }
  .ux-toolbar-actions .btn {
    flex: 1;
  }
}

/* Forms: tighter vertical rhythm */
.sidebar .form-group {
  margin-bottom: 0.65rem;
}
.sidebar h3 {
  margin-top: 0.35rem;
}

/* Header nav: already hamburger — ensure tools don't overflow */
@media (max-width: 900px) {
  .header-bar {
    flex-wrap: nowrap;
  }
}

/* Grid / name picker workspaces: stack cleanly */
.gm-layout,
.np-layout {
  align-items: start;
}
@media (min-width: 901px) {
  .gm-sidebar,
  .np-sidebar {
    position: sticky;
    top: 0.75rem;
    max-height: calc(100vh - 1.5rem);
    overflow-y: auto;
  }
}
@media (max-width: 900px) {
  .gm-layout,
  .np-layout {
    grid-template-columns: 1fr !important;
  }
  .gm-workspace,
  .np-stage {
    order: -1;
  }
}

/* Load more stays reachable without hunting */
#btnMore {
  min-width: 160px;
}
