/* ───────── CSS Reset & Basic Setup ───────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Roboto Mono', monospace;
    color: #f0f0f0;
    background-color: #252849;
    overflow: hidden;
}

.app-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

/* ───────── Main Logo (Top-left on name screen) ───────── */
.main-logo-container {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
}
.main-logo-container img {
    max-width: 150px;
    height: auto;
}

/* ───────── Helper Classes ───────── */
.hidden { display: none !important; }
.active { display: flex !important; }

/* ───────── Pop-ups (Name Entry & Results) ───────── */
.popup-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 100;
    animation: fadeIn 0.3s ease-in-out;
}

#name-popup {
    background-color: transparent;
    backdrop-filter: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Generic popup style for results, etc. */
.popup-content {
    background-color: #1e2233;
    padding: 2.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid #333;
    width: 90%;
    max-width: 450px;
}

/* UPDATED: Specific style for the sign-in form container using Flexbox */
.name-form-container {
    background-color: rgba(0, 0, 0, 0.5); 
    border: 4px solid #4faf3b; 
    border-radius: 16px; 
    border-style: solid;
    
    /* THE FIX: Make the container a flexbox column */
    display: flex;
    flex-direction: column;
    /* This will now horizontally center ALL items inside it, including the logo */
    align-items: center; 
}

/* UPDATED: Style for the logo image inside the sign-in form */
.signin-logo-img {
    /* Centering is now handled by the parent, so we remove display and margin:auto */
    margin-bottom: 1.5rem; /* Keep the bottom margin for spacing */
    
    max-width: 400px;
    max-height: 200px;
    height: auto;
}

.name-form-container p {
    margin-bottom: 1.5rem;
    color: #ffffff;
    font-weight: bold;
    text-shadow: 1px 1px 3px rgba(0,0,0,0.5);
}

input[type="text"], input[type="email"], input[type="password"] {
    width: 100%;
    padding: 12px 15px;
    margin-bottom: 1rem;
    background-color: #252849;
    border: 1px solid #444;
    border-radius: 5px;
    color: #f0f0f0;
    font-size: 1rem;
    font-family: inherit;
}
input[type="text"]:focus, input[type="email"]:focus, input[type="password"]:focus {
    outline: none;
    border-color: #4faf3b;
}

/* Style for name input field */
#name-input {
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.6); 
    border-radius: 8px;
    color: #ffffff;
    text-align: center; 
}
#name-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}
#name-input:focus {
    border-color: rgba(255, 255, 255, 1.0); 
}

button {
    padding: 12px 25px;
    background-color: #4faf3b;
    color: #252849;
    border: none;
    border-radius: 5px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: all .2s ease;
    text-transform: uppercase;
    font-family: inherit;
}
button:hover {
    background-color: #6ad46a;
    transform: translateY(-2px);
}

/* Style for the "Начать игру" button */
#name-form button {
    background-color: transparent;
    border: 1px solid rgba(255, 255, 255, 0.6); 
    border-radius: 8px;
    color: #ffffff;
}
#name-form button:hover {
    background-color: rgba(255, 255, 255, 0.1); 
    border-color: rgba(255, 255, 255, 1.0); 
    transform: translateY(-2px);
}

button:disabled {
    background-color: #555;
    color: #999;
    cursor: not-allowed;
    transform: none;
}
button.danger {
    background-color: #e53935;
    color: #fff;
}
button.danger:hover {
    background-color: #f44336;
}

/* ───────── Game Screen  ───────── */
#game-screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #151833; 
}
.game-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    background-color: #1e2233;
    border-bottom: 1px solid #333;
}
.game-header .logo-img {
    height: 40px;
    width: auto;
}
.game-header .stock-name {
    color: #a9b3cc;
    font-size: 1.4rem;
    font-weight: bold;
}
.game-header .header-spacer {
    width: 150px; 
}
#chart-container {
    flex-grow: 1;
    width: 100%;
    background-color: #1e2233;
}
.game-controls {
    flex-shrink: 0;
    padding: 1rem;
    width: 100%;
    text-align: center;
    background-color: #1e2233;
    border-top: 1px solid #333;
}
#sell-button {
    width: 100%;
    max-width: 300px;
    padding: 15px;
    font-size: 1.2rem;
    background-color: #E83F29;
    color: #fff;
}
#sell-button:hover { background-color: #f06292; }

/* ───────── QR Container ───────── */
.qr-container {
    margin: 1rem 0;
}
.qr-container img {
    max-width: 150px;
    display: block;
    margin: 0 auto 0.5rem;
    border-radius: 4px;
}

/* ───────── Result Screen & Leaderboard ───────── */
.result-content { max-width: 600px; }
#result-title   { margin-bottom: 0.5rem; }
#result-details { margin-bottom: 0.5rem; font-size: 1.5rem; font-weight: bold; }
#initial-price, #sell-price { margin-bottom: 0.5rem; color: #ccc; }
#leaderboard {
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #333;
    border-radius: 5px;
    margin-bottom: 1.5rem;
}
#leaderboard table { width: 100%; border-collapse: collapse; }
#leaderboard th,
#leaderboard td { padding: 10px; text-align: left; }
#leaderboard thead {
    background-color: #36405a;
    position: sticky;
    top: 0;
    z-index: 10;
}
#leaderboard tbody tr:nth-child(even) { background-color: #2a3144; }
#leaderboard tbody tr.current-user {
    background-color: #4faf3b;
    color: #1e2233;
    font-weight: bold;
}
#play-again-button { margin-top: 1rem; }

/* ───────── Fixed Links Container ───────── */
.fixed-links {
    position: fixed;
    bottom: 15px;
    right: 15px;
    z-index: 150;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: flex-end;
}
.fixed-links a {
    color: #f0f0f0;
    background-color: rgba(75, 175, 59, 0.7);
    text-decoration: none;
    font-size: 0.8rem;
    padding: 8px 12px;
    border-radius: 5px;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    backdrop-filter: blur(3px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-weight: 700;
}
.fixed-links a:hover {
    background-color: #4faf3b;
    color: #252849;
    transform: scale(1.05);
}

/* ───────── Mobile Responsiveness ───────── */
@media (max-width: 768px) {
    .game-header .stock-name { font-size: 1.1rem; }
    .game-header .header-spacer { display: none; }
    .game-header { justify-content: space-between; }
}

@media (max-width: 600px) {
    .popup-content { padding: 1.5rem; width: 95%; }
    h1 { font-size: 1.5rem; }
    #leaderboard { max-height: 200px; }
    .fixed-links { bottom: 10px; right: 10px; }
    .fixed-links a { font-size: 0.7rem; padding: 6px 10px; }
}