@import url('https://fonts.googleapis.com/css2?family=Comic+Neue:wght@400;700&display=swap');

@font-face {
    font-family: 'Comic Sans Fallback';
    src: local('Comic Sans MS'),
         local('Comic Sans'),
         local('Balsamiq Sans'),
         local('Patrick Hand'),
         local('Architects Daughter'),
         local('Chalkboard SE'),
         local('Comic Neue');
    font-display: swap;
}

body, button, div, p, h1, h2, h3, h4, h5, h6, input, textarea, select, option {
    font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', 'Comic Sans Fallback', 'Balsamiq Sans', 'Patrick Hand', 'Architects Daughter', 'Chalkboard SE', cursive !important;
}

:root {
    --primary-blue: #2196f3;
    --secondary-blue: #64b5f6;
    --dark-blue: #1976d2;
    /* popup shadow variables: highlight and drop shadow colors */
    --popup-highlight: rgba(255,255,255,0.85);
    --popup-shadow: rgba(0,0,0,0.18);
    /* panel/background variables for boxed containers like games */
    --panel-bg-start: #f9fcff;
    --panel-bg-mid: #fef7ff;
    --panel-bg-end: #f5fbff;
    --panel-accent-a: rgba(170,225,255,0.35);
    --panel-accent-b: rgba(255,188,255,0.32);
    --panel-border: rgba(150,200,255,0.45);
    --panel-shadow: rgba(33,150,243,0.14);
    --panel-inset: rgba(255,255,255,0.9);
    /* text color to use on top of panel-accent backgrounds (ensure contrast) */
    --panel-accent-contrast: #073044;
    /* default peg color for Plinko (can be overridden by themes) */
    --peg-color: #bdbdbd;
}

/* Remove the "I'm Broke" button across games pages */
#broke-button { display: none !important; }

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


body {
    font-family: 'Comic Sans MS', 'Comic Sans', 'Comic Neue', 'Comic Sans Fallback', 'Balsamiq Sans', 'Patrick Hand', 'Architects Daughter', 'Chalkboard SE', cursive;
    background-color: #e0f7fa;
    position: relative;
}

.evil-fire-backdrop {
    position: fixed;
    inset: 0;
    background-image: url('../src/fire.gif');
    background-size: cover;
    background-position: center;
    opacity: 0.25;
    pointer-events: none;
    z-index: 0;
}

.poll-page-body {
    min-height: 100vh;
    background: linear-gradient(180deg, #eaf5ff 0%, #fef6ff 55%, #fff9f1 100%);
    font-family: 'Comic Sans MS', 'Comic Sans', cursive;
}

.poll-page-body header {
    position: static;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: linear-gradient(#e7effa, #d1e2ff);
    border-bottom: 1px solid rgba(159, 177, 221, 0.6);
    padding: 20px 10px;
}

/* (poll nav styling moved to polls.css via .poll-nav-tray / .poll-nav-group / .poll-nav-btn) */

.poll-page-body .poll-page {
    margin-top: 0;
}

.poll-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 40px 20px 80px;
    display: flex;
    flex-direction: column;
    gap: 48px;
}

.poll-hero {
    display: flex;
    flex-wrap: wrap;
    gap: 32px;
    align-items: stretch;
    background: #ffffff;
    border-radius: 24px;
    padding: 30px;
    border: 1px solid rgba(155, 178, 216, 0.6);
    box-shadow: 0 14px 32px rgba(27, 40, 56, 0.18);
    position: relative;
    overflow: hidden;
}

.poll-hero::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 30% 20%, rgba(255, 170, 255, 0.25), transparent 55%),
        radial-gradient(circle at 70% 0%, rgba(162, 209, 255, 0.3), transparent 50%);
    pointer-events: none;
    mix-blend-mode: screen;
}

.poll-hero .eyebrow,
.poll-vote .eyebrow,
.poll-leaderboard .eyebrow,
.poll-history .eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.85rem;
    color: #0d7c8f;
    margin-bottom: 8px;
}

.poll-hero-card {
    flex: 1 1 260px;
    background: linear-gradient(135deg, #8df2ff, #6fd6ff, #6ce1c8);
    color: #0a2d3c;
    border-radius: 20px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 180px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.4);
    text-shadow: 0 1px 0 rgba(255,255,255,0.6);
}

.poll-hero-card .label {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.75rem;
    opacity: 0.8;
}

.poll-hero-card .score {
    font-size: 1.2rem;
    margin-top: 8px;
    color: #043246;
}

.poll-countdown {
    margin-top: 18px;
    font-weight: 600;
    color: #4a235a;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.ghost-btn {
    border: 1px dashed rgba(22, 125, 146, 0.7);
    background: rgba(255, 255, 255, 0.85);
    padding: 10px 18px;
    border-radius: 18px;
    cursor: pointer;
    font-weight: 600;
    color: #0b5468;
    transition: transform 0.1s ease, background 0.2s ease;
    box-shadow: 0 4px 0 rgba(4, 83, 101, 0.2);
}

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

.poll-options-container {
    max-height: 600px;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 8px;
    margin-top: 20px;
}

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

