* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}

html {
    touch-action: manipulation;
    -ms-touch-action: manipulation;
}

body {
    font-family: 'Orbitron', monospace;
    background: #0a0a0a;
    color: #00ff00;
    overflow-x: hidden;
    position: relative;
    overscroll-behavior: none;
    touch-action: manipulation;
    min-height: 100vh;
}

/* Scanlines effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(0, 255, 0, 0.03) 2px,
        rgba(0, 255, 0, 0.03) 4px
    );
    pointer-events: none;
    z-index: 1;
}

/* Loading Screen */
#loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    transition: opacity 0.5s ease;
}

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

.loader-text {
    font-size: clamp(1rem, 3vw, 1.2rem);
    color: #00ff00;
    margin: 10px 0;
    opacity: 0;
    animation: fadeInOut 2s ease-in-out;
    text-align: center;
    padding: 0 20px;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

/* Main Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px;
    position: relative;
    z-index: 2;
    min-height: 100vh;
}

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

.title {
    font-size: clamp(2rem, 8vw, 4rem);
    font-weight: 900;
    color: #ff0080;
    text-shadow: 0 0 20px #ff0080;
    margin-bottom: 10px;
    animation: glow 2s ease-in-out infinite alternate;
}

@keyframes glow {
    from { text-shadow: 0 0 20px #ff0080; }
    to { text-shadow: 0 0 30px #ff0080, 0 0 40px #ff0080; }
}

.subtitle {
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    color: #00ffff;
    margin-bottom: 10px;
    padding: 0 10px;
}

/* Challenge Status */
.challenge-status {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    border: 2px solid #00ffff;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 5px;
}

.status-active {
    border-color: #00ff00;
    background: rgba(0, 255, 0, 0.1);
}

.status-completed {
    border-color: #ffff00;
    background: rgba(255, 255, 0, 0.1);
}

.status-reset {
    border-color: #ff0080;
    background: rgba(255, 0, 128, 0.1);
}

/* Counter Display */
.counter-section {
    text-align: center;
    margin-bottom: 30px;
}

.counter-display {
    font-size: clamp(2rem, 10vw, 4rem);
    font-weight: 900;
    color: #00ff00;
    text-shadow: 0 0 20px #00ff00;
    border: 3px solid #00ff00;
    padding: clamp(10px, 3vw, 20px);
    margin-bottom: 15px;
    background: rgba(0, 255, 0, 0.1);
    animation: counterGlow 1s ease-in-out infinite alternate;
    word-break: break-all;
}

@keyframes counterGlow {
    from { box-shadow: 0 0 20px rgba(0, 255, 0, 0.5); }
    to { box-shadow: 0 0 30px rgba(0, 255, 0, 0.8); }
}

.progress-bar {
    width: 100%;
    height: clamp(15px, 4vw, 20px);
    background: #333;
    border: 2px solid #00ff00;
    margin-bottom: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #00ff00, #00ffff);
    width: 0%;
    transition: width 0.3s ease;
    animation: progressGlow 2s ease-in-out infinite alternate;
}

@keyframes progressGlow {
    from { box-shadow: inset 0 0 10px rgba(0, 255, 255, 0.5); }
    to { box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.8); }
}

/* Tap Button */
.tap-section {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.tap-button {
    width: clamp(180px, 50vw, 300px);
    height: clamp(180px, 50vw, 300px);
    border-radius: 50%;
    background: #ff0080;
    border: 5px solid #fff;
    color: #fff;
    font-size: clamp(1.5rem, 6vw, 3rem);
    font-weight: 900;
    cursor: pointer;
    transition: all 0.1s ease;
    box-shadow: 0 0 30px rgba(255, 0, 128, 0.6);
    touch-action: manipulation;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
}

.tap-button:hover,
.tap-button:focus {
    transform: scale(1.05);
    box-shadow: 0 0 40px rgba(255, 0, 128, 0.8);
    outline: none;
}

.tap-button:active {
    transform: scale(0.95);
    box-shadow: 0 0 50px rgba(255, 0, 128, 1);
}

.tap-button:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 30px;
}

.stat-box {
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid #00ff00;
    padding: clamp(10px, 3vw, 20px);
    text-align: center;
    border-radius: 5px;
}

.stat-value {
    font-size: clamp(1.2rem, 4vw, 2rem);
    font-weight: 900;
    color: #00ffff;
    margin-bottom: 5px;
    word-break: break-all;
}

.stat-label {
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    color: #00ff00;
    line-height: 1.2;
}

/* Leaderboard */
.leaderboard {
    background: rgba(0, 0, 0, 0.8);
    border: 2px solid #00ffff;
    padding: clamp(10px, 3vw, 20px);
    margin-bottom: 20px;
    border-radius: 5px;
}

