/* Inter font is loaded via <link> in each HTML file for non-blocking delivery */

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.4s ease forwards;
}

body {
    font-family: 'Inter', sans-serif;
    background: radial-gradient(circle, #1a1a2e 0%, #16213e 100%);
    color: white;
    margin: 0;
    /* FIX 1: Allow vertical scrolling, but prevent horizontal bounce */
    overflow-x: hidden;
    overflow-y: auto; 
    overscroll-behavior-y: contain;
    /* REMOVED touch-action: none from body. We only want it on the Canvas. */
    
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Navigation */
.main-header {
    background: rgba(255, 255, 255, 0.05);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 1rem 0;
    width: 100%;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
    /* FIX 2: Better mobile layout for header */
    flex-wrap: wrap;
    gap: 10px;
}

h1 {
    font-weight: 900;
    letter-spacing: -1px;
    margin: 0;
    white-space: nowrap; /* Keep title on one line */
}

h1 span {
    color: #00d2ff;
}

nav {
    display: flex;
    align-items: center;
}

nav a {
    margin: 0 18px;
    text-decoration: none;
    color: #00d2ff;
    font-weight: 700;
    white-space: nowrap; /* Keep links from breaking */
    transition: color 0.2s ease, opacity 0.2s ease;
}

nav a:hover:not(.active) {
    color: rgba(255, 255, 255, 0.8);
}

nav a.active {
    color: #ffffff;
    text-decoration: none;
    transform: scale(1.25);
    display: inline-block;
}

/* Scoreboard */
#scoreboard {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    padding: 15px;
    margin: 0 auto 20px auto;
    position: relative;
    z-index: 10;
    width: 90vw;
    max-width: 600px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-box {
    display: flex;
    flex-direction: column;
    text-align: center;
}

.label {
    font-size: 0.7rem;
    color: #00d2ff;
    font-weight: bold;
    text-transform: uppercase;
}

.value {
    font-size: 1.5rem;
    font-weight: 900;
}

.name-value {
    max-width: 185px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Leaderboard Module */
#leaderboard-module {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.1);
    -webkit-backdrop-filter: blur(15px);
    backdrop-filter: blur(15px);
    border-radius: 12px;
    padding: 15px 20px;
    margin: 30px auto 0 auto;
    width: 90vw;
    max-width: 600px;
    box-sizing: border-box;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

#leaderboard-list {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lb-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.88rem;
    padding: 3px 6px;
    border-radius: 4px;
    color: rgba(255, 255, 255, 0.8);
}

.lb-row.lb-me {
    color: #FFD700;
    font-weight: bold;
    background: rgba(255, 215, 0, 0.08);
}

.lb-placeholder {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    text-align: center;
    width: 100%;
    display: block;
}

.lb-full-link {
    font-size: 0.75rem;
    color: #00d2ff;
    text-decoration: none;
    text-align: center;
    width: 100%;
    display: block;
    opacity: 0.7;
    margin-top: 4px;
}

.lb-full-link::after {
    content: ' →';
    font-size: 1.3em;
}

.lb-full-link:hover {
    opacity: 1;
}

/* Leaderboard page */
.lb-page {
    max-width: 680px;
    margin: 30px auto;
    padding: 0 20px;
}

.lb-page-header {
    text-align: center;
    margin-bottom: 24px;
}

.lb-page-header h2 {
    color: #00d2ff;
    font-size: 1.8rem;
    font-weight: 900;
    margin: 0 0 8px 0;
}

.lb-reset-notice {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.8rem;
    margin: 0;
}

.lb-page-list {
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.lb-page-row {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    align-items: center;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.75);
}

.lb-page-row:hover {
    background: rgba(255, 255, 255, 0.05);
}

.lb-page-row .lb-rank {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.35);
}

.lb-page-row.rank-1,
.lb-page-row.rank-2,
.lb-page-row.rank-3 {
    color: rgba(255, 255, 255, 0.95);
    border-left: 3px solid transparent;
    padding-left: 5px;
}

.lb-page-row.rank-1 { border-left-color: #FFD700; background: rgba(255, 215, 0, 0.07); }
.lb-page-row.rank-2 { border-left-color: #C0C0C0; background: rgba(192, 192, 192, 0.07); }
.lb-page-row.rank-3 { border-left-color: #cd7f32; background: rgba(205, 127, 50, 0.07); }

.lb-page-row.rank-1 .lb-rank { color: #FFD700; }
.lb-page-row.rank-2 .lb-rank { color: #C0C0C0; }
.lb-page-row.rank-3 .lb-rank { color: #cd7f32; }

.lb-page-row .lb-score {
    font-weight: 700;
    color: #00d2ff;
}

/* Game Layout */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
    flex-grow: 1;
}

.game-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    width: 100%;
}

@media (min-width: 1500px) {
    .game-container {
        flex-direction: row;
        align-items: center;
        justify-content: center;
        gap: 28px;
        padding: 10px 20px;
    }

    .game-area {
        flex: 0 1 960px;
        align-self: center;
    }

    #scoreboard {
        flex: 0 0 200px;
        width: 200px;
        max-width: none;
        margin: 0;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 20px;
        align-self: flex-start;
    }

    #leaderboard-module {
        flex: 0 0 260px;
        width: 260px;
        max-width: 260px;
        margin: 0;
        align-self: flex-start;
    }
}

canvas {
    width: 95vw;
    max-width: 960px;
    height: auto;
    max-height: 65vh;
    
    border-radius: 15px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border: 4px solid #16213e;
    display: block;
    margin: 0 auto;
    background-color: #000;
    
    image-rendering: pixelated;
    image-rendering: crisp-edges;

    /* FIX 3: Keep this here! It ensures only the game blocks scrolling while playing */
    touch-action: none; 
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* Game Over Overlay */
.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(22, 33, 62, 0.95);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 1.5rem 2.5rem;
    border-radius: 20px;
    border: 2px solid #00d2ff;
    text-align: center;
    z-index: 100;
    width: auto;
    min-width: 280px;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

.hidden {
    display: none;
}

.overlay h2 {
    margin: 0 0 16px 0;
    color: #ff4b2b;
    font-size: 2rem;
    font-weight: 900;
}

.name-input {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #00d2ff;
    border-radius: 10px;
    color: white;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    padding: 10px 15px;
    text-align: center;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 5px;
}

.name-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.name-input:focus {
    border-color: #3a7bd5;
    box-shadow: 0 0 10px rgba(0, 210, 255, 0.3);
}

/* Buttons */
.start-btn {
    background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%);
    color: white;
    border: none;
    border-radius: 30px;
    padding: 15px 40px;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px rgba(0, 210, 255, 0.4);
}

.start-btn:active {
    transform: scale(0.95);
}

/* Media Queries */
@media (max-width: 600px) {
    .header-content {
        flex-direction: column; /* Stack Title above Menu on very small phones */
        text-align: center;
    }
    
    nav {
        margin-top: 5px;
    }

    .watermark {
        font-size: 0.6rem;
        bottom: 10px;
        left: 10px;
        opacity: 0.2;
    }
}

@media (max-width: 480px) {
    .value {
        font-size: 1.2rem;
    }
    .start-btn {
        padding: 12px 30px;
        font-size: 0.9rem;
    }
    h1 {
        font-size: 1.2rem;
    }
    nav a {
        margin: 0 8px;
        font-size: 0.85rem;
    }
}

.canvas-footer {
    display: flex;
    justify-content: space-between;
    width: 95vw;
    max-width: 960px;
    margin-top: 8px;
    padding: 0 5px;
    box-sizing: border-box;
}

.footer-name,
.footer-version {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 400;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.watermark {
    position: fixed;
    bottom: 20px;
    left: 20px;
    font-size: 0.8rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 1px;
    text-transform: uppercase;
    z-index: 1000;
    pointer-events: none;
}

/* About Page Specific Styles */
.about-content {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px; /* Reduced for mobile */
    border-radius: 15px;
    text-align: left;
    max-width: 800px;
    margin: 20px auto;
    border: 1px solid rgba(255, 255, 255, 0.1);
    /* Allow about page to breathe on mobile */
    width: 90vw;
    box-sizing: border-box;
    flex-direction: column;
    align-items: stretch;
}

/* Ensure about sections don't overflow */
.about-section {
    word-wrap: break-word;
}

.about-section h2 {
    color: #00d2ff;
    font-size: 1.5rem; /* Slightly smaller for mobile */
    margin-bottom: 15px;
}

.about-section p {
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
}

.section-divider {
    border: 0;
    height: 1px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.2), transparent);
    margin: 30px 0;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); /* Better fit */
    gap: 15px;
    margin-top: 20px;
}

.control-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
}

