@font-face {
    font-family: 'Fira Code';
    src: url('/fonts/fira-code-latin-400-normal.woff2') format('woff2');
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: 'Fira Code';
    src: url('/fonts/fira-code-latin-700-normal.woff2') format('woff2');
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

:root {
    --bg-color: #0a0a0a;
    --text-color: #33ff33;
    --dim-text: #1a8a1a;
    --error-color: #ff3333;
    --warning-color: #ffff33;
    --glow-shadow: 0 0 10px rgba(51, 255, 51, 0.5);
    --font-main: 'Fira Code', ui-monospace, 'SFMono-Regular', 'Cascadia Mono', 'Segoe UI Mono', Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
    --red-flash: #ff0000;
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    min-height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
}

/* Utility class for hiding elements */
.hidden {
    display: none !important;
}

/* CRT Effects */
.crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 100%),
                linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.1) 50%),
                linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 100;
    pointer-events: none;
    background-size: 100% 100%, 100% 2px, 3px 100%;
}

.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom,
        rgba(18, 16, 16, 0) 50%,
        rgba(0, 0, 0, 0.1) 50%
    );
    background-size: 100% 4px;
    z-index: 101;
    pointer-events: none;
    animation: scanline 10s linear infinite;
}

@keyframes scanline {
    from { background-position: 0 0; }
    to { background-position: 0 100%; }
}

/* Terminal Layout */
.terminal {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    border: 1px solid var(--dim-text);
    padding: 20px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--glow-shadow);
    background: rgba(10, 10, 10, 0.9);
}

@media (max-width: 768px) {
    .terminal {
        padding: 12px;
        border: none;
    }

    .header {
        font-size: 0.78rem;
        margin-bottom: 12px;
    }

    .output {
        font-size: 0.96rem;
        margin-bottom: 12px;
    }

    .footer {
        font-size: 0.72rem;
        margin-top: 12px;
    }

    #command-input {
        font-size: 1rem;
    }
}

.header {
    border-bottom: 1px solid var(--dim-text);
    padding-bottom: 10px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center; /* Align items vertically */
}

.status-online {
    animation: flicker 3s infinite, glitch 5s infinite;
}

@keyframes glitch {
    0% { transform: translate(0); }
    1% { transform: translate(-2px, 2px); filter: hue-rotate(90deg); }
    2% { transform: translate(2px, -2px); filter: hue-rotate(0deg); }
    3% { transform: translate(0); }
    100% { transform: translate(0); }
}

@keyframes flicker {
    0% { opacity: 0.8; }
    5% { opacity: 0.4; }
    10% { opacity: 0.9; }
    15% { opacity: 0.7; }
    100% { opacity: 1; }
}

.output {
    flex-grow: 1;
    overflow-y: auto;
    margin-bottom: 20px;
    font-size: 1.1rem;
    line-height: 1.5;
    scrollbar-width: none;
}

.output::-webkit-scrollbar {
    display: none;
}

.input-line {
    display: flex;
    align-items: center;
    border-top: 1px solid var(--dim-text);
    padding-top: 10px;
}

.prompt {
    margin-right: 10px;
    font-weight: bold;
}

#command-input {
    background: transparent;
    border: none;
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: 1.1rem;
    width: 100%;
    outline: none;
    caret-color: var(--text-color);
}

.footer {
    margin-top: 20px;
    font-size: 0.8rem;
    color: var(--dim-text);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Gameplay Styles */
.line {
    margin-bottom: 5px;
}

.system { color: var(--dim-text); }
.error { color: var(--error-color); font-weight: bold; }
.warning { color: var(--warning-color); }
.success { color: var(--text-color); text-shadow: var(--glow-shadow); }

.typewriter {
    overflow: hidden;
    white-space: pre-wrap;
}

#strikes {
    color: var(--error-color);
}

#progress-bar {
    color: var(--text-color);
}

/* Login Overlay Styles */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95); /* Darker overlay */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 102; /* Above CRT effects */
}

.overlay-content {
    background-color: var(--bg-color);
    border: 1px solid var(--dim-text);
    box-shadow: var(--glow-shadow);
    padding: 30px;
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.overlay-content h1 {
    color: var(--text-color);
    margin-bottom: 20px;
    text-shadow: var(--glow-shadow);
}

.overlay-content p {
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border: 1px solid var(--text-color);
    background-color: transparent;
    color: var(--text-color);
    text-decoration: none;
    font-family: var(--font-main);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: var(--glow-shadow);
}

.btn:hover {
    background-color: var(--text-color);
    color: var(--bg-color);
    text-shadow: none;
    box-shadow: none;
}

.google-login-btn {
    border-color: #4285f4;
    color: #4285f4;
    box-shadow: 0 0 10px rgba(66, 133, 244, 0.5);
}

.google-login-btn:hover {
    background-color: #4285f4;
    color: #fff;
    box-shadow: none;
}

.donate-btn {
    border-color: #ffcc33;
    color: #ffcc33;
    box-shadow: 0 0 10px rgba(255, 204, 51, 0.45);
}

.donate-btn:hover {
    background-color: #ffcc33;
    color: #111;
    box-shadow: none;
}

/* Timer styles */
#timer-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-color);
    margin-left: 15px; /* Adjust spacing */
}

