:root {
    /* Color Palette - Premium Dark Theme */
    --bg-dark: #0f1115;
    --bg-panel: rgba(22, 25, 30, 0.6);
    --bg-panel-hover: rgba(30, 35, 43, 0.8);
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-glass-light: rgba(255, 255, 255, 0.15);

    --text-main: #f0f2f5;
    --text-muted: #9aa0a6;

    --accent-primary: #8a2be2;
    --accent-color: #8a2be2;
    --accent-secondary: #ff3366;
    --accent-secondary-rgb: 255, 51, 102;
    --accent-gradient: linear-gradient(135deg, #8a2be2, #ff3366);
    --accent-gradient-hover: linear-gradient(135deg, #9b4dff, #ff5c8a);

    --success: #2ecc71;
    --warning: #f1c40f;
    --danger: #e74c3c;

    /* Morphs Tag Colors */
    --tag-base: #34495e;
    --tag-dominant: #9b59b6;
    --tag-codominant: #e67e22;
    --tag-recessive: #3498db;

    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Shadows & Effects */
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --blur-glass: blur(12px);

    --transition-fast: 0.2s ease;
    --transition-smooth: 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow: hidden;
    /* App-like feel, scroll inside panels */
    background-image:
        radial-gradient(circle at 15% 50%, rgba(138, 43, 226, 0.08), transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(255, 51, 102, 0.08), transparent 25%);
}

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

/* 布局 Layout */
.app-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 260px;
    background: rgba(15, 17, 21, 0.8);
    backdrop-filter: var(--blur-glass);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    z-index: 10;
}

.brand {
    padding: 0 24px 32px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand .logo-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 8px rgba(138, 43, 226, 0.6));
}

.brand h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.brand span {
    color: var(--accent-secondary);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
}

.nav-links li {
    padding: 12px 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition-fast);
}

.nav-links li:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.nav-links li.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(138, 43, 226, 0.3);
}

.stats-card {
    margin: auto 20px 0;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
}

.stats-card h3 {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 12px;
    letter-spacing: 1px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 6px;
    font-weight: 500;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.topbar {
    height: 70px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-glass);
}

.topbar h2 {
    font-weight: 400;
    font-size: 24px;
}

.actions {
    display: flex;
    gap: 12px;
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: var(--shadow-glass);
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

.btn-primary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--border-glass-light);
}

.btn-primary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.2);
}

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

.btn-outline:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.05);
}

.btn-gradient {
    background: var(--accent-gradient);
    color: white;
    border: none;
}

.btn-gradient:hover:not(:disabled) {
    background: var(--accent-gradient-hover);
    box-shadow: 0 4px 15px rgba(255, 51, 102, 0.4);
}

.btn-jumbo {
    padding: 16px 32px;
    font-size: 18px;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-x {
    background-color: #000000;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-x:hover:not(:disabled) {
    background-color: #222222;
    border-color: rgba(255, 255, 255, 0.4);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: white;
    border: 1px solid var(--border-glass);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
}

.btn-download {
    background: rgba(76, 175, 80, 0.15);
    color: #81c784;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.btn-download:hover:not(:disabled) {
    background: rgba(76, 175, 80, 0.25);
    border-color: rgba(76, 175, 80, 0.5);
}

/* Views Container */
.views-wrapper {
    flex: 1;
    position: relative;
    padding: 32px;
    overflow-y: auto;
}

.view-panel {
    display: none;
    height: 100%;
    animation: fadeIn 0.3s ease;
}

.view-panel.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Rack Grid */
.rack-grid,
.incubator-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
    padding: 24px;
    min-height: 100%;
}

/* Market Grid */
.market-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.market-item {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 16px;
}

.market-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.market-item-header h4 {
    font-size: 18px;
    font-weight: 700;
}

.market-price {
    font-size: 18px;
    font-weight: 800;
    color: #4CAF50;
}

.market-item-body {
    display: flex;
    gap: 16px;
    align-items: center;
}

.market-visual-mini {
    width: 80px;
    height: 80px;
}

.market-item-footer {
    display: flex;
    gap: 8px;
}

