/* Carball.io Styles - Based on modern IO game design */

/* CSS Variables */
:root {
    --primary: #51cf66;
    --primary-dark: #2f9e44;
    --secondary: #69db7c;
    --danger: #ff6b6b;
    --warning: #ffd43b;
    --dark: #212529;
    --light: #f8f9fa;
    --bg-overlay: rgba(0, 0, 0, 0.75);
    --card-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --border-radius: 12px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body, html {
    height: 100%;
    font-family: 'Poppins', sans-serif;
    overflow: hidden;
    position: relative;
}

/* Background */
#background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../homebg.png') center/cover;
    z-index: -1;
}

body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    z-index: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

body.in-game::after {
    opacity: 0;
}

/* Main Menu */
#mainMenu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

#mainMenu.hidden {
    display: none !important;
}

#menuContainer {
    width: 100%;
    max-width: 1200px;
    text-align: center;
    padding: 20px;
    position: relative;
    z-index: 11;
}

/* Game Logo */
#gameName {
    margin-bottom: 40px;
    animation: fadeInUp 0.8s ease-out;
}

#gameLogoImg {
    width: 280px;
    max-width: 70vw;
    height: auto;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.3));
    animation: float 3s ease-in-out infinite;
}

#gameTitle {
    font-size: 48px;
    font-weight: 700;
    color: white;
    text-shadow: 0 4px 8px rgba(0, 0, 0, 0.5);
    margin-top: 15px;
    letter-spacing: 3px;
}

#gameSubtitle {
    font-size: 18px;
    font-weight: 300;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-top: 5px;
    letter-spacing: 2px;
}

/* Loading Text */
#loadingText {
    font-size: 24px;
    color: white;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    animation: pulse 2s ease-in-out infinite;
}

/* Menu Cards Container */
#menuCardHolder {
    display: block !important;
    animation: fadeInUp 0.8s ease-out 0.3s both;
}

.menu {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    justify-content: center;
    align-items: flex-start;
    max-width: 1180px;
    margin: 0 auto;
}

/* Panel Base Style */
.panel {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Menu Cards */
.serverCard {
    display: flex !important;
    padding: 0 !important; /* Remove padding for full coverage */
    cursor: pointer;
    overflow: hidden;
    border-radius: var(--border-radius);
}

.ad-card {
    transition: transform 0.2s ease;
}

.ad-card:hover {
    transform: scale(1.05);
}

.ad-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--border-radius);
}

.joinCard {
    flex: 0 0 380px;
    width: 380px;
    height: 380px;
}

.menuCard {
    flex: 0 0 350px;
    width: 350px;
    height: 350px;
    padding: 25px;
    transition: var(--transition);
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    box-sizing: border-box;
}

.menuCard:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

/* Menu Headers */
.menuHeader {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.menuHeader .material-icons {
    font-size: 24px;
    color: var(--primary);
}

.menuSubheader {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.menuText {
    font-size: 16px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 15px;
}

/* Stats Display */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(76, 110, 245, 0.1);
    border-radius: 8px;
}

.stat-row span:last-child {
    font-weight: 600;
    color: var(--primary);
}

/* Menu Buttons */
.menu-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.menuButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    user-select: none;
}

.menuButton:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(76, 110, 245, 0.4);
}

.menuButton.small {
    font-size: 13px;
    padding: 10px 16px;
}

.menuButton.big {
    font-size: 18px;
    padding: 16px 32px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
    margin: 15px 0;
    background: linear-gradient(45deg, var(--secondary), #40c057);
}

.menuButton.big:hover {
    background: linear-gradient(45deg, #40c057, var(--secondary));
}

.menuButton.secondary {
    background: var(--text-secondary);
    color: white;
}

.menuButton.secondary:hover {
    background: #495057;
}

/* Form Elements */
input[type="text"], select {
    width: 100%;
    padding: 15px 18px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: var(--transition);
    background: white;
    margin-bottom: 15px;
}

input[type="text"]:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.1);
}

/* Card Structure */
.card-header {
    margin-bottom: 12px;
}

