/* Component styles */

/* Waiting screen */
.waiting-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
}

.waiting-container h1 {
    font-size: 24px;
    font-weight: 600;
}

.participant-count {
    color: var(--text-secondary);
    font-size: 16px;
}

/* Participation button */
.waiting-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin: 5px 0 15px;
}

.btn-participate {
    padding: 16px 40px;
    font-size: 18px;
    font-weight: 600;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.3);
    margin-bottom: 20px;
}

.btn-participate:hover {
    transform: scale(1.02);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

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

.btn-participate.participating {
    background: var(--accent-success);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    animation: participatePulse 2s ease-in-out infinite;
}

.btn-participate.participating:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

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

.hash-display {
    margin-top: 20px;
    padding: 10px 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 12px;
    opacity: 0.7;
}

.hash-label {
    color: var(--text-secondary);
    margin-right: 5px;
}

.hash-display code {
    font-family: 'SF Mono', Monaco, monospace;
    color: var(--text-primary);
}

.pulse-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.1);
    border: 3px solid var(--accent-primary);
    animation: pulse 2s ease-in-out infinite;
}

/* Countdown screen */
.countdown-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 10;
}

.countdown-number {
    width: var(--countdown-size);
    height: var(--countdown-size);
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    font-size: 64px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: countdown-pulse 1s ease-in-out infinite;
}

.countdown-container p {
    color: var(--text-secondary);
    font-size: 18px;
}

/* Roulette screen */
.roulette-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    z-index: 10;
}

.roulette-text {
    font-size: 24px;
    font-weight: 600;
}

.progress-bar {
    width: 200px;
    height: 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    width: 0%;
    height: 100%;
    background: var(--accent-primary);
    border-radius: 4px;
    transition: width 100ms linear;
}

/* Result screen */
.result-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    text-align: center;
    z-index: 10;
    background: var(--bg-card);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 40px var(--shadow);
    max-width: 90%;
}

.winner-emoji {
    font-size: 64px;
    animation: bounce 0.5s ease;
}

.winner-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.winner-phrase {
    font-size: 18px;
    color: var(--text-secondary);
    margin: 10px 0;
    display: none; /* Hidden by default, shown in party mode */
}

/* Party mode shows phrase, hides list/verification */
.party-mode .winner-phrase {
    display: block;
}

.party-mode .participants-list,
.party-mode .result-verification {
    display: none !important;
}

.result-details {
    width: 100%;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 10px;
    font-size: 12px;
}

/* Participants list in result */
.participants-list {
    width: 100%;
    max-height: 150px;
    overflow-y: auto;
    margin: 15px 0;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 10px;
}

.participant-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 14px;
}

.participant-row.winner {
    background: rgba(16, 185, 129, 0.2);
    font-weight: 600;
}

.participant-num {
    color: var(--text-secondary);
    min-width: 24px;
}

.participant-name {
    flex: 1;
}

.winner-badge {
    font-size: 16px;
}

/* Verification section */
.result-verification {
    width: 100%;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 10px;
    margin-top: 10px;
}

.result-verification h3 {
    font-size: 14px;
    margin: 0 0 10px;
    color: var(--text-secondary);
}

.verification-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    margin: 5px 0;
    background: var(--bg-card);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.verification-row:hover {
    background: var(--bg-hover);
}

.verification-row .label {
    color: var(--text-secondary);
    min-width: 40px;
    font-size: 12px;
}

.verification-row code {
    flex: 1;
    font-family: 'SF Mono', Monaco, monospace;
    font-size: 11px;
    color: var(--text-primary);
}

.copy-hint {
    font-size: 12px;
    opacity: 0.5;
}

.copyable.copied {
    color: var(--accent-success);
}

.attempts-info {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 10px 0 0;
    text-align: center;
}

.btn-again {
    margin-top: 10px;
    padding: 12px 30px;
    font-size: 16px;
    font-weight: 600;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.btn-again:active {
    transform: scale(0.95);
    opacity: 0.9;
}

/* Finger circle - Vibrant solid colors */
.finger-circle {
    position: absolute;
    width: var(--finger-size);
    height: var(--finger-size);
    border-radius: 50%;
    /* Use transform for positioning - GPU accelerated */
    left: 0;
    top: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);

    /* Solid vibrant background */
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);

    /* JS spline interpolation handles movement - no CSS transition needed */
    /* Only transition opacity for fade effects */
    transition: opacity 150ms ease-out;
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    pointer-events: none;
    z-index: 100;
    overflow: hidden;
}

