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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: #666;
    font-size: 1.1rem;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 15px;
    box-shadow: 0 4px 16px rgba(31, 38, 135, 0.2);
}

.mode-btn {
    flex: 1;
    padding: 15px 20px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    background: transparent;
    color: #666;
}

.mode-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.mode-btn:hover {
    transform: translateY(-1px);
}

/* Game Container */
.game-container {
    flex: 1;
    margin-bottom: 30px;
}

.game-mode {
    display: none;
    background: rgba(255, 255, 255, 0.95);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.game-mode.active {
    display: block;
}

.game-mode h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    text-align: center;
}

.instructions {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
    font-size: 1.1rem;
}

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

.status {
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 4px solid #667eea;
}

.target-time {
    font-size: 1.5rem;
    margin-bottom: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-radius: 15px;
    font-weight: bold;
}

/* Buttons */
.action-btn {
    padding: 15px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 10px;
}

.action-btn.primary {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
}

.action-btn.secondary {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #ddd;
}

.action-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.action-btn:active {
    transform: translateY(0);
}

.tap-btn {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    font-size: 1.3rem;
    font-weight: bold;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 20px auto;
    display: block;
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.3);
}

.tap-btn:hover {
    transform: scale(1.05);
}

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

/* Input Section */
.input-section {
    margin: 20px 0;
}

.input-section label {
    display: block;
    margin-bottom: 15px;
    font-weight: 600;
    font-size: 1.1rem;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 20px 0;
    padding: 0 10px;
}

.slider-min, .slider-max {
    font-size: 0.9rem;
    color: #666;
    font-weight: 600;
    min-width: 25px;
}

#guess-slider {
    flex: 1;
    height: 8px;
    -webkit-appearance: none;
    appearance: none;
    background: linear-gradient(to right, #e9ecef 0%, #667eea 50%, #764ba2 100%);
    border-radius: 5px;
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

#guess-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

#guess-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

#guess-slider::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
    transition: all 0.2s ease;
}

#guess-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

#guess-value {
    color: #667eea;
    font-weight: bold;
    font-size: 1.2rem;
}

/* Result Section */
.result {
    margin: 20px 0;
    padding: 20px;
    border-radius: 15px;
    background: #f8f9fa;
}

.result-content {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.result.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.result.good {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.result.poor {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Statistics */
.statistics {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
}

.statistics h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

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

.stat-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    border-left: 4px solid #667eea;
}

.stat-card h4 {
    margin-bottom: 15px;
    color: #333;
}

.stat-item {
    margin: 8px 0;
    display: flex;
    justify-content: space-between;
    font-size: 0.95rem;
}

.stat-item span {
    font-weight: 600;
    color: #667eea;
}

/* Visualization Section */
.visualization-section {
    margin: 30px 0 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 15px;
    border-left: 4px solid #667eea;
}

.visualization-section h4 {
    margin-bottom: 15px;
    color: #333;
    text-align: center;
    font-size: 1.2rem;
}

.chart-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-bottom: 20px;
}

.chart-mode-btn {
    padding: 8px 16px;
    border: 2px solid #ddd;
    background: white;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
}

.chart-mode-btn.active {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border-color: #667eea;
}

.chart-mode-btn:hover {
    transform: translateY(-1px);
}

.chart-container {
    width: 100%;
    height: 300px;
    background: white;
    border-radius: 10px;
    border: 2px solid #e9ecef;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.chart-placeholder {
    text-align: center;
    color: #666;
    font-size: 1rem;
}

.chart-placeholder p {
    margin: 10px 0;
}

.chart-svg {
    width: 100%;
    height: 100%;
}

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

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: #666;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-color.perfect {
    background: #28a745;
}

.legend-color.good {
    background: #ffc107;
}

.legend-color.poor {
    background: #dc3545;
}

.legend-line {
    width: 20px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.diagonal {
    background: #999;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        #999 2px,
        #999 4px
    );
}

.legend-line.bestfit {
    background: #ff6b6b;
}

/* Advanced Mode Link */
.advanced-mode-link {
    text-align: center;
    margin: 30px 0;
}

.advanced-btn {
    display: inline-block;
    padding: 15px 30px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: white;
    text-decoration: none;
    border-radius: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    box-shadow: 0 8px 24px rgba(255, 107, 107, 0.3);
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.advanced-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(255, 107, 107, 0.4);
}

.advanced-btn:active {
    transform: translateY(0);
}

/* Settings */
.settings {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(31, 38, 135, 0.37);
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.18);
    margin-top: 20px;
}

.settings h3 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.setting-card {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 15px;
    border-left: 4px solid #667eea;
}

.setting-card h4 {
    margin-bottom: 20px;
    color: #333;
    font-size: 1.1rem;
}

.setting-item {
    margin: 15px 0;
}

.setting-item label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #555;
}

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

.chart-axis {
    stroke: #666;
    stroke-width: 1;
}

.chart-axis-label {
    font-size: 12px;
    fill: #666;
    text-anchor: middle;
}

.chart-grid {
    stroke: #e9ecef;
    stroke-width: 1;
    stroke-dasharray: 2,2;
}

.chart-point {
    cursor: pointer;
    transition: all 0.2s ease;
}

.chart-point:hover {
    r: 6;
    stroke-width: 2;
}

.chart-diagonal {
    stroke: #999;
    stroke-width: 2;
    stroke-dasharray: 5,5;
}

.chart-bestfit {
    stroke: #ff6b6b;
    stroke-width: 3;
    fill: none;
    opacity: 0.8;
}

.chart-tooltip {
    position: fixed;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 1000;
    transform: translate(-50%, -100%);
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header h1 {
        font-size: 2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .tap-btn {
        width: 150px;
        height: 150px;
        font-size: 1.1rem;
    }

    .mode-selector {
        flex-direction: column;
    }

    .chart-container {
        height: 250px;
        padding: 15px;
    }

    .chart-controls {
        flex-direction: column;
        gap: 5px;
    }

    .chart-legend {
        gap: 15px;
    }

    .slider-container {
        gap: 10px;
        padding: 0 5px;
    }

    #guess-slider::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
    }

    #guess-slider::-moz-range-thumb {
        width: 20px;
        height: 20px;
    }

    .settings-actions {
        gap: 10px;
    }
}

@media (max-width: 480px) {
    header {
        padding: 20px;
    }

    .game-mode {
        padding: 20px;
    }

    .tap-btn {
        width: 120px;
        height: 120px;
        font-size: 1rem;
    }

    .chart-container {
        height: 200px;
        padding: 10px;
    }

    .visualization-section {
        padding: 15px;
    }

    .chart-legend {
        gap: 10px;
        font-size: 0.75rem;
    }

    .legend-color {
        width: 10px;
        height: 10px;
    }

    .slider-container {
        gap: 8px;
        padding: 0;
    }

    .slider-min, .slider-max {
        font-size: 0.8rem;
        min-width: 20px;
    }

    #guess-slider::-webkit-slider-thumb {
        width: 18px;
        height: 18px;
    }

    #guess-slider::-moz-range-thumb {
        width: 18px;
        height: 18px;
    }

    #guess-value {
        font-size: 1.1rem;
    }

    .settings {
        padding: 20px;
    }

    .setting-card {
        padding: 15px;
    }

    .setting-item {
        margin: 12px 0;
    }

    .settings-actions {
        flex-direction: column;
        gap: 10px;
    }

    .settings-actions .action-btn {
        width: 100%;
        max-width: 250px;
        margin: 0 auto;
    }
}

/* Animation for status changes */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 0.5s ease-in-out;
}
