/* --- General Layout & Typography --- */
.game-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    color: var(--text);
    position: relative;
    z-index: 10;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

.clicker.section-title {
    font-size: clamp(1rem, 5vw, 3rem);
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.subtitle {
    font-size: clamp(1rem, 3vw, 1.5rem);
    opacity: 0.9;
}

.back-button {
    margin: 2rem auto;
    color: var(--text);
    display:inline-block;
    text-decoration: none;
    font-weight: 600;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    transition: all 0.3s ease;
    display:block;
    text-align:center;
}

.back-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-5px);
}

/* --- Game Area Layout --- */
.game-area {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .game-area {
        grid-template-columns: 1fr;
    }

    .back-button { /* Keep related media query adjustments together */
        margin-bottom: 1rem;
    }
}

/* --- Stats Panel --- */
.stats-panel {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat {
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    text-align: center;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.8;
    margin-bottom: 0.3rem;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    transition: transform 0.8s linear, color 0.8s linear;
}

/* Number Changed Effect */
.number-changed {
    transform: scale(1.5);
    color: var(--accent);
    transition: transform 0.1s cubic-bezier(0.16, 1, 0.3, 1), color 0.1s cubic-bezier(0.16, 1, 0.3, 1);
}

/* --- Connection Status --- */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 6px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    transition: all 0.3s ease;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #4CAF50; /* Default: green for connected */
    transition: background-color 0.5s ease;
}

.status-indicator.connecting {
    background-color: #FFC107; /* Yellow for connecting */
    animation: pulse 1.5s infinite;
}

.status-indicator.offline {
    background-color: #F44336; /* Red for offline */
}

.status-text {
    font-size: 0.85rem;
    font-weight: 600;
    transition: color 0.3s ease;
}

/* --- Game Content Area --- */
.game-content {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 2rem;
}

/* Bus Stop Visuals */
.bus-stop-container {
    position: relative;
    flex-grow: 1; /* Allow container to stretch vertically */
    background: linear-gradient(to bottom, rgba(0,0,0,0.3), rgba(0,0,0,0.1));
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.bus-sign {
    position: absolute;
    top: 20px;
    right: 30px;
    width: 60px;
    height: 80px;
    background: #0151A0;
    border-radius: 5px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 5px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.bus-sign-top {
    font-size: 0.8rem;
    font-weight: bold;
    color: white;
}

.bus-sign-number {
    font-size: 2rem;
    font-weight: bold;
    color: white;
}

.bus-visual {
    position: absolute;
    top: 30px;
    left: 30px;
    font-size: 3rem;
    animation: busBounce 3s ease-in-out infinite;
}

/* Click Area */
.click-area {
    width: 150px;
    height: 150px;
    background: linear-gradient(145deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3),
                inset 0 5px 10px rgba(255, 255, 255, 0.3),
                inset 0 -5px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s ease, box-shadow 0.1s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    overflow: visible;  /* Allow floating elements to overflow */
}

@media (min-width: 768px) {
    .click-area {
        width: 200px;
        height: 200px;
    }
}

.click-area:hover {
    transform: scale(1.05);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.4),
                inset 0 5px 15px rgba(255, 255, 255, 0.4),
                inset 0 -5px 15px rgba(0, 0, 0, 0.3);
}

.click-area:active {
    transform: scale(0.95);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2),
                inset 0 5px 10px rgba(255, 255, 255, 0.2),
                inset 0 -5px 10px rgba(0, 0, 0, 0.3);
}

.click-text {
    font-size: 1.3rem;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 2;
}

.click-ripple {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    opacity: 1;
    pointer-events: none;
}

.ripple-animation {
    animation: ripple 0.6s linear;
}

/* Floating Number Animation */
.floating-number {
    position: absolute;
    color: white;
    font-weight: bold;
    font-size: 1.2rem;
    pointer-events: none;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    z-index: 10;
    opacity: 0;
    user-select: none;
    transform-origin: center bottom;
    /* Remove transform: translate that was causing positioning issues */
}

.floating-number-animation {
    animation: floatUp 1.2s ease-out forwards;
}

@keyframes floatUp {
    0% {
        opacity: 0;
        transform: translateY(0);
    }
    20% {
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(-150px) scale(2);
    }
}

