/* Range Slider Styling */
.custom-slider {
    -webkit-appearance: none !important;
    appearance: none !important;
    background: transparent !important;
}

.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none !important;
    appearance: none !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    cursor: pointer !important;
    border: 4px solid #00ff88 !important;
    box-shadow: 0 0 15px rgba(0,255,136,0.8) !important;
    transform: scale(1.2) !important;
}

.custom-slider::-moz-range-thumb {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    background: #ffffff !important;
    cursor: pointer !important;
    border: 4px solid #00ff88 !important;
    box-shadow: 0 0 15px rgba(0,255,136,0.8) !important;
    -moz-appearance: none !important;
}

/* CSS Reset und Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 100%);
    color: #ffffff;
    min-height: 100vh;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

/* Container */
.container {
    min-height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 20px 0;
    margin-bottom: 20px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, #00ff88, #00bbff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 15px;
    text-shadow: 0 0 30px rgba(0,255,136,0.5);
}

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

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.1);
    padding: 10px 15px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.stat-label {
    font-size: 0.8rem;
    opacity: 0.7;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: bold;
    color: #00ff88;
}

/* Screens */
.screen {
    display: none;
    flex: 1;
}

.screen.active {
    display: block;
}

/* Menu Screen */
.menu-content {
    max-width: 500px;
    margin: 0 auto;
    padding: 0 20px;
}

.mode-selector {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.mode-btn {
    background: rgba(255,255,255,0.1);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 20px;
    padding: 30px 20px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    text-align: center;
}

.mode-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-5px);
}

.mode-btn.active {
    background: linear-gradient(135deg, rgba(0,255,136,0.2), rgba(0,187,255,0.2));
    border-color: #00ff88;
    box-shadow: 0 10px 30px rgba(0,255,136,0.3);
}

.mode-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.mode-title {
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.mode-desc {
    font-size: 0.9rem;
    opacity: 0.8;
    line-height: 1.4;
}

.settings {
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    border: 1px solid rgba(255,255,255,0.1);
}

.setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.setting:last-child {
    margin-bottom: 0;
}

.setting label {
    font-weight: 500;
    font-size: 1.1rem;
}

.setting select {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 10px;
    padding: 10px 15px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
}

.setting select option {
    background: #1a1a3e;
    color: white;
}

/* Custom Touch Slider */
.slider-setting {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    padding: 25px;
    background: rgba(0,255,136,0.05);
    border-radius: 15px;
    border: 1px solid rgba(0,255,136,0.2);
}

.slider-setting label {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    font-weight: 500;
}

.custom-slider {
    width: 100%;
    height: 60px;
    position: relative;
    cursor: pointer;
    padding: 15px 0;
    touch-action: none;
    user-select: none;
}

.slider-track {
    width: 100%;
    height: 25px;
    background: linear-gradient(to right, rgba(255,255,255,0.2), rgba(0,255,136,0.4));
    border-radius: 12px;
    border: 3px solid rgba(255,255,255,0.3);
    position: relative;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.3);
}

.slider-thumb {
    width: 55px;
    height: 55px;
    background: linear-gradient(135deg, #00ff88, #00bbff);
    border: 4px solid white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translate(-50%, -50%);
    cursor: grab;
    box-shadow: 0 8px 25px rgba(0,255,136,0.8);
    transition: all 0.2s ease;
    z-index: 10;
    display: block;
}

.slider-thumb:hover {
    transform: translate(-50%, -50%) scale(1.05);
    box-shadow: 0 10px 30px rgba(0,255,136,0.9);
}

.slider-thumb:active,
.slider-thumb.dragging {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 12px 35px rgba(0,255,136,1);
    cursor: grabbing;
}

/* Mobile optimizations */
@media (hover: none) and (pointer: coarse) {
    .custom-slider {
        height: 80px;
        padding: 20px 0;
    }
    
    .slider-track {
        height: 30px;
        border: 4px solid rgba(255,255,255,0.4);
    }
    
    .slider-thumb {
        width: 65px;
        height: 65px;
        border: 5px solid white;
    }
}

#roundCountValue {
    color: #00ff88;
    font-weight: bold;
    font-size: 1.1em;
}

.start-btn, .stats-btn {
    width: 100%;
    padding: 20px;
    font-size: 1.3rem;
    font-weight: bold;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.start-btn {
    background: linear-gradient(135deg, #00ff88, #00bbff);
    color: #000;
    box-shadow: 0 10px 30px rgba(0,255,136,0.4);
}

.start-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 40px rgba(0,255,136,0.6);
}

.stats-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 2px solid rgba(255,255,255,0.2);
}

