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

body {
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.main-container {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    align-items: flex-start;
}

.game-container {
    background: white;
    border-radius: 30px;
    padding: 25px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    flex: 1;
    max-width: 700px;
    text-align: center;
}

.leaderboard-container {
    background: white;
    border-radius: 30px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 350px;
    max-height: 90vh;
    overflow-y: auto;
}

.leaderboard-container h2 {
    color: #667eea;
    font-size: 1.8em;
    margin-bottom: 20px;
    text-align: center;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.leaderboard-item {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 15px;
    border: 2px solid #e0e0e0;
    transition: all 0.3s;
}

.leaderboard-item:hover {
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.player-header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 10px;
    font-weight: bold;
}

.player-rank {
    color: #764ba2;
    font-size: 1.2em;
    margin-right: 10px;
}

.player-name {
    color: #333;
    font-size: 1.1em;
    text-align: left;
}

.player-rewards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    margin-top: 10px;
}

.leaderboard-reward-slot {
    aspect-ratio: 1;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.leaderboard-reward-slot.has-reward {
    border-color: #28a745;
    background: white;
}

.leaderboard-reward-slot.empty-reward {
    background: repeating-linear-gradient(
        45deg,
        #e0e0e0,
        #e0e0e0 5px,
        #f0f0f0 5px,
        #f0f0f0 10px
    );
}

.leaderboard-reward-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.loading,
.no-players {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 20px;
}

.final-rewards-display {
    margin: 8px 0;
    position: relative;
    z-index: 1;
}

.final-rewards-display h3 {
    color: white;
    font-size: 1.1em;
    margin-bottom: 8px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.final-rewards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    max-width: 280px;
    margin: 0 auto;
}

.final-reward-slot {
    aspect-ratio: 1;
    border: 2px solid white;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.final-reward-slot.has-reward {
    border-color: #feca57;
    background: white;
    box-shadow: 0 5px 15px rgba(254, 202, 87, 0.5);
}

.final-reward-slot.empty-reward {
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.3),
        rgba(255, 255, 255, 0.3) 5px,
        rgba(255, 255, 255, 0.1) 5px,
        rgba(255, 255, 255, 0.1) 10px
    );
}

.final-reward-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.name-input-container {
    margin: 8px 0;
    position: relative;
    z-index: 1;
}

.name-input-container label {
    display: block;
    color: white;
    font-size: 1em;
    font-weight: bold;
    margin-bottom: 5px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

#playerName {
    font-size: 1.1em;
    padding: 8px 15px;
    border: 3px solid white;
    border-radius: 15px;
    text-align: center;
    width: 100%;
    font-weight: bold;
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
}

#playerName:focus {
    outline: none;
    border-color: #feca57;
    box-shadow: 0 0 15px rgba(254, 202, 87, 0.5);
}

h1 {
    color: #667eea;
    font-size: 2em;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 15px;
    font-size: 1.1em;
    font-weight: bold;
    flex-wrap: wrap;
    gap: 8px;
}

.score, .level, .progress {
    color: #764ba2;
    padding: 8px 15px;
    background: #f0f0f0;
    border-radius: 15px;
}

.game-area {
    margin: 15px 0;
}

.question {
    font-size: 3em;
    color: #333;
    margin: 20px 0;
    font-weight: bold;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.answer-input {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin: 15px 0;
    flex-wrap: wrap;
}

#answer {
    font-size: 2em;
    padding: 15px 25px;
    border: 3px solid #667eea;
    border-radius: 15px;
    text-align: center;
    width: 200px;
    font-weight: bold;
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
}

#answer:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

#answer::placeholder {
    font-size: 0.5em;
    opacity: 0.8;
}

#submit-btn {
    font-size: 1.5em;
    padding: 15px 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    transition: box-shadow 0.2s;
}

#submit-btn:hover {
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

#submit-btn:active {
    /* No animation */
}

