:root {
    --bg-color: #0d1117;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --accent: #58a6ff;
    --accent-hover: #1f6feb;
    --glass-bg: rgba(22, 27, 34, 0.75);
    --glass-border: rgba(255, 255, 255, 0.1);
    --wiki-bg: #f8f9fa;
    --win-accent: #2ea043;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #0d1117, #161b22, #0d1117);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

#app {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

.screen {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.screen.view-active {
    display: flex;
    opacity: 1;
}

/* Glassmorphism Panels */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 40px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    text-align: center;
    animation: floatIn 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.glass-panel h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #58a6ff, #a371f7, #58a6ff);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: gradientShift 5s linear infinite;
}

.glass-panel p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    font-size: 1.1rem;
    line-height: 1.5;
}

.mission-briefing {
    background: rgba(0, 0, 0, 0.4);
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 30px;
    text-align: left;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.route {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}
.route:first-child {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
}

.route .label {
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 1px;
}

.route .article-name {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--accent);
    max-width: 70%;
    text-align: right;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.route .article-name.loading {
    color: #ffd04f;
    animation: pulse 1.5s infinite;
}

/* Button */
.primary-btn {
    background: linear-gradient(135deg, #1f6feb, #58a6ff);
    color: white;
    border: none;
    padding: 16px 40px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: 0 4px 15px rgba(88, 166, 255, 0.3);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 25px rgba(88, 166, 255, 0.5);
    background: linear-gradient(135deg, #327cf2, #6ebafe);
}

.primary-btn:disabled {
    background: #30363d;
    color: #8b949e;
    cursor: not-allowed;
    box-shadow: none;
}

/* Game Header */
#game-screen {
    justify-content: flex-start;
}

.game-header {
    width: 100%;
    max-width: none;
    border-radius: 0 0 20px 20px;
    padding: 15px 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    z-index: 100;
    border-top: none;
    border-left: none;
    border-right: none;
}

.header-stat {
    display: flex;
    flex-direction: column;
    width: 30%;
    align-items: flex-start;
    text-align: left;
}

.header-stat.text-right {
    align-items: flex-end;
    text-align: right;
}

.header-stat.center-stat {
    align-items: center;
    width: 40%;
}

.header-stat .label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.header-stat .value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 4px;
}

.header-stat .timer {
    font-size: 2.2rem;
    font-variant-numeric: tabular-nums;
    font-weight: 800;
    color: #ffd04f;
    text-shadow: 0 2px 10px rgba(255, 208, 79, 0.3);
}

.header-stat .clicks {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 600;
}

.text-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Wiki Container */
#wiki-container {
    width: 100%;
    height: 100vh;
    padding-top: 100px;
    overflow-y: auto;
    position: relative;
    background: var(--wiki-bg);
}

#wiki-content {
    background: white;
    color: #24292f;
    padding: 40px 60px;
    max-width: 960px;
    margin: 0 auto;
    min-height: calc(100vh - 100px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.7;
    font-size: 1.05rem;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -10px 40px rgba(0,0,0,0.05);
}

/* Wikipedia Content Overrides */
#wiki-content h1, #wiki-content h2, #wiki-content h3 {
    font-family: 'Inter', sans-serif;
    border-bottom: 1px solid #eaecef;
    padding-bottom: 0.3em;
    margin-top: 24px;
    margin-bottom: 16px;
}
#wiki-content h1 { font-size: 2em; }
#wiki-content h2 { font-size: 1.5em; }

#wiki-content p {
    margin-bottom: 16px;
    color: #24292f;
}

#wiki-content a {
    color: #0969da;
    text-decoration: none;
    font-weight: 500;
}

#wiki-content a:hover {
    text-decoration: underline;
}

#wiki-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

/* Hide navigation boxes, edit links, etc */
.mw-editsection, .noprint, .navbox, .metadata, .infobox-header {
    display: none !important;
}

/* Loading Overlay */
#loading-overlay {
    position: fixed;
    top: 100px; left: 0; right: 0; bottom: 0;
    background: rgba(248, 249, 250, 0.85);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    transition: opacity 0.3s;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 5px solid rgba(88, 166, 255, 0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.5, 0, 0.5, 1) infinite;
}

/* Win Screen specifically */
#win-screen h2 {
    color: var(--win-accent);
    font-size: 2.5rem;
    margin-bottom: 30px;
    text-shadow: 0 4px 15px rgba(46, 160, 67, 0.3);
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.4);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.stat-value {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.path-title {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 15px;
    text-align: left;
    padding-left: 10px;
}

.path-list {
    max-height: 250px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 35px;
    text-align: left;
}

.path-list::-webkit-scrollbar {
    width: 8px;
}
.path-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.path-item {
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 1.05rem;
    font-weight: 500;
    color: #c9d1d9;
    display: flex;
    align-items: center;
}

.path-item::before {
    content: "→";
    margin-right: 15px;
    color: var(--accent);
    font-weight: bold;
}

.path-item:last-child {
    border-bottom: none;
    color: var(--win-accent);
}
.path-item:last-child::before {
    color: var(--win-accent);
    content: "★";
}

/* Keyframes */
@keyframes spin {
    100% { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes floatIn {
    from { opacity: 0; transform: translateY(30px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Icon Button */
.icon-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-primary);
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.2s;
    flex-shrink: 0;
}
.icon-btn:hover:not(:disabled) {
    background: var(--accent);
    color: white;
}
.icon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .glass-panel {
        padding: 25px 20px;
        width: 95%;
    }
    .glass-panel h1 { font-size: 2rem; }
    .glass-panel p { font-size: 0.95rem; }
    .route { padding: 8px 0; }
    .route .article-name { font-size: 1.05rem; max-width: 65%; }
    .primary-btn { padding: 12px 25px; font-size: 1.05rem; }

    .game-header {
        padding: 10px 15px;
        border-radius: 0 0 12px 12px;
        align-items: flex-start;
    }
    .header-stat { width: 33%; }
    .header-stat.center-stat { width: 34%; }
    .header-stat .label { font-size: 0.65rem; }
    .header-stat .value {
        font-size: 0.85rem;
        margin-top: 2px;
        line-height: 1.25;
    }
    
    /* Allow text wrapping instead of harsh ellipsis on mobile */
    .text-truncate {
        white-space: normal;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
        word-break: break-word;
    }

    .header-stat .timer {
        font-size: 1.4rem;
    }
    .header-stat .clicks {
        font-size: 0.8rem;
        margin-top: 1px;
    }
    .icon-btn {
        width: 22px;
        height: 22px;
        font-size: 0.9rem;
    }

    #wiki-container {
        padding-top: 110px; /* Increased to accommodate wrapped 3-line titles */
    }
    #wiki-content {
        padding: 20px 20px;
        font-size: 0.95rem;
        line-height: 1.55;
    }
    #wiki-content h1 { font-size: 1.6em; margin-top: 15px; }
    #wiki-content h2 { font-size: 1.3em; margin-top: 15px; }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        margin-bottom: 20px;
    }
    #win-screen h2 { font-size: 1.8rem; margin-bottom: 15px; }
    .stat-value { font-size: 1.6rem; }
    .stat-box { padding: 15px; }
}
