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

body {
    font-family: Arial, sans-serif;
    background: #1a1a1a;
    color: white;
    overflow: hidden;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

#gameContainer {
    position: relative;
    width: 100vw;
    height: 100vh;
}

#gameCanvas {
    display: block;
    background: #2a2a2a;
    cursor: none;
}

.screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    z-index: 10;
}

.enhanced-start {
    width: 90%;
    max-width: 600px;
    max-height: 95vh;
    background: rgba(26, 26, 46, 0.95);
    border-radius: 15px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(-20px);
        opacity: 0;
    }
}

.start-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
}

.start-bg-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.start-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at center, transparent 0%, rgba(26, 26, 46, 0.8) 100%);
}

.start-content {
    position: relative;
    z-index: 1;
    padding: 15px 20px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-title {
    font-size: 2.5rem;
    font-weight: bold;
    margin: 0 0 3px 0;
    background: linear-gradient(45deg, #4CAF50, #45a049, #66BB6A);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px rgba(76, 175, 80, 0.5);
    line-height: 1;
}

.title-letters {
    display: inline-block;
}

.letter {
    display: inline-block;
    animation: letterFloat 3s ease-in-out infinite;
}

.letter:nth-child(1) { animation-delay: 0.1s; }
.letter:nth-child(2) { animation-delay: 0.2s; }
.letter:nth-child(3) { animation-delay: 0.3s; }
.letter:nth-child(4) { animation-delay: 0.4s; }
.letter:nth-child(5) { animation-delay: 0.5s; }
.letter:nth-child(6) { animation-delay: 0.6s; }
.letter:nth-child(7) { animation-delay: 0.7s; }

.title-dot {
    display: inline-block;
    animation: dotPulse 2s ease-in-out infinite;
    color: #FFD700;
}

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

@keyframes dotPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
}

.game-subtitle {
    font-size: 0.9rem;
    color: #b0b0b0;
    margin-bottom: 5px;
    letter-spacing: 1px;
}

.game-preview {
    margin: 0;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.preview-title {
    font-size: 1.1rem;
    color: #fff;
    margin-bottom: 8px;
    font-weight: bold;
}

.preview-content {
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.preview-item {
    display: flex;
    align-items: center;
    gap: 15px;
    color: #e0e0e0;
    font-size: 0.9rem;
}

.preview-circle, .preview-tile {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 12px;
    border: 2px solid #fff;
    flex-shrink: 0;
}

.preview-tile {
    border-radius: 5px;
}

.preview-arrow {
    font-size: 1.5rem;
    color: #FFD700;
}

.stats-section {
    display: flex;
    justify-content: space-around;
    margin: 0;
    gap: 8px;
    flex-shrink: 0;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px 6px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 70px;
    flex: 1;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #4CAF50;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #b0b0b0;
}

.settings-section {
    margin: 15px 0;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-title {
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 15px;
    font-weight: bold;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.setting-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.setting-item label {
    color: #e0e0e0;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.setting-item select {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    color: #fff;
    padding: 5px 10px;
    font-size: 0.9rem;
}

.start-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 15px 0;
}

.play-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 30px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.play-btn.primary {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    box-shadow: 0 5px 15px rgba(76, 175, 80, 0.4);
}

.play-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.6);
}

.play-btn.secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.play-btn.secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-text {
    display: block;
    font-size: 1.2rem;
}

.btn-subtext {
    display: block;
    font-size: 0.9rem;
    opacity: 0.8;
    margin-top: 5px;
}

.social-section {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.social-btn {
    padding: 8px 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    color: #fff;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.social-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .enhanced-start {
        width: 98%;
        margin: 5px;
        max-height: 98vh;
    }
    
    .start-content {
        padding: 12px 10px;
    }
    
    .game-title {
        font-size: 2rem;
    }
    
    .game-subtitle {
        font-size: 0.9rem;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-section {
        flex-direction: row;
        gap: 6px;
    }
    
    .stat-card {
        padding: 6px 4px;
        min-width: 60px;
    }
    
    .stat-value {
        font-size: 1.4rem;
    }
    
    .preview-item {
        font-size: 0.8rem;
        gap: 8px;
    }
    
    .preview-circle, .preview-tile {
        width: 22px;
        height: 22px;
        font-size: 9px;
    }
    
    .play-btn {
        padding: 12px 25px;
        font-size: 1rem;
    }
    
    .btn-text {
        font-size: 1.1rem;
    }
    
    #playerInfo, #botInfo {
        font-size: 12px;
    }
    
    #timer {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .enhanced-start {
        width: 100%;
        margin: 0;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .start-content {
        padding: 10px 8px;
        gap: 8px;
    }
    
    .game-title {
        font-size: 1.8rem;
    }
    
    .play-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .play-btn.primary {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .btn-text {
        font-size: 1.1rem;
    }
    
    .btn-subtext {
        font-size: 0.7rem;
    }
    
    .settings-section {
        margin: 10px 0;
        padding: 8px;
    }
    
    .settings-title {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }
    
    .settings-grid {
        gap: 8px;
    }
    
    .stat-card {
        padding: 4px 3px;
    }
    
    .stat-value {
        font-size: 1.2rem;
    }
    
    #hud {
        padding: 8px 12px;
        font-size: 12px;
    }
}

/* Full screen optimizations */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

#gameContainer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    touch-action: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Enhanced safe area handling for mobile notches */
@supports (padding: max(0px)) {
    #hud {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
    
    #virtualJoystick {
        left: max(30px, env(safe-area-inset-left) + 10px);
        bottom: max(30px, env(safe-area-inset-bottom) + 10px);
    }
    
    .enhanced-start {
        margin: max(10px, env(safe-area-inset-top));
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .enhanced-start {
        width: 80%;
        max-height: 90vh;
    }
    
    .start-content {
        padding: 15px;
    }
    
    .game-title {
        font-size: 2rem;
    }
}

/* Enhanced Virtual Joystick Styles */
#virtualJoystick {
    position: absolute;
    bottom: 30px;
    left: 30px;
    width: 140px;
    height: 140px;
    z-index: 10;
    display: none;
    touch-action: none;
}

.joystick-base {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.joystick-stick {
    position: absolute;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 3px 15px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s ease, background-color 0.1s ease;
    border: 2px solid rgba(255, 255, 255, 0.5);
}

.joystick-stick.active {
    background: rgba(76, 175, 80, 0.9);
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 3px 20px rgba(76, 175, 80, 0.5);
}

/* Enhanced mobile breakpoints */
@media (max-width: 768px) {
    #virtualJoystick {
        display: block;
    }
    
    .joystick-base {
        width: 120px;
        height: 120px;
    }
    
    .joystick-stick {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    #virtualJoystick {
        bottom: 25px;
        left: 25px;
        width: 110px;
        height: 110px;
    }
    
    .joystick-base {
        width: 110px;
        height: 110px;
    }
    
    .joystick-stick {
        width: 38px;
        height: 38px;
    }
}

@media (max-width: 375px) {
    #virtualJoystick {
        bottom: 20px;
        left: 20px;
        width: 100px;
        height: 100px;
    }
    
    .joystick-base {
        width: 100px;
        height: 100px;
    }
    
    .joystick-stick {
        width: 35px;
        height: 35px;
    }
}

