html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    background: radial-gradient(circle at top, #1b3b7a 0%, #020824 55%, #000010 100%);
    font-family: sans-serif;
}

* {
    box-sizing: border-box;
}

.fixed-logo {
    position: fixed;
    top: -50px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    max-width: 550px;
    height: auto;
    object-fit: contain;
    background: transparent;
    pointer-events: none;
}

.bg-wrapper {
    position: relative;
    width: 100vw;
    min-height: 100vh;
    overflow: visible;
    background: radial-gradient(circle at top, #1b3b7a 0%, #020824 55%, #000010 100%);
}

.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.auth-overlay.hidden {
    display: none;
}

.auth-card {
    width: min(calc(100vw - 48px), 320px);
    padding: 24px 20px 19px;
    background: #1d1d23;
    border: 1px solid #3b3b43;
    border-radius: 12px;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.56), 0 16px 32px rgba(0, 0, 0, 0.22);
    color: #f5f4f8;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 13px;
}

.auth-card h2 {
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 650;
    line-height: 1.25;
}

.auth-subtitle {
    margin: 0 0 17px;
    color: #f1eff8;
    font-size: 13px;
    line-height: 1.35;
}

.auth-field {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
    margin-bottom: 11px;
}

.auth-field span {
    margin: 0;
    color: #f1eff6;
    font-size: 12px;
    line-height: 1.2;
}

.auth-field input {
    width: 100%;
    min-height: 32px;
    border: 1px solid #777780;
    border-radius: 9px;
    padding: 6px 9px;
    background: #202026;
    color: #fff;
    font: inherit;
    outline: none;
    caret-color: #d6d3ff;
}

.auth-field input:focus {
    border-color: #bcb8ff;
    box-shadow: 0 0 0 1px #bcb8ff;
}

.auth-error {
    min-height: 17px;
    margin: 2px 0 8px 66px;
    color: #ffaaa9;
    font-size: 12px;
    line-height: 1.35;
}

.auth-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 9px;
    margin-top: 1px;
}

.auth-button,
.auth-cancel {
    min-height: 34px;
    padding: 7px 16px;
    border-radius: 18px;
    font: 500 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    cursor: pointer;
    transition: background-color 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}

.auth-button {
    border: 1px solid #c8c5ff;
    background: #bcb8ff;
    color: #1a1920;
}

.auth-button:hover {
    background: #d0ceff;
}

.auth-cancel {
    border: 1px solid #aaa6fa;
    background: transparent;
    color: #d8d6ff;
}

.auth-cancel:hover {
    background: rgba(188, 184, 255, 0.12);
}

.auth-button:focus-visible,
.auth-cancel:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px #1d1d23, 0 0 0 4px #bcb8ff;
}

/* Canvas */
#particles {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.content-overlay::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 230px;
    background: linear-gradient(to bottom,
    rgba(2, 8, 36, 1) 0%,
    rgba(2, 8, 36, 1) 90%,
    transparent 100%);
    z-index: 997;
    pointer-events: none;
}

.content-overlay {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 250px;
    pointer-events: none;
    color: white;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.8);
    min-height: 100vh;
}

.games-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 10px;
    width: 100%;
    max-width: 1755px;
    justify-content: center;
}

.game-icon {
    flex: 0 0 160px;
    width: 160px;
    height: 210px;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    transition: transform 0.25s ease;
    cursor: pointer;
    pointer-events: auto;
    background: transparent;
    padding: 0;
    box-shadow: none;
}

.game-icon:hover {
    transform: translateY(-6px) scale(1.02);
}