.feedback {
    font-size: 1.5em;
    font-weight: bold;
    min-height: 50px;
    margin: 10px 0;
    padding: 10px;
    border-radius: 15px;
    transition: all 0.3s;
}

.feedback.correct {
    color: #28a745;
    background: #d4edda;
    animation: bounce 0.5s;
}

.feedback.wrong {
    color: #dc3545;
    background: #f8d7da;
    animation: shake 0.5s;
}

.feedback.empty {
    color: transparent;
    background: transparent;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-20px); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}


.stats {
    display: flex;
    justify-content: space-around;
    margin-top: 15px;
    font-size: 1.1em;
    color: #666;
}

.stats div {
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

#correct {
    color: #28a745;
    font-weight: bold;
}

#wrong {
    color: #dc3545;
    font-weight: bold;
}

/* Rewards Collection */
.rewards-collection {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 3px solid #f0f0f0;
}

.rewards-collection h3 {
    color: #667eea;
    font-size: 1.3em;
    margin-bottom: 12px;
    text-align: center;
}

.rewards-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

.reward-slot {
    aspect-ratio: 1;
    border: 2px solid #667eea;
    border-radius: 12px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    overflow: hidden;
    position: relative;
}

.reward-slot.has-reward {
    border-color: #28a745;
    background: white;
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

.reward-placeholder {
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        45deg,
        #e0e0e0,
        #e0e0e0 10px,
        #f0f0f0 10px,
        #f0f0f0 20px
    );
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
    font-size: 2em;
}

.reward-placeholder::before {
    content: "?";
    font-size: 3.5em;
    font-weight: bold;
    color: #bbb;
    line-height: 1;
}

.reward-collected {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    animation: rewardAppear 0.5s ease-out;
}

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

@keyframes rewardDisappear {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.3) rotate(15deg);
        opacity: 0.5;
    }
    100% {
        transform: scale(0) rotate(180deg);
        opacity: 0;
    }
}

.reward-slot.removing-reward {
    animation: rewardDisappear 0.6s ease-in;
    border-color: #dc3545 !important;
    background: #f8d7da !important;
}

.reward-slot.removing-reward .reward-collected {
    animation: rewardDisappear 0.6s ease-in;
}

.reward-removed-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(220, 53, 69, 0.9);
    color: white;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1.1em;
    z-index: 10;
    animation: messagePulse 0.6s ease-in-out;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

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

/* Reward Modal – прозрачен оверлей, играта се вижда отзад */
.reward-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.25);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.35s ease-out;
}

.reward-modal.show {
    display: flex;
    opacity: 1;
}

.reward-modal.reward-modal-closing {
    opacity: 0;
    pointer-events: none;
}

.reward-modal.reward-modal-closing .reward-content {
    animation: rewardClose 0.45s ease-in forwards;
}

@keyframes rewardClose {
    to {
        transform: translateY(75%) scale(0.35);
        opacity: 0;
    }
}

.reward-content {
    background: linear-gradient(135deg, rgba(255, 107, 107, 0.92) 0%, rgba(254, 202, 87, 0.92) 50%, rgba(72, 219, 251, 0.92) 100%);
    border-radius: 30px;
    padding: 20px;
    max-width: 600px;
    max-height: 85vh;
    width: 90%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: rewardOpen 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.reward-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.25) 0%, transparent 70%);
    animation: rotate 3s linear infinite;
}