@media (max-width: 320px) {
    #virtualJoystick {
        bottom: 15px;
        left: 15px;
        width: 90px;
        height: 90px;
    }
    
    .joystick-base {
        width: 90px;
        height: 90px;
    }
    
    .joystick-stick {
        width: 32px;
        height: 32px;
    }
}

/* Safe area handling for mobile notches */
@supports (padding: max(0px)) {
    #virtualJoystick {
        bottom: max(30px, env(safe-area-inset-bottom) + 10px);
        left: max(30px, env(safe-area-inset-left) + 10px);
    }
    
    @media (max-width: 480px) {
        #virtualJoystick {
            bottom: max(25px, env(safe-area-inset-bottom) + 10px);
            left: max(25px, env(safe-area-inset-left) + 10px);
        }
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 600px) {
    #virtualJoystick {
        bottom: 20px;
        left: 20px;
        width: 100px;
        height: 100px;
    }
}

button {
    background: #4CAF50;
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 16px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

button:hover {
    background: #45a049;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent);
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    grid-template-areas: 
        "player timer bots"
        "powerups powerups powerups";
    align-items: center;
    gap: 20px;
    z-index: 5;
    font-size: 14px;
}

.timer-display {
    grid-area: timer;
    font-size: 32px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    text-align: center;
    min-width: 80px;
}

.player-stats {
    grid-area: player;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
}

.stat-icon {
    font-size: 16px;
    text-shadow: 0 0 5px currentColor;
}

.stat-value {
    color: white;
}

.bot-stats {
    grid-area: bots;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.bot-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0, 0, 0, 0.3);
    padding: 4px 8px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: bold;
}

.bot-icon {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    text-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}

.bot-value {
    color: white;
    min-width: 20px;
    text-align: center;
}

.power-up-status {
    grid-area: powerups;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.power-up-indicator {
    background: rgba(0, 0, 0, 0.5);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.power-up-icon {
    font-size: 12px;
}

.power-up-bar {
    width: 40px;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
}

.power-up-progress {
    height: 100%;
    transition: width 0.1s ease;
}

/* Toast Notifications */
.toast-notification {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    padding: 12px 24px;
    border-radius: 25px;
    font-weight: bold;
    font-size: 14px;
    color: white;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: toastSlideUp 0.5s ease-out;
    max-width: 90%;
    text-align: center;
    word-wrap: break-word;
}

@keyframes toastSlideUp {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

@keyframes toastSlideDown {
    from {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
    to {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
}

@media (max-width: 768px) {
    .toast-notification {
        bottom: 100px;
        font-size: 13px;
        padding: 10px 20px;
    }
}

@media (max-width: 480px) {
    .toast-notification {
        bottom: 120px;
        font-size: 12px;
        padding: 8px 16px;
    }
}

@media (max-width: 768px) {
    #hud {
        padding: 10px 15px;
        gap: 15px;
    }
    
    .timer-display {
        font-size: 28px;
    }
    
    .stat-item, .bot-item {
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .stat-icon, .bot-icon {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    #hud {
        padding: 8px 12px;
        gap: 10px;
    }
    
    .timer-display {
        font-size: 24px;
    }
    
    .stat-item, .bot-item {
        font-size: 10px;
        padding: 2px 5px;
    }
    
    .power-up-indicator {
        font-size: 10px;
        padding: 2px 5px;
    }
}

#finalScores {
    margin: 20px 0;
    font-size: 16px;
    line-height: 1.8;
}

#finalScores div {
    margin: 5px 0;
}