.header-left {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.toggle-label {
    color: white;
    font-size: 12px;
    font-weight: normal;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}

/* Toggle Switch Styles */
.toggle-switch {
    width: 60px;
    height: 30px;
    background: #ccc;
    border-radius: 15px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active {
    background: #4CAF50;
}

.switch-handle {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 3px rgba(0, 0, 0, 0.2);
}

.toggle-switch.active .switch-handle {
    transform: translateX(30px);
}

.header-right {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
}

.menu-button {
    background: linear-gradient(135deg, #2c3e50, #2c3e50);
    border: none;
    border-radius: 25px;
    padding: 12px 24px;
    color: white;
    font-weight: bold;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.2);
    transition: all 0.3s ease;
}

.menu-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(241, 7, 30, 0.67);
}

.balance-display {
    background: rgba(13, 23, 48, 0.72);
    border: 1px solid rgba(160, 195, 255, 0.22);
    border-radius: 999px;
    padding: 14px 28px;
    color: #f5f8ff;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow:
        0 10px 30px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    letter-spacing: 0.2px;
}

.balance-label {
    color: rgba(230, 238, 255, 0.72);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.12em;
}

/* Info Panel Styles */
.info-panel {
    position: fixed;
    top: 80px;
    left: 20px;
    background: linear-gradient(135deg, #2c3e50, #475e7e);
    border: 2px solid #5a7088;
    border-radius: 15px;
    padding: 20px;
    color: white;
    z-index: 1002;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-20px);
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    max-width: 300px;
}

.info-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.info-content h3 {
    margin: 0 0 15px 0;
    color: #ffffff;
    font-size: 20px;
    text-align: center;
}

.info-content p {
    margin: 0 0 10px 0;
    font-size: 14px;
    line-height: 1.4;
}

.close-info {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    width: 25px;
    height: 25px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.close-info:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Game Popup Styles */
.game-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(135deg, #2c3e50, #475e7e);
    border: 2px solid #5a7088;
    border-radius: 15px;
    padding: 30px;
    color: white;
    z-index: 1003;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    min-width: 300px;
    text-align: center;
}

.game-popup.show {
    opacity: 1;
    visibility: visible;
}

.popup-content h3 {
    margin: 0 0 20px 0;
    color: #ffffff;
    font-size: 24px;
    text-align: center;
}

.popup-content p {
    margin: 0 0 25px 0;
    font-size: 16px;
    line-height: 1.4;
}

.popup-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.popup-btn {
    padding: 10px 25px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 80px;
}

.play-btn {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    color: white;
}

.play-btn:hover {
    background: linear-gradient(135deg, #229954, #27ae60);
    transform: translateY(-2px);
}

.cancel-btn {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.cancel-btn:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-2px);
}

@media (max-width: 900px) {
    .fixed-logo {
        max-width: min(80vw, 420px);
        top: -30px;
    }

    .content-overlay {
        padding-top: 190px;
    }

    .games-grid {
        gap: 4px;
        padding: 10px;
        max-width: 900px;
    }

    .balance-display {
        padding: 14px 22px;
        font-size: 16px;
    }
}

@media (max-width: 640px) {
    .auth-card {
        padding: 22px 18px;
    }

    .auth-card h2 {
        font-size: 16px;
    }

    .header-left {
        top: 8px;
        left: 8px;
        align-items: flex-start;
        max-width: calc(100vw - 24px);
        gap: 4px;
    }

    .toggle-switch {
        width: 48px;
        height: 24px;
    }

    .switch-handle {
        width: 18px;
        height: 18px;
        top: 3px;
        left: 3px;
    }

    .toggle-switch.active .switch-handle {
        transform: translateX(24px);
    }

    .toggle-label {
        white-space: normal;
        font-size: 10px;
        line-height: 1.2;
    }

    .header-right {
        top: 8px;
        right: 8px;
    }

    .balance-display {
        padding: 8px 12px;
        font-size: 12px;
        border-width: 2px;
        gap: 6px;
    }

    .balance-label {
        font-size: 10px;
        letter-spacing: 0.1em;
    }

    .fixed-logo {
        max-width: 74vw;
        top: 14px;
    }

    .content-overlay {
        padding-top: 210px;
        align-items: flex-start;
    }

    .games-grid {
        width: 100%;
        gap: 4px;
        padding: 10px;
    }

    .game-icon {
        flex-basis: calc((100% - 4px) / 2);
        width: calc((100% - 4px) / 2);
        height: auto;
        aspect-ratio: 160 / 210;
    }

    .game-icon:hover {
        transform: none;
        box-shadow: none;
    }

    .game-popup {
        width: min(88vw, 340px);
        min-width: 0;
        padding: 22px 18px;
    }

    .popup-buttons {
        flex-direction: column;
    }

    .popup-btn {
        width: 100%;
    }
}
