/* ========================================
   CSS Variables for Theme Support
   ======================================== */
:root {
    /* Light Theme Colors */
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8ecf1;
    --text-primary: #1a1a2e;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
    
    /* Accent Colors */
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #3b82f6;
    
    /* Component Specific */
    --click-area-bg: linear-gradient(135deg, #6366f1 0%, #818cf8 100%);
    --progress-bar: #10b981;
    --stat-highlight: #fef3c7;
}

[data-theme="dark"] {
    /* Dark Theme Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --border-color: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-hover: rgba(0, 0, 0, 0.5);
    
    --click-area-bg: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%);
    --stat-highlight: #422006;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

/* ========================================
   Container & Layout
   ======================================== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ========================================
   Header Styles
   ======================================== */
.header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: all 0.3s ease;
    width: 100%;
    min-height: 80px;
    display: flex;
    align-items: center;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    width: 100%;
    min-height: 80px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-primary);
    margin: 0;
}

.header-nav {
    display: flex;
    gap: 1rem;
}

.nav-link {
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    font-weight: 500;
}

.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--color-primary);
    color: white;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 1.25rem;
}

.btn-icon:hover {
    background: var(--color-primary);
    transform: translateY(-2px);
}

/* ========================================
   Test Container
   ======================================== */
.test-container {
    padding: 3rem 0;
}

.section-title {
    text-align: center;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

/* ========================================
   Timer Selection
   ======================================== */
.timer-selection {
    margin-bottom: 2rem;
    text-align: center;
}

.timer-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.timer-btn {
    padding: 1rem 2rem;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.timer-btn:hover {
    border-color: var(--color-primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.timer-btn.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* ========================================
   Click Area
   ======================================== */
.click-area-wrapper {
    margin: 2rem 0;
}

.click-area {
    position: relative;
    background: var(--click-area-bg);
    border-radius: 24px;
    padding: 3rem;
    min-height: 400px;
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 40px var(--shadow);
    transition: all 0.3s ease;
    overflow: hidden;
}

.click-area:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 50px var(--shadow-hover);
}

.click-area.active {
    animation: pulse 0.5s ease infinite;
}

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

.click-content {
    position: relative;
    z-index: 2;
    text-align: center;
    width: 100%;
}

.main-counter {
    font-size: 6rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin-bottom: 1rem;
    animation: fadeIn 0.5s ease;
}

.click-prompt {
    font-size: 1.5rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    margin-bottom: 1rem;
}

.timer-display {
    font-size: 2rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
    font-family: 'Courier New', monospace;
}

/* Progress Bar */
.progress-container {
    margin-top: 2rem;
    width: 100%;
    height: 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: var(--progress-bar);
    width: 0%;
    transition: width 0.1s linear;
    border-radius: 10px;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

/* Ripple Effect */
.ripple-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    animation: ripple-animation 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple-animation {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

/* ========================================
   Stats Display
   ======================================== */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin: 2rem 0;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    box-shadow: 0 4px 12px var(--shadow);
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px var(--shadow-hover);
}

.stat-card.highlight {
    background: var(--stat-highlight);
    border: 2px solid var(--color-warning);
}

.stat-icon {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
}

/* ========================================
   Control Buttons
   ======================================== */
.control-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.btn {
    padding: 1rem 2.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px var(--shadow);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-hover);
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-icon {
    font-size: 1.25rem;
}

/* ========================================
   Leaderboard Section
   ======================================== */
.leaderboard-section {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 2rem;
    margin: 3rem 0;
    box-shadow: 0 4px 12px var(--shadow);
}

.leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.leaderboard-title {
    font-size: 1.75rem;
    color: var(--text-primary);
}

.btn-small {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.btn-small:hover {
    transform: translateY(-2px);
}

.btn-small.btn-danger {
    background: var(--color-danger);
    color: white;
}

.leaderboard-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.leaderboard-content {
    min-height: 200px;
}

.leaderboard-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.leaderboard-empty .hint {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.score-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    transition: all 0.3s ease;
}

.score-item:hover {
    transform: translateX(4px);
}

.score-item.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffed4e 100%);
    color: #000;
    font-weight: 700;
}

.score-item.rank-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #e8e8e8 100%);
    color: #000;
    font-weight: 600;
}

.score-item.rank-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #e8a87c 100%);
    color: #000;
    font-weight: 600;
}

.score-rank {
    font-size: 1.5rem;
    font-weight: 800;
    min-width: 40px;
}

.score-details {
    flex: 1;
    padding: 0 1rem;
}

.score-cps {
    font-size: 1.25rem;
    font-weight: 700;
}

.score-info {
    font-size: 0.875rem;
    opacity: 0.8;
}

.score-date {
    font-size: 0.875rem;
    opacity: 0.7;
    white-space: nowrap;
}

/* ========================================
   Hero Description Section
   ======================================== */
.hero-description {
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 3rem;
    margin: 3rem 0;
    box-shadow: 0 4px 12px var(--shadow);
}

.hero-title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.hero-paragraph {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

/* ========================================
   Modal Styles
   ======================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: var(--color-danger);
    color: white;
    transform: rotate(90deg);
}

.modal-body {
    padding: 2rem;
}

.help-section {
    margin-bottom: 2rem;
}

.help-section h3 {
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.help-section ul,
.help-section ol {
    margin-left: 1.5rem;
    color: var(--text-secondary);
}

.help-section li {
    margin-bottom: 0.5rem;
}

/* ========================================
   Confirmation Modal
   ======================================== */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
    backdrop-filter: blur(4px);
}

.confirm-modal-content {
    background: var(--bg-secondary);
    border-radius: 20px;
    max-width: 400px;
    width: 90%;
    padding: 2.5rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    text-align: center;
}

.confirm-modal-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    animation: pulse 2s ease infinite;
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.confirm-modal-title {
    margin: 0 0 0.75rem 0;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
}

.confirm-modal-message {
    margin: 0 0 1.5rem 0;
    color: var(--text-secondary);
    line-height: 1.6;
    font-size: 1rem;
}

.confirm-modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

.confirm-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.confirm-btn-cancel {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.confirm-btn-cancel:hover {
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.confirm-btn-confirm {
    background: var(--color-primary);
    color: white;
}

.confirm-btn-confirm:hover {
    background: var(--color-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

/* ========================================
   Footer Styles
   ======================================== */
.footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    margin-top: 4rem;
    padding: 3rem 0 1rem;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.footer-description {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.footer-heading {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
}

.footer-link:hover {
    color: var(--color-primary);
    padding-left: 0.5rem;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.875rem;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 768px) {
    .header {
        min-height: auto;
    }
    
    .header-container {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
        min-height: auto;
    }

    .header-left {
        flex-direction: column;
        gap: 1rem;
        width: 100%;
    }

    .header-nav {
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-link {
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .header-title {
        font-size: 1.5rem;
        text-align: center;
    }

    .main-counter {
        font-size: 4rem;
    }

    .click-area {
        padding: 2rem;
        min-height: 300px;
    }

    .timer-buttons {
        grid-template-columns: 1fr 1fr;
    }

    .control-buttons {
        flex-direction: column;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

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

    .leaderboard-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .footer-content {
        grid-template-columns: 1fr;
    }
}

/* ========================================
   Animations
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

/* ========================================
   Accessibility
   ======================================== */
:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