#timer-display.low-time {
    color: var(--red-flash);
    animation: pulse-red 1s infinite;
}

@keyframes pulse-red {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.05); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* User Info in Header */
#user-info {
    display: flex;
    align-items: center;
}

#user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    margin-right: 10px;
    border: 1px solid var(--text-color);
    box-shadow: var(--glow-shadow);
}

#user-name {
    margin-right: 15px;
}

#logout-btn {
    font-size: 0.8rem;
    padding: 5px 10px;
    border: 1px solid var(--error-color);
    color: var(--error-color);
    box-shadow: 0 0 5px rgba(255, 51, 51, 0.5);
}

#logout-btn:hover {
    background-color: var(--error-color);
    color: var(--bg-color);
    box-shadow: none;
}


/* Leaderboard Styles */
.leaderboard-container {
    margin-top: 20px;
    border-top: 1px solid var(--dim-text);
    padding-top: 20px;
}

.leaderboard-container h3 {
    text-align: center;
    color: var(--text-color);
    text-shadow: var(--glow-shadow);
    margin-bottom: 15px;
}

.leaderboard-list {
    list-style: none;
    padding: 0;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px dashed rgba(51, 255, 51, 0.2);
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-item .rank {
    font-weight: bold;
    color: var(--text-color);
    margin-right: 10px;
}

.leaderboard-item .player-info {
    display: flex;
    align-items: center;
    flex-grow: 1;
}

.leaderboard-item .player-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    margin-right: 10px;
    border: 1px solid var(--dim-text);
}

.leaderboard-item .player-name {
    color: var(--text-color);
}

.leaderboard-item .player-score {
    font-weight: bold;
    color: var(--warning-color);
}

.leaderboard-item .player-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.leaderboard-item .player-rate {
    font-size: 0.72rem;
    color: var(--dim-text);
}

/* ── Landing Page ─────────────────────────────────── */
.landing {
    position: fixed;
    inset: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-main);
    overflow-y: auto;
    z-index: 200;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.landing-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    justify-content: center;
    padding: 40px 20px;
    max-width: 1100px;
    width: 100%;
    flex: 1;
}

.landing-hero {
    flex: 1 1 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.landing-title {
    font-size: 3rem;
    text-shadow: var(--glow-shadow);
    letter-spacing: 0.15em;
    animation: flicker 3s infinite;
}

.landing-subtitle {
    color: var(--dim-text);
    font-size: 1rem;
}

.landing-subtitle--ar {
    font-size: 0.9rem;
    direction: rtl;
    font-family: sans-serif;
    color: var(--dim-text);
}

.landing-desc {
    line-height: 1.9;
    font-size: 1rem;
}

.landing-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.landing-leaderboard {
    flex: 0 1 320px;
    border: 1px solid var(--dim-text);
    padding: 20px;
    box-shadow: var(--glow-shadow);
    align-self: flex-start;
}

.landing-leaderboard h2 {
    text-align: center;
    margin-bottom: 15px;
    font-size: 1rem;
    text-shadow: var(--glow-shadow);
}

.landing-lb-msg {
    text-align: center;
    color: var(--dim-text);
    font-size: 0.85rem;
    margin-top: 10px;
}

@media (max-width: 680px) {
    .landing-actions .btn {
        width: 100%;
        text-align: center;
    }
}

/* ── Donate Modal ──────────────────────────────────── */
.donate-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.88);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.donate-modal {
    background: var(--bg-color);
    border: 1px solid #ffcc33;
    box-shadow: 0 0 20px rgba(255, 204, 51, 0.35);
    padding: 30px;
    max-width: 460px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 20px;
    font-family: var(--font-main);
    color: var(--text-color);
}

.donate-modal h2 {
    color: #ffcc33;
    text-shadow: 0 0 8px rgba(255, 204, 51, 0.5);
    font-size: 1.1rem;
    text-align: center;
}

.donate-modal p {
    color: var(--dim-text);
    font-size: 0.9rem;
    text-align: center;
}

.donate-amounts {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.donate-amount-btn {
    border-color: #ffcc33;
    color: #ffcc33;
    box-shadow: 0 0 8px rgba(255, 204, 51, 0.3);
    min-width: 100px;
}

.donate-amount-btn:hover {
    background-color: #ffcc33;
    color: #111;
    box-shadow: none;
}

.donate-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.donate-custom label {
    color: var(--dim-text);
    font-size: 0.85rem;
    white-space: nowrap;
}

.donate-custom-input {
    background: transparent;
    border: 1px solid var(--dim-text);
    color: var(--text-color);
    font-family: var(--font-main);
    font-size: 0.95rem;
    padding: 6px 10px;
    width: 110px;
    outline: none;
}

.donate-custom-input:focus {
    border-color: #ffcc33;
    box-shadow: 0 0 6px rgba(255, 204, 51, 0.3);
}

.donate-cancel-btn {
    border-color: var(--error-color);
    color: var(--error-color);
    align-self: center;
    font-size: 0.85rem;
    padding: 6px 16px;
}

.donate-cancel-btn:hover {
    background-color: var(--error-color);
    color: var(--bg-color);
}