@keyframes rewardOpen {
    from {
        transform: translateY(60px) scale(0.75);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.reward-header {
    position: relative;
    z-index: 1;
    margin-bottom: 10px;
}

.reward-header h2 {
    font-size: 2em;
    color: white;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin-bottom: 5px;
    animation: pulse 1s infinite;
}

.reward-subtitle {
    font-size: 1.2em;
    color: white;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

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

.reward-characters {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
    margin: 40px 0;
    position: relative;
    z-index: 1;
}

/* Наградно изображение - единично */
.reward-image-container {
    position: relative;
    z-index: 1;
    margin: 10px auto;
    max-width: 300px;
    animation: bounceIn 0.8s ease-out;
}

.reward-image-single {
    width: 100%;
    height: auto;
    border-radius: 15px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
    object-fit: contain;
    display: block;
    background: white;
    padding: 8px;
}

.character-1 {
    animation-delay: 0.1s;
}

.character-2 {
    animation-delay: 0.2s;
}

.character-3 {
    animation-delay: 0.3s;
}

.character-4 {
    animation-delay: 0.4s;
}

.character-5 {
    animation-delay: 0.5s;
}

.character-6 {
    animation-delay: 0.6s;
}

.character-7 {
    animation-delay: 0.7s;
}

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

.character .emoji {
    font-size: 3em;
    display: block;
    margin-bottom: 10px;
}

.reward-message {
    position: relative;
    z-index: 1;
    margin: 10px 0;
    color: white;
    font-size: 1.1em;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    line-height: 1.4;
}

.reward-message p {
    margin: 5px 0;
}

#rewardMessageMain {
    font-size: 1.1em;
    animation: pulse 1.5s infinite;
}

.reward-close-btn {
    position: relative;
    z-index: 1;
    font-size: 1.2em;
    padding: 10px 35px;
    background: white;
    color: #667eea;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Comic Sans MS', 'Arial', sans-serif;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
    transition: box-shadow 0.2s, background 0.2s;
    margin-top: 10px;
}

.reward-close-btn:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    background: #f0f0f0;
}

.reward-close-btn:active {
    /* No animation */
}

/* Confetti effect */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #feca57;
    animation: confettiFall 3s linear infinite;
}

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

/* Responsive design */
@media (max-width: 1200px) {
    .main-container {
        flex-direction: column;
    }
    
    .leaderboard-container {
        width: 100%;
        max-width: 700px;
        margin: 0 auto;
    }
}

@media (max-width: 600px) {
    h1 {
        font-size: 1.8em;
    }
    
    .question {
        font-size: 3em;
    }
    
    #answer {
        font-size: 1.5em;
        width: 150px;
    }
    
    #submit-btn {
        font-size: 1.2em;
        padding: 12px 30px;
    }
    
    .game-info {
        font-size: 1.1em;
    }
    
    .score, .level, .progress {
        padding: 8px 15px;
    }
    
    .rewards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
        max-width: 100%;
    }
    
    .rewards-collection h3 {
        font-size: 1.2em;
    }
    
    .reward-content {
        padding: 30px 20px;
    }
    
    .reward-header h2 {
        font-size: 2em;
    }
    
    .reward-subtitle {
        font-size: 1.2em;
    }
    
    .reward-image-container {
        max-width: 90%;
        margin: 20px auto;
    }
    
    .reward-image-single {
        border-radius: 15px;
        padding: 8px;
    }
    
    .reward-message {
        font-size: 1.2em;
    }
    
    .reward-close-btn {
        font-size: 1.2em;
        padding: 12px 40px;
    }
}

/* Много малък екран (телефон) */
@media (max-width: 380px) {
    .main-container {
        flex-direction: column;
        padding: 12px;
    }
    
    .game-container,
    .leaderboard-container {
        width: 100%;
        padding: 16px;
    }
    
    h1 {
        font-size: 1.4em;
    }
    
    .question {
        font-size: 2.2em;
    }
    
    #answer {
        width: 120px;
        font-size: 1.2em;
    }
    
    .rewards-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    
    .reward-slot {
        min-height: 50px;
    }
    
    .reward-placeholder::before {
        font-size: 2.5em;
    }
    
    .reward-content {
        padding: 20px 14px;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .reward-header h2 {
        font-size: 1.5em;
    }
    
    .reward-close-btn {
        padding: 12px 24px;
        font-size: 1rem;
    }
}