.market-item-footer .btn {
    flex: 1;
}

.mb-4 { margin-bottom: 24px; }
.mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; }
.mt-3 { margin-top: 16px; }
.mt-2 { margin-top: 12px; }

.snake-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    overflow: hidden;
    will-change: transform, opacity;
}

.snake-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent-gradient);
    opacity: 0;
    transition: var(--transition-fast);
}

.snake-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-glass-light);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.snake-card:hover::before {
    opacity: 1;
}

.snake-card-visual {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 12px;
    flex-shrink: 0;
}

.snake-card-visual svg {
    width: 100%;
    height: auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
    transition: var(--transition-smooth);
}

.snake-card:hover .snake-card-visual svg {
    transform: scale(1.05);
}

.snake-card-info {
    width: 100%;
    text-align: center;
    flex-shrink: 0;
}

.snake-card-info h4 {
    font-size: 16px;
    margin-bottom: 4px;
    word-break: break-word;
    /* モルフ名が長い場合に折り返す */
}

.snake-card-info p {
    font-size: 12px;
    color: var(--text-muted);
}

.gender-icon {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 13px;
    font-weight: 600;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    padding: 2px 8px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.gender-m {
    color: #3498db;
}

.gender-f {
    color: #e74c3c;
}

/* Breeder Layout */
.breeder-layout {
    display: flex;
    justify-content: center;
    align-items: stretch;
    /* Change from center to avoid vertical clipping */
    gap: 40px;
    min-height: 100%;
    padding: 20px 0;
    max-width: 1000px;
    margin: 0 auto;
    flex-wrap: wrap;
    /* Add wrap so it stacks nicely on small screens */
}

.parent-slot {
    flex: 1;
    max-width: 320px;
    min-height: 400px;
    height: auto;
    display: flex;
    flex-direction: column;
}

.slot-header {
    background: rgba(0, 0, 0, 0.2);
    padding: 16px;
    text-align: center;
    font-weight: 600;
    font-family: var(--font-heading);
    border-bottom: 1px solid var(--border-glass);
}

.slot-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    position: relative;
    cursor: pointer;
    transition: var(--transition-fast);
}

.slot-content:hover {
    background: rgba(255, 255, 255, 0.02);
}

.empty-state {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    border: 2px dashed var(--border-glass);
    border-radius: 12px;
    padding: 30px;
    width: 100%;
}

.breed-action-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.heart-pulse {
    font-size: 40px;
    animation: pulse 1.5s infinite;
    text-shadow: 0 0 20px rgba(255, 51, 102, 0.5);
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

.breed-odds-preview {
    font-size: 13px;
    color: var(--text-muted);
    text-align: center;
    min-width: 240px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.odds-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-main);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid var(--accent-primary);
    padding-bottom: 4px;
}

.odds-desc {
    font-size: 11px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.odds-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.odds-item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid var(--border-glass);
    transition: var(--transition-fast);
    gap: 12px;
}

.odds-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-glass-light);
}

.odds-visual {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.odds-visual svg {
    width: 100%;
    height: 100%;
}

.mystery-snake svg {
    filter: brightness(0) opacity(0.3) blur(1px) !important;
}

.odds-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.odds-name {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-main);
    text-align: left;
}

.odds-percent {
    color: var(--accent-secondary);
    font-weight: 800;
    font-size: 15px;
    font-family: var(--font-heading);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.jumbo-glass {
    width: 90%;
    max-width: 800px;
    height: auto;
    min-height: 480px;
    max-height: 85vh;
    padding: 0;
    position: relative;
    transform: scale(0.95);
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.selection-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.selection-header {
    padding: 24px 24px 0 24px;
    flex-shrink: 0;
}

.selection-content {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    align-content: start;
}

.modal-overlay.active .jumbo-glass {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 28px;
    cursor: pointer;
    z-index: 2;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.2);
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-secondary);
}

.snake-detail-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

.snake-visual-large {
    flex: 6;
    background: radial-gradient(circle at center, rgba(138, 43, 226, 0.1), transparent 70%);
    display: flex;
    justify-content: center;
    align-items: center;
    border-right: 1px solid var(--border-glass);
}

