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

body {
    background: #000;
    overflow: hidden;
    font-family: 'Press Start 2P', monospace;
    -webkit-user-select: none;
    user-select: none;
}

#canvas {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    pointer-events: none;
}

#overlay > * {
    pointer-events: auto;
}

.menu-container, .setup-container, .gameover-container, .calibration-container, .mode-select-container {
    text-align: center;
    padding: 40px;
    background: rgba(0, 0, 0, 0.92);
    border: 3px solid #00FFFF;
    border-radius: 10px;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.3), inset 0 0 30px rgba(0, 255, 255, 0.1);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
}

.title {
    font-size: clamp(24px, 6vw, 48px);
    color: #00FFFF;
    text-shadow: 0 0 20px #00FFFF, 0 0 40px #FF00FF, 0 0 60px #00FFFF;
    margin-bottom: 10px;
    animation: glow 2s ease-in-out infinite alternate;
    letter-spacing: 4px;
}

@keyframes glow {
    from { text-shadow: 0 0 20px #00FFFF, 0 0 40px #FF00FF; }
    to { text-shadow: 0 0 30px #00FFFF, 0 0 60px #FF00FF, 0 0 80px #FFFFFF; }
}

.tagline {
    font-size: clamp(10px, 2.5vw, 14px);
    color: #FFFFFF;
    margin-bottom: 30px;
    opacity: 0.8;
}

.subtitle {
    font-size: clamp(12px, 3vw, 18px);
    color: #FF00FF;
    margin-bottom: 30px;
}

.ball-demo {
    width: 40px;
    height: 40px;
    background: #FFFFFF;
    border-radius: 50%;
    margin: 20px auto;
    box-shadow: 0 0 20px #FFFFFF, 0 0 40px rgba(255, 255, 255, 0.5);
    animation: bounce 1s ease-in-out infinite;
}

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

.mode-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 30px 0;
    flex-wrap: wrap;
}

.btn-mode {
    font-family: 'Press Start 2P', monospace;
    background: rgba(0, 0, 0, 0.7);
    border: 3px solid #00FFFF;
    border-radius: 10px;
    padding: 20px 25px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    min-width: 180px;
}

.btn-mode:hover {
    transform: scale(1.05);
    border-color: #FFFFFF;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
}

.btn-mode.magenta {
    border-color: #FF00FF;
}

.btn-mode.magenta:hover {
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.5);
}

.mode-icon {
    font-size: 32px;
}

.mode-text {
    font-size: 14px;
    color: #FFFFFF;
}

.mode-desc {
    font-size: 8px;
    color: rgba(255, 255, 255, 0.6);
}

.btn-start {
    font-family: 'Press Start 2P', monospace;
    font-size: clamp(12px, 3vw, 18px);
    padding: 20px 40px;
    background: linear-gradient(180deg, #00FFFF, #008888);
    border: none;
    border-radius: 5px;
    color: #000;
    cursor: pointer;
    margin: 20px 0;
    transition: all 0.2s;
    animation: pulse 1.5s ease-in-out infinite;
    min-width: 200px;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 20px #00FFFF; }
    50% { box-shadow: 0 0 40px #00FFFF, 0 0 60px #00FFFF; }
}

.btn-start:hover {
    transform: scale(1.1);
    background: linear-gradient(180deg, #00FFFF, #00AAAA);
}

.btn-start:active {
    transform: scale(0.95);
}

.btn-secondary {
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 15px 30px;
    background: transparent;
    border: 2px solid #FF00FF;
    color: #FF00FF;
    cursor: pointer;
    border-radius: 5px;
    display: inline-block;
    margin: 10px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: rgba(255, 0, 255, 0.2);
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.5);
}

.btn-skip {
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 10px 20px;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    border-radius: 5px;
    display: block;
    margin: 10px auto;
}

.btn-skip:hover {
    border-color: rgba(255, 255, 255, 0.6);
    color: rgba(255, 255, 255, 0.8);
}

.instructions {
    font-size: clamp(8px, 2vw, 12px);
    color: rgba(255, 255, 255, 0.6);
    margin-top: 20px;
    line-height: 1.8;
}

.footer-link {
    display: block;
    margin-top: 30px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
}

.footer-link:hover {
    color: rgba(255, 255, 255, 0.7);
}

/* Settings button */
.settings-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    border-radius: 5px;
}

.settings-btn:hover {
    border-color: #00FFFF;
    color: #00FFFF;
}

/* Settings panel */
.settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    border: 3px solid #00FFFF;
    border-radius: 10px;
    padding: 30px;
    z-index: 200;
    min-width: 300px;
}

