:root {
    --ink-color: #1a1a1a;
    --paper-color: #fcfcfc;
    --panel-bg: #ffffff;
    --accent-color: #ff4757;
    --shadow-offset: 6px;
    --border-width: 3px;
    --font-main: 'Patrick Hand', cursive;
    --font-title: 'Architects Daughter', cursive;
    --grid-line-color: rgba(26, 26, 26, 0.05);
    --placeholder-bg: #eee;
}

body.dark-mode {
    --ink-color: #e8e8e8;
    --paper-color: #0d0d0d;
    --panel-bg: #1a1a1a;
    --accent-color: #ff6b81;
    --grid-line-color: rgba(255, 255, 255, 0.08);
    --placeholder-bg: #2d2d2d;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--paper-color);
    color: var(--ink-color);
    font-family: var(--font-main);
    margin: 0;
    padding: 20px;
    overflow-x: hidden;
    background-image:
        linear-gradient(var(--ink-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--ink-color) 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: -1px -1px;
    /* Make grid lines very subtle */
    background-image:
        linear-gradient(var(--grid-line-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-line-color) 1px, transparent 1px);
}

.comic-page {
    max-width: 1000px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
    padding-bottom: 50px;
    width: 100%;
}

/* Comic Panel Common Styles */
.comic-panel {
    background: var(--panel-bg);
    border: var(--border-width) solid var(--ink-color);
    box-shadow: var(--shadow-offset) var(--shadow-offset) 0px var(--ink-color);
    padding: 20px;
    position: relative;
    transition: transform 0.2s ease;
}

.comic-panel:hover {
    transform: translate(-2px, -2px);
    box-shadow: calc(var(--shadow-offset) + 2px) calc(var(--shadow-offset) + 2px) 0px var(--ink-color);
}

.panel-label {
    position: absolute;
    top: -15px;
    left: 10px;
    background: var(--ink-color);
    color: var(--paper-color);
    padding: 2px 10px;
    font-family: var(--font-title);
    font-size: 0.9rem;
    transform: rotate(-2deg);
}

/* Typography */
h1,
h2,
h3 {
    font-family: var(--font-title);
    text-transform: uppercase;
    margin-top: 0;
}

.comic-title {
    font-size: 3.5rem;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1);
    margin-bottom: 0.5rem;
}

.comic-subtitle {
    font-size: 1.5rem;
    font-style: italic;
    color: var(--ink-color);
    opacity: 0.7;
    margin-bottom: 1rem;
}

/* Hero Section */
.hero-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px;
    position: relative;
}

.hero-image-placeholder {
    width: 100%;
    height: 200px;
    background: var(--placeholder-bg);
    border: 2px dashed var(--ink-color);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    color: #888;
}

.speech-bubble {
    position: relative;
    background: var(--panel-bg);
    border: 2px solid var(--ink-color);
    border-radius: 50%;
    padding: 20px;
    max-width: 300px;
    margin: 20px auto;
    text-align: center;
}

.speech-bubble::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 20%;
    width: 0;
    height: 0;
    border: 15px solid transparent;
    border-top-color: var(--ink-color);
    border-bottom: 0;
    border-left: 0;
    margin-left: -10px;
    margin-bottom: -15px;
}

/* Nav */
.nav-panel ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-around;
    gap: 10px;
}

.nav-panel a {
    text-decoration: none;
    color: var(--ink-color);
    font-weight: bold;
    font-size: 1.2rem;
    border-bottom: 2px solid transparent;
}

.nav-panel a:hover {
    border-bottom: 2px solid var(--accent-color);
    transform: rotate(-2deg);
    display: inline-block;
    color: var(--accent-color);
}

/* Character Sheet */
.character-sheet {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 600px) {
    .character-sheet {
        grid-template-columns: 150px 1fr;
    }
}

