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

:root {
    --bg: #0a0a0a;
    --bg-card: #141414;
    --accent: #8b1a1a;
    --accent-light: #b22222;
    --text: #e8e8e8;
    --text-muted: #999;
    --border: #2a2a2a;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    text-shadow: 0 1px 3px black;
}

#renderCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    outline: none;
}

.lang-toggle {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    display: flex;
    gap: 0.25rem;
}

.lang-toggle button {
    background: rgba(20, 20, 20, 0.8);
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 0.4rem 0.8rem;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.lang-toggle button:first-child {
    border-radius: 4px 0 0 4px;
}

.lang-toggle button:last-child {
    border-radius: 0 4px 4px 0;
}

.lang-toggle button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.legacy-link {
    position: fixed;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 100;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.legacy-link:hover {
    color: var(--accent-light);
}

.content {
    position: relative;
    z-index: 1;
}

.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    position: relative;
}

.hero h1 {
    font-size: clamp(2.5rem, 8vw, 5rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.8), 0 0 60px rgba(0, 0, 0, 0.5);
}

.tagline {
    font-size: clamp(1rem, 2.5vw, 1.4rem);
    color: var(--text-muted);
    margin-bottom: 3rem;
    text-shadow: 0 2px 15px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 0, 0, 0.5);
}

.scroll-indicator {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    z-index: 10;
    transition: opacity 0.4s ease;
}

.scroll-indicator.hidden {
    opacity: 0;
    pointer-events: none;
}

.scroll-indicator span {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.15em;
}

.scroll-arrow {
    width: 20px;
    height: 20px;
    border-right: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    transform: rotate(45deg);
    animation: scrollBounce 2s ease-in-out infinite;
}

@keyframes scrollBounce {
    0%, 100% { transform: rotate(45deg) translateY(0); opacity: 1; }
    50% { transform: rotate(45deg) translateY(8px); opacity: 0.5; }
}

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

.stats {
    display: flex;
    gap: 3rem;
    justify-content: center;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
}

.stat-num {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--accent-light);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

section {
    max-width: 900px;
    margin: 0 auto;
    padding: 5rem 2rem;
}

h2 {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    position: relative;
    display: inline-block;
}

h2::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -0.4rem;
    width: 40px;
    height: 3px;
    background: var(--accent);
}

.about p {
    font-size: 1.1rem;
    color: var(--text-muted);
    max-width: 700px;
}

.timeline {
    border-left: 2px solid var(--border);
    padding-left: 2rem;
    margin-left: 0.5rem;
}

.timeline-item {
    position: relative;
    margin-bottom: 2.5rem;
}

.timeline-dot {
    position: absolute;
    left: -2.45rem;
    top: 0.3rem;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg);
}

.timeline-date {
    font-size: 0.85rem;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.timeline-content h3 {
    font-size: 1.1rem;
    margin: 0.3rem 0 0.2rem;
}

.timeline-content p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.section-subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.portfolio-sub {
    font-size: 1.1rem;
    color: var(--accent-light);
    margin: 2.5rem 0 1.2rem;
    font-weight: 500;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.game-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
}

.game-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.game-img {
    aspect-ratio: 16 / 9;
    background-size: cover;
    background-position: center;
    background-color: var(--bg);
    position: relative;
}

.game-img::after {
    content: attr(data-title);
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--text-muted);
    opacity: 0.4;
    pointer-events: none;
}

.game-img:not([style*="background-image"])::after,
.game-img.placeholder::after {
    opacity: 0.6;
}

.game-img.placeholder {
    background: linear-gradient(135deg, var(--bg-card), var(--border));
}

.game-info {
    padding: 1rem;
}

.game-info h3 {
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.game-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

.pub-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
}

.pub-icon {
    font-size: 2rem;
    margin-bottom: 0.8rem;
}

