/* Core theme variables */
:root {
    --primary-bg: #121212;
    --primary-bg-rgb: 18, 18, 18;
    --secondary-bg: #1e1e1e;
    --secondary-bg-rgb: 30, 30, 30;
    --tertiary-bg: #252525;
    --accent-color: #C25B56;
    --text-color: #e6e6e6;
    /* Ghost Colors */
    --iblis-color: #c62828;
    --diogen-color: #795548;
    --agesh-color: #90caf9;
    --shade-color: #424242;
    --unreal-color: #e91e63;
    --oni-color: #311b92;
    --thaye-color: #4caf50;
    --raiju-color: #2196f3;
    --yuri-color: #880e4f;
    --mayor-color: #9c27b0;
    --jin-color: #ff9800;
    --anima-color: #8bc34a;
    --grippo-color: #607d8b;
    --boogie-color: #ff5722;
    --rafe-color: #3f51b5;
    --yaga-color: #673ab7;
    --abaddon-color: #212121;
    --revenant-color: #9e9e9e;
    --poltergeist-color: #78909c;
    --hunter-color: #5d4037;
    --myling-color: #7986cb;
    --gorio-color: #43a047;
    --demon-color: #8b0000;
    --ghoul-color: #6a1b9a;
}
/* Light theme override */
:root[data-theme="light"] {
    --primary-bg: #f8f8f8;
    --primary-bg-rgb: 248, 248, 248;
    --secondary-bg: #ffffff;
    --secondary-bg-rgb: 255, 255, 255;
    --tertiary-bg: #f0f0f0;
    --accent-color: #d32f2f;
    --text-color: #212121;
}

/* Base styles */
body {
    font-family: 'Roboto', Arial, sans-serif;
    margin: 0;
    padding: 8px;
    background: linear-gradient(135deg, var(--primary-bg) 0%, var(--secondary-bg) 100%);
    background-size: 400% 400%;
    animation: gradient 15s ease infinite;
    color: var(--text-color);
    transition: all 0.3s ease;
    font-size: 0.9rem;
    line-height: 1.5;
}

@keyframes gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    max-width: 1200px;
    margin: 0 auto 20px;
    padding: 12px;
    background-color: var(--secondary-bg);
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: transform 0.3s, box-shadow 0.3s;
}

.container:hover {
    box-shadow: 0 5px 15px rgba(0,0,0,0.7);
}

/* Header styles */
.header {
    margin-bottom: 20px;
    padding: 15px 20px;
}

.header-content {
    display: flex;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    text-align: left;
}

.header-text {
    margin-left: 15px;
}

.site-logo {
    height: 150px;
    filter: drop-shadow(0 0 3px var(--accent-color));
    transition: transform 0.3s;
}

.site-logo:hover {
    transform: rotate(5deg) scale(1.1);
}

h1, h2, h3 {
    color: var(--accent-color);
    margin: 0 0 10px 0;
    font-weight: 600;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 5px;
    letter-spacing: 0.5px;
}

.header-tagline {
    font-size: 1rem;
    color: var(--accent-color);
    margin-bottom: 25px;
    font-style: italic;
}

/* Progress bar */
.progress-bar {
    height: 6px;
    width: 100%;
    background-color: var(--tertiary-bg);
    border-radius: 3px;
    margin: 15px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--accent-color);
    width: 0; /* Controlled by JS based on completed traits */
    transition: width 0.5s ease-out;
}

.back-button {
            display: inline-block;
            padding: 8px 15px;
            background-color: var(--tertiary-bg);
            color: var(--accent-color);
            text-decoration: none;
            border-radius: 4px;
            transition: all 0.3s;
            font-weight: 500;
        }

        .back-button:hover {
            background-color: rgba(187, 134, 252, 0.1);
        }


/* Accordion styles */
details {
    margin: 0 0 20px 0;
    background-color: var(--secondary-bg);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
    transition: transform 0.3s;
}

details:hover {
    transform: translateY(-3px);
}

details summary {
    cursor: pointer;
    padding: 12px 15px;
    color: var(--text-color);
    background-color: var(--tertiary-bg);
    list-style: none;
    font-weight: bold;
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: background-color 0.3s;
}

details summary:hover {
    background-color: rgba(185, 28, 28, 0.1);
}

details summary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.5);
}

details summary::-webkit-details-marker {
    display: none;
}

details summary::before {
    content: "▶";
    font-size: 0.8em;
    margin-right: 8px;
    transition: transform 0.3s;
}

details[open] summary::before {
    transform: rotate(90deg);
}

details .content {
    padding: 20px;
    background-color: var(--tertiary-bg);
    margin-top: 10px;
    border-radius: 5px;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Control buttons explanation section */
.control-buttons-explanation {
    margin-top: 25px;
}

.control-button-item {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 20px;
    transition: transform 0.3s;
    text-align: left;
}

.control-button-item:hover {
    transform: translateX(5px);
}

.button-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-bg);
    font-size: 20px;
    flex-shrink: 0;
    box-shadow: 0 3px 5px rgba(0,0,0,0.2);
    transition: transform 0.3s, box-shadow 0.3s;
}