.avatar-placeholder {
    width: 150px;
    height: 150px;
    background: var(--placeholder-bg);
    border: 2px solid var(--ink-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stats-box ul {
    list-style: none;
    padding: 0;
}

.stats-box li {
    margin-bottom: 5px;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 2px;
}

/* Projects */
.projects-container {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.project-image {
    height: 150px;
    background: var(--placeholder-bg);
    border: 2px solid var(--ink-color);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tech-stack {
    font-size: 0.9rem;
    color: var(--ink-color);
    opacity: 0.8;
    font-weight: bold;
    margin-top: 10px;
}

/* Skills */
.skill-item {
    margin-bottom: 10px;
    font-weight: bold;
}

.skill-bar {
    display: block;
    height: 10px;
    background: var(--ink-color);
    margin-top: 5px;
    position: relative;
}

.skill-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(45deg,
            transparent,
            transparent 5px,
            rgba(255, 255, 255, 0.3) 5px,
            rgba(255, 255, 255, 0.3) 10px);
}

/* Form */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.sketchy-input {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--ink-color);
    background: transparent;
    font-family: var(--font-main);
    font-size: 1rem;
    outline: none;
}

.sketchy-input:focus {
    box-shadow: 2px 2px 0px var(--accent-color);
}

.sketchy-btn {
    background: var(--ink-color);
    color: var(--paper-color);
    border: none;
    padding: 10px 20px;
    font-family: var(--font-title);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 3px 3px 0px #888;
    transition: all 0.1s;
}

.sketchy-btn:hover {
    transform: translate(-1px, -1px);
    box-shadow: 4px 4px 0px #888;
    background: var(--accent-color);
}

.sketchy-btn:active {
    transform: translate(2px, 2px);
    box-shadow: 1px 1px 0px #888;
}

/* --- Dynamic Missions Styles --- */
.category-tabs {
    display: flex;
    justify-content: flex-start;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding: 5px 2px 12px;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
    scrollbar-color: var(--ink-color) transparent;
}

/* Dark mode scrollbar styling */
body.dark-mode .category-tabs {
    scrollbar-color: rgba(232, 232, 232, 0.5) rgba(255, 255, 255, 0.1);
}

body.dark-mode .category-tabs::-webkit-scrollbar {
    height: 8px;
}

body.dark-mode .category-tabs::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

body.dark-mode .category-tabs::-webkit-scrollbar-thumb {
    background: rgba(232, 232, 232, 0.5);
    border-radius: 4px;
}

body.dark-mode .category-tabs::-webkit-scrollbar-thumb:hover {
    background: rgba(232, 232, 232, 0.7);
}

.tab-btn {
    background: var(--panel-bg);
    color: var(--ink-color);
    border: 2px solid var(--ink-color);
    padding: 8px 16px;
    font-family: 'Architects Daughter', cursive;
    flex: 0 0 auto;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
    scroll-snap-align: start;
}

.tab-btn:hover {
    transform: translateY(-2px);
    box-shadow: 3px 5px 0 rgba(0, 0, 0, 0.2);
}

.tab-btn.active {
    background: #ff4757;
    color: white;
    transform: scale(1.05);
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.missions-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 30px;
    width: 100%;
    overflow-x: auto;
    padding: 10px 2px 18px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    max-width: 100%;
    min-width: 0;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--ink-color) transparent;
}

/* Dark mode scrollbar styling */
body.dark-mode .missions-grid {
    scrollbar-color: rgba(232, 232, 232, 0.5) rgba(255, 255, 255, 0.1);
}

body.dark-mode .missions-grid::-webkit-scrollbar {
    height: 8px;
}

body.dark-mode .missions-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

body.dark-mode .missions-grid::-webkit-scrollbar-thumb {
    background: rgba(232, 232, 232, 0.5);
    border-radius: 4px;
}

body.dark-mode .missions-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(232, 232, 232, 0.7);
}

.project-panel {
    /* Override absolute widths for grid context if necessary, 
       but keeping .comic-panel styles is usually fine for cards */
    display: flex;
    flex-direction: column;
    flex: 0 0 clamp(260px, 82vw, 360px);
    scroll-snap-align: start;
}

.project-panel p,
.project-panel .tech-stack {
    transition: opacity 0.3s ease;
}

/* Desktop: hide description by default, show on hover */
@media (min-width: 900px) {
    .missions-grid {
        scroll-snap-type: x proximity;
    }

    .project-panel {
        flex: 0 0 min(360px, calc((100% - 60px) / 3));
    }

    .project-panel p,
    .project-panel .tech-stack {
        opacity: 0;
        pointer-events: none;
    }

    .project-panel:hover p,
    .project-panel:hover .tech-stack {
        opacity: 1;
        pointer-events: auto;
    }
}

