/* CSS Variables for Telegram Web App theming */
:root {
    --telegram-bg-color: black;
    --telegram-text-color: white;
}

/* Telegram Web App specific styles */
.tg-web-app {
    /* These styles will be applied when running in Telegram */
    background-color: var(--telegram-bg-color);
    color: var(--telegram-text-color);
}

body {
    touch-action: none; /* Prevents default touch behaviors */
    -webkit-touch-callout: none; /* Prevents callouts */
    -webkit-user-select: none; /* Prevents text selection */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    background-color: var(--telegram-bg-color, black);
    color: var(--telegram-text-color, white);
    cursor: crosshair;
    overflow: hidden;
    margin: 0 !important;
    padding: 0 !important;
    /* Ensure full height in Telegram */
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
}

canvas {
    image-rendering: -moz-crisp-edges;
    image-rendering: -webkit-crisp-edges;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
}

.chat-input {
    z-index: 1; /* for HUD elements */
    position: fixed;
    display: none;
    font: 14px monospace;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 10px;
    margin: 0;
    outline: none;
    min-width: 300px;
    bottom: 60px;  /* BOTTOM_MARGIN + PADDING */
    left: 10px;    /* PADDING */
}

.chat-input.max-length {
    box-shadow: 0 0 7px rgba(31, 23, 23, 0.5);
}

/* ============================================
   Main Menu - Minimalistic Modern Design
   ============================================ */

@import url("https://fonts.googleapis.com/css2?family=Russo+One&display=swap");

/* Menu Container */
.menu-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9001;
    font-family: "Russo One", sans-serif;
    pointer-events: none;
}

.menu-container > * {
    pointer-events: auto;
}

/* Canvas behind UI */
#menu-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9000;
}

/* Game Title */
.game-title {
    color: #fae428;
    font-size: 2.2rem;
    font-family: "Russo One", sans-serif;
    text-align: center;
    margin: 0 0 2.5rem 0;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-weight: 400;
}

/* Error Message */
.error-message {
    background: rgba(250, 40, 86, 0.1);
    border: 1px solid rgba(250, 40, 86, 0.4);
    padding: 0.75rem 1.5rem;
    margin: 0 0 1.5rem 0;
    color: #fa2856;
    font-size: 0.85rem;
    text-align: center;
    letter-spacing: 0.05em;
}

/* Auth Sections */
.auth-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    font-weight: 400;
    margin: 0 0 0.5rem 0;
    text-align: center;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.welcome-text {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
    font-weight: 400;
    margin: 0 0 1rem 0;
    text-align: center;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* OAuth Buttons - Minimal */
.btn-oauth {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.6rem 1.2rem;
    font-family: "Russo One", sans-serif;
    font-size: 0.7rem;
    text-decoration: none;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.btn-oauth:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.9);
}

.btn-oauth svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.btn-oauth:hover svg {
    opacity: 1;
}

/* Start Game Button - The Hero */
.btn-start-game {
    position: relative;
    margin-top: 1.5rem;
    width: 200px;
    height: 56px;
    border: 1px solid #fae428;
    background: transparent;
    color: #fae428;
    font-family: "Russo One", sans-serif;
    font-size: 0.9rem;
    text-transform: uppercase;
    text-align: center;
    cursor: pointer;
    letter-spacing: 0.15em;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-start-game:hover {
    background: rgba(250, 228, 40, 0.08);
    box-shadow: 0 0 20px rgba(250, 228, 40, 0.15);
}

.btn-start-game:active {
    transform: scale(0.98);
}

/* Warp animation container */
.warp-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 2px;
    height: 2px;
    background: #fae428;
    transform: translate(-50%, -50%);
    z-index: 10000;
    pointer-events: none;
    opacity: 0;
}

.warp-overlay.active {
    animation: warpJump 1.2s ease-in forwards;
}

@keyframes warpJump {
    0% {
        width: 2px;
        height: 2px;
        opacity: 1;
        box-shadow: 0 0 30px 10px #fae428;
    }
    30% {
        width: 4px;
        height: 200px;
        opacity: 1;
        box-shadow: 0 0 60px 20px #cd28fa;
    }
    60% {
        width: 4px;
        height: 100vh;
        opacity: 0.8;
        box-shadow: 0 0 100px 40px #fa2856;
    }
    100% {
        width: 100vw;
        height: 100vh;
        opacity: 1;
        background: #000;
        box-shadow: none;
    }
}

/* Logout Button */
.btn-logout {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-family: "Russo One", sans-serif;
    font-size: 0.65rem;
    padding: 0.5rem 1rem;
    margin-top: 1rem;
    cursor: pointer;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.2s ease;
}

.btn-logout:hover {
    color: #fa2856;
}

/* User Card - Minimal */
.user-card {
    text-align: center;
    margin: 0.5rem 0;
}

