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

html, body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
    position: fixed;
    width: 100%;
    touch-action: none; /* Prevent touch scrolling */
    -webkit-overflow-scrolling: none;
    overscroll-behavior: none;
}

/* Menu Bar */
.menu-bar {
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.menu-left h1 {
    color: #fff;
    font-size: 1.8em;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin: 0;
}

.menu-right {
    display: flex;
    gap: 15px;
}

.help-btn, .reset-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    font-size: 1.5em;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.help-btn:hover, .reset-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.5);
}

/* Container */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5px;
    height: calc(100vh - 80px); /* Account for menu bar */
    max-width: 100%;
    width: 100%;
    overflow: hidden;
    position: relative;
    touch-action: none;
}

.scoreboard {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 3px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    width: auto;
    max-width: 600px;
}

.player {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 0 0 auto;
}

.player h2 {
    color: #fff;
    margin-bottom: 3px;
    font-size: 0.9em;
    white-space: nowrap;
}

.score {
    font-size: 1.8em;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    line-height: 1;
}

.controls {
    color: #fff;
    margin-top: 3px;
    font-size: 0.7em;
    opacity: 0.8;
    white-space: nowrap;
}

.vs {
    font-size: 1.3em;
    font-weight: bold;
    color: #fff;
    flex: 0 0 auto;
}

#gameCanvas {
    border: 3px solid #fff;
    border-radius: 10px;
    background: #1a1a2e;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    display: block;
    margin: 0 auto;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    max-width: 100%;
    height: auto;
}

.game-status {
    margin-top: 5px;
    margin-bottom: 5px;
    font-size: 2em;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    min-height: 30px;
    animation: pulse 1s ease-in-out infinite;
    text-align: center;
}

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

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
}

#modeModal {
    display: block;
}

.modal.show {
    display: block;
}

.modal-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    margin: 5% auto;
    padding: 30px;
    border: 3px solid #fff;
    border-radius: 20px;
    width: 80%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    color: #fff;
    position: relative;
}

.modal-content h2 {
    margin-bottom: 20px;
    font-size: 2em;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    color: #ffd700;
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 1.3em;
}

.modal-content p {
    margin: 8px 0;
    font-size: 1.1em;
    line-height: 1.6;
}

.modal-content strong {
    color: #ffd700;
}

.help-section {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.close {
    color: #fff;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.close:hover,
.close:focus {
    color: #ffd700;
    transform: scale(1.2);
}

@media (max-width: 900px) {
    body {
        overflow: auto;
    }
    
    .container {
        height: auto;
    }
    
    #gameCanvas {
        width: 100%;
        height: auto;
    }
    
    .menu-left h1 {
        font-size: 1.2em;
    }
    
    .scoreboard {
        flex-direction: column;
        gap: 15px;
        min-width: auto;
    }
    
    .vs {
        margin: 10px 0;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
    
    .mode-selection {
        flex-direction: column;
    }
    
    .mode-btn {
        width: 100%;
    }
}

/* Mode Selection Styles */
.mode-selection {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
}

.mode-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    padding: 30px 20px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    text-align: center;
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border-color: #ffd700;
}

.mode-btn:active {
    transform: translateY(-2px);
}

.mode-icon {
    font-size: 4em;
    margin-bottom: 10px;
}

.mode-btn h3 {
    margin: 10px 0;
    font-size: 1.3em;
}

.mode-btn p {
    margin: 5px 0;
    opacity: 0.9;
    font-size: 0.9em;
}

/* Control Scheme Selection */
.control-scheme-selection {
    margin: 20px 0;
    display: none;
}

.control-scheme-selection h3 {
    color: #ffd700;
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5em;
}

.control-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 15px;
    padding: 25px 20px;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border-color: #4ecdc4;
}

.control-btn:active {
    transform: translateY(-2px);
}

.control-icon {
    font-size: 3em;
    margin-bottom: 10px;
}

.control-btn h4 {
    margin: 10px 0;
    font-size: 1.2em;
    color: #ffd700;
}

.control-btn p {
    margin: 5px 0;
    opacity: 0.9;
    font-size: 0.9em;
}

.mode-description {
    background: rgba(255, 255, 255, 0.1);
    padding: 20px;
    border-radius: 10px;
    margin-top: 20px;
}

.mode-description h4 {
    color: #ffd700;
    margin-bottom: 10px;
}

.mode-description p {
    margin: 5px 0;
    padding-left: 10px;
}

/* Mobile Touch Controls */
.mobile-controls {
    display: none; /* Hidden by default */
    position: fixed;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    flex-direction: column;
    gap: 15px;
    z-index: 100;
}

.mobile-controls.show {
    display: flex !important; /* Only show when needed */
    animation: slideInRight 0.3s ease-out;
}

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

.touch-button {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    color: #fff;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
}

.touch-button:active {
    background: rgba(78, 205, 196, 0.5);
    transform: scale(0.92);
    box-shadow: 0 0 25px rgba(78, 205, 196, 0.7), inset 0 2px 8px rgba(0, 0, 0, 0.3);
    border-color: #4ecdc4;
}