.project-image-container {
    width: 100%;
    aspect-ratio: 4 / 3;
    height: auto;
    background: var(--placeholder-bg);
    margin: 10px 0;
    overflow: hidden;
    border: 2px solid #000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.project-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.project-media {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.loading-text,
.empty-state {
    font-family: 'Patrick Hand', cursive;
    font-size: 1.5rem;
    text-align: center;
    width: 100%;
    padding: 40px;
    flex: 0 0 100%;
}

@media (max-width: 768px) {
    body {
        /* Shift entire site left by reducing left padding significantly */
        padding-left: 5px;
        padding-right: 15px;
    }
}

/* --- Social & Contact Footer --- */
.social-section {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px dashed var(--ink-color);
    text-align: center;
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin: 20px 0;
}

.social-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50px;
    height: 50px;
    border: 2px solid var(--ink-color);
    border-radius: 50%;
    color: var(--ink-color);
    font-size: 1.5rem;
    text-decoration: none;
    transition: all 0.2s;
    background: var(--panel-bg);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

.social-icon:hover {
    transform: translateY(-3px) rotate(5deg);
    box-shadow: 4px 6px 0 rgba(0, 0, 0, 0.2);
    /* Individual colors on hover could be cool, but keeping it black/white/accent is safer for theme */
    background: var(--accent-color);
    color: #fff;
    border-color: #000;
}

/* Specific brand colors on hover if preferred, but overriding generic hover above */
.social-icon.instagram:hover {
    background: #E1306C;
}

.social-icon.linkedin:hover {
    background: #0077b5;
}

.social-icon.youtube:hover {
    background: #ff0000;
}

.contact-links {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    margin-top: 20px;
}

.social-link {
    color: var(--ink-color);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.social-link:hover {
    border: 2px solid var(--ink-color);
    background: var(--panel-bg);
    transform: scale(1.05) rotate(-1deg);
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

/* Mission Link Icon */
.mission-link-icon {
    font-size: 0.7em;
    /* Slightly smaller than the title */
    margin-left: 8px;
    color: var(--ink-color);
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-block;
    vertical-align: middle;
}

.mission-link-icon:hover {
    color: var(--accent-color);
    transform: scale(1.2) rotate(-10deg);
}

/* --- Game Modal Styles --- */
.modal-overlay {
    display: none;
    /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    backdrop-filter: blur(5px);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal-container {
    width: 100%;
    max-width: 450px;
    /* Phone-ish width */
    height: 85vh;
    /* Tall portrait */
    background: var(--paper-color);
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border-radius: 20px;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease-out;
    border: 4px solid var(--ink-color);
    transition: max-width 0.3s ease, height 0.3s ease;
}

.modal-container.landscape {
    max-width: 90vw;
    /* Wide screen */
    height: 90vh;
    border-radius: 10px;
    /* Slightly less rounded for monitor look */
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--accent-color);
    color: white;
    border: 2px solid var(--ink-color);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-family: var(--font-title);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}

.modal-close-btn:hover {
    transform: scale(1.1);
    background: #ff6b81;
}

.iframe-wrapper {
    width: 100%;
    height: 100%;
    background: #000;
    flex: 1;
}

#game-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Play Button on Mission Card */
.play-btn-icon {
    font-size: 0.9em;
    margin-left: 8px;
    color: var(--ink-color);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
}

.play-btn-icon:hover {
    color: var(--accent-color);
    transform: scale(1.2) rotate(10deg);
}

/* --- Toggle Switch Styles --- */
.cursor-toggle-container {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.toggle-group {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    -webkit-transition: .4s;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    -webkit-transition: .4s;
    transition: .4s;
}

input:checked+.slider {
    background-color: #2196F3;
    /* Blue color matching the reference */
}

input:checked+.slider:before {
    -webkit-transform: translateX(26px);
    -ms-transform: translateX(26px);
    transform: translateX(26px);
}

/* Rounded sliders */
.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}