.user-card p {
    margin: 0.3rem 0;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

.user-name {
    color: #fae428;
    font-size: 0.9rem !important;
}

.user-email {
    color: rgba(255, 255, 255, 0.4);
}

.user-providers {
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.65rem !important;
    margin-top: 0.5rem !important;
}

.loading {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.75rem;
    letter-spacing: 0.1em;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-title {
        font-size: 1.8rem;
        letter-spacing: 0.15em;
    }

    .btn-start-game {
        width: 180px;
        height: 50px;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .game-title {
        font-size: 1.5rem;
    }

    .btn-oauth {
        padding: 0.5rem 1rem;
        font-size: 0.65rem;
    }

    .btn-start-game {
        width: 160px;
        height: 46px;
        font-size: 0.8rem;
    }

    .auth-input,
    .password-row,
    .auth-divider,
    .auth-field-error,
    .forgot-row {
        width: 220px;
    }

    .code-input {
        width: 160px;
    }

    .oauth-buttons {
        width: 220px;
    }
}

/* ============================================
   Email + Password Auth
   ============================================ */

.auth-input {
    box-sizing: border-box;
    width: 280px;
    padding: 0.7rem 1rem;
    font-family: "Russo One", sans-serif;
    font-size: 0.75rem;
    background: rgba(12, 12, 24, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: rgba(255, 255, 255, 0.9);
    letter-spacing: 0.05em;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-input::placeholder {
    color: rgba(255, 255, 255, 0.28);
    letter-spacing: 0.05em;
}

.auth-input:focus {
    border-color: rgba(120, 160, 255, 0.5);
    box-shadow: 0 0 10px rgba(80, 120, 255, 0.15);
}

/* Override browser autofill yellow/white flash */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus {
    -webkit-text-fill-color: rgba(255, 255, 255, 0.9);
    -webkit-box-shadow: 0 0 0px 1000px rgba(20, 20, 20, 0.97) inset;
    transition: background-color 5000s ease-in-out 0s;
}

.auth-input.input-error {
    border-color: #fa2856;
    box-shadow: 0 0 8px rgba(250, 40, 86, 0.3);
}

/* Password composite row — looks like one input field */
.password-row {
    box-sizing: border-box;
    display: flex;
    align-items: stretch;
    width: 280px;
    background: rgba(20, 20, 20, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.password-row:focus-within {
    border-color: rgba(120, 160, 255, 0.5);
    box-shadow: 0 0 10px rgba(80, 120, 255, 0.15);
}

.password-row.input-error {
    border-color: #fa2856;
    box-shadow: 0 0 8px rgba(250, 40, 86, 0.3);
}

.password-row .auth-input {
    border: none;
    width: auto;
    flex: 1;
    min-width: 0;
}

.password-row .auth-input:focus {
    border: none;
    box-shadow: none;
}

.btn-eye {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    padding: 0 0.6rem;
    transition: color 0.2s ease;
}

.btn-eye:hover {
    color: rgba(255, 255, 255, 0.6);
}

.btn-eye svg {
    width: 16px;
    height: 16px;
}

.btn-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.2);
    color: #fae428;
    cursor: pointer;
    padding: 0 0.8rem;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.btn-submit:hover {
    background: rgba(250, 228, 40, 0.08);
}

.btn-submit:disabled {
    opacity: 0.3;
    cursor: default;
}

.btn-submit svg {
    width: 14px;
    height: 14px;
}

/* Forgot password link */
.forgot-row {
    box-sizing: border-box;
    width: 280px;
    text-align: right;
    margin: -0.25rem 0 0.25rem 0;
}

.forgot-link {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.25);
    font-family: "Russo One", sans-serif;
    font-size: 0.55rem;
    cursor: pointer;
    letter-spacing: 0.05em;
    padding: 0;
    transition: color 0.2s ease;
}

.forgot-link:hover {
    color: rgba(255, 255, 255, 0.5);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.4s ease;
}

.auth-field-error {
    color: #fa2856;
    font-size: 0.6rem;
    font-family: "Russo One", sans-serif;
    letter-spacing: 0.05em;
    margin: -0.25rem 0 0 0;
    text-align: left;
    width: 280px;
}

.auth-divider {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 1rem;
    width: 280px;
    margin: 0.25rem 0;
    color: rgba(255, 255, 255, 0.2);
    font-family: "Russo One", sans-serif;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

/* OAuth buttons match input width */
.oauth-buttons {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    width: 280px;
}

.oauth-buttons .btn-oauth {
    flex: 1;
}

/* Verify button (used in verification + reset sections) */
.btn-action {
    box-sizing: border-box;
    width: 280px;
    height: 42px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: transparent;
    color: rgba(255, 255, 255, 0.6);
    font-family: "Russo One", sans-serif;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-action:hover {
    border-color: rgba(255, 255, 255, 0.4);
    color: rgba(255, 255, 255, 0.9);
}

.btn-action:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Verification code input */
.code-input {
    box-sizing: border-box;
    width: 200px;
    padding: 0.8rem 1rem;
    font-family: monospace;
    font-size: 1.4rem;
    text-align: center;
    letter-spacing: 0.5em;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fae428;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.code-input:focus {
    border-color: rgba(250, 228, 40, 0.4);
}

.code-input.input-error {
    border-color: #fa2856;
    box-shadow: 0 0 8px rgba(250, 40, 86, 0.3);
}

/* Verify/reset description — NOT uppercase (unlike subtitle) */
.verify-desc {
    color: rgba(255, 255, 255, 0.45);
    font-size: 0.7rem;
    font-weight: 400;
    margin: 0 0 0.5rem 0;
    text-align: center;
    letter-spacing: 0.05em;
}

.verify-email {
    color: rgba(255, 255, 255, 0.7);
}

/* Back link */
.btn-back {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.25);
    font-family: "Russo One", sans-serif;
    font-size: 0.55rem;
    cursor: pointer;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0.4rem;
    transition: color 0.2s ease;
}

.btn-back:hover {
    color: rgba(255, 255, 255, 0.5);
}