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

body {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    background: #000;
    min-height: 100vh;
    overflow: hidden;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    /* Prevent text selection and touch callouts on mobile */
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior: none;
    /* Prevent zoom on double tap */
    touch-action: manipulation;
}

.container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: #000;
}

.sound-toggle {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 10;
    width: 40px;
    height: 40px;
    background: rgba(128, 128, 128, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    transition: background 0.2s;
    /* Better touch target for mobile */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.sound-toggle:hover {
    background: rgba(128, 128, 128, 0.5);
}

.sound-toggle:active {
    background: rgba(128, 128, 128, 0.7);
}

.sound-toggle svg {
    width: 24px;
    height: 24px;
    color: white;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

.sound-toggle.muted svg {
    color: rgba(255, 255, 255, 0.5);
}

.game-select {
    position: absolute;
    top: 20px;
    left: 70px;
    z-index: 10;
    width: 150px;
    height: 40px;
    background: rgba(128, 128, 128, 0.3);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: white;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 10px;
    padding: 5px 10px;
    cursor: pointer;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='white' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    padding-right: 30px;
    /* Better touch target for mobile */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.game-select:hover {
    background-color: rgba(128, 128, 128, 0.5);
}

.game-select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.8);
}

.game-select option {
    background: #000;
    color: white;
    padding: 5px;
}

.canvas-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

#video {
    display: none;
}

/* Start Camera Button */
.start-camera-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    width: 280px;
    height: 120px;
    background: rgba(255, 255, 255, 0.15);
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.start-camera-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 1);
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 12px 40px rgba(255, 255, 255, 0.2);
}

.start-camera-btn:active {
    transform: translate(-50%, -50%) scale(0.98);
}

.start-camera-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: translate(-50%, -50%);
}

/* Error / info state (e.g. "Use HTTPS" on iOS) */
.start-camera-btn.start-camera-error {
    width: 300px;
    max-width: 90vw;
    min-height: 100px;
    height: auto;
    padding: 16px;
}

.start-camera-btn.start-camera-error .start-camera-subtext {
    max-width: 100%;
    word-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
}

.start-camera-text {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 18px;
    color: white;
    text-align: center;
    line-height: 1.4;
}