/* Party mode: instant movement, no lag */
.party-mode .finger-circle {
    transition: transform 100ms ease-out, opacity 150ms ease-out;
}

.finger-circle::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(
        circle at 30% 30%,
        rgba(255, 255, 255, 0.35) 0%,
        transparent 50%
    );
    pointer-events: none;
}

.finger-circle.highlighted {
    /* Scale handled via JS or separate property */
    box-shadow: 0 0 30px currentColor;
    z-index: 110;
}


.finger-circle.inactive {
    opacity: 0.5;
}

/* Frozen state - iOS cancelled touch but finger still participates */
.finger-circle.frozen {
    opacity: 0.7;
    border: 3px dashed rgba(255, 255, 255, 0.6);
}

/* Color classes for fingers - Vibrant solid colors with glow */
.finger-color-0 {
    background: linear-gradient(145deg, rgba(var(--finger-1-rgb), 0.95), rgba(var(--finger-1-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-1-rgb), 0.5), 0 0 30px rgba(var(--finger-1-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-1 {
    background: linear-gradient(145deg, rgba(var(--finger-2-rgb), 0.95), rgba(var(--finger-2-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-2-rgb), 0.5), 0 0 30px rgba(var(--finger-2-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-2 {
    background: linear-gradient(145deg, rgba(var(--finger-3-rgb), 0.95), rgba(var(--finger-3-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-3-rgb), 0.5), 0 0 30px rgba(var(--finger-3-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-3 {
    background: linear-gradient(145deg, rgba(var(--finger-4-rgb), 0.95), rgba(var(--finger-4-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-4-rgb), 0.5), 0 0 30px rgba(var(--finger-4-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-4 {
    background: linear-gradient(145deg, rgba(var(--finger-5-rgb), 0.95), rgba(var(--finger-5-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-5-rgb), 0.5), 0 0 30px rgba(var(--finger-5-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-5 {
    background: linear-gradient(145deg, rgba(var(--finger-6-rgb), 0.95), rgba(var(--finger-6-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-6-rgb), 0.5), 0 0 30px rgba(var(--finger-6-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-6 {
    background: linear-gradient(145deg, rgba(var(--finger-7-rgb), 0.95), rgba(var(--finger-7-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-7-rgb), 0.5), 0 0 30px rgba(var(--finger-7-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-7 {
    background: linear-gradient(145deg, rgba(var(--finger-8-rgb), 0.95), rgba(var(--finger-8-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-8-rgb), 0.5), 0 0 30px rgba(var(--finger-8-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-8 {
    background: linear-gradient(145deg, rgba(var(--finger-9-rgb), 0.95), rgba(var(--finger-9-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-9-rgb), 0.5), 0 0 30px rgba(var(--finger-9-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-9 {
    background: linear-gradient(145deg, rgba(var(--finger-10-rgb), 0.95), rgba(var(--finger-10-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-10-rgb), 0.5), 0 0 30px rgba(var(--finger-10-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}

/* Extended colors 10-19 */
.finger-color-10 {
    background: linear-gradient(145deg, rgba(var(--finger-11-rgb), 0.95), rgba(var(--finger-11-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-11-rgb), 0.5), 0 0 30px rgba(var(--finger-11-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-11 {
    background: linear-gradient(145deg, rgba(var(--finger-12-rgb), 0.95), rgba(var(--finger-12-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-12-rgb), 0.5), 0 0 30px rgba(var(--finger-12-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-12 {
    background: linear-gradient(145deg, rgba(var(--finger-13-rgb), 0.95), rgba(var(--finger-13-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-13-rgb), 0.5), 0 0 30px rgba(var(--finger-13-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-13 {
    background: linear-gradient(145deg, rgba(var(--finger-14-rgb), 0.95), rgba(var(--finger-14-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-14-rgb), 0.5), 0 0 30px rgba(var(--finger-14-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-14 {
    background: linear-gradient(145deg, rgba(var(--finger-15-rgb), 0.95), rgba(var(--finger-15-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-15-rgb), 0.5), 0 0 30px rgba(var(--finger-15-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-15 {
    background: linear-gradient(145deg, rgba(var(--finger-16-rgb), 0.95), rgba(var(--finger-16-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-16-rgb), 0.5), 0 0 30px rgba(var(--finger-16-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-16 {
    background: linear-gradient(145deg, rgba(var(--finger-17-rgb), 0.95), rgba(var(--finger-17-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-17-rgb), 0.5), 0 0 30px rgba(var(--finger-17-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-17 {
    background: linear-gradient(145deg, rgba(var(--finger-18-rgb), 0.95), rgba(var(--finger-18-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-18-rgb), 0.5), 0 0 30px rgba(var(--finger-18-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-18 {
    background: linear-gradient(145deg, rgba(var(--finger-19-rgb), 0.95), rgba(var(--finger-19-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-19-rgb), 0.5), 0 0 30px rgba(var(--finger-19-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}
.finger-color-19 {
    background: linear-gradient(145deg, rgba(var(--finger-20-rgb), 0.95), rgba(var(--finger-20-rgb), 0.75));
    box-shadow: 0 4px 20px rgba(var(--finger-20-rgb), 0.5), 0 0 30px rgba(var(--finger-20-rgb), 0.3), inset 0 2px 0 rgba(255,255,255,0.3);
}

/* Highlighted state - pulsing glow */
/* Scale is handled via JS for GPU optimization */

/* Loser state - dimmed so winner stands out */
.finger-circle.loser {
    opacity: 0.3;
    filter: grayscale(50%);
    transition: opacity 0.5s ease-out, filter 0.5s ease-out;
}

/* Winner state - golden glow with crown */
.finger-circle.winner {
    border: 4px solid #FFD700 !important;
    box-shadow:
        0 0 0 4px #FFF,
        0 0 0 8px #FFD700,
        0 0 40px #FFD700,
        0 0 80px rgba(255, 215, 0, 0.6),
        inset 0 0 20px rgba(255, 255, 255, 0.4) !important;
    animation: winnerGlow 1s ease-in-out infinite;
    z-index: 200;
    overflow: visible !important;
}

/* Hide the highlight gradient for winner */
.finger-circle.winner::before {
    display: none;
}

/* Crown above winner */
.winner-crown {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 32px;
    animation: crownBounce 0.6s ease-in-out infinite;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    z-index: 201;
    pointer-events: none;
}

.finger-circle.winner::after {
    background: linear-gradient(135deg, #FFD700, #FFA500) !important;
    opacity: 1;
}

@keyframes winnerGlow {
    0%, 100% {
        box-shadow: 0 0 0 4px #FFF, 0 0 0 8px #FFD700, 0 0 40px #FFD700, 0 0 80px rgba(255, 215, 0, 0.6);
    }
    50% {
        box-shadow: 0 0 0 5px #FFF, 0 0 0 10px #FFD700, 0 0 60px #FFD700, 0 0 100px rgba(255, 215, 0, 0.7);
    }
}

@keyframes crownBounce {
    0%, 100% { transform: translateX(-50%) translateY(0) rotate(-5deg); }
    50% { transform: translateX(-50%) translateY(-5px) rotate(5deg); }
}

/* Bottom controls container */
.bottom-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    background: var(--bg-card);
    border-radius: 50px;
    box-shadow: 0 4px 20px var(--shadow);
    z-index: 50;
}

.toggle-label {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* Toggle switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 52px;
    height: 28px;
    flex-shrink: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-secondary);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--accent-success);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

/* No-hold mode active - show circle in center */
.pulse-circle.no-hold-active {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--accent-success);
    animation: pulse-active 1.5s ease-in-out infinite;
}

@keyframes pulse-active {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(16, 185, 129, 0); }
}

/* Overlay styles */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 30px;
    max-width: 340px;
    width: 90%;
    text-align: center;
    animation: slideUp 0.3s ease;
    max-height: 80vh;
    overflow-y: auto;
}

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

.overlay-header {
    margin-bottom: 20px;
}

.overlay-emoji {
    font-size: 48px;
    display: block;
    margin-bottom: 10px;
}

.overlay-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.winner-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    margin-bottom: 20px;
}

.winner-username {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-primary);
}

.winner-display-name {
    font-size: 16px;
    color: var(--text-secondary);
}

.overlay-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-icon {
    font-size: 16px;
}

.overlay-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.btn-overlay {
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-overlay:active {
    transform: scale(0.97);
    opacity: 0.9;
}

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

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

.btn-close-overlay {
    width: 100%;
    margin-top: 5px;
}

/* Participants modal list */
.participants-modal-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 15px 0;
    padding: 10px;
    background: var(--bg-secondary);
    border-radius: 12px;
    text-align: left;
}

.participants-modal-list .participant-row {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.participants-modal-list .participant-row:last-child {
    margin-bottom: 0;
}

.participants-modal-list .participant-row.winner {
    background: rgba(16, 185, 129, 0.2);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Hide toggle in party mode */
.party-mode .bottom-controls {
    display: none;
}