.pub-cover {
    width: 100%;
    max-width: 150px;
    height: auto;
    border-radius: 4px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.pub-card h3 {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.pub-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.pub-tag,
.game-role {
    color: var(--accent-light);
    font-weight: 500;
}

.skills-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 2rem;
}

.skill-group h3 {
    font-size: 1rem;
    margin-bottom: 0.8rem;
    color: var(--accent-light);
}

.skill-group ul {
    list-style: none;
}

.skill-group li {
    padding: 0.3rem 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.skill-group li::before {
    content: '›';
    color: var(--accent);
    margin-right: 0.5rem;
}

.edu-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.edu-item {
    display: flex;
    gap: 2rem;
    align-items: flex-start;
}

.edu-year {
    font-size: 0.85rem;
    color: var(--accent-light);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-width: 120px;
}

.edu-item h3 {
    font-size: 1.05rem;
    margin-bottom: 0.2rem;
}

.edu-item p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.teaching-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
}

.teaching-tags span {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 0.4rem 0.9rem;
    border-radius: 20px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.fun-facts ul {
    list-style: none;
}

.fun-facts li {
    padding: 0.4rem 0;
    color: var(--text-muted);
}

.fun-facts li::before {
    content: '→ ';
    color: var(--accent);
}

.toc {
    text-align: center;
    padding: 2rem 0 0;
}

.toc ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.3rem;
    list-style: none;
}

.toc a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.toc a:hover {
    color: var(--accent-light);
}

.toc-separator {
    color: var(--border);
}

.cv-download {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.cv-download a {
    color: var(--accent-light);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.cv-download a:hover {
    color: var(--text);
}

.cv-separator {
    color: var(--text-muted);
}

.contact {
    text-align: center;
    padding: 5rem 2rem;
}

.demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
}

.demo-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    isolation: isolate;
}

.demo-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
}

.demo-card:hover .demo-play-hint-wrapper {
    opacity: 0;
}

.demo-video {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
    cursor: pointer;
}

.demo-play-hint-wrapper {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    transition: opacity 0.4s ease;
    z-index: 2;
}

.demo-play-hint {
    width: 40px;
    height: 40px;
    background: rgba(139, 26, 26, 0.85);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    animation: pulse 2s ease-in-out infinite;
}

.demo-play-hint::after {
    content: '';
    display: block;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 7px 0 7px 12px;
    border-color: transparent transparent transparent #fff;
    margin-left: 3px;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.15); opacity: 1; }
}

.demo-info {
    padding: 1rem;
}

.demo-info h3 {
    font-size: 1rem;
    margin-bottom: 0.3rem;
}

.demo-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.contact-links {
    display: flex;
    gap: 2rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

.contact-links a {
    color: var(--text);
    text-decoration: none;
    font-size: 1.1rem;
    transition: color 0.2s;
}

.contact-links a:hover {
    color: var(--accent-light);
}

.small {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.small a {
    color: var(--text-muted);
    text-decoration: none;
}

.small a:hover {
    color: var(--accent-light);
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 200;
    justify-content: center;
    align-items: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 2.5rem;
    max-width: 500px;
    width: 90%;
    position: relative;
    color: var(--text);
}

.modal-content h2 {
    margin-bottom: 1.5rem;
}

.modal-content p {
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.6;
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--accent-light);
}

@media (max-width: 600px) {
    .stats {
        gap: 1.5rem;
    }

    .stat-num {
        font-size: 2rem;
    }

    .edu-item {
        flex-direction: column;
        gap: 0.3rem;
    }

    .contact-links {
        flex-direction: column;
        gap: 1rem;
    }
}

.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 40px;
    height: 40px;
    background: var(--accent);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.2s;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover {
    transform: translateY(-2px);
    background: var(--accent-light);
}

@media print {
    .back-to-top {
        display: none !important;
    }

    #renderCanvas,
    .scroll-indicator,
    .lang-toggle,
    .legacy-link,
    .modal,
    .toc {
        display: none !important;
    }

    body {
        background: #fff;
        color: #111;
        font-size: 11pt;
    }

    section {
        padding: 1rem 0;
        max-width: none;
    }

    h2 { color: #111; }
    h2::after { background: #8b1a1a; }
    h3 { color: #333; }

    .about p,
    .timeline-content p,
    .game-info p,
    .pub-card p,
    .demo-info p,
    .edu-item p,
    .skill-group li,
    .fun-facts li {
        color: #333;
    }

    .game-card, .pub-card, .demo-card {
        border: 1px solid #ccc;
        break-inside: avoid;
    }

    .content {
        position: static;
    }

    a { color: #111; }
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
}