.snake-visual-large svg {
    width: 80%;
    max-height: 80%;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.4));
}

.snake-info {
    flex: 4;
    padding: 32px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.snake-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.snake-header h2 {
    font-size: 28px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    word-break: break-word;
    line-height: 1.2;
}

.morph-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 24px;
}

.tag {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}

.tag-normal {
    background: var(--tag-base);
    color: white;
}

.tag-dominant {
    background: var(--tag-dominant);
    color: white;
}

.tag-codominant {
    background: var(--tag-codominant);
    color: white;
}

.tag-recessive {
    background: var(--tag-recessive);
    color: white;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 32px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-glass);
}

.stat-box .label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.stat-box .val {
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-heading);
}

.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    flex-shrink: 0;
    margin-top: 16px;
    padding-bottom: 8px;
}

.action-bar .btn {
    flex: 1 1 auto;
    justify-content: center;
    white-space: normal;
    text-align: center;
    line-height: 1.3;
    min-height: 40px;
}

.mt-auto {
    margin-top: auto;
}

/* Utilities */
.text-center {
    text-align: center;
}

/* Scrollbar styling for a premium feel */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* My Rack Controls */
.rack-controls {
    display: flex;
    gap: 24px;
    padding: 16px 24px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-group label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.select-glass,
.input-glass {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    padding: 8px 12px;
    font-family: var(--font-body);
    font-size: 14px;
    outline: none;
    transition: var(--transition-fast);
}

.select-glass:focus,
.input-glass:focus {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.1);
}

.select-glass option {
    background: #1a1d23;
    color: var(--text-main);
}