.leaderboard h3 {
    color: #00ffff;
    margin-bottom: 15px;
    text-align: center;
    font-size: clamp(1rem, 3vw, 1.2rem);
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    padding: 8px;
    border-bottom: 1px solid #333;
    color: #00ff00;
    font-size: clamp(0.8rem, 2.5vw, 1rem);
    align-items: center;
}

.leaderboard-item.current-user {
    background: rgba(255, 0, 128, 0.2);
    color: #ff0080;
    border-radius: 3px;
}

.leaderboard-item span:first-child {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 10px;
}

.leaderboard-item span:last-child {
    font-weight: bold;
    min-width: 60px;
    text-align: right;
}

/* Messages */
.message-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(1.2rem, 5vw, 2rem);
    font-weight: 900;
    color: #ff0080;
    text-shadow: 0 0 20px #ff0080;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    text-align: center;
    padding: 0 20px;
    max-width: 90vw;
}

.message-display.show {
    opacity: 1;
    animation: messageFloat 2s ease-out;
}

@keyframes messageFloat {
    0% { transform: translate(-50%, -50%) scale(0.5); }
    50% { transform: translate(-50%, -60%) scale(1.2); }
    100% { transform: translate(-50%, -70%) scale(1); opacity: 0; }
}

/* Floating Emojis */
.floating-emoji {
    position: fixed;
    font-size: clamp(1.5rem, 4vw, 2rem);
    pointer-events: none;
    z-index: 50;
    animation: floatUp 2s ease-out forwards;
}

@keyframes floatUp {
    0% { 
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }
    100% { 
        opacity: 0;
        transform: translateY(-200px) rotate(360deg);
    }
}

/* Fixed UI Elements */
.user-info {
    position: fixed;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ff00;
    padding: 8px;
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    z-index: 10;
    border-radius: 5px;
    max-width: 45vw;
}

.user-info div {
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.connection-status {
    position: fixed;
    top: 10px;
    left: 10px;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ff00;
    padding: 8px;
    font-size: clamp(0.7rem, 2vw, 0.9rem);
    z-index: 10;
    border-radius: 5px;
}

.status-online {
    color: #00ff00;
}

.status-offline {
    color: #ff0080;
}

/* Waiting Screen */
.waiting-screen {
    display: none;
    text-align: center;
    padding: 50px 20px;
}

.waiting-screen.show {
    display: block;
}

.waiting-title {
    font-size: clamp(2rem, 6vw, 3rem);
    color: #ffff00;
    text-shadow: 0 0 20px #ffff00;
    margin-bottom: 20px;
}

.waiting-message {
    font-size: clamp(1rem, 3vw, 1.5rem);
    color: #00ffff;
    margin-bottom: 30px;
}

/* Victory Screen */
.victory-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: #00ff00;
    text-align: center;
    font-family: 'Orbitron', monospace;
    padding: 20px;
}

.victory-screen.show {
    display: flex;
}

.victory-title {
    font-size: clamp(2rem, 8vw, 4rem);
    color: #ff0080;
    text-shadow: 0 0 30px #ff0080;
    margin-bottom: 20px;
}

.victory-stats {
    background: rgba(0, 255, 0, 0.1);
    border: 2px solid #00ff00;
    padding: 20px;
    margin: 20px 0;
    border-radius: 10px;
    max-width: 500px;
}

.share-buttons {
    display: flex;
    gap: 15px;
    margin-top: 30px;
    flex-wrap: wrap;
    justify-content: center;
}

.share-button {
    background: #00ff00;
    color: #000;
    border: none;
    padding: 12px 20px;
    font-size: clamp(0.9rem, 2.5vw, 1rem);
    font-family: 'Orbitron', monospace;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(0, 255, 0, 0.5);
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.share-button:hover {
    transform: scale(1.05);
    box-shadow: 0 0 30px rgba(0, 255, 0, 0.8);
}

/* Celebration */
.celebration {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 200;
}

.confetti {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ff0080;
    animation: confettiFall 3s linear forwards;
}

@keyframes confettiFall {
    0% { transform: translateY(-100vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .container {
        padding: 5px;
    }
    
    .header {
        padding-top: 80px;
        margin-bottom: 15px;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .user-info, .connection-status {
        font-size: 0.7rem;
        padding: 6px;
    }
    
    .share-buttons {
        flex-direction: column;
        align-items: center;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .leaderboard-item {
        font-size: 0.8rem;
        padding: 6px;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .header {
        padding-top: 40px;
        margin-bottom: 10px;
    }
    
    .tap-section {
        margin-bottom: 15px;
        padding: 10px 0;
    }
    
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 5px;
    }
}