/* Global Styles */
* {
    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%);
    overflow: hidden;
    height: 100vh;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    height: 100vh;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Join Screen */
.join-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 50px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 400px;
}

.game-title {
    font-size: 3em;
    color: #4a7c59;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.lobby-title {
    text-align: center;
}

.game-subtitle {
    font-size: 1.2em;
    color: #8b6f47;
    margin-bottom: 30px;
}

.join-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

input[type="text"] {
    padding: 15px;
    border: 2px solid #4a7c59;
    border-radius: 10px;
    font-size: 1.1em;
    transition: all 0.3s;
}

input[type="text"]:focus {
    outline: none;
    border-color: #76b583;
    box-shadow: 0 0 10px rgba(118, 181, 131, 0.5);
}

.primary-button {
    padding: 15px 30px;
    background: linear-gradient(135deg, #76b583, #4a7c59);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.primary-button:active {
    transform: translateY(0);
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.large-button {
    font-size: 1.5em;
    padding: 20px 50px;
}

.error-message {
    color: #d32f2f;
    margin-top: 15px;
    font-weight: bold;
    min-height: 20px;
}

/* Lobby Screen */
.lobby-container {
    width: 90%;
    max-width: 1400px;
    height: 90vh;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow-y: auto;
}

/* Animal Marquee */
.animal-marquee {
    width: 100%;
    overflow: hidden;
    background: linear-gradient(135deg, #c8e6c9, #a5d6a7);
    border-radius: 15px;
    padding: 15px 0;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.animal-marquee-content {
    display: flex;
    animation: marquee 20s linear infinite;
    width: fit-content;
}

.marquee-animal {
    font-size: 3em;
    margin: 0 30px;
    display: inline-block;
    animation: bounce 2s ease-in-out infinite;
}

.marquee-animal:nth-child(1) { animation-delay: 0s; }
.marquee-animal:nth-child(2) { animation-delay: 0.1s; }
.marquee-animal:nth-child(3) { animation-delay: 0.2s; }
.marquee-animal:nth-child(4) { animation-delay: 0.3s; }
.marquee-animal:nth-child(5) { animation-delay: 0.4s; }
.marquee-animal:nth-child(6) { animation-delay: 0.5s; }
.marquee-animal:nth-child(7) { animation-delay: 0.6s; }
.marquee-animal:nth-child(8) { animation-delay: 0.7s; }
.marquee-animal:nth-child(9) { animation-delay: 0.8s; }
.marquee-animal:nth-child(10) { animation-delay: 0.9s; }

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

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

.room-code-display {
    text-align: center;
    font-size: 1.5em;
    color: #4a7c59;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

.room-code {
    font-weight: bold;
    background: #e8f5e9;
    padding: 10px 20px;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
}

.copy-button {
    background: #76b583;
    border: none;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s;
}

.copy-button:hover {
    background: #4a7c59;
}

.lobby-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 20px;
}

/* Instructions Card */
.instructions-card {
    background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.instructions-card h2 {
    color: #2e7d32;
    margin-bottom: 20px;
    font-size: 1.8em;
    text-align: center;
}

.instruction-section {
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
}

.instruction-section h3 {
    color: #4a7c59;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.instruction-section p {
    color: #333;
    line-height: 1.6;
    margin-bottom: 5px;
}

.instruction-section strong {
    color: #2e7d32;
}

.warning {
    color: #f57c00 !important;
    font-weight: bold;
}

.collectibles-list {
    list-style: none;
    padding: 0;
}

.collectibles-list li {
    margin: 8px 0;
    font-size: 1.1em;
    color: #333;
}

.item-icon {
    display: inline-block;
    margin-right: 8px;
    font-size: 24px;
    vertical-align: middle;
}

/* Players Section */
.players-section {
    background: linear-gradient(135deg, #fff3e0, #ffe0b2);
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.players-section h2 {
    color: #e65100;
    margin-bottom: 15px;
    font-size: 1.8em;
    text-align: center;
}

.player-count {
    text-align: center;
    font-size: 1.3em;
    color: #f57c00;
    font-weight: bold;
    margin-bottom: 20px;
}

.lobby-players-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.lobby-player-item {
    background: rgba(255, 255, 255, 0.8);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.player-animal {
    font-size: 2em;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    border: 3px solid #f57c00;
}

.player-info {
    flex: 1;
}

.player-name {
    font-weight: bold;
    font-size: 1.2em;
    color: #333;
}

.player-animal-name {
    color: #666;
    font-size: 0.9em;
}

.lobby-actions {
    text-align: center;
}

.min-players-note {
    color: #666;
    margin-bottom: 15px;
    font-style: italic;
}

/* Game Screen */
#gameScreen {
    background: linear-gradient(135deg, #a8e6cf, #dcedc1);
}

.game-hud {
    position: absolute;
    top: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 100;
}

.timer-display {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 30px;
    border-radius: 15px;
    font-size: 2em;
    font-weight: bold;
    color: #4a7c59;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.timer-label {
    margin-right: 10px;
}

.scoreboard {
    background: rgba(255, 255, 255, 0.95);
    padding: 15px;
    border-radius: 15px;
    max-width: 300px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.score-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.5);
}

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

.score-info {
    flex: 1;
}

.score-name {
    font-weight: bold;
    color: #333;
}

.score-points {
    color: #4a7c59;
    font-weight: bold;
    font-size: 1.1em;
}

.score-item.current-player {
    background: rgba(118, 181, 131, 0.3);
    border: 2px solid #4a7c59;
}

#gameCanvas {
    display: block;
    margin: 0 auto;
    background: linear-gradient(135deg, #c8e6c9, #a5d6a7);
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

/* Ability Indicator */
.ability-indicator {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    padding: 15px 25px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
    z-index: 100;
    min-width: 280px;
}

.ability-indicator.available {
    border: 3px solid #76b583;
}

.ability-indicator.available .ability-icon {
    animation: pulse 1.5s infinite;
    color: #76b583;
}

.ability-indicator.active {
    border: 3px solid #ff9800;
    background: rgba(255, 152, 0, 0.1);
}

.ability-indicator.active .ability-icon {
    animation: spin 0.5s linear infinite;
    color: #ff9800;
}

.ability-indicator.cooldown {
    border: 3px solid #ff9800;
    opacity: 0.8;
}

.ability-indicator.cooldown .ability-icon {
    color: #ff9800;
}

.ability-icon {
    font-size: 2.5em;
    flex-shrink: 0;
}

.ability-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ability-text {
    font-size: 1em;
    font-weight: bold;
    color: #333;
}

.ability-progress-container {
    width: 100%;
    height: 8px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.ability-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #76b583, #4caf50);
    border-radius: 4px;
    transition: width 0.1s linear;
    width: 100%;
}

.ability-indicator.cooldown .ability-progress-bar {
    background: linear-gradient(90deg, #ff9800, #ffc107);
}

.ability-countdown {
    font-size: 1.5em;
    font-weight: bold;
    color: #ff9800;
    min-width: 30px;
    text-align: center;
    flex-shrink: 0;
}

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

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

/* Results Screen */
.results-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 50px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    min-width: 600px;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.winner-announcement {
    margin: 30px 0;
    padding: 30px;
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(255, 215, 0, 0.4);
}

.winner-name {
    font-size: 2.5em;
    font-weight: bold;
    color: #f57c00;
    margin: 10px 0;
}

.winner-animal {
    font-size: 4em;
    margin: 10px 0;
}

.winner-score {
    font-size: 1.8em;
    color: #4a7c59;
    font-weight: bold;
}

.final-scoreboard {
    margin: 30px 0;
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
}

.final-score-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.final-score-item.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border: 3px solid #f57c00;
}

.final-score-item.rank-2 {
    background: linear-gradient(135deg, #e0e0e0, #f5f5f5);
    border: 3px solid #9e9e9e;
}

.final-score-item.rank-3 {
    background: linear-gradient(135deg, #ffab91, #ffccbc);
    border: 3px solid #ff6f00;
}

.final-rank {
    font-size: 1.5em;
    font-weight: bold;
    color: #333;
    min-width: 40px;
}

.final-animal {
    font-size: 2em;
}

.final-info {
    flex: 1;
}

.final-name {
    font-weight: bold;
    font-size: 1.3em;
    color: #333;
}

.final-animal-name {
    color: #666;
}

.final-points {
    font-size: 1.5em;
    font-weight: bold;
    color: #4a7c59;
}

/* Responsive */
@media (max-width: 1200px) {
    .lobby-content {
        grid-template-columns: 1fr;
    }
}