/* Responsive Design for Mobile Devices */
@media (max-width: 768px) {
    body {
        overflow: auto;
        /* Allow scrolling on mobile if needed */
    }

    .app-container {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
        padding-bottom: 70px;
        /* Space for bottom nav */
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 8px 16px;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        background: rgba(15, 17, 21, 0.9);
        position: sticky;
        top: 0;
        z-index: 100;
    }

    .brand {
        padding: 0;
        margin: 0;
        flex-shrink: 0;
    }

    .brand h1 {
        font-size: 18px;
    }

    .brand .logo-icon {
        font-size: 22px;
    }

    /* Language toggle prominent on mobile */
    #btn-lang-toggle {
        margin-left: auto !important;
        flex-shrink: 0;
        white-space: nowrap;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.2) !important;
        color: white !important;
        font-weight: 700 !important;
    }

    .topbar {
        padding: 12px 16px;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        height: auto;
        gap: 8px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        position: sticky;
        top: 0;
        background: rgba(15, 17, 21, 0.9);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 100;
    }

    /* Stats Card on Mobile: Single horizontal scroll or condensed row */
    .stats-card {
        margin: 0;
        padding: 10px 16px;
        border: none;
        background: rgba(0, 0, 0, 0.3);
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        gap: 16px;
        flex: 1;
        min-width: 0;
        border-bottom: 1px solid var(--border-glass);
        white-space: nowrap;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .stats-card::-webkit-scrollbar {
        display: none;
    }

    .stats-card h3 {
        display: none;
    }

    .stat-row {
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        display: flex;
        gap: 6px;
        font-size: 11px;
    }

    /* Bottom Navigation */
    .nav-links {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 64px;
        flex-direction: row;
        background: rgba(15, 17, 21, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 0;
        margin: 0;
        gap: 0;
        border-top: 1px solid var(--border-glass);
        z-index: 1000;
        border-radius: 0;
    }

    .nav-links li {
        flex: 1;
        height: 100%;
        padding: 0;
        border-radius: 0;
        flex-direction: column;
        justify-content: center;
        gap: 2px;
    }

    .nav-links li.active {
        background: transparent;
        color: var(--accent-secondary);
        box-shadow: none;
    }

    .nav-links li.active .icon {
        transform: scale(1.1);
    }

    .nav-links li .icon {
        font-size: 22px;
        transition: transform 0.2s ease;
    }

    .nav-links li.active .text {
        color: var(--accent-secondary);
    }

    .nav-links li .text {
        font-size: 8px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-muted);
    }

    .main-content {
        overflow: visible;
        height: auto;
    }

    .topbar h2 {
        font-size: 18px;
        font-weight: 800;
        color: var(--text-main);
        margin: 0;
        white-space: nowrap;
    }

    .actions {
        flex: 1;
        overflow-x: auto;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        gap: 8px;
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .actions::-webkit-scrollbar {
        display: none;
    }

    .actions .btn {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 6px 12px;
        font-size: 10px;
        border-radius: 12px;
    }

    .views-wrapper {
        padding: 12px;
    }

    .rack-grid,
    .incubator-grid,
    .market-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
        padding: 0;
    }

    .project-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .rack-controls {
        padding: 12px;
        gap: 12px;
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .breeder-layout {
        flex-direction: column;
        gap: 20px;
    }

    .parent-slot {
        max-width: 100%;
        height: auto;
        min-height: 200px;
    }

    .slot-content .snake-card {
        width: 100%;
        max-width: 250px;
    }

    .jumbo-glass {
        width: 95%;
        max-height: 90vh;
        aspect-ratio: auto;
        flex-direction: column;
        overflow-y: auto;
    }

    .selection-layout {
        height: auto;
    }

    .selection-content {
        overflow-y: visible;
        padding-bottom: 24px;
    }

    .snake-detail-layout {
        flex-direction: column;
        height: auto;
    }

    .snake-visual-large {
        flex: none;
        min-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
    }

    .snake-visual-large svg {
        width: 60%;
    }

    .snake-info {
        padding: 20px;
    }

    .snake-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .snake-header h2 {
        font-size: 24px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .action-bar {
        flex-direction: column;
        gap: 12px;
    }

    .action-bar .btn {
        margin-left: 0 !important;
        width: 100%;
    }

    .market-item {
        padding: 16px;
    }

    .market-item-body {
        flex-direction: column;
        text-align: center;
    }
}

/* Pedigree Tree Styles */
.pedigree-tree-container {
    display: block; /* Change from flex to block to allow internal centering with margin:auto */
    overflow: auto;
    padding: 40px 20px;
    height: 100%;
}

.pedigree-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 50px;
    position: relative;
    width: fit-content;
    margin: 0 auto;
}

.pedigree-generation {
    display: flex;
    justify-content: center;
    position: relative;
}

.pedigree-branch {
    display: flex;
    justify-content: center;
    gap: 60px;
    position: relative;
}

.pedigree-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 140px;
    background: rgba(20, 25, 40, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    position: relative;
}

.pedigree-node:hover {
    transform: translateY(-5px);
    border-color: var(--primary-color);
    box-shadow: 0 10px 40px 0 rgba(255, 87, 87, 0.2);
}

.pedigree-node.active-node {
    border-color: #4da6ff;
    box-shadow: 0 0 20px rgba(77, 166, 255, 0.3);
}

.pedigree-node[data-gender="M"] {
    border-top: 3px solid #4da6ff;
}

.pedigree-node[data-gender="F"] {
    border-top: 3px solid #ff4dff;
}

.pedigree-node.unknown {
    opacity: 0.6;
    border-top: 3px solid #888;
    cursor: default;
}

.pedigree-node.unknown:hover {
    transform: none;
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
}

.pedigree-visual {
    width: 80px;
    height: 80px;
    margin-bottom: 10px;
}

.pedigree-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    text-align: center;
    margin-bottom: 4px;
    word-break: break-word;
}

.pedigree-gen {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
}

/* Connecting lines for the tree */
.pedigree-generation-parents {
    position: relative;
}

.pedigree-generation-parents::after {
    content: '';
    position: absolute;
    top: 50%;
    /* 140px node width + 30px padding = 170px total bounding box. 
       Center of node is exactly 85px from edge */
    left: 85px; 
    right: 85px; 
    height: 2px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 0;
}

.pedigree-node {
    z-index: 1;
}

/* Vertical line from parents down to child */
.pedigree-generation-parents::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 2px;
    height: calc(50% + 50px);
    /* Extends down to the child generation */
    background: rgba(255, 255, 255, 0.2);
    z-index: 0;
}

