:root {
    --primary-color: #ff6347; /* Tomato */
    --secondary-color: #4682b4; /* SteelBlue */
    --background-color: #f0f8ff; /* AliceBlue */
    --text-color: #333;
    --card-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --border-color: #ddd;
    --header-bg: var(--primary-color);
    --header-text: white;
    --button-bg: var(--secondary-color);
    --button-text: white;
    --link-color: var(--secondary-color);
}

body.dark-mode {
    --primary-color: #e55337;
    --secondary-color: #5a9bd4;
    --background-color: #121212;
    --text-color: #e0e0e0;
    --card-bg: #1e1e1e;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --border-color: #444;
    --header-bg: #1f1f1f;
    --button-bg: var(--secondary-color);
    --link-color: var(--secondary-color);
}

body {
    font-family: 'Lato', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    margin: 0;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 2rem;
    text-align: center;
    box-shadow: 0 2px 4px var(--shadow-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: background-color 0.3s;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 2rem;
}

header h1 {
    font-family: 'Bangers', cursive;
    font-size: 2.5rem;
    margin: 0;
    letter-spacing: 2px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

nav .nav-tab {
    font-family: 'Bangers', cursive;
    font-size: 1.5rem;
    letter-spacing: 1px;
    background: none;
    border: none;
    color: var(--header-text);
    padding: 0.5rem 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: border-color 0.3s, opacity 0.3s;
    opacity: 0.7;
}

nav .nav-tab:hover {
    opacity: 1;
}

nav .nav-tab.active {
    border-bottom-color: var(--primary-color);
    opacity: 1;
}

body.dark-mode nav .nav-tab.active {
    border-bottom-color: var(--button-text);
}

main {
    padding: 2rem;
}

.view-container {
    display: none;
}

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

.comic-gallery, .character-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.comic-card, .character-card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 8px var(--shadow-color);
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s;
    display: flex;
    flex-direction: column;
}

.comic-card {
    cursor: pointer;
}

.comic-card:hover, .character-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px var(--shadow-color);
}

.character-card.highlight {
    box-shadow: 0 0 15px 5px var(--primary-color);
}

.comic-card-image, .character-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    object-position: top;
    border-bottom: 2px solid var(--primary-color);
    background-color: #ccc;
}
.character-card-image {
    object-position: center;
    height: 250px;
}

.comic-card-content, .character-card-content {
    padding: 1rem;
    flex-grow: 1;
}

.comic-card-content h2, .character-card-content h3 {
    margin-top: 0;
    font-family: 'Bangers', cursive;
    color: var(--secondary-color);
    font-size: 1.8rem;
}
.character-card-content h3 {
    font-size: 2rem;
}

.comic-card-content p, .character-card-content p {
    font-size: 0.9rem;
    color: #888;
}

.character-card-content .character-summary {
    font-size: 0.9rem;
    color: var(--text-color);
    margin-top: 10px;
    flex-grow: 1;
}

.character-card-content .character-appearances {
    font-size: 0.8rem;
    color: #888;
    font-style: italic;
}

body.dark-mode .comic-card-content p, 
body.dark-mode .character-card-content p {
    color: #aaa;
}

body.dark-mode .character-card-content .character-summary {
    color: var(--text-color);
}

body.dark-mode .character-card-content .character-appearances {
    color: #888;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background-color: var(--card-bg);
    margin: auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 1200px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: background-color 0.3s;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 25px;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1010;
}

.close-button:hover,
.close-button:focus {
    color: var(--primary-color);
    text-decoration: none;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
    transition: border-color 0.3s;
    flex-wrap: wrap;
    gap: 10px;
}

.modal-header h2 {
    font-family: 'Bangers', cursive;
    color: var(--secondary-color);
    margin: 0;
    flex-grow: 1;
    min-width: 150px;
}

.modal-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.autoplay-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Visually hidden but accessible checkbox */
.autoplay-toggle-checkbox {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.autoplay-label {
    cursor: pointer;
    display: block;
    position: relative;
    width: 38px;
    height: 38px;
}

#autoplay-toggle-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background-color: #888; /* Default off state color */
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px 20px;
    transition: background-color 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
}

.autoplay-toggle-checkbox:checked + #autoplay-toggle-btn {
    background-color: var(--button-bg); /* Active color */
}

#autoplay-duration-input {
    width: 45px;
    padding: 5px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: var(--background-color);
    color: var(--text-color);
    text-align: center;
    font-size: 0.9rem;
    -moz-appearance: textfield;
}

#autoplay-duration-input::-webkit-outer-spin-button,
#autoplay-duration-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.zoom-controls button {
    background: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-left: 5px;
    transition: background-color 0.2s;
}

#fullscreen-btn {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 14H5v5h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 20px 20px;
    width: 38px;
    font-size: 0; /* Hide text */
}