.touch-button.pressed {
    background: rgba(78, 205, 196, 0.7);
    border-color: #4ecdc4;
    box-shadow: 0 0 30px #4ecdc4, inset 0 2px 8px rgba(0, 0, 0, 0.3);
    transform: scale(0.92);
}

/* Mobile Start Button */
.mobile-start-btn {
    display: none;
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 24px;
    font-size: 0.95em;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 30px;
    color: #fff;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.mobile-start-btn:active {
    transform: translateX(-50%) scale(0.93);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

@media (max-width: 900px) {
    /* Don't force display - let JavaScript control it */
    .mobile-start-btn {
        display: block !important;
    }
    
    html, body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100vh;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }
    
    .container {
        padding: 0;
        height: 100vh;
        overflow: hidden;
        position: fixed;
        justify-content: flex-start;
        padding-top: 5px;
    }
    
    .menu-bar {
        padding: 6px 10px;
        min-height: 40px;
        background: rgba(0, 0, 0, 0.4);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
    }
    
    .menu-left h1 {
        font-size: 1em;
        line-height: 1.3;
        font-weight: 600;
    }
    
    .scoreboard {
        gap: 10px;
        padding: 8px 15px;
        margin-bottom: 5px;
        max-width: 95%;
        min-height: 0;
        background: rgba(255, 255, 255, 0.15);
        -webkit-backdrop-filter: blur(15px);
        backdrop-filter: blur(15px);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .player h2 {
        font-size: 0.8em;
        margin-bottom: 3px;
        line-height: 1.2;
        font-weight: 600;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    }
    
    .score {
        font-size: 1.8em;
        line-height: 1;
        font-weight: 700;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.6);
    }
    
    .controls {
        font-size: 0.65em;
        margin-top: 3px;
        line-height: 1;
        opacity: 0.9;
    }
    
    .vs {
        font-size: 1.2em;
        line-height: 1;
        font-weight: 700;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    }
    
    .game-status {
        font-size: 0.85em;
        margin-top: 5px;
        margin-bottom: 3px;
        min-height: 20px;
        line-height: 1.3;
        padding: 3px 10px;
        font-weight: 600;
    }
    
    .touch-button {
        width: 70px;
        height: 70px;
        font-size: 1.8em;
        border-width: 3px;
        background: rgba(255, 255, 255, 0.25);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    }
    
    .touch-button:active {
        background: rgba(78, 205, 196, 0.7);
        transform: scale(0.9);
        box-shadow: 0 0 30px rgba(78, 205, 196, 0.8);
    }
    
    .help-btn, .reset-btn {
        width: 36px;
        height: 36px;
        font-size: 1.1em;
        border-width: 2px;
    }
    
    .mobile-start-btn {
        padding: 8px 20px;
        font-size: 0.9em;
        border-width: 3px;
        bottom: 5px;
        font-weight: 700;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    }
    
    #gameCanvas {
        width: 96%;
        max-width: 100%;
        height: auto;
        border-width: 3px;
        border-radius: 8px;
        box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
    }
    
    .modal-content {
        width: 92%;
        margin: 8% auto;
        padding: 25px;
        max-height: 80vh;
    }
    
    .mode-selection {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .mode-btn {
        padding: 25px 20px;
    }
    
    .control-options {
        grid-template-columns: 1fr;
        gap: 15px;
    }
}

@media (max-width: 900px) and (orientation: landscape) {
    .menu-bar {
        padding: 4px 8px;
        min-height: 35px;
    }
    
    .menu-left h1 {
        font-size: 0.85em;
        line-height: 1.2;
    }
    
    .container {
        height: 100vh;
        padding: 0;
        padding-top: 3px;
    }
    
    .scoreboard {
        flex-direction: row;
        padding: 5px 12px;
        margin-bottom: 3px;
        max-width: 75%;
        min-height: 0;
    }
    
    .player h2 {
        font-size: 0.7em;
        margin-bottom: 2px;
        line-height: 1.2;
    }
    
    .score {
        font-size: 1.3em;
        line-height: 1;
    }
    
    .controls {
        font-size: 0.55em;
        line-height: 1;
    }
    
    .vs {
        font-size: 1em;
        margin: 0 5px;
        line-height: 1;
    }
    
    .game-status {
        font-size: 0.7em;
        margin-top: 3px;
        margin-bottom: 2px;
        min-height: 16px;
        line-height: 1.2;
        padding: 2px 8px;
    }
    
    .mobile-start-btn {
        padding: 5px 16px;
        font-size: 0.75em;
        bottom: 3px;
        border-width: 2px;
    }
    
    .touch-button {
        width: 55px;
        height: 55px;
        font-size: 1.4em;
        border-width: 3px;
    }
    
    .help-btn, .reset-btn {
        width: 30px;
        height: 30px;
        font-size: 0.9em;
        border-width: 2px;
    }
    
    #gameCanvas {
        max-height: none;
        width: 97%;
        border-width: 2px;
        border-radius: 6px;
    }
}

/* Landscape specific overrides for mobile controls */
@media (max-width: 900px) and (orientation: landscape) {
    .mobile-controls {
        right: 8px;
        gap: 10px;
    }
}