.control-button-item:hover .button-icon {
    transform: scale(1.1);
    box-shadow: 0 5px 10px rgba(0,0,0,0.3);
}

.button-details {
    flex-grow: 1;
}

.button-title {
    font-weight: bold;
    margin-bottom: 5px;
    color: var(--accent-color);
}

.button-description {
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Trait section styles */
.trait-section {
    margin: 10px 0;
    padding: 12px;
    background-color: var(--tertiary-bg);
    border-radius: 5px;
    transition: transform 0.3s, opacity 0.3s, box-shadow 0.3s;
}

.trait-section:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    background-color: rgba(185, 28, 28, 0.05);
}

.trait-section h2 {
    margin-bottom: 15px;
    border-bottom: 1px solid rgba(185, 28, 28, 0.2);
    padding-bottom: 8px;
}

.trait-checkboxes-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px 20px;
}

.trait-checkbox {
    margin-bottom: 6px;
    position: relative;
}

.trait-checkbox label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background-color 0.3s, transform 0.2s;
}

.trait-checkbox label:hover {
    background-color: rgba(185, 28, 28, 0.1);
    transform: translateX(3px);
}

.trait-checkbox label:focus-within {
    background-color: rgba(185, 28, 28, 0.2);
}

.trait-checkbox input[type="checkbox"] {
    margin-right: 10px;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--accent-color);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.trait-checkbox input[type="checkbox"]:checked {
    background-color: var(--accent-color);
    transform: scale(1.1);
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.5);
}

.trait-checkbox input[type="checkbox"]:checked:after {
    content: "✓";
    position: absolute;
    color: var(--primary-bg);
    font-size: 14px;
    left: 3px;
    top: -1px;
}

.trait-checkbox input[type="checkbox"]:focus {
    box-shadow: 0 0 0 3px rgba(187, 134, 252, 0.5);
}

/* Confirmation and elimination styles */
.confirmation-trait {
    background-color: rgba(185, 28, 28, 0.1);
    border-left: 3px solid var(--accent-color);
    padding-left: 8px;
    margin: 2px 0;
    border-radius: 4px;
}

.elimination-trait {
    opacity: 0.7;
    text-decoration: line-through;
    text-decoration-color: var(--accent-color);
    text-decoration-thickness: 2px;
}

/* Ghost trait sections */
.ghost-traits {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.trait-group {
    padding: 8px 0;
}

/* Ghost list styles */
.ghost-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 15px;
    transition: all 0.3s ease;
}

.ghost-item {
    background-color: var(--tertiary-bg);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: transform 0.3s, box-shadow 0.3s;
    transform-origin: center;
}

.ghost-item:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 8px 15px rgba(0,0,0,0.3);
    z-index: 2;
}

/* Ghost item specific styles */
.ghost-item.confirmation-trait {
    background-color: rgba(185, 28, 28, 0.1);
    border: 2px solid var(--accent-color);
    font-weight: bold;
    grid-column: span 2;
    font-size: 1.1em;
    z-index: 2;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(185, 28, 28, 0); }
    100% { box-shadow: 0 0 0 0 rgba(185, 28, 28, 0); }
}

.ghost-item.elimination-trait {
    opacity: 0.5;
    text-decoration: line-through;
    text-decoration-color: var(--accent-color);
    text-decoration-thickness: 2px;
}

.just-eliminated {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}

.just-confirmed {
    animation: bounce 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

@keyframes bounce {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Button styles */
.button-group {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

.button {
    padding: 8px 16px;
    background-color: var(--accent-color);
    color: var(--primary-bg);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
}

.button:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.5);
}

/* Tooltip styles */
.tooltip {
    position: relative;
    display: inline-block;
    margin-left: 8px;
    color: var(--accent-color);
    cursor: help;
}

.tooltip .tooltip-text {
    visibility: hidden;
    position: absolute;
    z-index: 1;
    width: 200px;
    background-color: var(--secondary-bg);
    color: var(--text-color);
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    left: 50%;
    transform: translateX(-50%);
    bottom: 125%;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--accent-color);
    color: var(--primary-bg);
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(-10px);
}

/* Fixed side buttons container */
.fixed-side-buttons {
    position: fixed;
    right: 12px;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
    background: rgba(var(--secondary-bg-rgb), 0.7);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s;
}

.fixed-side-buttons:hover {
    background: rgba(var(--secondary-bg-rgb), 0.9);
    transform: scale(1.05);
}