.card-content {
    flex-grow: 1;
    padding: 0;
}

.card-footer {
    margin-top: 12px;
    padding-top: 0;
}

/* Form Elements */
.form-group {
    margin-bottom: 8px;
}

.form-label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
}

.form-input,
.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background: white;
    transition: var(--transition);
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(76, 110, 245, 0.1);
}

/* Control Toggle */
.control-toggle {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.toggle-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 12px;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition);
    background: white;
    min-width: 65px;
    font-size: 11px;
    font-weight: 500;
}

.toggle-option:hover {
    border-color: var(--primary);
    background: rgba(76, 110, 245, 0.05);
}

.toggle-option input[type="radio"] {
    display: none;
}

.toggle-option input[type="radio"]:checked + .material-icons {
    color: var(--primary);
}

.toggle-option input[type="radio"]:checked ~ span {
    color: var(--primary);
}

.toggle-option .material-icons {
    font-size: 18px;
    color: var(--text-secondary);
    transition: var(--transition);
}

/* Play Button */
.play-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.play-button:hover {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(76, 110, 245, 0.3);
}

.play-button .material-icons {
    font-size: 20px;
}


/* Server Info */
#serverInfo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(76, 110, 245, 0.1);
    border-radius: 8px;
}

#serverInfo .material-icons {
    color: var(--secondary);
    font-size: 28px;
}

.server-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Settings Button */
#settingsButton {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    z-index: 1000;
}

#settingsButton:hover {
    transform: scale(1.1) rotate(45deg);
}

#settingsButton .material-icons {
    font-size: 24px;
    color: var(--primary);
}

/* Links Container */
#linksContainer {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    font-size: 14px;
    z-index: 1000;
}

#linksContainer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

#linksContainer a:hover {
    color: var(--primary-dark);
}

/* Player Count */
.player-count {
    position: fixed;
    top: 20px;
    left: 20px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 20px;
    font-weight: 600;
    font-size: 18px;
    color: white;
    backdrop-filter: blur(10px);
    z-index: 1000;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    animation: fadeIn 0.3s ease-out;
    padding-top: 50px;
}

.modal[style*="block"] {
    display: flex !important;
}

.modal__overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 2000;
}

.modal__container {
    position: relative;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
    z-index: 2001;
    animation: modalSlideIn 0.3s ease-out;
    margin: auto;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid #e9ecef;
    background: rgba(76, 110, 245, 0.05);
}

.modal__title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal__title .material-icons {
    color: var(--primary);
}

.modal__close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition);
    padding: 5px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal__close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
}

.modal__content {
    padding: 25px;
    max-height: calc(80vh - 80px);
    overflow-y: auto;
    color: var(--text-primary);
}

/* Goals Display in Modal */
.goals-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 15px;
    background: linear-gradient(45deg, var(--secondary), #40c057);
    color: white;
    border-radius: 8px;
    margin-bottom: 25px;
    font-size: 18px;
    font-weight: 600;
}

/* Skin Cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.card {
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: var(--transition);
    cursor: pointer;
}

.card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.card_image img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.card_title {
    font-size: 16px;
    font-weight: 600;
    margin: 12px 0 8px;
    color: var(--text-primary);
}

.card_text {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.card_btn {
    margin-top: 12px;
    font-size: 12px;
    padding: 8px 16px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    padding: 20px;
    text-align: center;
    background: rgba(76, 110, 245, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(76, 110, 245, 0.2);
}

.stat-card h4 {
    color: var(--text-secondary);
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.stat-card .value {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-card .subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
}

.stats-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

/* GAME UI - HIDDEN BY DEFAULT */
#gameGUI {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    pointer-events: none;
    display: none !important; /* Force hide when not in game */
}

#gameGUI.active {
    display: block !important;
}

#gameGUI > * {
    position: absolute;
    color: white;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

#score {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 36px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.6);
    padding: 12px 24px;
    border-radius: 25px;
    backdrop-filter: blur(10px);
}

#time {
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 24px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