.settings-panel h2 {
    color: #00FFFF;
    margin-bottom: 20px;
    font-size: 16px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 15px 0;
    color: #FFFFFF;
    font-size: 10px;
}

.toggle {
    width: 50px;
    height: 26px;
    background: #333;
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle.active {
    background: #00FFFF;
}

.toggle::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #FFFFFF;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    transition: left 0.3s;
}

.toggle.active::after {
    left: 27px;
}

/* Difficulty selector */
.difficulty-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.btn-difficulty {
    font-family: 'Press Start 2P', monospace;
    background: rgba(0, 0, 0, 0.7);
    border: 3px solid #FF00FF;
    border-radius: 10px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 140px;
    text-align: center;
}

.btn-difficulty:hover, .btn-difficulty.selected {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(255, 0, 255, 0.5);
    background: rgba(255, 0, 255, 0.2);
}

.btn-difficulty .diff-name {
    font-size: 14px;
    color: #FFFFFF;
    margin-bottom: 8px;
    display: block;
}

.btn-difficulty .diff-desc {
    font-size: 8px;
    color: rgba(255, 255, 255, 0.6);
}

/* Modifier selector */
.modifier-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin: 20px 0;
    flex-wrap: wrap;
}

.btn-modifier {
    font-family: 'Press Start 2P', monospace;
    font-size: 9px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00FFFF;
    border-radius: 8px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.3s;
    color: #FFFFFF;
}

.btn-modifier:hover, .btn-modifier.selected {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
}

.btn-modifier .mod-icon {
    font-size: 16px;
    display: block;
    margin-bottom: 5px;
}

/* Calibration styles */
.calibration-container {
    min-width: 350px;
}

.calibration-title {
    font-size: 20px;
    color: #00FFFF;
    margin-bottom: 10px;
}

.calibration-subtitle {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 30px;
}

.calibration-step {
    padding: 30px;
    border: 2px solid;
    border-radius: 10px;
    margin: 20px 0;
}

.calibration-step.cyan {
    border-color: #00FFFF;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.2);
}

.calibration-step.magenta {
    border-color: #FF00FF;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.2);
}

.calibration-phase {
    font-size: 14px;
    color: #FFFFFF;
    margin-bottom: 10px;
}

.calibration-instruction {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 20px;
}

.calibration-timer {
    font-size: 48px;
    color: #FFFFFF;
    text-shadow: 0 0 20px currentColor;
    margin: 20px 0;
}

.volume-meter-large {
    width: 100%;
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
    margin: 20px 0;
}

.volume-meter-fill {
    height: 100%;
    transition: width 0.05s;
    border-radius: 5px;
}

.volume-meter-fill.cyan {
    background: linear-gradient(to right, #008888, #00FFFF);
}

.volume-meter-fill.magenta {
    background: linear-gradient(to right, #880088, #FF00FF);
}

.calibration-success {
    color: #00FF00;
    font-size: 14px;
    margin: 20px 0;
}

.threshold-display {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
}

/* Demo mode button */
.demo-option {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.demo-option p {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 10px;
}

/* Setup container */
.setup-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.players-row {
    display: flex;
    gap: 30px;
    justify-content: center;
    flex-wrap: wrap;
}

.test-panel {
    padding: 30px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    width: 250px;
    transition: all 0.3s;
}

.test-panel.done {
    border-color: #00FF00;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.3);
}

.test-panel h2 {
    font-size: 18px;
    margin-bottom: 15px;
}

.test-panel p {
    font-size: 12px;
    color: #FFFFFF;
    margin-bottom: 20px;
}

.volume-bar {
    width: 100%;
    height: 80px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.volume-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 0%;
    transition: height 0.05s;
    border-radius: 5px;
}

.volume-fill.p1 {
    background: linear-gradient(to top, #00FFFF, #00AAAA);
}

.volume-fill.p2 {
    background: linear-gradient(to top, #FF00FF, #AA00AA);
}

.ai-panel {
    padding: 30px;
    border: 2px solid #FF00FF;
    border-radius: 10px;
    width: 250px;
    box-shadow: 0 0 20px rgba(255, 0, 255, 0.3);
}

.ai-panel h2 {
    font-size: 18px;
    margin-bottom: 15px;
}

.ai-avatar {
    font-size: 48px;
    margin: 15px 0;
    animation: robot-bob 1s ease-in-out infinite;
}

@keyframes robot-bob {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-5px) rotate(5deg); }
}

.ai-ready {
    font-size: 10px;
    color: #00FF00;
    animation: blink 1s ease-in-out infinite;
}

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

/* Game over styles */
.gameover-container {
    border-color: #FF00FF;
    box-shadow: 0 0 50px rgba(255, 0, 255, 0.3), inset 0 0 30px rgba(255, 0, 255, 0.1);
}

.winner-text {
    font-size: clamp(20px, 5vw, 36px);
    margin-bottom: 20px;
    animation: glow 1s ease-in-out infinite alternate;
}

.final-score {
    font-size: clamp(32px, 8vw, 64px);
    margin: 20px 0;
}

.stats {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    margin: 20px 0;
    line-height: 2.2;
    text-align: left;
    display: inline-block;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 20px 0;
}

.stat-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 10px;
    border-radius: 5px;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.8);
}

.stat-label {
    color: rgba(255, 255, 255, 0.5);
    display: block;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 14px;
}

.stat-value.cyan {
    color: #00FFFF;
}

.stat-value.magenta {
    color: #FF00FF;
}

.button-row {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}

/* Power note callouts */
.power-callout {
    position: fixed;
    font-size: 24px;
    font-weight: bold;
    pointer-events: none;
    animation: callout-pop 0.6s ease-out forwards;
    z-index: 50;
}

@keyframes callout-pop {
    0% { transform: scale(0.5); opacity: 1; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1) translateY(-30px); opacity: 0; }
}

