/* Hangman Professional Gaming UI */
@import url('game-styles.css');

body {
    overflow: hidden !important;
}

.game-container {
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    position: relative;
}

.screen {
    overflow: hidden !important;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding-bottom: 10px;
    position: relative;
}

/* Hide all waiting areas by default */
.waiting-area {
    display: none !important;
}

/* Only show waiting area when parent screen is visible */
.screen[style*="display: block"] .waiting-area,
#hangmanPartyCreated[style*="display: block"] .waiting-area {
    display: block !important;
}

/* Hide spinners by default */
.spinner {
    display: none !important;
}

.waiting-area .spinner {
    display: block !important;
    margin: 0 auto;
}

/* Absolutely hide any orphaned waiting elements */
body > .waiting-text,
body > .spinner,
.game-container > .waiting-text,
.game-container > .spinner {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

/* New Word Button - Top Left */
.new-word-btn {
    position: absolute;
    top: 80px;
    left: 20px;
    padding: 12px 24px;
    font-size: 1em;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s;
    z-index: 100;
}

.new-word-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* Game Stats */
.game-stats {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin-bottom: 10px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 8px 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-label {
    font-size: 0.9em;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 3px;
    font-weight: 500;
}

.stat-value {
    font-size: 1.5em;
    font-weight: 700;
    color: #fbbf24;
}

/* Canvas */
canvas {
    display: block;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 350px;
    height: 350px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

/* Word Display */
.word-display {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
    min-height: 60px;
    max-height: 60px;
    align-items: center;
}

.letter-slot {
    width: 45px;
    height: 55px;
    border-bottom: 4px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    font-weight: 700;
    color: white;
    transition: all 0.3s;
}

.letter-slot.space {
    border-bottom: none;
    width: 25px;
}

.letter-slot.revealed {
    animation: revealLetter 0.4s ease;
    color: #fbbf24;
    text-shadow: 0 0 15px rgba(251, 191, 36, 0.6);
}

@keyframes revealLetter {
    0% { transform: scale(0) rotateY(0deg); opacity: 0; }
    50% { transform: scale(1.3) rotateY(180deg); }
    100% { transform: scale(1) rotateY(360deg); opacity: 1; }
}

/* Keyboard */
.keyboard {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin: 10px auto 0;
    padding-bottom: 10px;
    max-width: 700px;
}

.letter-key {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    color: white;
    font-size: 1.3em;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.letter-key:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.6);
}

.letter-key:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.letter-key.used {
    background: rgba(100, 116, 139, 0.5);
    border-color: rgba(100, 116, 139, 0.3);
}

/* Message */
.message {
    text-align: center;
    font-size: 1.2em;
    margin: 8px 0;
    min-height: 30px;
    max-height: 30px;
    font-weight: 600;
}

.message.win {
    color: #4ade80;
    text-shadow: 0 0 15px rgba(74, 222, 128, 0.6);
}

.message.lose {
    color: #f87171;
}

/* Responsive */
@media (max-width: 1200px) {
    canvas {
        width: 380px;
        height: 380px;
    }
    
    .letter-key {
        width: 50px;
        height: 50px;
        font-size: 1.3em;
    }
    
    .letter-slot {
        width: 48px;
        height: 60px;
        font-size: 2.2em;
    }
}

@media (max-width: 768px) {
    canvas {
        width: 300px;
        height: 300px;
    }
    
    .letter-key {
        width: 40px;
        height: 40px;
        font-size: 1.1em;
        gap: 6px;
    }
    
    .letter-slot {
        width: 38px;
        height: 50px;
        font-size: 1.8em;
        gap: 8px;
    }
    
    .new-word-btn {
        top: 70px;
        left: 10px;
        padding: 8px 16px;
        font-size: 0.85em;
    }
    
    .stat-box {
        padding: 8px 20px;
    }
    
    .stat-value {
        font-size: 1.4em;
    }
}

/* Players List */
.players-list {
    margin: 25px 0;
    text-align: left;
}

.players-list h3 {
    font-size: 1.3em;
    margin-bottom: 15px;
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
}

.player-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 15px 20px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.player-item.ready {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
}

.player-name {
    font-size: 1.1em;
    font-weight: 600;
    color: #fff;
}

.player-status {
    font-size: 0.9em;
    padding: 5px 12px;
    border-radius: 8px;
    font-weight: 600;
}

.player-status.waiting {
    background: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.player-status.ready {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

/* Countdown */
.countdown {
    font-size: 4em;
    font-weight: 800;
    color: #fbbf24;
    text-align: center;
    margin: 30px 0;
    text-shadow: 0 0 30px rgba(251, 191, 36, 0.6);
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Co-op Game Layout */
.coop-game-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: calc(100vh - 150px);
    overflow: hidden;
}

/* Opponent View */
.opponent-view {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

.opponent-view h3 {
    font-size: 1em;
    margin-bottom: 10px;
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

#opponentCanvas {
    width: 250px;
    height: 250px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 10px;
}

.opponent-stats {
    font-size: 0.9em;
    color: #fbbf24;
    font-weight: 600;
    margin-bottom: 10px;
}

.word-display-small {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 100%;
}

.word-display-small .letter-slot {
    width: 25px;
    height: 30px;
    font-size: 1.2em;
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.word-display-small .letter-slot.revealed {
    color: #fbbf24;
    text-shadow: 0 0 10px rgba(251, 191, 36, 0.6);
    animation: none; /* No animation for opponent view */
}

.word-display-small .letter-slot.space {
    width: 15px;
    border-bottom: none;
}

/* Your Game */
.your-game {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .coop-game-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    
    .opponent-view {
        max-height: 200px;
    }
    
    #opponentCanvas {
        width: 150px;
        height: 150px;
    }
}