.stats-btn:hover {
    background: rgba(255,255,255,0.15);
    transform: translateY(-3px);
}

/* Game Screen */
.game-info {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    background: rgba(255,255,255,0.05);
    border-radius: 15px;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

.info-item span:first-child {
    opacity: 0.7;
    margin-right: 10px;
}

.info-item span:last-child {
    font-weight: bold;
    color: #00ff88;
}

.game-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    border-radius: 25px;
    border: 3px solid rgba(255,255,255,0.2);
    margin-bottom: 30px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
}

.game-area.ready {
    background: rgba(255,255,136,0.1);
    border-color: #ffff88;
    box-shadow: 0 0 50px rgba(255,255,136,0.3);
}

.game-area.go {
    background: rgba(0,255,136,0.2);
    border-color: #00ff88;
    box-shadow: 0 0 50px rgba(0,255,136,0.5);
}

.game-area.color-red {
    background: rgba(255,0,0,0.2);
    border-color: #ff0000;
    box-shadow: 0 0 50px rgba(255,0,0,0.5);
}

.game-area.color-blue {
    background: rgba(0,100,255,0.2);
    border-color: #0064ff;
    box-shadow: 0 0 50px rgba(0,100,255,0.5);
}

.game-area.color-yellow {
    background: rgba(255,255,0,0.2);
    border-color: #ffff00;
    box-shadow: 0 0 50px rgba(255,255,0,0.5);
}

.game-area.color-green {
    background: rgba(0,255,0,0.2);
    border-color: #00ff00;
    box-shadow: 0 0 50px rgba(0,255,0,0.5);
}

.instruction {
    font-size: 1.5rem;
    text-align: center;
    font-weight: 500;
}

.game-controls {
    text-align: center;
}

.abort-btn {
    background: rgba(255,100,100,0.2);
    border: 2px solid rgba(255,100,100,0.5);
    color: white;
    padding: 15px 30px;
    border-radius: 15px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.abort-btn:hover {
    background: rgba(255,100,100,0.3);
    transform: translateY(-2px);
}

/* Results Screen */
.results-content {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 20px;
    text-align: center;
}

.results-content h2 {
    font-size: 2.5rem;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #00ff88, #00bbff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.result-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-stat {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(255,255,255,0.2);
}

.summary-label {
    display: block;
    font-size: 0.9rem;
    opacity: 0.7;
    margin-bottom: 10px;
}

.summary-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: #00ff88;
}

.results-list {
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    max-height: 300px;
    overflow-y: auto;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 1.1rem;
}

.result-item:last-child {
    border-bottom: none;
}

.result-round {
    opacity: 0.7;
}

.result-time {
    font-weight: bold;
    color: #00ff88;
}

.result-time.best {
    color: #ffff88;
}

.result-time.worst {
    color: #ff8888;
}

.results-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.play-again-btn, .back-btn, .clear-btn {
    flex: 1;
    min-width: 200px;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.play-again-btn {
    background: linear-gradient(135deg, #00ff88, #00bbff);
    color: #000;
}

.back-btn {
    background: rgba(255,255,255,0.1);
    color: white;
    border: 2px solid rgba(255,255,255,0.2);
}

.clear-btn {
    background: rgba(255,100,100,0.2);
    color: white;
    border: 2px solid rgba(255,100,100,0.5);
}

.play-again-btn:hover, .back-btn:hover, .clear-btn:hover {
    transform: translateY(-3px);
}

/* Stats Screen */
.stats-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 20px;
}

.stats-content h2 {
    text-align: center;
    font-size: 2.5rem;
    margin-bottom: 30px;
    background: linear-gradient(135deg, #00ff88, #00bbff);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.overall-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.overall-stat {
    background: rgba(255,255,255,0.1);
    padding: 25px;
    border-radius: 20px;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.2);
}

.overall-stat-label {
    display: block;
    font-size: 1rem;
    opacity: 0.7;
    margin-bottom: 10px;
}

.overall-stat-value {
    display: block;
    font-size: 2rem;
    font-weight: bold;
    color: #00ff88;
}

.history-chart {
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.5);
}