/* Vertical line from child up to parents */
.pedigree-node.has-parents::before {
    content: '';
    position: absolute;
    top: -50px;
    left: 50%;
    width: 2px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    z-index: 0;
}

/* Breeding Projects */
.view-desc {
    margin-bottom: 24px;
    color: var(--text-muted);
}

.project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.project-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass-light);
    border-radius: 20px;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.project-card:hover {
    border-color: var(--accent-primary);
    background: rgba(255, 255, 255, 0.06);
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
}

.project-status-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 10px;
    font-weight: 800;
    padding: 4px 10px;
    border-radius: 30px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-available {
    background: rgba(52, 152, 219, 0.2);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.4);
}

.status-active {
    background: rgba(241, 196, 15, 0.2);
    color: #f1c40f;
    border: 1px solid rgba(241, 196, 15, 0.4);
    animation: pulse-border 2s infinite;
}

.status-completed {
    background: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.4);
}

@keyframes pulse-border {
    0% {
        border-color: rgba(241, 196, 15, 0.4);
        box-shadow: 0 0 0 0 rgba(241, 196, 15, 0.2);
    }

    50% {
        border-color: rgba(241, 196, 15, 0.8);
        box-shadow: 0 0 0 8px rgba(241, 196, 15, 0);
    }

    100% {
        border-color: rgba(241, 196, 15, 0.4);
        box-shadow: 0 0 0 0 rgba(241, 196, 15, 0);
    }
}

.project-card.completed {
    border-color: #4CAF50;
}

.project-card.completed::after {
    content: 'ACHIEVED';
    position: absolute;
    top: 15px;
    right: -35px;
    background: #4CAF50;
    color: white;
    padding: 4px 40px;
    font-size: 10px;
    font-weight: 800;
    transform: rotate(45deg);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-right: 85px;
    /* Avoid collision with status badge */
}

.project-title {
    font-size: 18px;
    font-weight: bold;
    color: #fff;
}

.project-difficulty {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    font-weight: 800;
}

.project-difficulty.diff-1 {
    color: #4CAF50;
}

.project-difficulty.diff-2 {
    color: #FF9800;
}

.project-difficulty.diff-3 {
    color: #F44336;
}

.project-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

.project-progress-container {
    margin-top: auto;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 6px;
}

.progress-bar-bg {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 4px;
    transition: width 0.8s cubic-bezier(0.17, 0.67, 0.83, 0.67);
}

.project-genes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.gene-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
}

.gene-tag.active {
    background: rgba(76, 175, 80, 0.15);
    color: #81C784;
    border-color: rgba(76, 175, 80, 0.4);
}

.project-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.project-reward {
    font-weight: bold;
    color: #4CAF50;
    font-size: 14px;
}

/* Save Actions Styling */
#btn-export,
#btn-import {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

#btn-export:hover,
#btn-import:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-color);
}

#btn-save {
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.2);
}

/* Welcome / Onboarding */
.welcome-layout {
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.welcome-header h1 {
    background: linear-gradient(135deg, #fff 0%, var(--accent-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.welcome-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin-top: 2rem;
}

@media (min-width: 600px) {
    .welcome-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.welcome-step {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: transform 0.3s ease;
}

.welcome-step:hover {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.06);
}

.welcome-step h3 {
    margin-bottom: 10px;
    color: var(--accent-color);
}

.welcome-step p {
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.8;
}

.btn-jumbo {
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 15px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

/* Welcome Tip or other remaining welcome styles */
.welcome-tip {
    background: rgba(255, 193, 7, 0.1);
    color: #ffc107;
    padding: 8px 15px;
    border-radius: 20px;
    display: inline-block;
    font-size: 0.85rem;
}

.starter-name {
    font-weight: 800;
    font-size: 0.9rem;
    color: var(--text-main);
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* =========================================
   Achievement System
   ========================================= */

/* View Layout */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    padding: 20px;
}

/* Card Styling */
.achievement-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
}

.achievement-card.locked {
    opacity: 0.5;
    filter: grayscale(100%);
}

.achievement-card.unlocked {
    background: rgba(46, 204, 113, 0.05); /* subtle green tint */
    border-color: rgba(46, 204, 113, 0.3);
    box-shadow: 0 4px 15px rgba(46, 204, 113, 0.1);
}

.achievement-card.unlocked::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #2ecc71, #27ae60);
    border-radius: 12px 0 0 12px;
}

/* Icon */
.achi-icon {
    font-size: 36px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 50%;
    flex-shrink: 0;
}

.achievement-card.unlocked .achi-icon {
    background: rgba(255, 215, 0, 0.15); /* Gold bg for unlocked */
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.3);
}