.start-camera-subtext {
    font-family: 'Press Start 2P', 'Courier New', monospace;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

/* Mobile styles for start button */
@media (max-width: 768px) {
    .start-camera-btn {
        width: 240px;
        height: 100px;
        padding: 16px;
    }
    
    .start-camera-text {
        font-size: 16px;
    }
    
    .start-camera-subtext {
        font-size: 9px;
    }
}

@media (max-width: 480px) {
    .start-camera-btn {
        width: 200px;
        height: 90px;
        padding: 14px;
    }
    
    .start-camera-text {
        font-size: 14px;
    }
    
    .start-camera-subtext {
        font-size: 8px;
    }
}

/* Mode Toggle Switch (Left, below logo) */
.mode-toggle {
    position: absolute;
    top: 80px;
    left: 20px;
    z-index: 10;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 120px;
    height: 40px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(128, 128, 128, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 0;
    transition: 0.3s;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 10px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.toggle-slider:before {
    display: none;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: rgba(100, 100, 120, 0.4);
    border-color: rgba(255, 255, 255, 0.4);
}

.toggle-label {
    font-size: 12px;
    font-weight: normal;
    z-index: 1;
    transition: color 0.3s;
}

.toggle-label-photo {
    color: white;
}

.toggle-label-video {
    color: rgba(255, 255, 255, 0.5);
}

.toggle-switch input:checked ~ .toggle-slider .toggle-label-photo {
    color: rgba(255, 255, 255, 0.5);
}

.toggle-switch input:checked ~ .toggle-slider .toggle-label-video {
    color: white;
}

/* Effect Selector Grid (Left, below mode toggle) */
.effect-selector {
    position: absolute;
    top: 130px;
    left: 20px;
    z-index: 10;
}

.effect-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    width: 140px;
}

.effect-preview {
    cursor: pointer;
    transition: transform 0.2s ease;
}

.effect-preview:hover {
    transform: scale(1.05);
}

.effect-preview-square {
    width: 65px;
    height: 65px;
    background: rgba(128, 128, 128, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.effect-preview:hover .effect-preview-square {
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(128, 128, 128, 0.4);
}

.effect-preview.active .effect-preview-square {
    border-color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}

.effect-label {
    font-size: 11px;
    font-weight: normal;
    color: white;
    text-align: center;
}

/* Effect-specific preview colors */
.effect-preview[data-effect="halo"] .effect-preview-square {
    background: rgba(102, 126, 234, 0.3);
}

.effect-preview[data-effect="wings"] .effect-preview-square {
    background: rgba(240, 147, 251, 0.3);
}

.effect-preview[data-effect="sparkle"] .effect-preview-square {
    background: rgba(255, 215, 0, 0.3);
}

.effect-preview[data-effect="bubble"] .effect-preview-square {
    background: rgba(150, 200, 255, 0.3);
}

.effect-preview[data-effect="runner"] .effect-preview-square {
    background: rgba(255, 165, 0, 0.3);
}

.effect-preview[data-effect="none"] .effect-preview-square {
    background: rgba(128, 128, 128, 0.3);
}

/* Action Button Container (Center Bottom) */
.action-button-container {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
}

.action-btn {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 4px solid white;
    background: rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    outline: none;
    /* Better touch target for mobile */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.action-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.3);
    box-shadow: 0 6px 20px rgba(255, 255, 255, 0.4);
}

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

.action-btn-inner {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: white;
    transition: all 0.3s ease;
}

/* Video mode - red button */
.action-btn.video-mode {
    border-color: #f5576c !important;
}

.action-btn.video-mode .action-btn-inner {
    background: #f5576c !important;
}

.action-btn.video-mode:hover {
    background: rgba(245, 87, 108, 0.3) !important;
    border-color: #f5576c !important;
    box-shadow: 0 6px 20px rgba(245, 87, 108, 0.4) !important;
}

/* Recording state */
.action-btn.recording {
    background: rgba(200, 50, 70, 0.5);
    border-color: #c83246;
    animation: pulse 1.5s ease-in-out infinite;
}

.action-btn.recording .action-btn-inner {
    background: #c83246;
    border-radius: 8px;
    width: 30px;
    height: 30px;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 15px rgba(245, 87, 108, 0.4);
    }
    50% {
        box-shadow: 0 4px 25px rgba(245, 87, 108, 0.8);
    }
}

.status {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    text-align: center;
    padding: 10px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 14px;
    min-height: 20px;
    pointer-events: none;
}

/* Responsive design */
@media (max-width: 768px) {
    .logo {
        max-width: 120px;
        max-height: 40px;
        top: 10px;
        left: 10px;
    }
    
    .mode-toggle {
        top: 60px;
        left: 10px;
    }
    
    .toggle-switch {
        width: 100px;
        height: 35px;
    }
    
    .toggle-slider:before {
        height: 27px;
        width: 42px;
    }
    
    .toggle-switch input:checked + .toggle-slider:before {
        transform: translateX(50px);
    }
    
    .toggle-label {
        font-size: 11px;
    }
    
    .effect-selector {
        top: 105px;
        left: 10px;
    }
    
    .effect-grid {
        width: 120px;
        gap: 8px;
    }
    
    .effect-preview-square {
        width: 56px;
        height: 56px;
    }
    
    .effect-label {
        font-size: 10px;
    }
    
    .action-button-container {
        bottom: 20px;
    }
    
    .action-btn {
        width: 70px;
        height: 70px;
    }
    
    .action-btn-inner {
        width: 50px;
        height: 50px;
    }
    
    .action-btn.recording .action-btn-inner {
        width: 25px;
        height: 25px;
    }
    
    .status {
        bottom: 5px;
        font-size: 12px;
    }
    
    .sound-toggle {
        top: 10px;
        left: 10px;
        width: 44px;
        height: 44px;
    }
    
    .game-select {
        top: 10px;
        left: 60px;
        width: 140px;
        height: 44px;
        font-size: 9px;
    }
}

/* Mobile-specific optimizations */
@media (max-width: 480px) {
    .sound-toggle {
        width: 48px;
        height: 48px;
    }
    
    .game-select {
        width: 130px;
        font-size: 8px;
        padding: 8px 8px 8px 8px;
        padding-right: 28px;
    }
    
    .action-btn {
        width: 80px;
        height: 80px;
    }
    
    .action-btn-inner {
        width: 60px;
        height: 60px;
    }
}

/* Landscape orientation on mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .sound-toggle {
        top: 10px;
        left: 10px;
    }
    
    .game-select {
        top: 10px;
        left: 60px;
    }
    
    .action-button-container {
        bottom: 15px;
    }
}
