* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 600px;
    min-height: 500px;
}

.screen {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.screen.active {
    display: block;
}

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

h1 {
    color: #667eea;
    text-align: center;
    font-size: 2.5em;
    margin-bottom: 10px;
}

h2 {
    color: #667eea;
    text-align: center;
    font-size: 2em;
    margin-bottom: 20px;
}

h3 {
    color: #333;
    text-align: center;
    font-size: 1.5em;
    margin: 20px 0;
}

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

.input-group {
    margin-bottom: 30px;
}

.input-group label {
    display: block;
    color: #333;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 1.1em;
}

.input-group input {
    width: 100%;
    padding: 15px;
    font-size: 1.1em;
    border: 2px solid #ddd;
    border-radius: 10px;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    padding: 15px 30px;
    font-size: 1.1em;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    width: 100%;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

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

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

.btn-secondary {
    background: #6c757d;
    color: white;
    margin-top: 10px;
}

.btn-play {
    background: #28a745;
    color: white;
    font-size: 1.3em;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-play.playing {
    background: #218838;
}

.btn-play:disabled {
    opacity: 0.9;
    cursor: not-allowed;
}

.btn-play.playing::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
        transparent 0%,
        rgba(255,255,255,0.2) 25%,
        rgba(255,255,255,0.3) 50%,
        rgba(255,255,255,0.2) 75%,
        transparent 100%
    );
    animation: soundWaveSweep 1.5s ease-in-out infinite;
}

@keyframes soundWaveSweep {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Sound wave bars animation */
.sound-wave {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-left: 12px;
    position: relative;
    z-index: 10;
}

.sound-wave span {
    display: inline-block;
    width: 4px;
    height: 15px;
    background: white;
    border-radius: 3px;
    animation: soundWave 0.8s ease-in-out infinite;
}

.sound-wave span:nth-child(1) {
    animation-delay: 0s;
}

.sound-wave span:nth-child(2) {
    animation-delay: 0.1s;
}

.sound-wave span:nth-child(3) {
    animation-delay: 0.2s;
}

.sound-wave span:nth-child(4) {
    animation-delay: 0.3s;
}

.sound-wave span:nth-child(5) {
    animation-delay: 0.1s;
}

@keyframes soundWave {
    0%, 100% {
        height: 10px;
        opacity: 0.7;
    }
    50% {
        height: 25px;
        opacity: 1;
    }
}

.stats {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 2px solid #eee;
    text-align: center;
    color: #666;
}

.stats p {
    margin: 5px 0;
    font-size: 1em;
}

.stats span {
    font-weight: 700;
    color: #667eea;
}

/* Game Screen */
.game-header {
    text-align: center;
    margin-bottom: 30px;
}

.sound-counter {
    color: #666;
    font-size: 1.1em;
    font-weight: 600;
}

.game-content {
    margin: 30px 0;
}

.audio-player {
    text-align: center;
    margin-bottom: 20px;
}

.question {
    margin: 30px 0;
}

.voting-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-top: 20px;
}

.btn-vote {
    padding: 20px;
    font-size: 1.2em;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.btn-human {
    background: linear-gradient(135deg, #56ab2f 0%, #a8e063 100%);
    color: white;
}

.btn-ai {
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%);
    color: white;
}

.progress-dots {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 30px;
}

.dot {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #ddd;
    transition: all 0.3s;
}

.dot.active {
    background: #667eea;
    transform: scale(1.3);
}

.dot.correct {
    background: #28a745;
}

.dot.incorrect {
    background: #dc3545;
}

/* Results Screen */
.score-card {
    text-align: center;
    margin: 40px 0;
}

.score-circle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    margin: 0 auto 20px;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    position: relative;
    opacity: 0;
    transform: scale(0);
}

.score-circle.animate {
    animation: scoreReveal 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes scoreReveal {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    100% {
        opacity: 1;
        transform: scale(1) rotate(0deg);
    }
}

.score-circle-content {
    display: flex;
    align-items: baseline;
    justify-content: center;
    line-height: 1;
}

.score-number {
    font-size: 5em;
    font-weight: 700;
}

.score-label {
    font-size: 2em;
    font-weight: 600;
    margin-left: 5px;
    opacity: 0.9;
}

.score-message {
    font-size: 1.3em;
    color: #666;
    margin-top: 20px;
    opacity: 0;
    transform: translateY(10px);
}

.score-message.show {
    animation: messageSlideIn 0.5s ease-out 0.4s forwards;
}

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

/* Leaderboard Screen */
.leaderboard-list {
    margin: 30px 0;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    margin: 10px 0;
    background: #f8f9fa;
    border-radius: 10px;
    border-left: 5px solid #667eea;
    transition: all 0.3s;
}

.leaderboard-item:hover {
    transform: translateX(5px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.leaderboard-item.top-score {
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
    border-left-color: #ffd700;
}

.leaderboard-item .rank {
    font-size: 1.5em;
    font-weight: 700;
    color: #667eea;
    min-width: 40px;
}

.leaderboard-item.top-score .rank {
    color: #ffd700;
}

.leaderboard-item .name {
    flex: 1;
    font-size: 1.2em;
    font-weight: 600;
    color: #333;
    margin-left: 15px;
}

.leaderboard-item .score {
    font-size: 1.3em;
    font-weight: 700;
    color: #667eea;
}

.leaderboard-actions {
    margin-top: 30px;
}

.leaderboard-stats {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.leaderboard-stats p {
    color: #666;
    font-size: 1em;
    margin: 5px 0;
}

/* Feedback Animations */
.feedback-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.feedback-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.feedback-content {
    text-align: center;
    color: white;
    font-size: 6em;
    animation: feedbackPop 0.6s ease-out;
}

.feedback-message {
    font-size: 0.3em;
    margin-top: 20px;
    font-weight: 600;
}

@keyframes feedbackPop {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Celebration animation for correct answers */
@keyframes celebrate {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.1) rotate(-5deg);
    }
    75% {
        transform: scale(1.1) rotate(5deg);
    }
}

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

/* Shake animation for incorrect answers */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    75% {
        transform: translateX(10px);
    }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

/* Confetti elements */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: #ffd700;
    position: absolute;
    animation: confettiFall 1.5s ease-out forwards;
    z-index: 999;
}

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

/* Question transition */
.game-content.fade-out {
    animation: fadeOut 0.3s ease-out;
}

.game-content.fade-in {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.95);
    }
}

/* Pulse animation for active dot */
@keyframes pulse {
    0%, 100% {
        transform: scale(1.3);
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
    }
    50% {
        transform: scale(1.4);
        box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
    }
}

.dot.active {
    background: #667eea;
    animation: pulse 1.5s infinite;
}

/* Live Leaderboard (Top Right) */
.live-leaderboard {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 300px;
    max-height: 500px;
    background: rgba(255, 255, 255, 0.98);
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    padding: 15px;
    z-index: 999;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.live-leaderboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.live-leaderboard-header h3 {
    margin: 0;
    font-size: 1.2em;
    color: #667eea;
}

.live-students-count {
    font-size: 0.85em;
    color: #666;
    font-weight: 600;
}

.live-leaderboard-scores {
    flex: 1;
    overflow-y: auto;
    max-height: 420px;
}

.live-leaderboard-scores::-webkit-scrollbar {
    width: 6px;
}

.live-leaderboard-scores::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.live-leaderboard-scores::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 3px;
}

.live-score-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    margin: 5px 0;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 3px solid #667eea;
    animation: slideInRight 0.3s ease-out;
}

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

