* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Courier New', 'Consolas', monospace;
    background: #000;
    color: #fff;
    touch-action: manipulation;
}

.screen {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* ===== MENU SCREEN ===== */
#menu {
    justify-content: center;
    align-items: center;
    background: radial-gradient(ellipse at center, #111 0%, #000 100%);
}

.menu-container {
    text-align: center;
    padding: 20px;
}

.title {
    font-size: clamp(3rem, 15vw, 6rem);
    font-weight: bold;
    color: #fff;
    text-shadow: 
        0 0 10px #fff,
        0 0 20px #fff,
        0 0 40px #0ff,
        0 0 80px #0ff;
    margin-bottom: 10px;
    animation: flicker 2s infinite alternate;
}

@keyframes flicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
    75% { opacity: 0.9; }
}

.subtitle {
    font-size: clamp(1rem, 4vw, 1.5rem);
    color: #0ff;
    letter-spacing: 10px;
    margin-bottom: 40px;
    text-shadow: 0 0 10px #0ff;
}

.menu-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

#playerName {
    width: 280px;
    max-width: 90vw;
    padding: 15px 25px;
    font-size: 1.2rem;
    font-family: inherit;
    border: 3px solid #fff;
    background: transparent;
    color: #fff;
    outline: none;
    transition: all 0.3s;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#playerName:focus {
    border-color: #0ff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

#playerName::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.btn-play {
    padding: 15px 50px;
    font-size: 1.3rem;
    font-family: inherit;
    font-weight: bold;
    border: 3px solid #fff;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.btn-play:hover {
    background: #fff;
    color: #000;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.5);
}

.btn-play:active {
    transform: scale(0.98);
}

.rules {
    color: #666;
    font-size: 0.9rem;
    margin-top: 10px;
}

.status-message {
    margin-top: 30px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.found-text {
    font-size: 1.3rem;
    color: #0f0;
    margin-bottom: 10px;
}

.opponent-name {
    font-size: 1.1rem;
    color: #0ff;
    margin-bottom: 20px;
}

.countdown {
    font-size: 5rem;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 20px #fff;
    animation: pulse 0.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from { transform: scale(1); opacity: 1; }
    to { transform: scale(1.2); opacity: 0.8; }
}

/* ===== GAME SCREEN ===== */
#gameScreen {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: #000;
}

.score-board {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    gap: 20px;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.05);
}

.player-score {
    display: flex;
    align-items: center;
    gap: 15px;
}

.player1-score {
    flex-direction: row;
}

.player2-score {
    flex-direction: row-reverse;
}

.player-name {
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    color: #888;
    text-transform: uppercase;
    letter-spacing: 1px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.player1-score .player-name {
    color: #0ff;
}

.player2-score .player-name {
    color: #f0f;
}

.score {
    font-size: clamp(2rem, 8vw, 3.5rem);
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 10px #fff;
    min-width: 60px;
    text-align: center;
}

.vs-divider {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px;
}

.winning-score {
    font-size: 0.8rem;
    color: #666;
}

.game-container {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 0;
    padding: 10px;
}

#gameCanvas {
    border: 3px solid #fff;
    box-shadow: 
        0 0 10px rgba(255, 255, 255, 0.3),
        inset 0 0 50px rgba(255, 255, 255, 0.05);
    max-width: 100%;
    max-height: 100%;
}

.game-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 20px #fff;
    text-align: center;
    pointer-events: none;
    z-index: 10;
}

/* ===== MOBILE CONTROLS ===== */
.mobile-controls {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.touch-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

.touch-indicator {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 2rem;
    pointer-events: none;
}

.touch-hint {
    font-size: 0.7rem;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    letter-spacing: 2px;
}

/* ===== OVERLAY ===== */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.overlay-content {
    text-align: center;
    padding: 40px;
    border: 3px solid #fff;
    max-width: 90vw;
}

.overlay-content h2 {
    font-size: clamp(1.5rem, 6vw, 2.5rem);
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 3px;
}

.final-score {
    font-size: clamp(2rem, 8vw, 4rem);
    margin-bottom: 30px;
    color: #fff;
    text-shadow: 0 0 10px #fff;
}

/* ===== CONTROLS HINT ===== */
.controls-hint {
    position: fixed;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8rem;
    color: #444;
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    white-space: nowrap;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px), (hover: none) {
    .mobile-controls {
        display: block;
    }
    
    .controls-hint {
        display: none;
    }
    
    .touch-indicator {
        opacity: 0.5;
    }
}

@media (max-width: 480px) {
    .score-board {
        padding: 10px;
        gap: 10px;
    }
    
    .player-name {
        max-width: 60px;
    }
    
    .vs-divider {
        padding: 0 10px;
    }
}

/* Landscape mode on mobile */
@media (orientation: landscape) and (max-height: 500px) {
    .score-board {
        position: fixed;
        top: 0;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        padding: 5px 20px;
        border-radius: 0 0 10px 10px;
        z-index: 20;
    }
    
    .score {
        font-size: 1.5rem;
    }
    
    .player-name {
        font-size: 0.7rem;
    }
    
    .game-container {
        padding: 5px;
    }
}

/* Retro scanline effect */
#gameCanvas {
    position: relative;
}

.game-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1;
}