.stats-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* PWA-spezifische Styles */
.install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #00ff88, #00bbff);
    padding: 15px 30px;
    border-radius: 50px;
    box-shadow: 0 10px 30px rgba(0,255,136,0.5);
    z-index: 1000;
    animation: slideUp 0.5s ease;
    display: flex;
    gap: 15px;
    align-items: center;
}

.install-content {
    display: flex;
    gap: 15px;
    align-items: center;
    color: #000;
    font-weight: 500;
}

.install-prompt button {
    background: rgba(255,255,255,0.9);
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.install-prompt button:hover {
    background: white;
    transform: scale(1.05);
}

.offline-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    background: #ff6b6b;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    display: none;
    z-index: 1000;
}

body.offline .offline-indicator {
    display: block;
}

.update-notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, #00ff88, #00bbff);
    padding: 15px;
    text-align: center;
    z-index: 2000;
    animation: slideDown 0.5s ease;
    color: #000;
    font-weight: 500;
}

.update-notification button {
    background: rgba(255,255,255,0.9);
    border: none;
    padding: 8px 15px;
    border-radius: 15px;
    margin-left: 15px;
    cursor: pointer;
    font-weight: 500;
}

.notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1500;
}

.notification {
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 10px;
    border-left: 4px solid #00ff88;
    animation: slideInRight 0.3s ease;
    max-width: 300px;
}

.notification.success {
    border-left-color: #00ff88;
}

.notification.error {
    border-left-color: #ff6b6b;
}

.notification.warning {
    border-left-color: #ffbb33;
}

/* Verhindere Zoom auf Mobile */
input, button, select, textarea {
    font-size: 16px !important;
    -webkit-appearance: none;
}

/* iOS Safe Areas */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(10px, env(safe-area-inset-left));
        padding-right: max(10px, env(safe-area-inset-right));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

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

@keyframes slideDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(300px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.pulse {
    animation: pulse 1s infinite;
}

/* 4 Buttons Game Interface */
.button-game-area {
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    margin-bottom: 30px;
    border-radius: 25px;
    border: 3px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.02);
    padding: 30px;
}

/* Central Color Field */
.color-field {
    width: 150px;
    height: 150px;
    border-radius: 20px;
    border: 4px solid rgba(255,255,255,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem;
    margin: 20px 0;
    background: rgba(255,255,255,0.1);
    transition: all 0.3s ease;
}

.color-field.show-red {
    background: #ff4444;
    border-color: #ff4444;
    box-shadow: 0 0 30px rgba(255,68,68,0.8);
    color: white;
}

.color-field.show-green {
    background: #44ff44;
    border-color: #44ff44;
    box-shadow: 0 0 30px rgba(68,255,68,0.8);
    color: black;
}

.color-field.show-blue {
    background: #4444ff;
    border-color: #4444ff;
    box-shadow: 0 0 30px rgba(68,68,255,0.8);
    color: white;
}

.color-field.show-yellow {
    background: #ffff44;
    border-color: #ffff44;
    box-shadow: 0 0 30px rgba(255,255,68,0.8);
    color: black;
}

.color-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
    max-width: 300px;
    width: 100%;
}

.color-btn {
    width: 120px;
    height: 120px;
    border: 4px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    font-size: 3rem;
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-btn:hover {
    transform: scale(1.05);
    border-width: 6px;
}

.color-btn.active {
    transform: scale(1.1);
    box-shadow: 0 0 30px rgba(255,255,255,0.5);
    border-color: white;
}

/* Buttons should NOT highlight as targets - only show feedback */

.color-btn.wrong {
    border-color: #ff6b6b;
    background: rgba(255,107,107,0.2);
    animation: shake 0.5s ease-in-out;
}

.color-btn.correct {
    border-color: #00ff88;
    background: rgba(0,255,136,0.2);
    animation: pulse 0.5s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2rem;
    }
    
    .mode-selector {
        grid-template-columns: 1fr;
    }
    
    .color-buttons {
        gap: 15px;
        max-width: 250px;
    }
    
    .color-btn {
        width: 100px;
        height: 100px;
        font-size: 2.5rem;
    }
    
    .stats {
        gap: 15px;
    }
    
    .stat {
        padding: 8px 12px;
    }
    
    .game-area {
        min-height: 300px;
    }
    
    .instruction {
        font-size: 1.2rem;
    }
    
    .results-actions {
        flex-direction: column;
    }
    
    .play-again-btn, .back-btn, .clear-btn {
        min-width: auto;
    }
}