.live-score-item.top-1 {
    background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
    border-left-color: #ffd700;
}

.live-score-item.in-progress {
    background: #e3f2fd;
    border-left-color: #2196f3;
    opacity: 0.8;
}

.live-score-name {
    flex: 1;
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.live-score-value {
    font-weight: 700;
    color: #667eea;
    font-size: 1em;
}

.live-empty {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
    font-size: 0.9em;
}

/* Sync Status Indicator */
.sync-status {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.95);
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    z-index: 1000;
    transition: all 0.3s;
}

.sync-icon {
    font-size: 1.2em;
    animation: pulse-dot 2s infinite;
}

.sync-status.online .sync-icon {
    color: #28a745;
}

.sync-status.offline .sync-icon {
    color: #ffc107;
}

.sync-text {
    font-weight: 600;
    color: #333;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Responsive */
@media (max-width: 600px) {
    .screen {
        padding: 30px 20px;
    }

    h1 {
        font-size: 2em;
    }

    h2 {
        font-size: 1.5em;
    }

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

    .score-circle {
        width: 150px;
        height: 150px;
    }

    .score-number {
        font-size: 3.5em;
    }

    .score-label {
        font-size: 1.5em;
    }

    .feedback-content {
        font-size: 4em;
    }

    /* Move live leaderboard to bottom on mobile */
    .live-leaderboard {
        position: static;
        width: 100%;
        max-width: none;
        margin-top: 20px;
        order: 999; /* Move to end */
    }

    /* Position it at bottom of screen on mobile */
    body {
        display: flex;
        flex-direction: column;
    }

    .container {
        flex: 1;
    }
}
