* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    width: 100%;
    height: 100vh;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #000;
    color: #fff;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Burger Menu Button */
.burger-menu {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    cursor: pointer;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
}

.burger-menu:hover {
    background: rgba(255, 255, 255, 0.2);
}

.burger-menu span {
    width: 25px;
    height: 3px;
    background: #fff;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.burger-menu.active span:nth-child(1) {
    transform: translateY(9px) rotate(45deg);
}

.burger-menu.active span:nth-child(2) {
    opacity: 0;
}

.burger-menu.active span:nth-child(3) {
    transform: translateY(-9px) rotate(-45deg);
}

/* Settings Panel */
.settings-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    background: rgba(20, 20, 20, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: -5px 0 20px rgba(0, 0, 0, 0.5);
    z-index: 999;
    transition: right 0.4s ease;
    overflow-y: auto;
    /* Allow touch interactions in settings */
    touch-action: auto;
    user-select: auto;
    -webkit-user-select: auto;
}

.settings-panel.active {
    right: 0;
}

.settings-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-header h2 {
    font-size: 24px;
    font-weight: 600;
}

.settings-content {
    padding: 20px;
}

.settings-section {
    margin-bottom: 30px;
}

.settings-section h3 {
    font-size: 18px;
    font-weight: 500;
    margin-bottom: 15px;
    color: rgba(255, 255, 255, 0.8);
}

.setting-item {
    margin-bottom: 20px;
}

.setting-item label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 16px;
    touch-action: auto;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #4CAF50;
    touch-action: auto;
}

.setting-item input[type="number"] {
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    color: #fff;
    font-size: 16px;
    touch-action: auto;
}

.setting-item input[type="number"]:focus {
    outline: none;
    border-color: #4CAF50;
}

.reset-btn {
    width: 100%;
    padding: 12px;
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid rgba(244, 67, 54, 0.4);
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    touch-action: auto;
}

.reset-btn:hover {
    background: rgba(244, 67, 54, 0.3);
}

.test-mode-btn {
    width: 100%;
    padding: 12px;
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid rgba(76, 175, 80, 0.4);
    color: #fff;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.3s ease;
    touch-action: auto;
}

.test-mode-btn:hover:not(:disabled) {
    background: rgba(76, 175, 80, 0.3);
}

.test-mode-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Game Area */
.game-area {
    width: 100%;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.instruction-text {
    font-size: 22px;
    text-align: center;
    opacity: 0.5;
    transition: opacity 0.3s ease;
    padding: 20px;
    max-width: 90%;
}

.instruction-text.hidden {
    opacity: 0;
}

/* Touch Container */
#touch-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    pointer-events: none;
    z-index: 100;
}

/* Touch Indicator */
.touch-indicator {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 48px;
    font-weight: bold;
    transform: translate(-50%, -50%);
    transition: all 0.3s ease;
    pointer-events: none;
    border: 3px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.2);
    /* Always white text with black outline for readability */
    color: white !important;
    text-shadow: 
        -2px -2px 0 #000,
        2px -2px 0 #000,
        -2px 2px 0 #000,
        2px 2px 0 #000,
        -2px 0 0 #000,
        2px 0 0 #000,
        0 -2px 0 #000,
        0 2px 0 #000,
        -3px -3px 4px rgba(0,0,0,0.8),
        3px 3px 4px rgba(0,0,0,0.8);
}

.touch-indicator.winner {
    animation: winnerPulse 1s ease-in-out infinite;
    border-width: 5px;
    box-shadow: 0 0 50px currentColor, 0 0 100px currentColor;
    z-index: 200;
}

@keyframes winnerPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
    }
}

.touch-indicator.winner::before {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    border-radius: 50%;
    background: radial-gradient(circle, currentColor 0%, transparent 70%);
    opacity: 0.3;
    animation: winnerRipple 2s ease-out infinite;
}

