/* ============================================
   SPACEBAR CLICKER — Tool / Game Styles
   ============================================ */

/* ---------- Hero Section ---------- */
.hero {
    padding: var(--space-3xl) 0 var(--space-xl);
    text-align: center;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-full);
    background: var(--bg-glass);
    border: var(--border-card);
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-lg);
    font-weight: 500;
}

.hero-badge .pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-green);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 0 0 var(--accent-green-glow);
    }

    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 8px transparent;
    }
}

.hero h1 {
    font-size: 3rem;
    font-weight: 900;
    line-height: 1.1;
    margin-bottom: var(--space-md);
    letter-spacing: -0.02em;
}

.hero h1 .gradient-text {
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero .subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto var(--space-xl);
    line-height: 1.6;
}

/* ---------- Tool Container ---------- */
.tool-container {
    max-width: 680px;
    margin: 0 auto;
    position: relative;
}

.tool-card {
    background: #141728;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: 2px solid #232741;
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    position: relative;
    overflow: hidden;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.05);
}

.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-hero);
    opacity: 1;
}

[data-theme="light"] .tool-card {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.1), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

/* ---------- Timer & Mode Selector ---------- */
.tool-header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-xl);
    flex-wrap: wrap;
    gap: var(--space-md);
}

.tool-modes {
    display: flex;
    justify-content: center;
    gap: var(--space-xs);
    flex-wrap: wrap;
}

.reset-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.1);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
    transition: all var(--transition-fast);
}

.reset-btn:hover {
    background: var(--accent-red);
    color: #fff;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
    transform: rotate(-15deg);
}

.mode-btn {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-glass);
    border: var(--border-subtle);
    transition: all var(--transition-fast);
}

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

.mode-btn.active {
    color: #fff;
    background: var(--gradient-button);
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

/* ---------- Stats Display ---------- */
.stats-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
    background: #090b14;
    border: 2px solid #1c1f33;
    border-radius: var(--radius-md);
    padding: var(--space-lg) var(--space-sm);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .stats-row {
    background: #f1f5f9;
    border-color: #cbd5e1;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
}

.stat-box {
    text-align: center;
    padding: 0 var(--space-sm);
    background: transparent;
    border: none;
    position: relative;
}

.stat-box:not(:last-child)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 10%;
    height: 80%;
    width: 2px;
    background: #1c1f33;
}

[data-theme="light"] .stat-box:not(:last-child)::after {
    background: #cbd5e1;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
    transition: transform var(--transition-fast) ease-out;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .stat-value {
    color: #1a202c;
    text-shadow: none;
}

.stat-value.highlight {
    color: var(--accent-green);
    text-shadow: 0 0 20px var(--accent-green-glow);
}

.stat-value.cps {
    color: var(--accent-cyan);
    text-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}

/* ---------- Progress Bar ---------- */
.progress-container {
    margin-bottom: var(--space-xl);
}

.progress-bar {
    height: 12px;
    background: #090b14;
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
    border: 1px solid #1c1f33;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);
}

[data-theme="light"] .progress-bar {
    background: #e2e8f0;
    border-color: #cbd5e1;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #06b6d4, #6366f1);
    border-radius: var(--radius-full);
    width: 0%;
    transition: width 100ms linear;
    position: relative;
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}

.progress-fill::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6));
    border-radius: 0 var(--radius-full) var(--radius-full) 0;
}

.progress-time {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-sm);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* ---------- Spacebar Button Area ---------- */
.spacebar-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

.spacebar-key {
    width: 100%;
    max-width: 480px;
    height: 100px;
    border-radius: var(--radius-lg);
    background: linear-gradient(180deg, #2a2d45 0%, #1e2030 100%);
    border: 2px solid #111;
    border-bottom: 8px solid #0d0f1a;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-size: 1.1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
    transition: transform 0.05s ease, box-shadow 0.05s ease, border-bottom-width 0.05s ease, background 0.05s ease;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .spacebar-key {
    background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
    border: 2px solid #cbd5e1;
    border-bottom: 8px solid #94a3b8;
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.1), inset 0 2px 0 rgba(255, 255, 255, 1);
    color: #475569;
}

.spacebar-key .key-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    z-index: 1;
}

.spacebar-key .key-icon {
    font-size: 1.4rem;
}