#speedometer {
    bottom: 20px;
    left: 20px;
    font-size: 18px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
}

#goal, #countdown {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 72px;
    font-weight: 700;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

#goal.show, #countdown.show {
    opacity: 1;
}

.boostBar {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

#boostBarPercent {
    height: 100%;
    background: linear-gradient(90deg, #ffd43b, #51cf66);
    transition: width 0.1s ease;
    border-radius: 8px;
}

/* Mobile Controls - Hidden by default */
#mobile {
    visibility: hidden !important;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
}

#mobile.active {
    visibility: visible !important;
}

.mobile-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.mobile-row {
    display: flex;
    gap: 10px;
}

.mobilebig, .mobilesmall {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobilebig {
    width: 60px;
    height: 60px;
    font-size: 20px;
}

.mobilesmall {
    width: 55px;
    height: 40px;
    font-size: 12px;
}

.mobilebig:active, .mobilesmall:active {
    background: rgba(76, 110, 245, 0.8);
    border-color: var(--primary);
    transform: scale(0.95);
}

/* Chat Input - Hidden by default */
#chatInput {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 16px;
    padding: 12px 16px;
    border: 2px solid var(--primary);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    z-index: 150;
    display: none !important;
}

#chatInput.active {
    display: block !important;
}

/* Match Info - Hidden by default */
#matchInfo {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1500;
    display: none !important;
}

#matchInfo.active {
    display: block !important;
}

#matchInfo .panel {
    padding: 40px;
    text-align: center;
    min-width: 400px;
}

#matchInfo h1 {
    font-size: 32px;
    margin-bottom: 20px;
    color: var(--primary);
}

#matchInfo hr {
    border: none;
    height: 1px;
    background: #e9ecef;
    margin: 20px 0;
}

#matchInfo p {
    font-size: 18px;
    margin: 10px 0;
    color: var(--text-secondary);
}

.match-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 25px;
}

/* Force Landscape Mobile */
#forcelandscapemobile {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-overlay);
    color: white;
    display: none;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 3000;
}

.landscape-message {
    padding: 40px;
}

.landscape-message .material-icons {
    font-size: 72px;
    margin-bottom: 20px;
    animation: spin 2s linear infinite;
}



/* Joystick Zone */
#joystickZone {
    position: fixed;
    width: 50%;
    height: 100%;
    top: 0;
    left: 0;
    z-index: 100;
    visibility: hidden;
}

#joystickZone.active {
    visibility: visible;
}

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

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

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

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
    .menu {
        flex-direction: column;
        align-items: center;
    }

    .menuCard {
        min-width: 300px;
        max-width: 350px;
        width: 350px;
        height: 350px;
        margin-bottom: 15px;
    }

    /* Reorder cards on mobile: Join Game first, then Stats */
    .joinCard {
        order: 1;
    }

    .profileCard {
        order: 2;
    }

    /* Hide server info card on mobile - keep ads on desktop only */
    .serverCard {
        display: none;
    }

    #gameName {
        margin-bottom: 25px;
    }

    #gameTitle {
        font-size: 36px;
    }

    #gameSubtitle {
        font-size: 16px;
    }

    .modal__container {
        width: 95%;
        max-height: 90vh;
    }

    #score {
        font-size: 28px;
        padding: 10px 20px;
    }

    .control-options {
        flex-direction: column;
        gap: 8px;
    }

    .control-option {
        max-width: none;
        min-width: auto;
        justify-content: center;
    }

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

    #settingsButton {
        top: 15px;
        right: 15px;
        width: 45px;
        height: 45px;
    }

    .player-count {
        top: 15px;
        left: 15px;
        font-size: 16px;
        padding: 6px 14px;
    }
}

@media (max-width: 480px) {
    #menuContainer {
        padding: 15px;
    }

    .menuCard {
        min-width: 280px;
        padding: 20px;
    }

    #gameLogoImg {
        width: 220px;
    }

    #gameTitle {
        font-size: 28px;
    }

    .cards {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 15px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    #linksContainer {
        font-size: 12px;
        padding: 8px 16px;
    }
}