@keyframes winnerRipple {
    0% {
        transform: scale(0);
        opacity: 0.5;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

.touch-indicator.winner::after {
    content: '★';
    position: absolute;
    font-size: 40px;
    top: -40px;
    animation: starFloat 2s ease-in-out infinite;
}

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

/* Mobile Specific */
@media screen and (max-width: 480px) {
    .burger-menu {
        width: 45px;
        height: 45px;
        top: 15px;
        right: 15px;
    }
    
    .settings-panel {
        max-width: 100%;
    }
    
    .instruction-text {
        font-size: 18px;
    }
    
    .touch-indicator {
        width: 100px;
        height: 100px;
        font-size: 40px;
    }
    
    .double-tap-prompt {
        font-size: 16px;
        padding: 12px 24px;
        bottom: 30px;
    }
    
    .countdown-display {
        font-size: 120px;
    }
}

/* Landscape Mobile */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .burger-menu {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    
    .touch-indicator {
        width: 80px;
        height: 80px;
        font-size: 32px;
    }
    
    .double-tap-prompt {
        font-size: 14px;
        padding: 10px 20px;
        bottom: 20px;
    }
    
    .countdown-display {
        font-size: 100px;
    }
}

/* Manual Mode Interface */
.manual-mode-interface {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: #000;
    z-index: 50;
    overflow-y: auto;
    padding: 20px;
}

.manual-mode-interface.active {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.manual-mode-content {
    width: 100%;
    max-width: 600px;
    margin-top: 80px;
}

.manual-mode-content h2 {
    font-size: 32px;
    margin-bottom: 10px;
    text-align: center;
}

.manual-subtitle {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 30px;
    font-size: 16px;
}

.participant-input-section {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.participant-input-section input {
    flex: 1;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
}

.participant-input-section input:focus {
    outline: none;
    border-color: #4CAF50;
}

.add-btn {
    padding: 15px 30px;
    background: #4CAF50;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s ease;
    white-space: nowrap;
}

.add-btn:hover {
    background: #45a049;
}

.add-btn:active {
    transform: scale(0.98);
}

.participants-list {
    min-height: 100px;
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    padding: 10px;
}

.participant-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.participant-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.participant-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.participant-color {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.participant-name {
    font-size: 16px;
    font-weight: 500;
}

.remove-participant-btn {
    background: rgba(244, 67, 54, 0.3);
    border: 1px solid rgba(244, 67, 54, 0.5);
    color: #fff;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.remove-participant-btn:hover {
    background: rgba(244, 67, 54, 0.5);
}

.manual-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.randomize-btn {
    flex: 1;
    padding: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.randomize-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.randomize-btn:active:not(:disabled) {
    transform: translateY(0);
}

.randomize-btn:disabled {
    background: rgba(255, 255, 255, 0.1);
    cursor: not-allowed;
    opacity: 0.5;
}

.clear-btn {
    padding: 18px 30px;
    background: rgba(244, 67, 54, 0.2);
    border: 1px solid rgba(244, 67, 54, 0.4);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.clear-btn:hover {
    background: rgba(244, 67, 54, 0.3);
}

.result-display {
    display: none;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    animation: fadeInScale 0.5s ease;
}

.result-display.active {
    display: block;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.result-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 15px;
    text-align: center;
    color: #4CAF50;
}

.result-order {
    list-style: none;
}

.result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s ease;
    animation: slideIn 0.5s ease backwards;
}

.result-item:nth-child(1) { animation-delay: 0.1s; }
.result-item:nth-child(2) { animation-delay: 0.2s; }
.result-item:nth-child(3) { animation-delay: 0.3s; }
.result-item:nth-child(4) { animation-delay: 0.4s; }
.result-item:nth-child(5) { animation-delay: 0.5s; }
.result-item:nth-child(n+6) { animation-delay: 0.6s; }

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.result-item.winner {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    border: 2px solid rgba(102, 126, 234, 0.6);
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.4);
}

.result-position {
    font-size: 24px;
    font-weight: 700;
    min-width: 40px;
    text-align: center;
}

.result-color {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.result-name {
    flex: 1;
    font-size: 18px;
    font-weight: 500;
}

.result-badge {
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #000;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 700;
}

/* Test mode indicator */
.test-finger {
    opacity: 0.7;
    border-style: dashed !important;
}

/* Double Tap Prompt */
.double-tap-prompt {
    position: fixed;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    padding: 15px 30px;
    border-radius: 50px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    font-size: 18px;
    font-weight: 500;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 500;
    animation: floatUpDown 2s ease-in-out infinite;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    cursor: pointer;
}

.countdown-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 180px;
    font-weight: bold;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 600;
    text-shadow: 0 0 40px rgba(255, 255, 255, 0.8), 
                 0 0 80px rgba(255, 255, 255, 0.5),
                 0 5px 30px rgba(0, 0, 0, 0.5);
    animation: countdownPulse 1s ease-in-out infinite;
}

.countdown-display.visible {
    opacity: 0.9;
}

@keyframes countdownPulse {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.1);
    }
}

.double-tap-prompt.visible {
    opacity: 1;
    pointer-events: auto;
}

.double-tap-prompt:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

@keyframes floatUpDown {
    0%, 100% {
        transform: translateX(-50%) translateY(0);
    }
    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

.double-tap-prompt span {
    display: inline-block;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    }
    50% {
        text-shadow: 0 0 20px rgba(255, 255, 255, 0.8), 0 0 30px rgba(255, 255, 255, 0.5);
    }
}

@media screen and (max-width: 480px) {
    .manual-mode-content {
        margin-top: 20px;
    }
    
    .manual-mode-content h2 {
        font-size: 24px;
    }
    
    .participant-input-section {
        flex-direction: column;
    }
    
    .manual-actions {
        flex-direction: column;
    }
}