.spacebar-key.pressed {
    transform: translateY(8px);
    border-bottom-width: 0px;
    background: linear-gradient(180deg, #23253a 0%, #1a1c2a 100%);
    border-color: var(--accent-primary);
    box-shadow: 0 0 20px var(--accent-primary-glow), inset 0 1px 0 rgba(99, 102, 241, 0.2);
    color: #fff;
}

[data-theme="light"] .spacebar-key.pressed {
    background: linear-gradient(180deg, #e2e8f0 0%, #cbd5e1 100%);
    box-shadow: inset 0 4px 6px rgba(0, 0, 0, 0.1);
    border-color: var(--accent-primary);
    border-bottom-width: 0px;
    color: var(--accent-primary);
}

/* Ripple effect on press */
.spacebar-key .ripple {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, var(--accent-primary-glow), transparent);
    transform: scale(0);
    animation: ripple-anim 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple-anim {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* Instruction text */
.instruction-text {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
}

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

/* ---------- Game States ---------- */
/* Idle state */
.tool-card[data-state="idle"] .spacebar-key {
    animation: breathe 2s ease-in-out infinite;
}

@keyframes breathe {

    0%,
    100% {
        box-shadow: 0 15px 25px rgba(0, 0, 0, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.1);
    }

    50% {
        box-shadow: 0 15px 25px rgba(0, 0, 0, 0.5), 0 0 30px var(--accent-primary-glow), inset 0 2px 0 rgba(255, 255, 255, 0.1);
    }
}

/* Active state */
.tool-card[data-state="active"] .spacebar-key {
    animation: none;
}

/* Finished state */
.tool-card[data-state="finished"] .spacebar-key {
    opacity: 0.5;
    pointer-events: none;
}

/* ---------- Results Modal ---------- */
.results-panel {
    display: none;
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(6, 9, 24, 0.85);
    /* Dark overlay */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.results-panel.visible {
    display: flex;
    animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.results-panel-content {
    background: var(--bg-card);
    border: var(--border-card);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    text-align: center;
    max-width: 500px;
    width: 100%;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.1);
    animation: popInModal 0.4s var(--transition-spring);
    position: relative;
}

[data-theme="light"] .results-panel-content {
    background: #ffffff;
    border-color: #e2e8f0;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.1), inset 0 2px 0 rgba(255, 255, 255, 0.5);
}

.modal-close-btn {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--bg-glass);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    transition: all var(--transition-fast);
}

.modal-close-btn:hover {
    background: var(--accent-red);
    color: white;
}

@keyframes popInModal {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.result-rank {
    font-size: 3rem;
    margin-bottom: var(--space-sm);
}

.result-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: var(--space-xs);
    color: var(--text-primary);
}

.result-rank-label {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent-secondary);
    margin-bottom: var(--space-lg);
}

.result-stats {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.result-stat {
    padding: var(--space-md);
    background: var(--bg-glass);
    border-radius: var(--radius-md);
}

.result-stat .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: var(--space-xs);
}

.result-stat .value {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

.results-actions {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

/* ---------- High Score Badge ---------- */
.highscore-badge {
    display: none;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-green);
    margin-top: var(--space-md);
    justify-content: center;
    animation: popIn 0.5s var(--transition-spring);
}

.highscore-badge.visible {
    display: inline-flex;
}

@keyframes popIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}

/* ---------- Variant Page Specific ---------- */
.page-info {
    text-align: center;
    max-width: 600px;
    margin: 0 auto var(--space-xl);
}

.page-info .breadcrumb {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: var(--space-md);
}

.page-info .breadcrumb a {
    color: var(--text-muted);
}

.page-info .breadcrumb a:hover {
    color: var(--accent-secondary);
}

/* ---------- Animations ---------- */
.count-animate {
    animation: countBump 0.15s ease-out;
}

@keyframes countBump {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }

    100% {
        transform: scale(1);
    }
}

/* Sparkle effect on new high score */
.sparkle {
    position: absolute;
    pointer-events: none;
    animation: sparkleAnim 0.6s ease-out forwards;
}

@keyframes sparkleAnim {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }

    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* ---------- Toast Notification ---------- */
.toast {
    position: fixed;
    bottom: var(--space-xl);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: var(--border-card);
    border-radius: var(--radius-md);
    padding: var(--space-md) var(--space-xl);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    z-index: var(--z-toast);
    box-shadow: var(--shadow-lg);
    transition: transform var(--transition-spring);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.toast.visible {
    transform: translateX(-50%) translateY(0);
}

/* ---------- Responsive — Tool Specific ---------- */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2rem;
    }

    .hero .subtitle {
        font-size: 1rem;
    }

    .tool-card {
        padding: var(--space-lg);
    }

    .stats-row {
        grid-template-columns: 1fr 1fr 1fr;
        gap: var(--space-sm);
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .spacebar-key {
        height: 70px;
        font-size: 0.85rem;
    }

    .result-stats {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .results-actions {
        flex-direction: column;
    }

    .tool-modes {
        gap: 4px;
    }

    .mode-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: var(--space-xl) 0 var(--space-md);
    }

    .hero h1 {
        font-size: 1.6rem;
    }

    .spacebar-key {
        height: 64px;
        max-width: 100%;
    }
}