/* Common button styles */
.reset-button,
.theme-button,
.view-toggle-button,
.scroll-button {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 50%;
    background-color: var(--accent-color);
    color: var(--primary-bg);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.9;
    transition: opacity 0.3s, transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

/* Button hover effects */
.reset-button:hover,
.theme-button:hover,
.view-toggle-button:hover,
.scroll-button:hover {
    opacity: 1;
    transform: scale(1.1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Button active effects */
.reset-button:active,
.theme-button:active,
.view-toggle-button:active,
.scroll-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 3px rgba(0,0,0,0.2);
}

.reset-button:focus,
.theme-button:focus,
.view-toggle-button:focus,
.scroll-button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(185, 28, 28, 0.5);
}

/* Active state for view toggle */
.view-toggle-button.active {
    background-color: var(--text-color);
    color: var(--primary-bg);
}

/* Scroll buttons container */
.scroll-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Initial state for scroll buttons */
#scrollTop,
#scrollBottom {
    display: none;
}

/* View status indicator */
.view-status {
    text-align: left;
    margin-top: 15px;
    font-size: 0.8rem;
    color: var(--accent-color);
    opacity: 0.8;
    padding: 5px 10px;
    background-color: rgba(185, 28, 28, 0.05);
    border-radius: 4px;
}

/* Footer styles */
.footer {
    text-align: center;
    padding: 15px 10px;
    margin-top: 30px;
    background-color: var(--secondary-bg);
    color: var(--text-color);
    border-top: 1px solid rgba(185, 28, 28, 0.2);
    font-size: 0.85rem;
    max-width: 1200px;
    margin-left: auto;
    margin-right: auto;
    border-radius: 0 0 8px 8px;
    transition: transform 0.3s;
}

.footer:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.footer a {
    color: var(--accent-color);
    text-decoration: none;
    transition: color 0.3s, text-decoration 0.3s;
}

.footer a:hover {
    color: var(--text-color);
    text-decoration: underline;
}

/* Dark and Light mode transition */
.theme-transition {
    transition: background-color 0.5s, color 0.5s, border-color 0.5s;
}

/* Media query for tablets */
@media (max-width: 992px) {
    .trait-checkboxes-container {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .ghost-list {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
    
    .ghost-item.confirmation-trait {
        grid-column: span 1;
    }
}

/* Media query for mobile */
@media (max-width: 768px) {
    .ghost-list {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }

    .ghost-item {
        font-size: 0.8rem;
        padding: 8px 6px;
    }
    
    .trait-checkbox label {
        padding: 8px 6px;
        margin-bottom: 8px;
    }
    
    .trait-checkbox input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    .fixed-side-buttons {
        right: 6px;
        bottom: 6px;
        transform: scale(0.95);
        gap: 12px; /* Increased gap for better spacing */
    }

    .reset-button,
    .theme-button,
    .view-toggle-button,
    .scroll-button {
        width: 48px;
        height: 48px;
        font-size: 18px;
    }

    body {
        font-size: 0.85rem;
        padding: 5px;
    }

    .container {
        padding: 8px;
        margin-bottom: 60px; /* Add space at bottom to avoid buttons overlapping content */
    }

    .tooltip .tooltip-text {
        width: 150px;
        font-size: 0.7rem;
        padding: 4px;
    }
    
    .control-button-item {
        flex-direction: row;
        align-items: flex-start;
        text-align: left;
        padding: 8px;
    }
    
    .button-icon {
        float: none !important;
        margin-right: 10px !important;
        margin-bottom: 0 !important;
    }
    
    .button-details {
        flex: 1;
    }
    
    .trait-checkboxes-container {
        grid-template-columns: repeat(1, 1fr);
    }
    
    .footer {
        font-size: 0.8rem;
        padding: 12px 5px;
    }
}

/* Media query for very small screens */
@media (max-width: 480px) {
    .ghost-list {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    }
    
    .ghost-item {
        font-size: 0.75rem;
        padding: 6px 4px;
    }
    
    .fixed-side-buttons {
        right: 3px; /* Moved all the way to the edge */
        bottom: 5px;
        transform: scale(0.9);
        transform-origin: bottom right; /* Set the origin of transformation */
    }
    
    .reset-button,
    .theme-button,
    .view-toggle-button,
    .scroll-button {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    /* Add extra space at the bottom for the buttons */
    .container {
        margin-bottom: 70px;
    }
    
    .button-description {
        font-size: 0.8rem;
    }
    
    /* Ensure single column for trait checkboxes on very small screens */
    .trait-checkboxes-container {
        grid-template-columns: 1fr;
        gap: 5px;
    }
    
    /* Footer responsive adjustments */
    .footer {
        font-size: 0.7rem;
        padding: 10px 5px;
        margin-top: 20px;
    }
    
    .back-button {
            display: inline-block;
            padding: 8px 15px;
            background-color: var(--tertiary-bg);
            color: var(--accent-color);
            text-decoration: none;
            border-radius: 4px;
            margin-bottom: 20px;
            transition: all 0.3s;
            font-weight: 500;
        }

        .back-button:hover {
            background-color: rgba(187, 134, 252, 0.1);
        }
}