/* Progress Bar */
.progress-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 1rem;
    text-align: center;
}

.progress-label {
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.progress-bar {
    height: 24px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s ease-out;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    box-shadow: inset 0 2px 5px rgba(255, 255, 255, 0.3);
}

.progress-percentage {
    font-size: 1.2rem;
    font-weight: 700;
}

/* --- Leaderboard --- */
.leaderboard {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}
@media (min-width: 768px) {
    .leaderboard {
        flex-direction: column;
        min-height:630px;

    }
}



.leaderboard h3 {
    text-align: center;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    font-weight: 600;
}

.leaderboard-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    font-size: 0.9rem;
    border: 2px solid transparent;
}

.leaderboard-loading {
    text-align: center;
    opacity: 0.7;
    padding: 1rem;
}

.leaderboard-name {
    font-weight: 600;
}

.leaderboard-score {
    color: var(--primary);
}

.leaderboard-self-animation {
    animation: borderPulseSelf 1s ease-out;
}

.leaderboard-other-animation {
    animation: borderPulseOther 1s ease-out;
}

/* --- User Panel --- */
.user-panel {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    margin-top: 2rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    padding: 1.5rem;
}

@media (max-width: 768px) {
    .user-panel {
        flex-direction: column;
    }
}

.user-section {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#username-input {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    padding: 0.5rem 1rem;
    color: var(--text);
    font-family: 'Montserrat', sans-serif;
}

#save-username {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
}

#save-username:hover {
    background: var(--secondary);
}

.game-description {
    flex: 1;
    font-size: 0.9rem;
    opacity: 0.9;
}

.note {
    margin-top: 0.5rem;
    font-style: italic;
    font-size: 0.8rem;
    opacity: 0.7;
}

/* --- Modal --- */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.4s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.4s ease forwards;
}

.modal.hide {
    animation: fadeOut 0.4s ease forwards;
}

.modal-content {
    position: relative;
    background: linear-gradient(135deg, rgba(1, 81, 160, 0.9) 0%, rgba(1, 175, 255, 0.9) 100%);
    margin: auto;
    padding: 0;
    border-radius: 20px;
    width: 90%;
    max-width: 340px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.8);
    opacity: 0;
    overflow: hidden;
    transition: transform 0.4s cubic-bezier(0.18, 0.89, 0.43, 1.19), opacity 0.4s ease;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal.show .modal-content {
    animation: zoomIn 0.4s 0.1s cubic-bezier(0.18, 0.89, 0.43, 1.19) forwards;
}

.modal.hide .modal-content {
    animation: zoomOut 0.3s ease forwards;
}

.modal-header {
    padding: 15px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    margin: 0;
    color: white;
    font-size: 1.3rem;
}

.modal-body {
    padding: 20px;
    text-align: center;
    position: relative;
}

#modal-message {
    color: white;
    font-size: 1.1rem;
    margin: 0;
}

.modal-footer {
    padding: 15px 20px;
    text-align: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-close {
    position: absolute;
    right: 15px;
    top: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    z-index: 110;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(3px);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.5);
    transform: rotate(90deg);
}

.modal-close::before,
.modal-close::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 3px;
    background: #fff;
    border-radius: 1px;
}

.modal-close::before {
    transform: rotate(45deg);
}

.modal-close::after {
    transform: rotate(-45deg);
}

#modal-ok-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    padding: 8px 25px;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Montserrat', sans-serif;
}

#modal-ok-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* --- Animations --- */

/* @keyframes numberChange {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); color: var(--accent); }
    100% { transform: scale(1);  }
} */

@keyframes pulse {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

@keyframes busBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes ripple {
    0% { transform: scale(0); opacity: 1; }
    100% { transform: scale(2); opacity: 0; }
}

/* Border Animation for Leaderboard Items */
@keyframes borderPulseSelf {
    0% { border: 2px solid transparent; }
    50% { border: 2px solid #FFD700; } /* Gold for current user */
    100% { border: 2px solid transparent; }
}

@keyframes borderPulseOther {
    0% { border: 2px solid transparent; }
    50% { border: 2px solid #00FF00; } /* Green for other users */
    100% { border: 2px solid transparent; }
}

/* Modal Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes zoomIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes zoomOut {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(0.8); opacity: 0; }
}