.control-item strong {
    display: block;
    color: #ff4b2b;
    margin-bottom: 5px;
    text-transform: uppercase;
    font-size: 0.8rem;
}

.contact-methods {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 25px;
}

.contact-methods .control-item {
    border-left: 4px solid #00d2ff;
    transition: transform 0.2s ease;
}

/* News Page */
.news-layout {
    display: flex;
    gap: 28px;
    max-width: 1020px;
    margin: 24px auto;
    padding: 0 20px;
    align-items: flex-start;
    box-sizing: border-box;
}

.news-nav {
    flex: 0 0 160px;
    position: sticky;
    top: 100px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 14px 16px;
}

.news-nav-title {
    font-size: 0.65rem;
    color: #00d2ff;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 10px;
}

.news-nav details {
    margin-bottom: 4px;
}

.news-nav summary {
    cursor: pointer;
    font-size: 0.72rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.45);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 4px 0;
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.news-nav summary::-webkit-details-marker { display: none; }

.news-nav summary::before {
    content: '▸';
    font-size: 1.3rem;
    transition: transform 0.15s;
    display: inline-block;
}

.news-nav details[open] summary::before {
    transform: rotate(90deg);
}

.news-nav a {
    display: block;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    padding: 4px 0 4px 14px;
    border-left: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.news-nav a:hover {
    color: white;
    border-left-color: #00d2ff;
}

.news-content {
    flex: 1;
    min-width: 0;
}

.news-page-heading {
    color: #00d2ff;
    font-size: 1.5rem;
    margin: 0 0 6px 0;
}

.news-page-sub {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
    margin: 0 0 16px 0;
}

.news-month-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.35);
    margin: 0 0 14px 0;
    scroll-margin-top: 100px;
}

@media (max-width: 640px) {
    .news-nav {
        display: none;
    }
}

.news-post {
    padding: 10px 0;
}

.news-date {
    font-size: 0.7rem;
    color: #00d2ff;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.news-title {
    color: white;
    font-size: 1.2rem;
    font-weight: 900;
    margin: 6px 0 10px 0;
}

.news-body {
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.8);
    margin: 0;
}