/* Pause menu */
.pause-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.6);
    cursor: pointer;
    border-radius: 5px;
    z-index: 50;
}

.pause-btn:hover {
    border-color: #00FFFF;
    color: #00FFFF;
}

.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 150;
}

.pause-menu {
    text-align: center;
    padding: 40px;
    background: rgba(0, 0, 0, 0.9);
    border: 3px solid #00FFFF;
    border-radius: 10px;
}

.pause-menu h2 {
    font-size: 24px;
    color: #00FFFF;
    margin-bottom: 30px;
}

.pause-menu button {
    display: block;
    width: 200px;
    margin: 10px auto;
    font-family: 'Press Start 2P', monospace;
    font-size: 12px;
    padding: 15px;
    background: transparent;
    border: 2px solid #FFFFFF;
    color: #FFFFFF;
    cursor: pointer;
    border-radius: 5px;
    transition: all 0.2s;
}

.pause-menu button:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.pause-menu button.primary {
    background: linear-gradient(180deg, #00FFFF, #008888);
    border-color: #00FFFF;
    color: #000;
}

/* Modifier indicator */
.modifier-indicator {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: #FFFF00;
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 15px;
    border-radius: 20px;
    border: 1px solid #FFFF00;
    z-index: 40;
}

/* Demo mode touch buttons */
.touch-hit-btn {
    position: fixed;
    bottom: 100px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    font-family: 'Press Start 2P', monospace;
    font-size: 10px;
    cursor: pointer;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.touch-hit-btn:active {
    transform: scale(0.9);
}

.touch-hit-btn.p1 {
    left: 50px;
    background: rgba(0, 255, 255, 0.3);
    border: 4px solid #00FFFF;
    color: #00FFFF;
}

.touch-hit-btn.p2 {
    right: 50px;
    background: rgba(255, 0, 255, 0.3);
    border: 4px solid #FF00FF;
    color: #FF00FF;
}

.demo-mode-notice {
    position: fixed;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 8px;
    color: #FFFF00;
    background: rgba(0, 0, 0, 0.8);
    padding: 8px 15px;
    border-radius: 5px;
    z-index: 40;
}

@media (max-width: 600px) {
    .menu-container, .setup-container, .gameover-container, .calibration-container, .mode-select-container {
        padding: 20px;
        margin: 10px;
    }
    
    .test-panel, .ai-panel {
        width: 200px;
        padding: 20px;
    }
    
    .mode-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn-mode {
        min-width: 200px;
    }
    
    .difficulty-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .touch-hit-btn {
        width: 80px;
        height: 80px;
        font-size: 8px;
        bottom: 50px;
    }
    
    .touch-hit-btn.p1 {
        left: 20px;
    }
    
    .touch-hit-btn.p2 {
        right: 20px;
    }
}

@media (orientation: portrait) and (max-width: 768px) {
    body::before {
        content: '📱 Rotate for best experience!';
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        background: rgba(0, 0, 0, 0.8);
        color: #00FFFF;
        padding: 10px 20px;
        border-radius: 20px;
        font-size: 10px;
        z-index: 1000;
        font-family: 'Press Start 2P', monospace;
    }
}