/* Text Content */
.achi-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.achi-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.achievement-card.unlocked .achi-title {
    color: #ffd700; /* Gold title */
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

.achi-desc {
    font-size: 12px;
    color: var(--text-muted);
    margin: 0;
    line-height: 1.4;
}

/* =========================================
   Toast Notifications
   ========================================= */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 15px;
    pointer-events: none; /* Let clicks pass through empty space */
}

.toast {
    background: linear-gradient(135deg, rgba(20, 20, 20, 0.95) 0%, rgba(30, 30, 30, 0.95) 100%);
    border: 1px solid rgba(255, 215, 0, 0.4);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 20px rgba(255, 215, 0, 0.1);
    border-left: 4px solid #ffd700;
    border-radius: 8px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 250px;
    max-width: 350px;
    pointer-events: auto; /* Allow clicking the toast if needed */
    
    /* Animation */
    transform: translateX(120%);
    opacity: 0;
    animation: toastSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.toast.hiding {
    animation: toastSlideOut 0.4s ease-in forwards;
}

.toast-icon {
    font-size: 28px;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.3));
}

.toast-content {
    display: flex;
    flex-direction: column;
}

.toast-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #ffd700;
    margin-bottom: 2px;
    font-weight: 800;
}

.toast-title {
    font-size: 14px;
    color: var(--text-main);
    font-weight: 500;
    margin: 0;
    white-space: pre-line;
    line-height: 1.4;
}

.toast-success { border-color: rgba(46, 204, 113, 0.4); border-left-color: #2ecc71; }
.toast-success .toast-header { color: #2ecc71; }

.toast-warning { border-color: rgba(241, 196, 15, 0.4); border-left-color: #f1c40f; }
.toast-warning .toast-header { color: #f1c40f; }

.toast-error { border-color: rgba(231, 76, 60, 0.4); border-left-color: #e74c3c; }
.toast-error .toast-header { color: #e74c3c; }

@keyframes toastSlideIn {
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toastSlideOut {
    to {
        transform: translateX(120%);
        opacity: 0;
    }
}

/* Adjustments for mobile */
@media (max-width: 768px) {
    .toast-container {
        top: 20px; /* Show at top on mobile as bottom is often blocked by UI/keyboards */
        bottom: auto;
        left: 20px;
        right: 20px;
        align-items: center;
    }
    .toast {
        width: 100%;
        max-width: 100%;
        transform: translateY(-120%);
        animation: toastSlideDown 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    }
    .toast.hiding {
        animation: toastSlideUp 0.4s ease-in forwards;
    }
}

@keyframes toastSlideDown {
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastSlideUp {
    to { transform: translateY(-120%); opacity: 0; }
}
/* Market Complex Sections */
.complex-section-header {
    grid-column: 1 / -1;
    margin-top: 48px;
    margin-bottom: 24px;
    padding: 28px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0.02) 100%);
    border-left: 6px solid var(--accent-primary);
    border-radius: 16px;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.complex-section-header:hover {
    transform: translateX(4px);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.03) 100%);
}

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

.complex-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent-primary);
    margin: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.complex-badge {
    padding: 6px 14px;
    background: rgba(var(--accent-secondary-rgb), 0.2);
    border: 1px solid var(--accent-secondary);
    color: var(--accent-secondary);
    border-radius: 30px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.complex-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
    max-width: 900px;
    margin: 0;
}

/* Ensure the first header doesn't have too much top margin */
.market-grid h3:first-of-type,
.market-grid .complex-section-header:first-of-type {
    margin-top: 16px;
}