.poll-option-card {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 12px 32px rgba(36, 4, 52, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid rgba(159, 177, 221, 0.4);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.poll-option-card:hover {
    transform: translateY(-4px);
    border-color: rgba(169, 60, 230, 0.4);
}

.poll-option-card.selected {
    border-color: #a93ce6;
    box-shadow: 0 16px 36px rgba(169, 60, 230, 0.25);
}

.poll-option-media img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    display: block;
}

.poll-option-placeholder {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(45deg, #eef2ff 0 14px, #fbe5ff 14px 28px);
    color: #0d5f74;
    font-weight: 600;
}

.poll-option-content {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.poll-option-content h4 {
    margin: 0;
}

.poll-name-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.wiki-link {
    display: inline-flex;
    align-items: center;
    color: #0ba7c1;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.1s ease;
    text-decoration: none;
}

.wiki-link:hover {
    opacity: 1;
    transform: translateY(-1px);
}

.wiki-link svg {
    width: 16px;
    height: 16px;
}

.poll-option-content .pitch {
    color: #5f5b6b;
    font-size: 0.95rem;
}

.poll-option-content .votes {
    font-weight: 600;
    color: #0c748c;
}

.poll-option-content .primary-btn {
    border: 1px solid #0ba7c1;
    border-radius: 14px;
    padding: 9px 15px;
    background: linear-gradient(90deg, #ffe0ff, #f9d7ff);
    color: #0b5468;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 0 rgba(91, 43, 120, 0.2);
}

.poll-option-content .primary-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    box-shadow: none;
}

.poll-option-content .primary-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.poll-leaderboard-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(27, 40, 56, 0.12);
    border: 1px solid rgba(159, 177, 221, 0.5);
}

.poll-leaderboard-list li {
    display: grid;
    grid-template-columns: 60px 1fr 80px;
    padding: 14px 18px;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.poll-leaderboard-list li:last-child {
    border-bottom: none;
}

.poll-leaderboard-list .rank {
    font-weight: 700;
    color: #0ba7c1;
}

.poll-history {
    max-width: 1100px;
    margin: 0 auto 40px;
    padding: 0 20px 40px;
}

.poll-history-tally {
    list-style: none;
    margin: 20px 0 0;
    padding: 0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(27, 40, 56, 0.12);
    overflow: hidden;
    border: 1px solid rgba(159, 177, 221, 0.5);
}

.poll-history-tally li {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    background: linear-gradient(90deg, rgba(255,255,255,1), rgba(249,246,255,0.7));
}

.poll-history-tally li:last-child {
    border-bottom: none;
}

.poll-history-tally .placeholder {
    grid-template-columns: 1fr;
    text-align: center;
    color: #7a6f84;
}

.history-date {
    font-weight: 600;
    color: #0c5a70;
}

.history-name {
    font-weight: 600;
    color: #0ba7c1;
}

.placeholder {
    color: #7a6f84;
}

.poll-footer {
    text-align: center;
    padding: 40px 20px;
    color: #6c5c7a;
}

.poll-info-overlay {
    position: fixed;
    inset: 0;
    background: rgba(19, 18, 38, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(2px);
}

.poll-info-panel {
    width: min(420px, 90vw);
    background: linear-gradient(160deg, #ffffff, #f5f0ff);
    border: 1px solid rgba(159, 177, 221, 0.8);
    border-radius: 20px;
    box-shadow: 0 25px 60px rgba(12, 17, 33, 0.35);
    padding: 28px;
    position: relative;
    color: #1b2a3b;
    font-family: 'Comic Sans MS', 'Comic Sans', cursive;
}

.poll-info-panel h2 {
    margin-bottom: 10px;
}

.poll-info-panel .lead {
    font-size: 1rem;
    margin-bottom: 14px;
    color: #3a3860;
}

.poll-info-panel ul {
    padding-left: 18px;
    margin: 0 0 14px;
    color: #443c6b;
}

.poll-info-panel li + li {
    margin-top: 6px;
}

.poll-info-panel .meta {
    font-size: 0.9rem;
    color: #5a5c80;
}

.poll-info-close {
    position: absolute;
    top: 10px;
    right: 12px;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    color: #5a5c80;
    cursor: pointer;
}

.poll-toast {
    position: fixed;
    bottom: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 12px 20px;
    border-radius: 999px;
    box-shadow: 0 18px 28px rgba(0,0,0,0.12);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s ease, bottom 0.2s ease;
    z-index: 2000;
}

.poll-toast.visible {
    opacity: 1;
    bottom: 28px;
}

.poll-toast.success { color: #1d8348; }
.poll-toast.error { color: #c0392b; }

@media (max-width: 720px) {
    .poll-hero {
        flex-direction: column;
    }

    .section-heading {
        flex-direction: column;
        align-items: flex-start;
    }

    .poll-leaderboard-list li {
        grid-template-columns: 40px 1fr 60px;
    }
}

body.evilized::after {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 25% 20%, rgba(255, 140, 140, 0.6), transparent 55%),
        radial-gradient(circle at 75% 10%, rgba(255, 80, 80, 0.46), transparent 50%),
        linear-gradient(180deg, rgba(255, 25, 25, 0.78), rgba(70, 0, 0, 0.88));
    pointer-events: none;
    z-index: 1500;
    mix-blend-mode: multiply;
}


header {
    background: linear-gradient(135deg, #2196f3, #64b5f6);
    color: white;
    padding: 8px 10px;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; 
}

.header-scroll-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: max-content;
    min-width: 100%;
}

/* Default: expanded 2-row layout */
.header-row-top {
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
}

.header-row-bottom {
    display: flex;
    align-items: center;
    width: max-content;
}

/* Toggle bar — always visible, below scroll-row, doesn't scroll */
.header-row-toggle {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    padding: 2px 0;
    cursor: pointer;
    user-select: none;
    flex-shrink: 0;
}

.header-row-toggle .toggle-pill {
    width: 32px;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.35);
    transition: background 0.2s ease, width 0.2s ease;
}

.header-row-toggle:hover .toggle-pill {
    background: rgba(255, 255, 255, 0.6);
    width: 40px;
}

/* Collapsed: merge everything into 1 scrollable row */
header.header-collapsed .header-scroll-row {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

header.header-collapsed .header-row-top,
header.header-collapsed .header-row-bottom {
    display: contents;
}



/* Nav buttons base style (now outside .button-tray) */
.button-group.nav a.nav-btn {
    flex: 0 0 auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    background-color: white;
    color: #2196f3;
    border: 2px solid #2196f3;
    border-radius: 25px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    white-space: nowrap;
    text-decoration: none;
    display: inline-block;
}

.button-group.nav a.nav-btn:hover {
    background-color: #2196f3;
    color: white;
}

/* Volume Bar */
.volume-bar-container {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-width: 200px;
    text-align: center;
    animation: slideDown 0.3s ease-out;
}

.volume-bar-label {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    font-weight: 500;
}

.volume-bar-track {
    width: 100%;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.volume-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a, #ffeb3b, #ff9800, #f44336);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Mobile adjustments for volume bar */
@media (max-width: 768px) {
    .volume-bar-container {
        top: 70px;
        min-width: 160px;
        padding: 6px 12px;
    }
    
    .volume-bar-label {
        font-size: 10px;
    }
    
    .volume-bar-track {
        height: 5px;
    }
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
}

.modal .modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    border-radius: 10px;
    background: linear-gradient(180deg,
        var(--panel-bg-start, rgba(255,255,255,0.98)) 0%,
        var(--panel-bg-mid, rgba(245,245,245,0.95)) 50%,
        var(--panel-bg-end, rgba(235,235,235,0.92)) 100%);
    color: var(--ink, #1b2838);
    border: 2px solid var(--panel-border, rgba(0,0,0,0.05));
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

/* Music modal */
.music-modal-shell {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 12px;
}

.music-now {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--panel-border, #dfe6f1);
    border-radius: 12px;
    background: var(--panel-bg-start, #f5f8ff);
    color: var(--ink, #1b2838);
}

.music-volume {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--panel-border, #dfe6f1);
    border-radius: 12px;
    background: linear-gradient(135deg, var(--panel-bg-start, #f5f8ff), var(--panel-bg-mid, #eef3fb));
    color: var(--ink, #1b2838);
}

.music-volume-label {
    font-weight: 700;
    min-width: 60px;
}

.music-volume-control {
    flex: 1;
    height: 6px;
    accent-color: var(--accent, #64b5f6);
}

.music-volume-value {
    min-width: 40px;
    text-align: right;
    font-weight: 700;
    color: var(--ink, #1b2838);
}

.music-art {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    background: var(--accent, #1d2a44);
    color: var(--panel-accent-contrast, #f2f7ff);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 22px;
    box-shadow: 0 6px 18px var(--panel-shadow, rgba(29, 42, 68, 0.25));
}

.music-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.music-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--ink, #1b2838);
}

.music-desc {
    font-size: 0.9rem;
    color: var(--ink-muted, #4b5563);
}

.music-status {
    font-size: 0.85rem;
    color: var(--accent, #2563eb);
    font-weight: 600;
}

.music-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.music-controls button {
    flex: 1 1 90px;
    padding: 10px 12px;
    border: 1px solid var(--panel-border, #c6d4ee);
    border-radius: 10px;
    background: var(--panel-bg-start, #f3f6fd);
    color: var(--ink, #0f172a);
    font-weight: 600;
    box-shadow: 0 2px 8px var(--panel-shadow, rgba(15, 23, 42, 0.08));
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
}

.music-controls button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--panel-shadow, rgba(15, 23, 42, 0.12));
    background: var(--panel-bg-mid, #e7edfb);
}

.music-controls button.active {
    border-color: var(--accent, #2563eb);
    background: var(--panel-bg-mid, #dbeafe);
    color: var(--ink, #0f172a);
}

.music-progress {
    display: flex;
    align-items: center;
    gap: 10px;
}

.music-progress-bar {
    position: relative;
    flex: 1;
    height: 8px;
    border-radius: 999px;
    background: var(--panel-bg-mid, #e6edf5);
    overflow: hidden;
    cursor: pointer;
    padding: 6px 0;
    background-clip: content-box;
}

.music-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: var(--accent, #2563eb);
    transition: width 0.2s ease;
    pointer-events: none;
}

.music-time {
    font-size: 0.85rem;
    color: var(--ink-muted, #475569);
    min-width: 42px;
    text-align: center;
}

.music-track {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    margin-bottom: 10px;
    border-radius: 12px;
    border: 1px solid var(--panel-border, #e5edf7);
    background: var(--panel-bg-start, #f8fafc);
    flex-wrap: nowrap;
}

.music-track-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1 1 auto;
    min-width: 0;
}

.music-track-title {
    font-weight: 700;
    color: var(--ink, #0f172a);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-track-desc {
    font-size: 0.9rem;
    color: var(--ink-muted, #4b5563);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-track-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
    flex: 0 0 300px;
}

.music-track-price {
    font-weight: 700;
    color: var(--ink, #0f172a);
}

.music-track-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--ink-muted, #334155);
}

.music-inline-btn {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--panel-border, #c6d4ee);
    background: var(--panel-bg-start, white);
    color: var(--ink, #0f172a);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.12s ease;
}

.music-inline-btn:hover:enabled {
    background: var(--panel-bg-mid, #e7edfb);
    transform: translateY(-1px);
}

.music-inline-btn.secondary {
    background: var(--accent, #0f172a);
    color: var(--panel-accent-contrast, #f8fafc);
    border-color: var(--accent, #0f172a);
}

body.theme-light .music-inline-btn.secondary {
    color: #ffffff;
}

body.theme-dark .music-now,
body.theme-dark .music-volume,
body.theme-dark .music-track,
body.theme-midnight .music-now,
body.theme-midnight .music-volume,
body.theme-midnight .music-track {
    background: var(--panel-bg-mid, #171c20);
}

body.theme-dark .music-controls button,
body.theme-midnight .music-controls button,
body.theme-dark .music-inline-btn,
body.theme-midnight .music-inline-btn {
    background: var(--panel-bg-start, #13171b);
    color: var(--ink, #e8eef5);
}

body.theme-dark .music-controls button.active,
body.theme-midnight .music-controls button.active {
    background: var(--accent, #64b5f6);
    color: var(--panel-accent-contrast, #0b1321);
}

.music-inline-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 640px) {
    .music-track {
        flex-direction: column;
        align-items: flex-start;
    }

    .music-track-actions {
        width: 100%;
        justify-content: flex-start;
    }
}

.close-button {
    position: absolute;
    right: 16px;
    top: 12px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    background: none;
    border: none;
    font-weight: bold;
}

.close-button:hover {
    color: #000;
}

.button-tray {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    padding: 5px;
    flex: 0 0 auto;
    min-width: min-content;
    width: max-content;
}

.button-tray button {
    flex: 0 0 auto; 
    padding: 8px 16px;
    font-size: 0.9rem;
    background-color: white;
    color: #2196f3;
    border: 2px solid #2196f3;
    border-radius: 25px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    white-space: nowrap;
}

.button-tray button:hover {
    background-color: #2196f3;
    color: white;
}

main {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;        /* fallback */
    height: 100dvh;       /* iOS Safari 15.4+: excludes browser chrome */
    overflow: hidden;
    z-index: 1;
}

.bugs-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    overscroll-behavior: none;
}

.rock-obstacle {
    position: absolute;
    pointer-events: none;
    user-select: none;
    image-rendering: auto;
}

@media screen and (max-width: 768px) {
    header {
        padding: 5px;
    }

    .button-tray {
        padding: 5px 10px;
        gap: 6px;
    }

    .button-tray button {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .button-group.nav a.nav-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    body {
        overflow: auto !important;
    }

    header {
        position: fixed;
        top: 0;
        width: 100%;
        z-index: 1000;
    }
}

@media screen and (max-width: 375px) {
    .button-tray button {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    .button-group.nav a.nav-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
}

.bug {
    position: absolute;
    width: 75px;
    height: 75px; 
    border-radius: 50%; 
    pointer-events: none; 
    object-fit: cover; 
    will-change: transform;
    touch-action: none;
}

.evil-horns {
    position: absolute;
    pointer-events: none;
    user-select: none;
    transform-origin: center;
    z-index: 900;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.35));
}

@media (max-width: 768px) {
    .bug {
        width: 55px;
        height: 55px;
    }
}


.shiny {
    filter: invert(100%);
    border: 2px solid gold;
}

.feedback-form {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 500px;
    background: var(--bg, white);
    color: var(--ink, #1b2838);
    padding: 20px;
    border: 1px solid var(--panel-border, #ccc);
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    overflow-y: auto; 

    text-align: center; /* Center text */
}

.feedback-form h2 {
    margin-bottom: 20px;
    font-size: 24px;
    color: var(--ink, #1b2838);
}

.feedback-form input,
.feedback-form textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid var(--panel-border, #ccc);
    background-color: var(--panel-bg-start, white);
    color: var(--ink, #1b2838);
    border-radius: 5px;
    font-size: 16px;
}

.feedback-form input:focus,
.feedback-form textarea:focus {
    outline: none;
    border-color: var(--accent, #2196f3);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.feedback-form button {
    padding: 10px 20px;
    font-size: 16px;
    background-color: var(--accent, #2196f3);
    color: var(--ink, #1b2838);
    border: 1px solid var(--panel-border, #ccc);
    border-bottom: 2px solid var(--panel-border, #ccc);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
    box-shadow: 0 2px 0 var(--panel-border, #999);
}

.feedback-form button:hover {
    background-color: var(--accent-hover, #1976d2);
    transform: translateY(-1px);
    box-shadow: 0 3px 0 var(--panel-border, #999);
}

.feedback-form button:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 var(--panel-border, #999);
}

.feedback-form p {
    font-size: 12px;
    margin-top: 10px;
    color: var(--ink-muted, #888);
}

/* Memorial Wall Styling */
.memorial-wall {
    background: var(--bg, white);
    color: var(--ink, #1b2838);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    scrollbar-color: var(--accent, #888) var(--panel-bg-start, #f1f1f1);
}

.memorial-wall::-webkit-scrollbar {
    width: 10px;
}

.memorial-wall::-webkit-scrollbar-track {
    background: var(--panel-bg-start, #f1f1f1);
    border-radius: 8px;
}

.memorial-wall::-webkit-scrollbar-thumb {
    background: var(--accent, #888);
    border-radius: 8px;
}

.memorial-wall::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover, #666);
}

.memorial-header {
    background-color: var(--bg, white);
    border-bottom: 1px solid var(--panel-border, #ddd);
    color: var(--ink, #1b2838);
}

.memorial-close-btn {
    padding: 8px 20px;
    font-size: 14px;
    background-color: var(--panel-bg-start, white);
    color: var(--ink, #1b2838);
    border: 1px solid var(--panel-border, #ccc);
    border-bottom: 2px solid var(--panel-border, #ccc);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
    box-shadow: 0 2px 0 var(--panel-border, #999);
}

.memorial-close-btn:hover {
    background-color: var(--accent, #e0e0e0);
    transform: translateY(-1px);
    box-shadow: 0 3px 0 var(--panel-border, #999);
}

.memorial-close-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 var(--panel-border, #999);
}

.memorial-entry {
    border: 1px solid var(--panel-border, #ccc);
    border-bottom: 2px solid var(--panel-border, #999);
    background: linear-gradient(180deg, var(--panel-bg-start, white), var(--panel-bg-mid, #fafafa));
    color: var(--ink, #1b2838);
    margin-bottom: 12px;
    box-shadow: 0 2px 0 var(--panel-border, #999);
}

.memorial-cause {
    color: var(--accent, #ff4444);
    font-weight: 600;
}

/* Info Modal & Patch Notes Styling */
.info-modal,
.patch-notes-modal {
    background: var(--bg, white);
    color: var(--ink, #1b2838);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    scrollbar-color: var(--accent, #888) var(--panel-bg-start, #f1f1f1);
}

.info-modal::-webkit-scrollbar,
.patch-notes-modal::-webkit-scrollbar {
    width: 10px;
}

.info-modal::-webkit-scrollbar-track,
.patch-notes-modal::-webkit-scrollbar-track {
    background: var(--panel-bg-start, #f1f1f1);
    border-radius: 8px;
}

.info-modal::-webkit-scrollbar-thumb,
.patch-notes-modal::-webkit-scrollbar-thumb {
    background: var(--accent, #888);
    border-radius: 8px;
}

.info-modal::-webkit-scrollbar-thumb:hover,
.patch-notes-modal::-webkit-scrollbar-thumb:hover {
    background: var(--accent-hover, #666);
}

.info-header,
.patch-notes-header {
    background-color: var(--bg, white);
    border-bottom: 1px solid var(--panel-border, #ddd);
    color: var(--ink, #1b2838);
}

.info-header label {
    color: var(--ink-muted, #666);
}

.info-button,
.patch-notes-close-btn {
    padding: 8px 20px;
    font-size: 14px;
    background-color: var(--panel-bg-start, white);
    color: var(--ink, #1b2838);
    border: 1px solid var(--panel-border, #ccc);
    border-bottom: 2px solid var(--panel-border, #ccc);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: 600;
    box-shadow: 0 2px 0 var(--panel-border, #999);
}

.info-button:hover,
.patch-notes-close-btn:hover {
    background-color: var(--accent, #e0e0e0);
    transform: translateY(-1px);
    box-shadow: 0 3px 0 var(--panel-border, #999);
}

.info-button:active,
.patch-notes-close-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 var(--panel-border, #999);
}

.info-modal h2,
.patch-notes-modal h2 {
    color: var(--ink, #1b2838);
}

.info-modal h3,
.patch-notes-modal h3 {
    color: var(--ink, #1b2838);
}

.info-modal span,
.patch-notes-modal span {
    color: var(--ink-muted, #666);
}

/* Dark theme overrides for info/welcome modal - lighter text */
body.theme-dark .info-modal,
body.theme-dark .patch-notes-modal {
    color: #d0dae6 !important;
}

body.theme-dark .info-modal h2,
body.theme-dark .patch-notes-modal h2,
body.theme-dark .info-modal h3,
body.theme-dark .patch-notes-modal h3,
body.theme-dark .info-modal h4,
body.theme-dark .patch-notes-modal h4,
body.theme-dark .info-modal p,
body.theme-dark .patch-notes-modal p {
    color: #d0dae6 !important;
}

body.theme-dark .info-modal span,
body.theme-dark .patch-notes-modal span {
    color: #8a95a5 !important;
}

body.theme-midnight .info-modal,
body.theme-midnight .patch-notes-modal {
    color: #c0d8ec !important;
}

body.theme-midnight .info-modal h2,
body.theme-midnight .patch-notes-modal h2,
body.theme-midnight .info-modal h3,
body.theme-midnight .patch-notes-modal h3,
body.theme-midnight .info-modal h4,
body.theme-midnight .patch-notes-modal h4,
body.theme-midnight .info-modal p,
body.theme-midnight .patch-notes-modal p {
    color: #c0d8ec !important;
}

body.theme-midnight .info-modal span,
body.theme-midnight .patch-notes-modal span {
    color: #6a8aa8 !important;
}

.tooltip {
    position: absolute;
    background: white;
    border: 1px solid #ccc;
    border-radius: 5px;
    padding: 10px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-width: 200px;
}

.tooltip-close {
    position: absolute;
    top: 5px;
    right: 5px;
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
}

/* ── Bug Info Popup (CRT TV effect) ── */
#bugInfoBox {
    position: fixed;
    z-index: 999;
    width: 280px;
    background: #0c0c0c;
    color: #e0e0e0;
    font-family: 'Courier New', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
    padding: 0;
    border: 1px solid rgba(200, 200, 200, 0.2);
    border-radius: 4px;
    box-shadow:
        0 0 40px rgba(200, 210, 230, 0.06),
        0 0 2px rgba(255, 255, 255, 0.12),
        0 8px 24px rgba(0, 0, 0, 0.65),
        inset 0 0 100px rgba(180, 200, 220, 0.015);
    word-wrap: break-word;
    display: none;
    transform-origin: center center;
    overflow: hidden;
    transition: height 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* CRT scanlines */
#bugInfoBox::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 1px,
        rgba(0, 0, 0, 0.12) 1px,
        rgba(0, 0, 0, 0.12) 2px
    );
    pointer-events: none;
    z-index: 2;
    animation: crt-scanline-drift 8s linear infinite;
}

/* CRT screen overlay — vignette */
#bugInfoBox::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%; right: -50%; bottom: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(
        ellipse at center,
        transparent 40%,
        rgba(0, 0, 0, 0.25) 70%,
        rgba(0, 0, 0, 0.55) 100%
    );
    pointer-events: none;
    z-index: 2;
}

@keyframes crt-scanline-drift {
    0%   { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

#bugInfoBox .bug-info-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

#bugInfoBox .bug-info-portrait {
    position: relative;
    z-index: 3;
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 50%;
    border: 2px solid rgba(200, 200, 200, 0.3);
    background: #111;
    object-fit: cover;
    box-shadow: 0 0 10px rgba(200, 210, 230, 0.1);
}

#bugInfoBox .bug-info-name {
    font-size: 15px;
    font-weight: bold;
    color: #ffffff;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

#bugInfoBox .bug-info-name.shiny-name {
    color: gold;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.6), 0 0 20px rgba(255, 215, 0, 0.3);
}

#bugInfoBox .bug-info-body {
    padding: 0 14px 14px;
}

#bugInfoBox .bug-info-story {
    margin: 6px 0 8px;
    color: #d0d0d0;
    font-size: 12.5px;
}

#bugInfoBox .bug-info-born {
    color: #999;
    font-size: 11px;
    font-style: italic;
}

#bugInfoBox .bug-info-stats {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

#bugInfoBox .bug-info-stat {
    font-size: 11px;
    color: #b0b0b0;
    white-space: nowrap;
}

#bugInfoBox .bug-stat-label {
    color: #888;
}



/* ── CRT Turn ON — snappy center-out expand ── */
@keyframes crt-turn-on {
    0% {
        clip-path: inset(50% 50% 50% 50%);
        filter: brightness(3) saturate(0);
        opacity: 1;
    }
    20% {
        clip-path: inset(49.5% 0% 49.5% 0%);
        filter: brightness(2.5) saturate(0);
    }
    50% {
        clip-path: inset(20% 0% 20% 0%);
        filter: brightness(1.5) saturate(0.5);
    }
    100% {
        clip-path: inset(0% 0% 0% 0%);
        filter: brightness(1) saturate(1);
        opacity: 1;
    }
}

/* ── CRT Turn OFF — snappy collapse to dot ── */
@keyframes crt-turn-off {
    0% {
        clip-path: inset(0% 0% 0% 0%);
        filter: brightness(1) saturate(1);
        opacity: 1;
    }
    40% {
        clip-path: inset(45% 0% 45% 0%);
        filter: brightness(2) saturate(0.2);
    }
    70% {
        clip-path: inset(49.5% 10% 49.5% 10%);
        filter: brightness(3) saturate(0);
    }
    100% {
        clip-path: inset(50% 50% 50% 50%);
        filter: brightness(3) saturate(0);
        opacity: 0;
    }
}

/* ── CRT text flicker-in (phosphor warmup) ── */
@keyframes crt-text-flicker {
    0%   { opacity: 0; filter: brightness(1); }
    8%   { opacity: 1; filter: brightness(2); }
    12%  { opacity: 0.5; filter: brightness(1); }
    20%  { opacity: 1; filter: brightness(1.8); }
    28%  { opacity: 0.7; filter: brightness(1.1); }
    40%  { opacity: 1; filter: brightness(1.5); }
    55%  { opacity: 0.85; filter: brightness(1.08); }
    70%  { opacity: 1; filter: brightness(1.3); }
    85%  { opacity: 0.95; filter: brightness(1.03); }
    100% { opacity: 1; filter: brightness(1); }
}

/* ── CRT idle haze — phosphor brightness wobble like real CRT ── */
@keyframes crt-idle-haze {
    0%   { filter: brightness(1); }
    12%  { filter: brightness(1.06); }
    25%  { filter: brightness(0.95); }
    40%  { filter: brightness(1.05); }
    55%  { filter: brightness(0.96); }
    70%  { filter: brightness(1.04); }
    85%  { filter: brightness(0.97); }
    100% { filter: brightness(1); }
}

/* ── CRT line sweep — a bright horizontal bar sweeps down the content ── */
@keyframes crt-line-sweep {
    0%   { background-position: 0 -100%; }
    100% { background-position: 0 200%; }
}

/* ── CRT screen flash on open (reduced) ── */
@keyframes crt-screen-flash {
    0%   { box-shadow: 0 0 0 rgba(255,255,255,0), inset 0 0 0 rgba(255,255,255,0); }
    15%  { box-shadow: 0 0 40px rgba(200,210,230,0.2), inset 0 0 20px rgba(255,255,255,0.08); }
    40%  { box-shadow: 0 0 15px rgba(200,210,230,0.08), inset 0 0 8px rgba(255,255,255,0.03); }
    100% { box-shadow: 0 0 40px rgba(200,210,230,0.06), 0 0 2px rgba(255,255,255,0.12), 0 8px 24px rgba(0,0,0,0.65), inset 0 0 100px rgba(180,200,220,0.015); }
}

#bugInfoBox.crt-opening {
    display: block;
    animation: crt-turn-on 0.15s cubic-bezier(0.22, 0.61, 0.36, 1) forwards,
               crt-screen-flash 0.25s ease-out forwards;
}

#bugInfoBox.crt-opening .bug-info-body,
#bugInfoBox.crt-opening .bug-info-header {
    animation: crt-text-flicker 0.2s ease-out 0.08s both;
}

#bugInfoBox.crt-closing {
    display: block;
    animation: crt-turn-off 0.12s cubic-bezier(0.55, 0.06, 0.68, 0.19) forwards;
}

#bugInfoBox.crt-open {
    display: block;
    clip-path: inset(0% 0% 0% 0%);
}

#bugInfoBox.crt-open .bug-info-body,
#bugInfoBox.crt-open .bug-info-header {
    animation: crt-idle-haze 4s ease-in-out infinite;
}

/* Line sweep overlay for content swap — sharp bright line like CRT retrace */
#bugInfoBox.crt-swapping .bug-info-body,
#bugInfoBox.crt-swapping .bug-info-header {
    background-image: linear-gradient(
        180deg,
        transparent 0%,
        transparent 48%,
        rgba(255, 255, 255, 0.7) 49.5%,
        rgba(255, 255, 255, 1) 50%,
        rgba(255, 255, 255, 0.7) 50.5%,
        transparent 52%,
        transparent 100%
    );
    background-size: 100% 300%;
    animation: crt-line-sweep 0.25s linear both;
}

@media (max-width: 768px) {
    #bugInfoBox {
        width: auto;
        max-width: calc(100vw - 20px);
        font-size: 14px;
    }
}

body.gross-mode {
    background: repeating-linear-gradient(135deg, #fffb00 0 40px, #ff00c8 40px 80px, #00ffea 80px 120px, #fffb00 120px 160px);
    color: #00ff00 !important;
    font-family: "Papyrus", "Comic Sans MS", "Impact", cursive, fantasy !important;
    letter-spacing: 2px;
    font-size: 120% !important;
    filter: hue-rotate(90deg) contrast(2) blur(0.5px);
}

body.gross-mode * {
    background: none !important;
    color: #ff0000 !important;
    font-family: "Papyrus", "Comic Sans MS", "Impact", cursive, fantasy !important;
    text-shadow: 2px 2px 0 #00ffea, 0 0 10px #ff00c8;
    border-radius: 0 !important;
    border: 2px dashed #ff00c8 !important;
    box-shadow: 0 0 20px #fffb00, 0 0 10px #00ffea inset !important;
    transition: none !important;
}

body.gross-mode button, body.gross-mode input, body.gross-mode select, body.gross-mode textarea {
    background: #fffb00 !important;
    color: #ff00c8 !important;
    border: 3px double #00ffea !important;
    font-size: 1.2em !important;
    font-family: "Papyrus", "Comic Sans MS", "Impact", cursive, fantasy !important;
    text-transform: uppercase;
    letter-spacing: 3px;
    box-shadow: 0 0 10px #ff00c8, 0 0 5px #00ffea inset !important;
}

body.gross-mode .button-tray button {
    padding: 4px 8px !important;
    font-size: 0.7rem !important;
    border-radius: 15px !important;
    letter-spacing: 1px !important;
}

body.gross-mode a {
    color: #00ffea !important;
    text-decoration: underline wavy #ff00c8 !important;
    font-weight: bold;
}

body.gross-mode img, body.gross-mode .coin-icon {
    filter: grayscale(1) invert(1) hue-rotate(180deg) blur(2px) !important;
    border: 5px solid #ff00c8 !important;
    border-radius: 0 !important;
}



.gross-variant-fallback .bug {
    transition: none !important;
}

body.gross-mode .button-tray {
    background: #ff00c8 !important;
    border-bottom: 5px solid #fffb00 !important;
}

body.gross-mode .modal, body.gross-mode .modal-content {
    background: #ff00c8 !important;
    color: #fffb00 !important;
    border: 5px dotted #00ffea !important;
    box-shadow: 0 0 30px #fffb00 !important;
}

body.gross-mode .game-notification {
    background: #fffb00 !important;
    color: #ff00c8 !important;
    border: 3px solid #00ffea !important;
    font-size: 2em !important;
    text-shadow: 2px 2px 0 #00ffea;
}

.gross-popup {
    animation: grossPopupIn 0.3s;
    cursor: pointer;
    user-select: none;
    transition: box-shadow 0.2s;
    background: #fff700 !important;
}
.gross-popup:hover {
    box-shadow: 0 0 40px #ff00c8, 0 0 20px #fffb00 inset;
}

@keyframes grossPopupIn {
    from { opacity: 0; transform: scale(0.7);}
    to { opacity: 1; transform: scale(1);}
}

.theme-light { --border-light: #cdd7e3; --border-strong: #9fb1c7; }

.theme-light header {
    background: linear-gradient(#e7effa, #d1e2ff);
    color: #1b2838;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 0 #e3ecfb inset, 0 1px 0 #b8c9e1;
    scroll-behavior: smooth;
}

.theme-light header::-webkit-scrollbar {
    height: 8px;
}

.theme-light header::-webkit-scrollbar-track {
    background: transparent;
}

.theme-light header::-webkit-scrollbar-thumb {
    background: rgba(155, 177, 221, 0.5);
    border-radius: 4px;
}

.theme-light header::-webkit-scrollbar-thumb:hover {
    background: rgba(155, 177, 221, 0.8);
}

.theme-light .button-tray {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    padding: 5px;
    flex: 0 0 auto;
    min-width: min-content;
    width: max-content; 
}

.theme-light .button-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 22px 6px 6px;
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 2px 0 #c9d6e8;
}

.theme-light .button-group::before {
    content: attr(data-label);
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5b6b7f;
    opacity: 0.95;
    pointer-events: none;
}

.theme-light .button-tray button,
.theme-light .button-tray a.nav-btn,
.theme-light .button-group.nav a.nav-btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 0.9rem;
    background: #ffffff;
    color: #1b2838;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 2px 0 #c9d6e8;
    transition: background-color 0.2s, border-color 0.2s, transform 0.05s;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive !important;
}

.theme-light .button-tray button:hover,
.theme-light .button-tray a.nav-btn:hover,
.theme-light .button-group.nav a.nav-btn:hover {
    background: #eef5ff;
    border-color: #b3ccf8;
}
.theme-light .button-tray button:active,
.theme-light .button-tray a.nav-btn:active,
.theme-light .button-group.nav a.nav-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #c9d6e8;
}

.theme-light .header-row-toggle .toggle-pill {
    background: #9fb1c7;
}
.theme-light .header-row-toggle:hover .toggle-pill {
    background: #7a96b4;
}

.theme-light .site-branding {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin-bottom: 0;
    flex: 0 0 auto;
}

/* Holographic viewer modal styles (appended) */
.holo-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at center, rgba(6,10,20,0.6), rgba(2,4,8,0.9));
    z-index: 12000;
    padding: 20px;
    box-sizing: border-box;
}
.holo-card {
    width: min(920px, 94vw);
    height: min(660px, 86vh);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 28px 90px rgba(2,6,20,0.6);
    background: linear-gradient(180deg, rgba(8,12,20,0.6), rgba(2,4,8,0.95));
    backdrop-filter: blur(6px) saturate(120%);
    display: flex;
    flex-direction: column;
    color: #eaf6ff;
}
.holo-header {
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:10px 14px;
    gap:8px;
    color:#eaf6ff;
    font-weight:600;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), transparent);
}
.holo-canvas { width:100%; height:100%; display:block; background: radial-gradient(ellipse at center, rgba(24,34,56,0.18), rgba(6,8,12,0.95)); }
.holo-close {
    background:transparent;
    color:#fff;
    border:1px solid rgba(255,255,255,0.06);
    padding:6px 10px;
    border-radius:8px;
    cursor:pointer;
}
.holo-controls { display:flex; gap:8px; align-items:center; }

@media (max-width:720px) {
    .holo-card { width: 96vw; height: 74vh; }
    .holo-canvas { height: calc(100% - 52px); }
}
.theme-light .site-branding .brand {
	display: flex;
	align-items: center;
	gap: 12px;
	text-decoration: none;
	color: inherit;
}
.theme-light .site-branding .brand-logo {
	width: 48px;
	height: 48px;
	object-fit: cover;
	border-radius: 8px;
}
.theme-light .site-branding h1 {
	margin: 0;
	font-size: 1.4rem;
	line-height: 1.1;
}
.theme-light .site-branding .brand-tagline {
	margin: 0;
	font-size: 0.9rem;
	opacity: 0.85;
}

@media screen and (max-width: 768px) {
    .theme-light .button-tray { gap: 8px; padding: 6px 8px; }
    .theme-light .button-group { gap: 6px; padding: 20px 6px 6px; }
    .theme-light .button-tray button,
    .theme-light .button-tray a.nav-btn,
    .theme-light .button-group.nav a.nav-btn { border-radius: 6px; padding: 6px 12px; font-size: 0.85rem; }
}

/* Green mode: tint all bugs green (darker) */
body.greenified .bug {
    filter: hue-rotate(95deg) saturate(1.2) brightness(0.75) contrast(1.2) !important;
}
body.greenified .bug.shiny {
    /* keep shiny inversion but also hue-shift (darker) */
    filter: invert(100%) hue-rotate(95deg) saturate(1.2) brightness(0.75) contrast(1.2) !important;
}

/* ===== DARK MODE THEME ===== */
body.theme-dark { 
    --border-light: #3a4451; 
    --border-strong: #2d3541;
    background-color: #1a1f26 !important;
    /* subtler highlight and stronger drop shadow for dark backgrounds */
    --popup-highlight: rgba(255,255,255,0.12);
    --popup-shadow: rgba(0,0,0,0.6);
    /* panels for dark theme */
    --panel-bg-start: #13171b;
    --panel-bg-mid: #171c20;
    --panel-bg-end: #0f1418;
    --panel-accent-a: rgba(10,30,40,0.16);
    --panel-accent-b: rgba(40,10,30,0.10);
    --panel-border: rgba(255,255,255,0.04);
    --panel-shadow: rgba(0,0,0,0.6);
    --panel-inset: rgba(255,255,255,0.02);
    --panel-accent-contrast: #ffffff;
    --peg-color: rgba(255,255,255,0.12);
    /* feedback form variables */
    --bg: #1a1f26;
    --ink: #e8eef5;
    --accent: #64b5f6;
    --accent-hover: #42a5f5;
    --ink-muted: #9aa5b5;
}

.theme-dark header {
    background: linear-gradient(#2a3139, #1f262e);
    color: #e8eef5;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 0 #1a2028 inset, 0 1px 0 #3a4451;
    scroll-behavior: smooth;
}

.theme-dark header::-webkit-scrollbar {
    height: 8px;
}

.theme-dark header::-webkit-scrollbar-track {
    background: transparent;
}

.theme-dark header::-webkit-scrollbar-thumb {
    background: rgba(90, 100, 120, 0.5);
    border-radius: 4px;
}

.theme-dark header::-webkit-scrollbar-thumb:hover {
    background: rgba(90, 100, 120, 0.8);
}

.theme-dark .button-tray {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    padding: 5px;
    flex: 0 0 auto;
    min-width: min-content;
    width: max-content; 
}

.theme-dark .button-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 22px 6px 6px;
    background: #262d36;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 2px 0 #1a2028;
}

.theme-dark .button-group::before {
    content: attr(data-label);
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #9aa5b5;
    opacity: 0.95;
    pointer-events: none;
}

.theme-dark .button-tray button,
.theme-dark .button-tray a.nav-btn,
.theme-dark .button-group.nav a.nav-btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 0.9rem;
    background: #2f3742;
    color: #e8eef5;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 2px 0 #1a2028;
    transition: background-color 0.2s, border-color 0.2s, transform 0.05s;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive !important;
}

.theme-dark .button-tray button:hover,
.theme-dark .button-tray a.nav-btn:hover,
.theme-dark .button-group.nav a.nav-btn:hover {
    background: #3a4451;
    border-color: #4a5461;
}

.theme-dark .button-tray button:active,
.theme-dark .button-tray a.nav-btn:active,
.theme-dark .button-group.nav a.nav-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #1a2028;
}

.theme-dark .header-row-toggle .toggle-pill {
    background: #5a6470;
}
.theme-dark .header-row-toggle:hover .toggle-pill {
    background: #7a8694;
}

.theme-dark .site-branding {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.theme-dark .site-branding .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.theme-dark .site-branding .brand-logo {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
}

.theme-dark .site-branding h1 {
    margin: 0;
    font-size: 1.4rem;
    line-height: 1.1;
    color: #e8eef5;
}

.theme-dark .site-branding .brand-tagline {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.85;
    color: #b8c5d5;
}

/* ===== MIDNIGHT BLUE THEME ===== */
body.theme-midnight { 
    --border-light: #2a4560; 
    --border-strong: #1f3448;
    background-color: #0d1b2a !important;
    --popup-highlight: rgba(255,255,255,0.12);
    --popup-shadow: rgba(0,0,0,0.6);
    /* panels for midnight theme */
    --panel-bg-start: #081022;
    --panel-bg-mid: #0b1626;
    --panel-bg-end: #07121b;
    --panel-accent-a: rgba(10,40,70,0.14);
    --panel-accent-b: rgba(20,10,40,0.08);
    --panel-border: rgba(180,210,240,0.06);
    --panel-shadow: rgba(0,0,0,0.6);
    --panel-inset: rgba(255,255,255,0.02);
    --panel-accent-contrast: #d4e6f5;
    --peg-color: rgba(255,255,255,0.10);
    /* feedback form variables */
    --bg: #0d1b2a;
    --ink: #d4e6f5;
    --accent: #64b5f6;
    --accent-hover: #42a5f5;
    --ink-muted: #7a9ab8;
}

.theme-midnight header {
    background: linear-gradient(#1b3a52, #112840);
    color: #d4e6f5;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 0 #0d2030 inset, 0 1px 0 #2a4560;
    scroll-behavior: smooth;
}

.theme-midnight header::-webkit-scrollbar {
    height: 8px;
}

.theme-midnight header::-webkit-scrollbar-track {
    background: transparent;
}

.theme-midnight header::-webkit-scrollbar-thumb {
    background: rgba(74, 111, 165, 0.5);
    border-radius: 4px;
}

.theme-midnight header::-webkit-scrollbar-thumb:hover {
    background: rgba(74, 111, 165, 0.8);
}

.theme-midnight .button-tray {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    padding: 5px;
    flex: 0 0 auto;
    min-width: min-content;
    width: max-content; 
}

.theme-midnight .button-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 22px 6px 6px;
    background: #1a2f45;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 2px 0 #0d2030;
}

.theme-midnight .button-group::before {
    content: attr(data-label);
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #7a9ab8;
    opacity: 0.95;
    pointer-events: none;
}

.theme-midnight .button-tray button,
.theme-midnight .button-tray a.nav-btn,
.theme-midnight .button-group.nav a.nav-btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 0.9rem;
    background: #1f3a55;
    color: #d4e6f5;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 2px 0 #0d2030;
    transition: background-color 0.2s, border-color 0.2s, transform 0.05s;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive !important;
}

.theme-midnight .button-tray button:hover,
.theme-midnight .button-tray a.nav-btn:hover,
.theme-midnight .button-group.nav a.nav-btn:hover {
    background: #2a4a68;
    border-color: #3a5a78;
}

.theme-midnight .button-tray button:active,
.theme-midnight .button-tray a.nav-btn:active,
.theme-midnight .button-group.nav a.nav-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #0d2030;
}

.theme-midnight .header-row-toggle .toggle-pill {
    background: #3a5a78;
}
.theme-midnight .header-row-toggle:hover .toggle-pill {
    background: #4e7498;
}

.theme-midnight .site-branding {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.theme-midnight .site-branding .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.theme-midnight .site-branding .brand-logo {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
}

.theme-midnight .site-branding h1 {
    margin: 0;
    font-size: 1.4rem;
    line-height: 1.1;
    color: #d4e6f5;
}

.theme-midnight .site-branding .brand-tagline {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.85;
    color: #a0c4e0;
}

/* ===== SUNSET/WARM THEME ===== */
body.theme-sunset { 
    --border-light: #d4a373; 
    --border-strong: #b8885a;
    background-color: #ffecd1 !important;
    /* panels for sunset theme */
    --panel-bg-start: #fff7ef;
    --panel-bg-mid: #fff2e6;
    --panel-bg-end: #fff0e8;
    --panel-accent-a: rgba(255,200,150,0.22);
    --panel-accent-b: rgba(255,160,120,0.12);
    --panel-border: rgba(200,140,90,0.32);
    --panel-shadow: rgba(160,90,30,0.08);
    --panel-inset: rgba(255,255,255,0.95);
    --panel-accent-contrast: #3d2817;
    /* feedback form variables */
    --bg: #ffecd1;
    --ink: #3d2817;
    --accent: #ffb86f;
    --accent-hover: #ff9f5a;
    --ink-muted: #5a4027;
}

.theme-sunset header {
    background: linear-gradient(#ffd4a3, #ffb86f);
    color: #3d2817;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 0 #ffe5c0 inset, 0 1px 0 #d4a373;
    scroll-behavior: smooth;
}

.theme-sunset header::-webkit-scrollbar {
    height: 8px;
}

.theme-sunset header::-webkit-scrollbar-track {
    background: transparent;
}

.theme-sunset header::-webkit-scrollbar-thumb {
    background: rgba(212, 163, 115, 0.6);
    border-radius: 4px;
}

.theme-sunset header::-webkit-scrollbar-thumb:hover {
    background: rgba(212, 163, 115, 0.9);
}

.theme-sunset .button-tray {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    padding: 5px;
    flex: 0 0 auto;
    min-width: min-content;
    width: max-content; 
}

.theme-sunset .button-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 22px 6px 6px;
    background: #fff4e6;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 2px 0 #f5d5a8;
}

.theme-sunset .button-group::before {
    content: attr(data-label);
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b6f47;
    opacity: 0.95;
    pointer-events: none;
}

.theme-sunset .button-tray button,
.theme-sunset .button-tray a.nav-btn,
.theme-sunset .button-group.nav a.nav-btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 0.9rem;
    background: #fffaf0;
    color: #3d2817;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 2px 0 #f5d5a8;
    transition: background-color 0.2s, border-color 0.2s, transform 0.05s;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive !important;
}

.theme-sunset .button-tray button:hover,
.theme-sunset .button-tray a.nav-btn:hover,
.theme-sunset .button-group.nav a.nav-btn:hover {
    background: #ffe8cc;
    border-color: #c89a65;
}

.theme-sunset .button-tray button:active,
.theme-sunset .button-tray a.nav-btn:active,
.theme-sunset .button-group.nav a.nav-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #f5d5a8;
}

.theme-sunset .header-row-toggle .toggle-pill {
    background: #c89a65;
}
.theme-sunset .header-row-toggle:hover .toggle-pill {
    background: #dab07a;
}

.theme-sunset .site-branding {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.theme-sunset .site-branding .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.theme-sunset .site-branding .brand-logo {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
}

.theme-sunset .site-branding h1 {
    margin: 0;
    font-size: 1.4rem;
    line-height: 1.1;
    color: #3d2817;
}

.theme-sunset .site-branding .brand-tagline {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.85;
    color: #5a4027;
}

/* ===== FOREST GREEN THEME ===== */
body.theme-forest { 
    --border-light: #5a7c59; 
    --border-strong: #486246;
    background-color: #d4e8d4 !important;
    /* panels for forest theme */
    --panel-bg-start: #f3fbf3;
    --panel-bg-mid: #eef8ee;
    --panel-bg-end: #ecf7ec;
    --panel-accent-a: rgba(160,220,160,0.18);
    --panel-accent-b: rgba(120,190,120,0.10);
    --panel-border: rgba(120,180,120,0.18);
    --panel-shadow: rgba(20,50,20,0.06);
    --panel-inset: rgba(255,255,255,0.95);
    --panel-accent-contrast: #1f3a1e;
    /* feedback form variables */
    --bg: #d4e8d4;
    --ink: #1f3a1e;
    --accent: #8fb58e;
    --accent-hover: #6a9a69;
    --ink-muted: #2d4a2c;
}

.theme-forest header {
    background: linear-gradient(#a8c9a7, #8fb58e);
    color: #1f3a1e;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 0 #c2d9c1 inset, 0 1px 0 #5a7c59;
    scroll-behavior: smooth;
}

.theme-forest header::-webkit-scrollbar {
    height: 8px;
}

.theme-forest header::-webkit-scrollbar-track {
    background: transparent;
}

.theme-forest header::-webkit-scrollbar-thumb {
    background: rgba(90, 124, 89, 0.6);
    border-radius: 4px;
}

.theme-forest header::-webkit-scrollbar-thumb:hover {
    background: rgba(90, 124, 89, 0.9);
}

.theme-forest .button-tray {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    padding: 5px;
    flex: 0 0 auto;
    min-width: min-content;
    width: max-content; 
}

.theme-forest .button-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 22px 6px 6px;
    background: #e8f5e8;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 2px 0 #b8d8b7;
}

.theme-forest .button-group::before {
    content: attr(data-label);
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #4a6549;
    opacity: 0.95;
    pointer-events: none;
}

.theme-forest .button-tray button,
.theme-forest .button-tray a.nav-btn,
.theme-forest .button-group.nav a.nav-btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 0.9rem;
    background: #f0faf0;
    color: #1f3a1e;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 2px 0 #b8d8b7;
    transition: background-color 0.2s, border-color 0.2s, transform 0.05s;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive !important;
}

.theme-forest .button-tray button:hover,
.theme-forest .button-tray a.nav-btn:hover,
.theme-forest .button-group.nav a.nav-btn:hover {
    background: #d8edd8;
    border-color: #6a9469;
}

.theme-forest .button-tray button:active,
.theme-forest .button-tray a.nav-btn:active,
.theme-forest .button-group.nav a.nav-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #b8d8b7;
}

.theme-forest .header-row-toggle .toggle-pill {
    background: #6a9469;
}
.theme-forest .header-row-toggle:hover .toggle-pill {
    background: #82ad81;
}

.theme-forest .site-branding {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.theme-forest .site-branding .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.theme-forest .site-branding .brand-logo {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
}

.theme-forest .site-branding h1 {
    margin: 0;
    font-size: 1.4rem;
    line-height: 1.1;
    color: #1f3a1e;
}

.theme-forest .site-branding .brand-tagline {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.85;
    color: #2d4a2c;
}

/* ===== PURPLE/VIOLET THEME ===== */
body.theme-purple { 
    --border-light: #9575cd; 
    --border-strong: #7e57c2;
    background-color: #f3e5f5 !important;
    /* panels for purple theme */
    --panel-bg-start: #fbf7fd;
    --panel-bg-mid: #f6eefb;
    --panel-bg-end: #f3e8fb;
    --panel-accent-a: rgba(200,170,240,0.18);
    --panel-accent-b: rgba(210,160,230,0.12);
    --panel-border: rgba(160,120,200,0.18);
    --panel-shadow: rgba(80,40,120,0.06);
    --panel-inset: rgba(255,255,255,0.95);
    --panel-accent-contrast: #311b92;
    /* feedback form variables */
    --bg: #f3e5f5;
    --ink: #311b92;
    --accent: #b39ddb;
    --accent-hover: #9575cd;
    --ink-muted: #6a4c93;
}

.theme-purple header {
    background: linear-gradient(#d1c4e9, #b39ddb);
    color: #311b92;
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 0 #e1d7f5 inset, 0 1px 0 #9575cd;
    scroll-behavior: smooth;
}

.theme-purple header::-webkit-scrollbar {
    height: 8px;
}

.theme-purple header::-webkit-scrollbar-track {
    background: transparent;
}

.theme-purple header::-webkit-scrollbar-thumb {
    background: rgba(149, 117, 205, 0.6);
    border-radius: 4px;
}

.theme-purple header::-webkit-scrollbar-thumb:hover {
    background: rgba(149, 117, 205, 0.9);
}

.theme-purple .button-tray {
    display: flex;
    justify-content: flex-start;
    gap: 8px;
    padding: 5px;
    flex: 0 0 auto;
    min-width: min-content;
    width: max-content; 
}

.theme-purple .button-group {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 22px 6px 6px;
    background: #f8f4fc;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 8px;
    box-shadow: 0 2px 0 #d4c5e8;
}

.theme-purple .button-group::before {
    content: attr(data-label);
    position: absolute;
    top: 6px;
    left: 10px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6a4c93;
    opacity: 0.95;
    pointer-events: none;
}

.theme-purple .button-tray button,
.theme-purple .button-tray a.nav-btn,
.theme-purple .button-group.nav a.nav-btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 0.9rem;
    background: #ffffff;
    color: #311b92;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    border-radius: 6px;
    box-shadow: 0 2px 0 #d4c5e8;
    transition: background-color 0.2s, border-color 0.2s, transform 0.05s;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive !important;
}

.theme-purple .button-tray button:hover,
.theme-purple .button-tray a.nav-btn:hover,
.theme-purple .button-group.nav a.nav-btn:hover {
    background: #ede7f6;
    border-color: #ab8cd9;
}

.theme-purple .button-tray button:active,
.theme-purple .button-tray a.nav-btn:active,
.theme-purple .button-group.nav a.nav-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #d4c5e8;
}

.theme-purple .header-row-toggle .toggle-pill {
    background: #ab8cd9;
}
.theme-purple .header-row-toggle:hover .toggle-pill {
    background: #c0a6e6;
}

.theme-purple .site-branding {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px;
    margin-bottom: 0;
    flex: 0 0 auto;
}

.theme-purple .site-branding .brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.theme-purple .site-branding .brand-logo {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
}

.theme-purple .site-branding h1 {
    margin: 0;
    font-size: 1.4rem;
    line-height: 1.1;
    color: #311b92;
}

.theme-purple .site-branding .brand-tagline {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.85;
    color: #4527a0;
}

/* ===== THEME STYLING FOR GAME PAGE ELEMENTS ===== */

/* Coin balance styling for all themes */
body.theme-light .button-group.wallet .balance {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    box-shadow: 0 2px 0 #c9d6e8;
}
body.theme-light .button-group.wallet #coin-count { color: #1b2838; }
body.theme-light .button-group.wallet .coin-label { color: #5b6b7f; }

body.theme-dark .button-group.wallet .balance {
    background: #2f3742;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    box-shadow: 0 2px 0 #1a2028;
}
body.theme-dark .button-group.wallet #coin-count { color: #e8eef5; }
body.theme-dark .button-group.wallet .coin-label { color: #9aa5b5; }

body.theme-midnight .button-group.wallet .balance {
    background: #1f3a55;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    box-shadow: 0 2px 0 #0d2030;
}
body.theme-midnight .button-group.wallet #coin-count { color: #d4e6f5; }
body.theme-midnight .button-group.wallet .coin-label { color: #7a9ab8; }

body.theme-sunset .button-group.wallet .balance {
    background: #fffaf0;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    box-shadow: 0 2px 0 #f5d5a8;
}
body.theme-sunset .button-group.wallet #coin-count { color: #3d2817; }
body.theme-sunset .button-group.wallet .coin-label { color: #8b6f47; }

body.theme-forest .button-group.wallet .balance {
    background: #f0faf0;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    box-shadow: 0 2px 0 #b8d8b7;
}
body.theme-forest .button-group.wallet #coin-count { color: #1f3a1e; }
body.theme-forest .button-group.wallet .coin-label { color: #4a6549; }

body.theme-purple .button-group.wallet .balance {
    background: #ffffff;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    box-shadow: 0 2px 0 #d4c5e8;
}
body.theme-purple .button-group.wallet #coin-count { color: #311b92; }
body.theme-purple .button-group.wallet .coin-label { color: #6a4c93; }

/* User preference: remove the small bordered coin wrapper - keep layout but no border/shadow */
.button-group.wallet .balance {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

/* Game page main content areas */
body.theme-dark main { color: #e8eef5; }
body.theme-midnight main { color: #d4e6f5; }
body.theme-sunset main { color: #3d2817; }
body.theme-forest main { color: #1f3a1e; }
body.theme-purple main { color: #311b92; }

/* Modal styling for themes */

/* Theme Shop styling: use theme panel variables and avoid default green/blue accents */
.theme-shop-item {
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 10px;
    background: linear-gradient(180deg, var(--panel-bg-start), var(--panel-bg-mid));
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    color: inherit;
}
.theme-shop-item.active {
    border: 2px solid var(--panel-accent-a);
    background: linear-gradient(180deg, var(--panel-bg-mid), var(--panel-bg-end));
}
.theme-shop-item .active-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background: var(--panel-accent-a);
    color: var(--panel-accent-contrast);
    font-size: 0.75em;
    font-weight: 700;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.04);
}
.theme-shop-item .price-row { font-size: 0.9em; font-weight: 600; }
.theme-shop-item .price-free,
.theme-shop-item .price-owned {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--panel-accent-a);
    color: var(--panel-accent-contrast);
    border: 1px solid var(--panel-border);
}
.theme-shop-item .action-btn {
    padding: 10px;
    margin-top: 8px;
    border: 2px solid var(--panel-border);
    border-radius: 6px;
    font-size: 0.95em;
    font-weight: 600;
    transition: opacity 0.12s ease, transform 0.08s ease, box-shadow 0.12s ease;
    background: linear-gradient(180deg, var(--panel-bg-mid), var(--panel-bg-end));
    color: inherit;
    cursor: pointer;
}
.theme-shop-item .action-btn:hover:not(:disabled) { opacity: 0.9; transform: translateY(-1px); }
.theme-shop-item .action-btn.active,
.theme-shop-item .action-btn.active:disabled {
    background: var(--panel-accent-a);
    color: var(--panel-accent-contrast);
    cursor: default;
}

/* Theme-specific active visuals for the theme shop action button */
.theme-dark .theme-shop-item.active { border-color: var(--accent, #a93ce6); }
.theme-dark .theme-shop-item .action-btn.active { background: var(--accent, #a93ce6); color: var(--panel-accent-contrast, #e8eef5); border-color: var(--accent, #a93ce6); box-shadow: 0 4px 0 rgba(0,0,0,0.25); }

.theme-midnight .theme-shop-item.active { border-color: var(--accent, #64b5f6); }
.theme-midnight .theme-shop-item .action-btn.active { background: var(--accent, #64b5f6); color: var(--panel-accent-contrast, #d4e6f5); border-color: var(--accent, #64b5f6); box-shadow: 0 4px 0 rgba(0,0,0,0.25); }

.theme-sunset .theme-shop-item.active { border-color: var(--accent, #ffb86f); }
.theme-sunset .theme-shop-item .action-btn.active { background: var(--accent, #ffb86f); color: var(--panel-accent-contrast, #3d2817); border-color: var(--accent, #ffb86f); }

.theme-forest .theme-shop-item.active { border-color: var(--accent, #8fb58e); }
.theme-forest .theme-shop-item .action-btn.active { background: var(--accent, #8fb58e); color: var(--panel-accent-contrast, #1f3a1e); border-color: var(--accent, #8fb58e); }

.theme-purple .theme-shop-item.active { border-color: var(--accent, #b39ddb); }
.theme-purple .theme-shop-item .action-btn.active { background: var(--accent, #b39ddb); color: var(--panel-accent-contrast, #311b92); border-color: var(--accent, #b39ddb); }
.theme-shop-item .action-btn.owned {
    background: transparent;
    color: var(--panel-accent-contrast);
    border-color: var(--panel-border);
}

.modal-content {
    background: linear-gradient(180deg,
        var(--panel-bg-start, rgba(255,255,255,0.98)) 0%,
        var(--panel-bg-mid, rgba(245,245,245,0.95)) 50%,
        var(--panel-bg-end, rgba(235,235,235,0.92)) 100%);
    border: 2px solid var(--panel-border, var(--border-light));
    color: var(--ink, #1b2838);
    box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}

.modal-content h2 { color: var(--ink, #1b2838); }

.close-button {
    color: var(--ink-muted, #6b7280);
    transition: color 0.2s ease;
}

.close-button:hover { color: var(--ink, #1b2838); }

.shop-modal .modal-header h2,
.shop-modal .balance { color: var(--ink); }

.shop-modal {
    background: linear-gradient(180deg,
        var(--panel-bg-start) 0%,
        var(--panel-bg-mid) 50%,
        var(--panel-bg-end) 100%);
    border: 2px solid var(--panel-border);
    color: var(--ink);
}

.shop-modal-header {
    background: linear-gradient(135deg, var(--panel-bg-start), var(--panel-bg-mid));
    border-bottom: 2px solid var(--panel-border);
    padding: 16px;
    border-radius: 8px 8px 0 0;
}

.shop-item-card {
    border: 1px solid var(--panel-border, #cdd7e3);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    background: linear-gradient(180deg,
        var(--panel-bg-start, #f9fafb) 0%,
        var(--panel-bg-mid, #eef1f6) 50%,
        var(--panel-bg-end, #e5e9f1) 100%);
    color: var(--ink, #1b2838);
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.18);
}

.shop-item-row { flex-direction: row; align-items: center; gap: 10px; }

.shop-item-media {
    width: 64px;
    height: 64px;
    overflow: hidden;
    border-radius: 8px;
    border: 1px solid var(--panel-border, #cdd7e3);
    background: var(--panel-bg-mid, #f4f6fa);
}

.shop-item-body { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.shop-item-title { font-weight: 700; }
.shop-item-desc { font-size: 0.9em; color: var(--ink-muted, #556070); }
.shop-item-location { font-size: 0.85em; color: var(--ink-muted, #556070); }
.shop-item-price { font-size: 0.95em; font-weight: 700; }

.shop-button-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

.shop-action-btn,
.shop-toggle-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--panel-border, #cdd7e3);
    border-bottom: 2px solid var(--panel-border, #9aa5b5);
    border-radius: 10px;
    background: var(--accent, #6ae3ff);
    color: var(--ink, #0b1321);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    box-shadow: 0 3px 0 var(--panel-border, #9aa5b5);
}

.shop-action-btn:hover,
.shop-toggle-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--panel-border, #9aa5b5); }
.shop-action-btn:active,
.shop-toggle-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 var(--panel-border, #9aa5b5); }

.shop-action-btn:disabled,
.shop-toggle-btn:disabled {
    cursor: default;
    opacity: 0.6;
    box-shadow: none;
    transform: none;
}

.shop-toggle-btn[data-enabled="true"] { background: var(--accent-hover, #56c8ff); }
.shop-toggle-btn[data-enabled="false"] { background: var(--panel-bg-mid, #dde5f0); }

.shop-empty {
    text-align: center;
    color: var(--ink-muted, #6b7280);
    padding: 20px;
}

.settings-warning-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.settings-warning-content {
    background: linear-gradient(180deg,
        var(--panel-bg-start, #f7fafc) 0%,
        var(--panel-bg-mid, #eef2f7) 50%,
        var(--panel-bg-end, #e1e6ef) 100%);
    color: var(--ink, #1b2838);
    padding: 30px;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    text-align: center;
    position: relative;
    border: 2px solid var(--panel-border, #cdd7e3);
    box-shadow: 0 14px 35px rgba(0,0,0,0.35);
}

.settings-warning-icon { font-size: 60px; margin-bottom: 20px; }
.settings-warning-title { margin-bottom: 20px; color: var(--accent, #ff6a9e); }
.settings-warning-message { margin-bottom: 30px; line-height: 1.6; text-align: left; color: var(--ink, #1b2838); }

.settings-warning-actions { display: flex; gap: 15px; justify-content: space-between; flex-wrap: wrap; }

.settings-warning-button {
    flex: 1;
    padding: 12px;
    font-size: 16px;
    background: var(--accent, #6ae3ff);
    color: var(--ink, #0b1321);
    border: 1px solid var(--panel-border, #cdd7e3);
    border-bottom: 2px solid var(--panel-border, #9aa5b5);
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--panel-border, #9aa5b5);
    transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.settings-warning-button:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--panel-border, #9aa5b5); }
.settings-warning-button:active { transform: translateY(1px); box-shadow: 0 2px 0 var(--panel-border, #9aa5b5); }

.settings-warning-danger { background: linear-gradient(180deg, #ff789c 0%, #ff4f86 100%); color: #fff; }
.settings-warning-button:disabled { opacity: 0.6; cursor: default; transform: none; box-shadow: none; }

/* Settings dialog layout */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 16px;
}

.settings-dialog {
    width: min(920px, 100%);
    max-height: 90vh;
    background: linear-gradient(180deg,
        var(--panel-bg-start, #f7fafc) 0%,
        var(--panel-bg-mid, #eef2f7) 50%,
        var(--panel-bg-end, #e1e6ef) 100%);
    color: var(--ink, #1b2838);
    border: 2px solid var(--panel-border, #cdd7e3);
    border-radius: 16px;
    box-shadow: 0 18px 38px rgba(0,0,0,0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.settings-dialog__header {
    position: sticky;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: linear-gradient(180deg,
        var(--panel-bg-start, #f7fafc) 0%,
        var(--panel-bg-mid, #eef2f7) 100%);
    border-bottom: 1px solid var(--panel-border, #cdd7e3);
    z-index: 5;
}

.settings-dialog__title { margin: 0; font-size: 20px; font-weight: 800; }

.settings-dialog__close { margin-left: auto; }

.settings-dialog__body {
    padding: 12px 20px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: var(--panel-border, #cdd7e3) transparent;
}

.settings-dialog__body::-webkit-scrollbar { width: 8px; }
.settings-dialog__body::-webkit-scrollbar-thumb { background: var(--panel-border, #cdd7e3); border-radius: 8px; }
.settings-dialog__body::-webkit-scrollbar-track { background: transparent; }

.settings-form { display: flex; flex-direction: column; gap: 16px; }

.settings-section { display: flex; flex-direction: column; gap: 12px; }
.settings-section__title { margin: 0 0 4px 0; font-size: 16px; font-weight: 800; color: var(--ink, #1b2838); }

.settings-section--grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }

.setting-field {
    background: linear-gradient(180deg,
        var(--panel-bg-start, #f9fafb) 0%,
        var(--panel-bg-mid, #eef1f6) 50%,
        var(--panel-bg-end, #e5e9f1) 100%);
    border: 1px solid var(--panel-border, #cdd7e3);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.setting-label { font-weight: 700; }
.setting-desc { margin: 0; font-size: 13px; color: var(--ink-muted, #556070); line-height: 1.4; }

.setting-control { display: flex; align-items: center; gap: 10px; }
.setting-range { flex: 1; accent-color: var(--accent, #64b5f6); }
.setting-value { min-width: 52px; text-align: right; font-weight: 700; color: var(--ink, #1b2838); }

.settings-card {
    background: linear-gradient(180deg,
        var(--panel-bg-start, #f9fafb) 0%,
        var(--panel-bg-mid, #eef1f6) 50%,
        var(--panel-bg-end, #e5e9f1) 100%);
    border: 1px solid var(--panel-border, #cdd7e3);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 10px 24px rgba(0,0,0,0.14);
}

.settings-card__title { font-weight: 800; margin: 0; }
.settings-helper { margin: 0; color: var(--ink-muted, #556070); line-height: 1.5; }
.settings-helper--pill {
    display: inline-block;
    background: linear-gradient(180deg, rgba(255, 226, 173, 0.9) 0%, rgba(255, 214, 150, 0.9) 100%);
    color: #5a3b05;
    border: 1px solid rgba(255, 199, 120, 0.8);
    padding: 8px 10px;
    border-radius: 10px;
    font-weight: 700;
}

.settings-section--danger .settings-section__title { color: #ff7a8a; }
.settings-section--dev .settings-section__title { color: var(--accent, #64b5f6); }

.settings-btn {
    padding: 10px 14px;
    border: 1px solid var(--panel-border, #cdd7e3);
    border-bottom: 2px solid var(--panel-border, #9aa5b5);
    border-radius: 10px;
    background: var(--accent, #6ae3ff);
    color: var(--ink, #0b1321);
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 3px 0 var(--panel-border, #9aa5b5);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease, opacity 0.2s ease;
    text-align: center;
}

.settings-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--panel-border, #9aa5b5); }
.settings-btn:active { transform: translateY(1px); box-shadow: 0 2px 0 var(--panel-border, #9aa5b5); }
.settings-btn:disabled { opacity: 0.55; cursor: default; transform: none; box-shadow: none; }

.settings-btn-primary { background: linear-gradient(180deg, var(--accent, #64b5f6) 0%, var(--accent-hover, #42a5f5) 100%); color: var(--panel-accent-contrast, #0b1321); }
.settings-btn-muted { background: var(--panel-bg-mid, #dde5f0); color: var(--ink, #1b2838); }
.settings-btn-ghost { background: transparent; color: var(--ink, #1b2838); }
.settings-btn-danger { background: linear-gradient(180deg, #ff7a8a 0%, #f5536a 100%); color: #fff; }
.settings-btn-success { background: linear-gradient(180deg, #8be58c 0%, #52c65f 100%); color: #0f2412; }
.settings-btn-warning { background: linear-gradient(180deg, #ffd75e 0%, #ffba2f 100%); color: #3a2500; }
.settings-btn-purple { background: linear-gradient(180deg, #b084f5 0%, #8a6cf0 100%); color: #fff; }

.full-width { width: 100%; }

.settings-footer { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.settings-footer .settings-btn { flex: 1; min-width: 160px; }

@media (max-width: 720px) {
    .settings-dialog { max-height: 92vh; }
    .settings-dialog__header { flex-wrap: wrap; justify-content: center; text-align: center; }
    .settings-dialog__close { width: 100%; }
    .settings-section--grid { grid-template-columns: 1fr; }
    .settings-footer { flex-direction: column; }
}

/* Game card/panel styling */
body.theme-dark .blackjack-table,
body.theme-dark .game-window,
body.theme-dark .fish-widget {
    background: linear-gradient(180deg, rgba(47,55,66,0.95) 0%, rgba(38,45,54,0.9) 50%, rgba(35,42,51,0.85) 100%);
    border: 2px solid var(--border-light);
    color: #e8eef5;
}

body.theme-midnight .blackjack-table,
body.theme-midnight .game-window,
body.theme-midnight .fish-widget {
    background: linear-gradient(180deg, rgba(31,58,85,0.95) 0%, rgba(26,47,72,0.9) 50%, rgba(17,40,64,0.85) 100%);
    border: 2px solid var(--border-light);
    color: #d4e6f5;
}

body.theme-sunset .blackjack-table,
body.theme-sunset .game-window,
body.theme-sunset .fish-widget {
    background: linear-gradient(180deg, rgba(255,250,240,0.95) 0%, rgba(255,244,230,0.9) 50%, rgba(255,236,209,0.85) 100%);
    border: 2px solid var(--border-light);
    color: #3d2817;
}

body.theme-forest .blackjack-table,
body.theme-forest .game-window,
body.theme-forest .fish-widget {
    background: linear-gradient(180deg, rgba(240,250,240,0.95) 0%, rgba(232,245,232,0.9) 50%, rgba(220,240,220,0.85) 100%);
    border: 2px solid var(--border-light);
    color: #1f3a1e;
}

body.theme-purple .blackjack-table,
body.theme-purple .game-window,
body.theme-purple .fish-widget {
    background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(248,244,252,0.9) 50%, rgba(237,229,245,0.85) 100%);
    border: 2px solid var(--border-light);
    color: #311b92;
}

/* Text color overrides for game elements */
body.theme-dark .game-info h2,
body.theme-dark .blackjack-table p,
body.theme-dark .game-description { color: #e8eef5; }

body.theme-midnight .game-info h2,
body.theme-midnight .blackjack-table p,
body.theme-midnight .game-description { color: #d4e6f5; }

body.theme-sunset .game-info h2,
body.theme-sunset .blackjack-table p,
body.theme-sunset .game-description { color: #3d2817; }

body.theme-forest .game-info h2,
body.theme-forest .blackjack-table p,
body.theme-forest .game-description { color: #1f3a1e; }

body.theme-purple .game-info h2,
body.theme-purple .blackjack-table p,
body.theme-purple .game-description { color: #311b92; }

/* Game buttons - ensure visibility */
body.theme-dark .play-button,
body.theme-dark button:not(.button-tray button):not(.close-button):not([id*="shop"]):not([id*="music"]):not([id*="theme"]) {
    background: #3a4451;
    color: #e8eef5;
    border: 1px solid #4a5461;
}
body.theme-dark .play-button:hover,
body.theme-dark button:not(.button-tray button):not(.close-button):hover {
    background: #4a5461;
    border-color: #5a6471;
}

body.theme-midnight .play-button,
body.theme-midnight button:not(.button-tray button):not(.close-button):not([id*="shop"]):not([id*="music"]):not([id*="theme"]) {
    background: #2a4a68;
    color: #d4e6f5;
    border: 1px solid #3a5a78;
}
body.theme-midnight .play-button:hover,
body.theme-midnight button:not(.button-tray button):not(.close-button):hover {
    background: #3a5a78;
    border-color: #4a6a88;
}

body.theme-sunset .play-button,
body.theme-sunset button:not(.button-tray button):not(.close-button):not([id*="shop"]):not([id*="music"]):not([id*="theme"]) {
    background: #ffe8cc;
    color: #3d2817;
    border: 1px solid #c89a65;
}
body.theme-sunset .play-button:hover,
body.theme-sunset button:not(.button-tray button):not(.close-button):hover {
    background: #ffd9b3;
    border-color: #b8885a;
}

body.theme-forest .play-button,
body.theme-forest button:not(.button-tray button):not(.close-button):not([id*="shop"]):not([id*="music"]):not([id*="theme"]) {
    background: #d8edd8;
    color: #1f3a1e;
    border: 1px solid #6a9469;
}
body.theme-forest .play-button:hover,
body.theme-forest button:not(.button-tray button):not(.close-button):hover {
    background: #c8e3c8;
    border-color: #5a7c59;
}

body.theme-purple .play-button,
body.theme-purple button:not(.button-tray button):not(.close-button):not([id*="shop"]):not([id*="music"]):not([id*="theme"]) {
    background: #ede7f6;
    color: #311b92;
    border: 1px solid #ab8cd9;
}
body.theme-purple .play-button:hover,
body.theme-purple button:not(.button-tray button):not(.close-button):hover {
    background: #e1d7f5;
    border-color: #9575cd;
}

/* ===== FISHING PAGE PANELS - DARKER IN DARK MODES ===== */
body.theme-dark .fish-widget,
body.theme-dark .minigame-panel {
    background: linear-gradient(180deg, rgba(42,49,57,0.85) 0%, rgba(35,42,51,0.85) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 6px 6px 0 rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.05);
    color: #e8eef5;
}
body.theme-dark .widget-header,
body.theme-dark .minigame-header {
    background: linear-gradient(180deg, rgba(58,68,81,0.9) 0%, rgba(47,55,66,0.9) 100%);
    color: #e8eef5;
}
body.theme-dark .forecast-group {
    background: rgba(47,55,66,0.4);
    border-color: rgba(144,165,181,0.2);
}
body.theme-dark .forecast-title,
body.theme-dark .forecast-item { color: #b8c5d5; }
body.theme-dark .catch-splash {
    background: linear-gradient(180deg, rgba(47,55,66,0.98) 0%, rgba(38,45,54,0.98) 100%);
    border-color: #4a9eff;
    color: #e8eef5;
}
body.theme-dark .catch-splash-title,
body.theme-dark .catch-splash-sub { color: #e8eef5; }
body.theme-dark .wish-status-row { color: #e8eef5; }

body.theme-midnight .fish-widget,
body.theme-midnight .minigame-panel {
    background: linear-gradient(180deg, rgba(27,58,82,0.85) 0%, rgba(17,40,64,0.85) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 6px 6px 0 rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.05);
    color: #d4e6f5;
}
body.theme-midnight .widget-header,
body.theme-midnight .minigame-header {
    background: linear-gradient(180deg, rgba(42,74,104,0.9) 0%, rgba(31,58,85,0.9) 100%);
    color: #d4e6f5;
}
body.theme-midnight .forecast-group {
    background: rgba(31,58,85,0.4);
    border-color: rgba(122,154,184,0.2);
}
body.theme-midnight .forecast-title,
body.theme-midnight .forecast-item { color: #a0c4e0; }
body.theme-midnight .catch-splash {
    background: linear-gradient(180deg, rgba(31,58,85,0.98) 0%, rgba(26,47,72,0.98) 100%);
    border-color: #4fc3f7;
    color: #d4e6f5;
}
body.theme-midnight .catch-splash-title,
body.theme-midnight .catch-splash-sub { color: #d4e6f5; }
body.theme-midnight .wish-status-row { color: #d4e6f5; }

body.theme-sunset .fish-widget,
body.theme-sunset .minigame-panel {
    background: linear-gradient(180deg, rgba(255,250,240,0.95) 0%, rgba(255,244,230,0.95) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 6px 6px 0 rgba(184,136,90,0.25), inset 0 1px 0 rgba(255,255,255,0.8);
    color: #3d2817;
}
body.theme-sunset .widget-header,
body.theme-sunset .minigame-header {
    background: linear-gradient(180deg, rgba(255,228,204,0.9) 0%, rgba(255,212,163,0.9) 100%);
    color: #3d2817;
}

body.theme-forest .fish-widget,
body.theme-forest .minigame-panel {
    background: linear-gradient(180deg, rgba(240,250,240,0.95) 0%, rgba(232,245,232,0.95) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 6px 6px 0 rgba(90,124,89,0.25), inset 0 1px 0 rgba(255,255,255,0.8);
    color: #1f3a1e;
}
body.theme-forest .widget-header,
body.theme-forest .minigame-header {
    background: linear-gradient(180deg, rgba(216,237,216,0.9) 0%, rgba(200,227,200,0.9) 100%);
    color: #1f3a1e;
}

body.theme-purple .fish-widget,
body.theme-purple .minigame-panel {
    background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(248,244,252,0.95) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 6px 6px 0 rgba(126,87,194,0.25), inset 0 1px 0 rgba(255,255,255,0.8);
    color: #311b92;
}
body.theme-purple .widget-header,
body.theme-purple .minigame-header {
    background: linear-gradient(180deg, rgba(237,229,245,0.9) 0%, rgba(225,215,245,0.9) 100%);
    color: #311b92;
}

/* ===== COMPENDIUM PAGE THEME STYLING ===== */
body.theme-dark.compendium-page {
    background: radial-gradient(circle at 20% 20%, rgba(74,111,165,0.15), transparent 30%),
                radial-gradient(circle at 80% 0%, rgba(144,165,181,0.1), transparent 30%),
                linear-gradient(180deg, #1a1f26, #0d1419);
    color: #e8eef5;
}
body.theme-dark .summary-card,
body.theme-dark .stat-card {
    background: rgba(47,55,66,0.9);
    border: 1px solid var(--border-light);
    color: #e8eef5;
}

/* ======= Account Section (Header) ======= */
.account-section {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 0 6px;
}
.account-btn {
    flex: 0 0 auto;
    padding: 8px 16px;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    display: inline-block;
    background: #ffffff;
    color: #1b2838;
    border: 1px solid var(--border-light, #d0dcea);
    border-bottom-color: var(--border-strong, #b0c4de);
    box-shadow: 0 2px 0 #c9d6e8;
    transition: background-color 0.2s, border-color 0.2s, transform 0.05s;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive;
}
.account-btn:hover {
    background: #eef5ff;
    border-color: #b3ccf8;
    border-bottom-color: #b3ccf8;
}
.account-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #c9d6e8;
}
.user-profile { display: flex; align-items: center; gap: 8px; }
.user-display-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    color: #1b2838;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive;
}
.theme-dark .account-btn {
    background: #2f3742;
    color: #e8eef5;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    box-shadow: 0 2px 0 #1a2028;
}
.theme-dark .account-btn:hover { background: #3a4451; border-color: #4a5461; }
.theme-dark .account-btn:active { box-shadow: 0 1px 0 #1a2028; }
.theme-dark .user-display-name { color: #e8eef5; }

/* ======= Auth Modal ======= */
.auth-modal-content { max-width: 420px; }
.auth-label {
    display: block;
    margin-bottom: 12px;
    font-size: 0.9rem;
    font-weight: 500;
}
.auth-hint {
    font-weight: 400;
    opacity: 0.6;
    font-size: 0.8rem;
}
.auth-input {
    display: block;
    width: 100%;
    margin-top: 4px;
    padding: 8px 10px;
    font-size: 0.95rem;
    border: 2px solid var(--panel-border, #dfe6f1);
    border-radius: 8px;
    background: var(--panel-bg-start, #fff);
    color: var(--ink, #1b2838);
    box-sizing: border-box;
}
.auth-input:focus { border-color: #2196f3; outline: none; }
.auth-btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s, transform 0.05s;
    margin-top: 8px;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive;
    background: #ffffff;
    color: #1b6fd4;
    border: 1px solid #a0c0f0;
    border-bottom-color: #7aaae8;
    box-shadow: 0 2px 0 #c9d6e8;
}
.auth-btn:hover {
    background: #eef5ff;
    border-color: #7aaae8;
}
.auth-btn:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #c9d6e8;
}
.auth-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.auth-btn-danger {
    color: #c0392b;
    border-color: #e8a0a0;
    border-bottom-color: #d07070;
    box-shadow: 0 2px 0 #e8c9c9;
}
.auth-btn-danger:hover {
    background: #fff5f5;
    border-color: #d07070;
}
.theme-dark .auth-btn {
    background: #2f3742;
    color: #8bb8f0;
    border: 1px solid var(--border-light);
    border-bottom-color: var(--border-strong);
    box-shadow: 0 2px 0 #1a2028;
}
.theme-dark .auth-btn:hover { background: #3a4451; }
.theme-dark .auth-btn-danger { color: #e07070; border-color: #5a3030; border-bottom-color: #6a2020; box-shadow: 0 2px 0 #1a0808; }
.theme-dark .auth-btn-danger:hover { background: #3a2828; }
.auth-error {
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 6px;
    background: #fdecea;
    color: #c0392b;
    font-size: 0.9rem;
}
.auth-success {
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: 6px;
    background: #e8f5e9;
    color: #2e7d32;
    font-size: 0.9rem;
}
.auth-switch {
    text-align: center;
    margin-top: 12px;
    font-size: 0.85rem;
}
.auth-switch a { color: #2196f3; text-decoration: underline; cursor: pointer; }
.auth-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-size: 0.9rem;
    cursor: pointer;
}
.auth-checkbox-label a { color: #2196f3; }
.auth-terms-text {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px;
    border: 1px solid var(--panel-border, #dfe6f1);
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
}
.auth-terms-text ul { margin: 8px 0; padding-left: 20px; }
.auth-terms-text li { margin-bottom: 6px; }

/* ======= Save Conflict Modal ======= */

/* ======= Profile Modal (Redesigned) ======= */
.profile-modal-content {
    max-width: 480px;
    padding: 0 !important;
    overflow: hidden;
}
.profile-modal-content .close-button {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 10;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.5);
    font-size: 1.6rem;
}
.profile-modal-content .close-button:hover { color: #ffd; }

/* Hero / Header */
.profile-hero {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 20px 20px;
    background: linear-gradient(135deg, #4a90d9 0%, #357abd 40%, #6c5ce7 100%);
    border-bottom: 3px solid rgba(0,0,0,0.1);
}
.profile-hero-name {
    margin-top: 10px;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.3);
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive;
}
.profile-hero-link {
    background: none;
    border: none;
    color: rgba(255,255,255,0.8);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 2px 0;
    text-decoration: underline;
    font-family: inherit;
    margin-top: 2px;
}
.profile-hero-link:hover {
    color: #fff;
}
.profile-name-input {
    max-width: 200px;
    margin: 6px auto 0;
    text-align: center;
    font-size: 0.95rem;
}
.profile-change-name-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
    margin-top: 6px;
}
.profile-customize-btn {
    width: 100%;
    margin-bottom: 8px;
    font-size: 1rem;
    padding: 10px;
}

/* Tags */
.profile-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    padding: 8px 16px;
}
.profile-tag, .admin-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border: 2px solid;
    border-radius: 4px;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive;
    background: rgba(255,255,255,0.08);
    letter-spacing: 0.3px;
}
.admin-tag-remove {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.6;
}
.admin-tag-remove:hover { opacity: 1; }

/* Tag effects */
.tag-gradient {
    background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.03));
    border-image: linear-gradient(135deg, currentColor, rgba(255,255,255,0.3)) 1;
}
.tag-shine {
    position: relative;
    overflow: hidden;
}
.tag-shine::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -60%;
    width: 40%;
    height: 200%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.35), transparent);
    transform: skewX(-20deg);
    animation: tagShine 3s ease-in-out infinite;
}
@keyframes tagShine {
    0%, 100% { left: -60%; }
    50% { left: 120%; }
}
.tag-glow {
    box-shadow: 0 0 6px currentColor, 0 0 12px currentColor;
    animation: tagGlow 2s ease-in-out infinite alternate;
}
@keyframes tagGlow {
    0% { box-shadow: 0 0 4px currentColor, 0 0 8px currentColor; }
    100% { box-shadow: 0 0 8px currentColor, 0 0 18px currentColor; }
}
.tag-sparkle {
    animation: tagSparkle 1.5s ease-in-out infinite;
}
@keyframes tagSparkle {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.4); }
}
.tag-rainbow {
    animation: tagRainbow 4s linear infinite;
    border-image: none !important;
}
@keyframes tagRainbow {
    0% { border-color: #ff0000; color: #ff0000; }
    16% { border-color: #ff8800; color: #ff8800; }
    33% { border-color: #ffff00; color: #ffff00; }
    50% { border-color: #00cc00; color: #00cc00; }
    66% { border-color: #0088ff; color: #0088ff; }
    83% { border-color: #8800ff; color: #8800ff; }
    100% { border-color: #ff0000; color: #ff0000; }
}
.tag-moody-gradient {
    background: linear-gradient(135deg, #FF6B35, #8B5CF6);
    border-image: linear-gradient(135deg, #FF6B35, #8B5CF6) 1;
    color: #fff;
}

.profile-hero .auth-error,
.profile-hero .auth-success {
    margin-top: 10px;
    width: 100%;
    text-align: center;
}

/* Avatar */
.profile-avatar-wrap {
    position: relative;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255,255,255,0.8);
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    background: rgba(255,255,255,0.2);
}
.profile-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Avatar Picker */
.avatar-picker {
    padding: 16px 20px;
    border-bottom: 1px solid var(--panel-border, #dfe6f1);
    background: var(--panel-bg-start, #f8faff);
}
.avatar-picker-title {
    margin: 0 0 10px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    color: var(--ink, #1b2838);
}
.avatar-picker-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    justify-content: center;
}
.avatar-tab {
    padding: 6px 16px;
    border: 1px solid var(--panel-border, #cfd8e8);
    border-radius: 20px;
    background: transparent;
    color: var(--ink, #1b2838);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive;
}
.avatar-tab:hover { background: rgba(74,144,217,0.1); }
.avatar-tab.active {
    background: #4a90d9;
    color: #fff;
    border-color: #4a90d9;
}
.theme-dark .avatar-tab { border-color: var(--border-light); color: var(--ink); }
.theme-dark .avatar-tab.active { background: #4a90d9; color: #fff; border-color: #4a90d9; }

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
    gap: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding: 4px;
}
.avatar-grid-item {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    background: rgba(0,0,0,0.05);
}
.avatar-grid-item:hover {
    transform: scale(1.1);
    border-color: #4a90d9;
    box-shadow: 0 2px 8px rgba(74,144,217,0.3);
}
.avatar-grid-item.selected {
    border-color: #4a90d9;
    box-shadow: 0 0 0 2px rgba(74,144,217,0.4);
}
.avatar-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.avatar-picker-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}
.avatar-picker-actions .auth-btn {
    width: auto;
    padding: 6px 24px;
    font-size: 0.85rem;
}

/* Profile Sections (Accordion) */
.profile-sections {
    padding: 12px 20px 20px;
}
.profile-section {
    border: 1px solid var(--panel-border, #dfe6f1);
    border-radius: 10px;
    margin-bottom: 10px;
    overflow: hidden;
    background: var(--panel-bg-start, #fff);
}
.profile-section-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 12px 14px;
    border: none;
    background: none;
    color: var(--ink, #1b2838);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    font-family: 'Comic Sans Fallback', "Comic Sans MS", "Comic Sans", cursive;
    gap: 8px;
    transition: background 0.15s;
}
.profile-section-toggle:hover {
    background: rgba(74,144,217,0.06);
}
.profile-section-icon { font-size: 1.1rem; }
.profile-section-arrow {
    margin-left: auto;
    font-size: 0.8rem;
    transition: transform 0.2s;
}
.profile-section-toggle[aria-expanded="true"] .profile-section-arrow {
    transform: rotate(180deg);
}
.profile-section-body {
    padding: 0 14px 14px;
}
.profile-section-collapsed {
    display: none;
}

/* Bio field tweaks */
.profile-bio-input {
    resize: vertical;
    min-height: 60px;
}
.profile-bio-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 6px;
}
.profile-bio-count {
    font-size: 0.78rem;
    opacity: 0.6;
    color: var(--ink, #1b2838);
}
.profile-btn-inline {
    width: auto !important;
    padding: 6px 18px !important;
    font-size: 0.85rem !important;
}

/* Account settings fields */
.profile-field-group {
    margin-bottom: 14px;
}
.profile-field-group:last-child { margin-bottom: 0; }
.profile-field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink, #1b2838);
}
.profile-field-row {
    display: flex;
    gap: 8px;
    align-items: flex-start;
}
.profile-field-row .auth-input { flex: 1; }
.profile-field-row .auth-btn {
    width: auto;
    padding: 8px 16px;
    white-space: nowrap;
    margin-top: 0;
}
.profile-pw-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.profile-pw-form .auth-btn {
    align-self: flex-end;
    width: auto;
    padding: 6px 18px;
    font-size: 0.85rem;
}

/* Cloud save buttons side by side */
.profile-cloud-btns {
    display: flex;
    gap: 8px;
}
.profile-cloud-btns .auth-btn { flex: 1; }

/* Danger zone */
.profile-section-danger {
    border-color: #e8a0a0;
}
.profile-section-danger .profile-section-toggle { color: #c0392b; }
.profile-danger-text {
    font-size: 0.82rem;
    opacity: 0.7;
    margin: 0 0 10px;
    color: var(--ink, #1b2838);
}

/* Dark theme overrides for profile */
.theme-dark .profile-hero {
    background: linear-gradient(135deg, #2a4a6b 0%, #1e3a5f 40%, #3d2d6b 100%);
}
.theme-dark .profile-section {
    border-color: var(--border-light);
    background: var(--panel-bg-start, #2a2f38);
}
.theme-dark .profile-section-toggle { color: var(--ink); }
.theme-dark .profile-section-toggle:hover { background: rgba(139,184,240,0.08); }
.theme-dark .avatar-picker { background: var(--panel-bg-start, #2a2f38); border-color: var(--border-light); }
.theme-dark .avatar-picker-title { color: var(--ink); }
.theme-dark .avatar-grid-item { background: rgba(255,255,255,0.08); }
.theme-dark .avatar-grid-item:hover { border-color: #8bb8f0; box-shadow: 0 2px 8px rgba(139,184,240,0.3); }
.theme-dark .avatar-grid-item.selected { border-color: #8bb8f0; box-shadow: 0 0 0 2px rgba(139,184,240,0.4); }
.theme-dark .profile-section-danger { border-color: #5a3030; }
.theme-dark .profile-section-danger .profile-section-toggle { color: #e07070; }
.theme-dark .profile-tag { background: rgba(255,255,255,0.06); }

/* Color Picker */
.cp-preview {
    width: 100%;
    height: 60px;
    border-radius: 10px;
    margin-bottom: 8px;
    border: 2px solid rgba(0,0,0,0.1);
}
.cp-hex-display {
    text-align: center;
    font-family: 'Courier New', monospace;
    font-size: 1.1em;
    font-weight: 700;
    margin-bottom: 12px;
    color: #333;
}
.cp-slider-group {
    margin-bottom: 10px;
}
.cp-label {
    display: block;
    font-size: 0.85em;
    font-weight: 600;
    margin-bottom: 4px;
    color: #555;
}
.cp-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 14px;
    border-radius: 8px;
    outline: none;
    cursor: pointer;
    border: 1px solid rgba(0,0,0,0.1);
}
.cp-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #888;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: pointer;
}
.cp-range::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #888;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    cursor: pointer;
}
.cp-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.cp-actions .profile-btn-inline {
    flex: 1;
}
.cp-reset-btn {
    background: #e0e0e0 !important;
    color: #333 !important;
}
.cp-reset-btn:hover {
    background: #d0d0d0 !important;
}

/* Color Picker dark theme */
.theme-dark .cp-hex-display { color: var(--ink, #e0e6f0); }
.theme-dark .cp-label { color: var(--ink-muted, #abb5c4); }
.theme-dark .cp-preview { border-color: rgba(255,255,255,0.15); }
.theme-dark .cp-range { border-color: rgba(255,255,255,0.15); }
.theme-dark .cp-range::-webkit-slider-thumb { background: #ccc; border-color: #666; }
.theme-dark .cp-range::-moz-range-thumb { background: #ccc; border-color: #666; }
.theme-dark .cp-reset-btn { background: #444 !important; color: #ddd !important; }
.theme-dark .cp-reset-btn:hover { background: #555 !important; }

/* Responsive */
@media (max-width: 500px) {
    .profile-modal-content { max-width: 100%; }
    .avatar-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); }
    .profile-cloud-btns { flex-direction: column; }
    .profile-field-row { flex-direction: column; }
    .profile-field-row .auth-btn { width: 100%; }
}

.save-conflict-options {
    display: flex;
    gap: 12px;
}
.save-conflict-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 16px 12px;
    border: 2px solid var(--panel-border, #dfe6f1);
    border-radius: 10px;
    background: var(--panel-bg-start, #f5f8ff);
    color: var(--ink, #1b2838);
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
    font-size: 0.95rem;
}
.save-conflict-btn:hover {
    border-color: #2196f3;
    background: rgba(33,150,243,0.08);
}
.save-conflict-date {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Dark theme overrides for auth */
.theme-dark .auth-input {
    background: #2f3742;
    border-color: var(--border-light);
    color: #e8eef5;
}
.theme-dark .auth-error { background: #3b1f1f; color: #e74c3c; }
.theme-dark .auth-success { background: #1b3a1b; color: #66bb6a; }
.theme-dark .auth-terms-text { border-color: var(--border-light); }
.theme-dark .save-conflict-btn {
    background: #2f3742;
    border-color: var(--border-light);
    color: #e8eef5;
}
.theme-dark .save-conflict-btn:hover {
    border-color: #2196f3;
    background: rgba(33,150,243,0.15);
}

@media screen and (max-width: 480px) {
    .save-conflict-options { flex-direction: column; }
    .account-section { gap: 4px; }
    .account-btn { padding: 5px 10px; font-size: 0.8rem; }
}
body.theme-dark .compendium-header-bar {
    background: rgba(42,49,57,0.95);
    border-bottom-color: var(--border-light);
}
body.theme-dark .ghost-link {
    background: rgba(47,55,66,0.7);
    color: #e8eef5;
    border-color: var(--border-light);
}
body.theme-dark .compendium-list li {
    background: rgba(47,55,66,0.6);
    border-color: var(--border-light);
    color: #e8eef5;
}
body.theme-dark .compendium-list li:hover {
    background: rgba(58,68,81,0.8);
}
body.theme-dark .compendium-list li.active {
    background: rgba(74,111,165,0.3);
    border-color: #4a9eff;
}

body.theme-midnight.compendium-page {
    background: radial-gradient(circle at 20% 20%, rgba(74,111,165,0.2), transparent 30%),
                radial-gradient(circle at 80% 0%, rgba(122,154,184,0.12), transparent 30%),
                linear-gradient(180deg, #0d1b2a, #071221);
    color: #d4e6f5;
}
body.theme-midnight .summary-card,
body.theme-midnight .stat-card {
    background: rgba(31,58,85,0.9);
    border: 1px solid var(--border-light);
    color: #d4e6f5;
}
body.theme-midnight .compendium-header-bar {
    background: rgba(27,58,82,0.95);
    border-bottom-color: var(--border-light);
}
body.theme-midnight .ghost-link {
    background: rgba(31,58,85,0.7);
    color: #d4e6f5;
    border-color: var(--border-light);
}
body.theme-midnight .compendium-list li {
    background: rgba(31,58,85,0.6);
    border-color: var(--border-light);
    color: #d4e6f5;
}
body.theme-midnight .compendium-list li:hover {
    background: rgba(42,74,104,0.8);
}
body.theme-midnight .compendium-list li.active {
    background: rgba(74,111,165,0.35);
    border-color: #4fc3f7;
}

body.theme-sunset.compendium-page {
    background: radial-gradient(circle at 20% 20%, rgba(212,163,115,0.15), transparent 30%),
                radial-gradient(circle at 80% 0%, rgba(200,136,90,0.1), transparent 30%),
                linear-gradient(180deg, #ffecd1, #ffe0bc);
    color: #3d2817;
}
body.theme-sunset .summary-card,
body.theme-sunset .stat-card {
    background: rgba(255,250,240,0.95);
    border: 1px solid var(--border-light);
    color: #3d2817;
}
body.theme-sunset .compendium-header-bar {
    background: rgba(255,244,230,0.95);
    border-bottom-color: var(--border-light);
}
body.theme-sunset .ghost-link {
    background: rgba(255,250,240,0.8);
    color: #3d2817;
    border-color: var(--border-light);
}

body.theme-forest.compendium-page {
    background: radial-gradient(circle at 20% 20%, rgba(90,124,89,0.15), transparent 30%),
                radial-gradient(circle at 80% 0%, rgba(106,148,105,0.1), transparent 30%),
                linear-gradient(180deg, #d4e8d4, #c8ddc8);
    color: #1f3a1e;
}
body.theme-forest .summary-card,
body.theme-forest .stat-card {
    background: rgba(240,250,240,0.95);
    border: 1px solid var(--border-light);
    color: #1f3a1e;
}
body.theme-forest .compendium-header-bar {
    background: rgba(232,245,232,0.95);
    border-bottom-color: var(--border-light);
}
body.theme-forest .ghost-link {
    background: rgba(240,250,240,0.8);
    color: #1f3a1e;
    border-color: var(--border-light);
}

body.theme-purple.compendium-page {
    background: radial-gradient(circle at 20% 20%, rgba(149,117,205,0.15), transparent 30%),
                radial-gradient(circle at 80% 0%, rgba(171,140,217,0.1), transparent 30%),
                linear-gradient(180deg, #f3e5f5, #ede0f5);
    color: #311b92;
}
body.theme-purple .summary-card,
body.theme-purple .stat-card {
    background: rgba(255,255,255,0.95);
    border: 1px solid var(--border-light);
    color: #311b92;
}
body.theme-purple .compendium-header-bar {
    background: rgba(248,244,252,0.95);
    border-bottom-color: var(--border-light);
}
body.theme-purple .ghost-link {
    background: rgba(255,255,255,0.8);
    color: #311b92;
    border-color: var(--border-light);
}

/* ===== THEME FIXES: preserve specific site elements ===== */
/* Keep the fishing forecast text in its original (normal) color — do not theme it */
/* Forecast: keep default (light) color in light theme, let other themes inherit body text */
body.theme-light .forecast-title,
body.theme-light .forecast-item {
    color: #0b2a4f !important;
}
/* In dark/midnight/other themes, allow forecast display to inherit the page/theme text color
   so bug-names follow overall theme text while rarity badges remain untouched. */
body.theme-dark .forecast-display,
body.theme-midnight .forecast-display,
body.theme-sunset .forecast-display,
body.theme-forest .forecast-display,
body.theme-purple .forecast-display {
    color: inherit !important;
}

/* Restore caught indicators (compendium + fishing) to their intended styling */
body.theme-dark .compendium-page .caught-pill,
body.theme-midnight .compendium-page .caught-pill,
body.theme-dark .compendium-page .detail-chip.caught,
body.theme-midnight .compendium-page .detail-chip.caught {
    background: linear-gradient(135deg, #e8f0ff, #cddcff) !important;
    border: 1px solid rgba(26,115,232,0.25) !important;
    color: #0b2a4f !important;
    box-shadow: 0 4px 10px rgba(26,115,232,0.12), inset 0 1px 0 rgba(255,255,255,0.9) !important;
}

/* Fishing-specific caught text: let the popup text follow the theme/text color so it's readable
   in dark themes. Rarity colors are enforced elsewhere and will not be changed. */
body.theme-dark .catch-splash .caught-text,
body.theme-midnight .catch-splash .caught-text,
body.theme-sunset .catch-splash .caught-text,
body.theme-forest .catch-splash .caught-text,
body.theme-purple .catch-splash .caught-text {
    color: inherit !important;
}
body.theme-dark .caught-bug,
body.theme-midnight .caught-bug,
body.theme-sunset .caught-bug,
body.theme-forest .caught-bug,
body.theme-purple .caught-bug {
    color: #0b2a4f !important;
}

/* Compendium 'ghost-link' buttons should keep compendium styling (light button appearance) */
body.theme-dark.compendium-page .ghost-link,
body.theme-midnight.compendium-page .ghost-link,
body.theme-sunset.compendium-page .ghost-link,
body.theme-forest.compendium-page .ghost-link,
body.theme-purple.compendium-page .ghost-link {
    background: rgba(255,255,255,0.65) !important;
    color: #0b2a4f !important;
    border-color: rgba(26,115,232,0.15) !important;
    box-shadow: 0 6px 14px rgba(26,115,232,0.12) !important;
}

/* Fishing donate / enter-coins controls: restore original contrast and borders */
body.theme-dark #wish-amount,
body.theme-midnight #wish-amount,
body.theme-sunset #wish-amount,
body.theme-forest #wish-amount,
body.theme-purple #wish-amount {
    border: 2px solid #0f5ba8 !important;
    color: #062243 !important;
    background: #ffffff !important;
}
body.theme-dark #wish-custom-btn,
body.theme-midnight #wish-custom-btn,
body.theme-sunset #wish-custom-btn,
body.theme-forest #wish-custom-btn,
body.theme-purple #wish-custom-btn,
body.theme-dark #wish-donate-all-btn,
body.theme-midnight #wish-donate-all-btn,
body.theme-sunset #wish-donate-all-btn,
body.theme-forest #wish-donate-all-btn,
body.theme-purple #wish-donate-all-btn {
    border: 2px solid #0f5ba8 !important;
    background: linear-gradient(135deg, #e6f0ff 0%, #c8daff 45%, #9fbfff 100%) !important;
    color: #062243 !important;
    box-shadow: 0 4px 0 rgba(17, 76, 151, 0.25), inset 0 1px 0 rgba(255,255,255,0.9) !important;
    border-radius: 8px !important;
    font-weight: 800 !important;
}

/* Theme compendium controls inside the fishing page */
body.theme-dark .compendium-count {
    background: rgba(47,55,66,0.6) !important;
    border-color: var(--border-light) !important;
    color: #e8eef5 !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03) !important;
}
body.theme-midnight .compendium-count {
    background: rgba(31,58,85,0.6) !important;
    border-color: var(--border-light) !important;
    color: #d4e6f5 !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03) !important;
}
body.theme-dark .compendium-btn {
    border: 2px solid var(--border-light) !important;
    background: linear-gradient(180deg, rgba(58,68,81,0.95) 0%, rgba(47,55,66,0.95) 100%) !important;
    color: #e8eef5 !important;
    box-shadow: 0 6px 0 rgba(0,0,0,0.25) !important;
}
body.theme-midnight .compendium-btn {
    border: 2px solid var(--border-light) !important;
    background: linear-gradient(180deg, rgba(42,74,104,0.95) 0%, rgba(31,58,85,0.95) 100%) !important;
    color: #d4e6f5 !important;
    box-shadow: 0 6px 0 rgba(0,0,0,0.28) !important;
}

/* ===== WISH / DONATE THEME ADJUSTMENTS (COLOR ONLY) ===== */
/* Wish note text (small helper line) */
body.theme-dark .wish-note,
body.theme-midnight .wish-note,
body.theme-sunset .wish-note,
body.theme-forest .wish-note,
body.theme-purple .wish-note {
    color: inherit !important; /* follow theme text color for readability */
}

/* Wish input / donate buttons: keep original layout but adjust colors per theme */
body.theme-dark #wish-amount,
body.theme-dark #wish-custom-btn,
body.theme-dark #wish-donate-all-btn {
    color: #e8eef5 !important;
    border-color: var(--border-light) !important;
}
body.theme-dark #wish-amount { background: rgba(47,55,66,0.6) !important; }
body.theme-dark #wish-custom-btn,
body.theme-dark #wish-donate-all-btn {
    background: linear-gradient(180deg, rgba(58,68,81,0.95) 0%, rgba(47,55,66,0.95) 100%) !important;
    box-shadow: 0 4px 0 rgba(0,0,0,0.25) !important;
}

body.theme-midnight #wish-amount,
body.theme-midnight #wish-custom-btn,
body.theme-midnight #wish-donate-all-btn {
    color: #d4e6f5 !important;
    border-color: var(--border-light) !important;
}
body.theme-midnight #wish-amount { background: rgba(31,58,85,0.6) !important; }
body.theme-midnight #wish-custom-btn,
body.theme-midnight #wish-donate-all-btn {
    background: linear-gradient(180deg, rgba(42,74,104,0.95) 0%, rgba(31,58,85,0.95) 100%) !important;
    box-shadow: 0 4px 0 rgba(0,0,0,0.28) !important;
}

/* Ensure other themes still have readable wish controls (minimal overrides) */
body.theme-sunset #wish-amount,
body.theme-forest #wish-amount,
body.theme-purple #wish-amount { color: inherit !important; background: #ffffff !important; border-color: #0f5ba8 !important; }
body.theme-sunset #wish-custom-btn,
body.theme-forest #wish-custom-btn,
body.theme-purple #wish-custom-btn,
body.theme-sunset #wish-donate-all-btn,
body.theme-forest #wish-donate-all-btn,
body.theme-purple #wish-donate-all-btn {
    color: inherit !important;
    border-color: #0f5ba8 !important;
    background: linear-gradient(135deg, #e6f0ff 0%, #c8daff 45%, #9fbfff 100%) !important;
}

/* Also ensure compendium summary (X/128 bugs caught) uses theme text colors for contrast */
body.theme-dark .compendium-count,
body.theme-midnight .compendium-count {
    color: inherit !important;
}


/* Normalize header button font-sizes so Music/Themes match Home/Games */
.button-tray button,
.button-tray a.nav-btn,
.button-group.nav a.nav-btn {
    font-size: 0.9rem !important;
}

/* Ensure coin/balance display keeps readable contrast */
body.theme-dark .button-group.wallet #coin-count,
body.theme-midnight .button-group.wallet #coin-count {
    color: #e8eef5 !important;
}

/* ===== GUARANTEE: RARITY TEXT COLORS MUST NEVER CHANGE WITH THEME ===== */
/* Only the text color is enforced; no layout or background changes. */
.rarity-common, .detail-chip.rarity-common { color: #888888 !important; }
.rarity-uncommon, .detail-chip.rarity-uncommon { color: #00aa00 !important; }
.rarity-rare, .detail-chip.rarity-rare { color: #0099ff !important; }
.rarity-epic, .detail-chip.rarity-epic { color: #d946ef !important; }
.rarity-ultra, .detail-chip.rarity-ultra { color: #ff0000 !important; }
.rarity-legendary, .detail-chip.rarity-legendary { color: #ffa500 !important; }
.rarity-mythic, .rarity-mythical, .detail-chip.rarity-mythic, .detail-chip.rarity-mythical { color: #7a4cff !important; }
.rarity-super, .detail-chip.rarity-super { color: #39ff14 !important; }
.rarity-medium-rare, .detail-chip.rarity-medium-rare { color: #d946ef !important; }
.detail-chip.rarity-awesome { color: #2f1a7a !important; }

/* ===== BUG RACE PAGE THEME STYLING ===== */
body.theme-dark .game-container {
    background: linear-gradient(180deg, rgba(47,55,66,0.92) 0%, rgba(38,45,54,0.92) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 8px 10px 0 rgba(0,0,0,0.35), 0 12px 32px rgba(0,0,0,0.3);
    color: #e8eef5;
}
body.theme-dark .race-header h1 { color: #e8eef5; }
body.theme-dark #betting-panel,
body.theme-dark #race-controls,
body.theme-dark #race-results {
    background: rgba(42,49,57,0.85);
    border: 1px solid var(--border-light);
    color: #e8eef5;
}
body.theme-dark #betting-panel h2,
body.theme-dark #race-results h2 { color: #e8eef5; }
body.theme-dark .bet-group label { color: #9aa5b5; }
body.theme-dark .race-track-container {
    background: rgba(26,32,40,0.6);
}

body.theme-midnight .game-container {
    background: linear-gradient(180deg, rgba(31,58,85,0.92) 0%, rgba(26,47,72,0.92) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 8px 10px 0 rgba(0,0,0,0.4), 0 12px 32px rgba(0,0,0,0.35);
    color: #d4e6f5;
}
body.theme-midnight .race-header h1 { color: #d4e6f5; }
body.theme-midnight #betting-panel,
body.theme-midnight #race-controls,
body.theme-midnight #race-results {
    background: rgba(27,58,82,0.85);
    border: 1px solid var(--border-light);
    color: #d4e6f5;
}
body.theme-midnight #betting-panel h2,
body.theme-midnight #race-results h2 { color: #d4e6f5; }
body.theme-midnight .bet-group label { color: #7a9ab8; }
body.theme-midnight .race-track-container {
    background: rgba(13,27,42,0.6);
}

body.theme-sunset .game-container {
    background: linear-gradient(180deg, rgba(255,250,240,0.92) 0%, rgba(255,236,209,0.92) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 8px 10px 0 rgba(184,136,90,0.25), 0 12px 32px rgba(139,111,71,0.2);
    color: #3d2817;
}
body.theme-sunset .race-header h1 { color: #3d2817; }
body.theme-sunset #betting-panel,
body.theme-sunset #race-controls,
body.theme-sunset #race-results {
    background: rgba(255,250,240,0.9);
    border: 1px solid var(--border-light);
    color: #3d2817;
}
body.theme-sunset #betting-panel h2,
body.theme-sunset #race-results h2 { color: #3d2817; }
body.theme-sunset .bet-group label { color: #8b6f47; }

body.theme-forest .game-container {
    background: linear-gradient(180deg, rgba(240,250,240,0.92) 0%, rgba(220,240,220,0.92) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 8px 10px 0 rgba(90,124,89,0.25), 0 12px 32px rgba(74,101,73,0.2);
    color: #1f3a1e;
}
body.theme-forest .race-header h1 { color: #1f3a1e; }
body.theme-forest #betting-panel,
body.theme-forest #race-controls,
body.theme-forest #race-results {
    background: rgba(240,250,240,0.9);
    border: 1px solid var(--border-light);
    color: #1f3a1e;
}
body.theme-forest #betting-panel h2,
body.theme-forest #race-results h2 { color: #1f3a1e; }
body.theme-forest .bet-group label { color: #4a6549; }

body.theme-purple .game-container {
    background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(237,229,245,0.92) 100%);
    border: 2px solid var(--border-light);
    box-shadow: 8px 10px 0 rgba(126,87,194,0.25), 0 12px 32px rgba(106,76,147,0.2);
    color: #311b92;
}
body.theme-purple .race-header h1 { color: #311b92; }
body.theme-purple #betting-panel,
body.theme-purple #race-controls,
body.theme-purple #race-results {
    background: rgba(255,255,255,0.9);
    border: 1px solid var(--border-light);
    color: #311b92;
}
body.theme-purple #betting-panel h2,
body.theme-purple #race-results h2 { color: #311b92; }
body.theme-purple .bet-group label { color: #6a4c93; }

/* Combat tester styles moved to styles/test-combat.css */