#fullscreen-btn.exit-fullscreen {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M5 16h3v3h2v-5H5v2zm3-8H5v2h5V5H8v3zm6 11h2v-3h3v-2h-5v5zm2-11V5h-2v5h5V8h-3z'/%3E%3C/svg%3E");
}

.zoom-controls button:hover {
    background-color: #5a9bd4;
}

body.dark-mode .zoom-controls button:hover {
    background-color: #7caeeb;
}

.modal-image-container {
    flex-grow: 1;
    overflow: hidden;
    cursor: grab;
    background-color: #f0f0f0;
    border-radius: 4px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

body.dark-mode .modal-image-container {
    background-color: #2a2a2a;
}

.modal-image-container:active {
    cursor: grabbing;
}

.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background-color: rgba(30, 30, 30, 0.5);
    color: white;
    border: none;
    font-size: 2rem;
    padding: 0;
    cursor: pointer;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s, opacity 0.3s;
    z-index: 10;
    opacity: 0;
    line-height: 50px; /* Center the arrow */
}

.modal-image-container:hover .modal-nav-btn {
    opacity: 1;
}

.modal-nav-btn:hover {
    background-color: rgba(0, 0, 0, 0.8);
}

.modal-nav-btn.prev {
    left: 15px;
}

.modal-nav-btn.next {
    right: 15px;
}

.modal-nav-btn:disabled {
    background-color: rgba(30, 30, 30, 0.2);
    cursor: not-allowed;
    opacity: 0.5;
}

#modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease-out;
    transform-origin: center center;
}

.modal-details {
    max-height: 40%;
    overflow-y: auto;
    margin-top: 15px;
    padding-right: 15px;
}

.modal-details h3 {
    color: var(--primary-color);
    margin-bottom: 5px;
}
.modal-details p, .modal-details pre {
    margin-top: 0;
    margin-bottom: 15px;
}

.modal-details #modal-characters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.character-tag {
    background-color: var(--secondary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s;
}

.character-tag:hover {
    background-color: var(--primary-color);
    transform: scale(1.05);
}

.recommended-comics-container {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    padding-bottom: 10px;
}

.recommended-comic-card {
    width: 130px;
    flex-shrink: 0;
    cursor: pointer;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    background-color: var(--card-bg);
    display: flex;
    flex-direction: column;
}

.recommended-comic-card:hover {
    transform: scale(1.05);
    box-shadow: 0 0 8px var(--primary-color);
}

.recommended-comic-card img {
    width: 100%;
    height: 80px;
    object-fit: cover;
    object-position: top;
    display: block;
}

.recommended-comic-card p {
    font-size: 0.8rem;
    padding: 8px 5px;
    margin: 0;
    text-align: center;
    color: var(--text-color);
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Wiki Section Styles */
#wiki-view {
    max-width: 800px;
    margin: 0 auto;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 8px var(--shadow-color);
}

#wiki-view h2 {
    font-family: 'Bangers', cursive;
    color: var(--secondary-color);
    text-align: center;
    font-size: 2.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
}

.wiki-section {
    margin-bottom: 2rem;
}

.wiki-section h3 {
    font-family: 'Bangers', cursive;
    color: var(--primary-color);
    font-size: 1.8rem;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.wiki-section h4 {
    font-family: 'Bangers', cursive;
    color: var(--secondary-color);
    font-size: 1.5rem;
    letter-spacing: 1px;
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
    border-left: 3px solid var(--secondary-color);
    padding-left: 10px;
}

.wiki-image {
    max-width: 100%;
    border-radius: 8px;
    margin: 1rem 0;
    box-shadow: 0 2px 6px var(--shadow-color);
}

.wiki-section p, .credits-list {
    font-size: 1.1rem;
    line-height: 1.7;
}

.wiki-section p a {
    color: var(--link-color);
    text-decoration: none;
    font-weight: bold;
}

.wiki-section p a:hover {
    text-decoration: underline;
}

.credits-list {
    list-style: none;
    padding-left: 0;
}

.credits-list li {
    background: var(--background-color);
    padding: 1rem;
    border-radius: 5px;
    margin-bottom: 0.5rem;
    border-left: 4px solid var(--secondary-color);
}

.credits-list strong {
    color: var(--primary-color);
}

.credits-list em {
    color: var(--secondary-color);
    font-style: normal;
    font-weight: bold;
}

/* Theme Switcher */
.theme-switcher {
    position: relative;
    display: inline-block;
}

.theme-toggle-label {
    display: block;
    width: 60px;
    height: 30px;
    background-color: #ccc;
    border-radius: 15px;
    cursor: pointer;
    position: relative;
    transition: background-color 0.3s;
}

body.dark-mode .theme-toggle-label {
    background-color: #444;
}

.theme-toggle-input {
    display: none;
}

.theme-toggle-slider {
    position: absolute;
    top: 3px;
    left: 4px;
    width: 24px;
    height: 24px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s;
}

.theme-toggle-input:checked + .theme-toggle-slider {
    transform: translateX(29px);
}