/* Game Styles */
.game-container {
    min-height: 100vh;
    height: 100vh;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: 'Montserrat', sans-serif;
    overflow: hidden;
    box-sizing: border-box;
}

.game-header {
    text-align: center;
    color: #1f2937;
    flex-shrink: 0;
}

.game-header h1 {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    margin-bottom: 10px;
    font-family: 'Playfair Display', serif;
}

.game-header p {
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    color: #6b7280;
    opacity: 0.9;
}

.game-wrapper {
    position: relative;
    border: 3px solid #0ea5e9;
    background: #000;
    border-radius: 10px;
    box-shadow: 0 0 30px rgba(14, 165, 233, 0.3);
    overflow: hidden;
    flex: 1;
    max-width: 100%;
    max-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#gameCanvas {
    display: block;
    image-rendering: pixelated;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.game-ui {
    position: absolute;
    top: 15px;
    left: 15px;
    color: #0ea5e9;
    font-size: clamp(12px, 2vw, 16px);
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
    z-index: 10;
    background: rgba(255, 255, 255, 0.95);
    padding: clamp(8px, 1.5vw, 12px) clamp(10px, 2vw, 15px);
    border-radius: 8px;
    border: 2px solid #0ea5e9;
    font-weight: 600;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.game-ui div {
    margin-bottom: 5px;
}

.game-ui div:last-child {
    margin-bottom: 0;
}

.game-over {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    color: #1f2937;
    padding: clamp(20px, 4vw, 30px);
    text-align: center;
    border: 3px solid #0ea5e9;
    display: none;
    z-index: 20;
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(14, 165, 233, 0.5);
    min-width: clamp(250px, 50vw, 300px);
    max-width: 90vw;
}

.game-over h2 {
    margin: 0 0 20px 0;
    color: #ff6b6b;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-family: 'Playfair Display', serif;
}

.game-over p {
    margin: 10px 0;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    color: #6b7280;
}

.game-over button {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border: none;
    color: #fff;
    padding: clamp(12px, 2.5vw, 15px) clamp(20px, 4vw, 30px);
    font-size: clamp(1rem, 2.5vw, 1.1rem);
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    border-radius: 8px;
    margin-top: 20px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.game-over button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(14, 165, 233, 0.4);
}

.game-instructions {
    color: #0ea5e9;
    font-size: clamp(12px, 2.5vw, 16px);
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    padding: clamp(10px, 2vw, 15px) clamp(15px, 3vw, 25px);
    border-radius: 8px;
    border: 2px solid #0ea5e9;
    line-height: 1.4;
    max-width: 400px;
    font-weight: 400;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
    font-size: small;
}

.back-to-wedding {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    color: #1f2937;
    padding: clamp(10px, 2vw, 12px) clamp(16px, 3vw, 20px);
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 2px solid #0ea5e9;
    z-index: 30;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-size: clamp(12px, 2.5vw, 14px);
}

.back-to-wedding:hover {
    background: #0ea5e9;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(14, 165, 233, 0.4);
}

/* Name Input Overlay */
.name-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.name-overlay-content {
    background: rgba(255, 255, 255, 0.95);
    color: #1f2937;
    padding: 40px;
    text-align: center;
    border: 3px solid #0ea5e9;
    border-radius: 15px;
    box-shadow: 0 0 40px rgba(14, 165, 233, 0.5);
    min-width: 400px;
}

.name-overlay-content h2 {
    margin: 0 0 25px 0;
    color: #0ea5e9;
    font-size: 1.8rem;
    font-family: 'Playfair Display', serif;
}

.name-overlay-content input {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    border: 2px solid #0ea5e9;
    border-radius: 8px;
    margin-bottom: 25px;
    font-family: 'Montserrat', sans-serif;
    box-sizing: border-box;
}

.name-overlay-content input:focus {
    outline: none;
    border-color: #0284c7;
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.3);
}

.name-overlay-content button {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border: none;
    color: #fff;
    padding: 15px 30px;
    font-size: 1.1rem;
    cursor: pointer;
    font-family: 'Montserrat', sans-serif;
    border-radius: 8px;
    font-weight: 600;
    transition: all 0.3s ease;
}

.name-overlay-content button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(14, 165, 233, 0.4);
}

.name-overlay-content button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.name-overlay-content .name-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.name-overlay-content button {
    min-width: 140px;
}

.randomize-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff5252 100%) !important;
}

.randomize-btn:hover {
    background: linear-gradient(135deg, #ff5252 0%, #ff3838 100%) !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-container {
        padding: 15px;
    }
    
    .game-wrapper {
        border-width: 2px;
    }
    
    /* Mobile: Optimize game over popup */
    .game-over {
        padding: 20px;
        margin: 15px;
        max-width: 90vw;
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .game-over h2 {
        font-size: clamp(20px, 5vw, 24px);
        margin-bottom: 15px;
    }
    
    .game-over .final-score {
        font-size: clamp(16px, 4vw, 18px);
        margin: 15px 0;
    }
    
    .game-over button {
        padding: 15px 25px;
        font-size: clamp(16px, 4vw, 18px);
        min-width: 140px;
        margin-top: 15px;
    }
    
    /* Mobile: Optimize podium */
    .podium-section h3 {
        font-size: clamp(18px, 4.5vw, 20px);
        margin-bottom: 15px;
    }
    
    .podium {
        gap: 8px;
        margin-bottom: 15px;
    }
    
    .podium-place {
        min-width: 70px;
    }
    
    .podium-rank {
        font-size: clamp(20px, 5vw, 24px);
        margin-bottom: 6px;
    }
    
    .podium-name {
        font-size: clamp(11px, 3vw, 13px);
        max-width: 80px;
        margin-bottom: 4px;
    }
    
    .podium-score {
        font-size: clamp(12px, 3.5vw, 14px);
    }
    
    /* Mobile: Optimize name overlay */
    .name-overlay-content {
        padding: 30px 25px;
        min-width: 320px;
        max-width: 90vw;
        margin: 20px;
    }
    
    .name-overlay-content h2 {
        font-size: clamp(20px, 5vw, 24px);
        margin-bottom: 20px;
    }
    
    .name-overlay-content input {
        padding: 15px;
        font-size: clamp(16px, 4vw, 18px);
        margin-bottom: 20px;
    }
    
    .name-overlay-content .name-buttons {
        gap: 12px;
        flex-direction: column;
        align-items: center;
    }
    
    .name-overlay-content button {
        min-width: 160px;
        padding: 15px 20px;
        font-size: clamp(14px, 3.5vw, 16px);
    }
    
    /* Mobile: Show only arrow, hide text */
    .back-to-wedding {
        width: 40px;
        height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 0;
        line-height: 0;
    }
    
    .back-to-wedding::before {
        content: "←";
        font-size: 20px;
        font-weight: bold;
    }
}

@media (max-width: 480px) {
    .game-container {
        padding: 10px;
    }
    
    .game-header {
        margin-bottom: 10px;
    }
    
    .game-wrapper {
        border-width: 2px;
    }
    
    .game-ui {
        top: 10px;
        left: 10px;
        font-size: clamp(14px, 3.5vw, 16px);
        padding: 8px 12px;
    }
    
    .game-instructions {
        bottom: 10px;
        left: 10px;
        font-size: clamp(12px, 3vw, 14px);
        padding: 8px 12px;
        max-width: 90vw;
    }
    
    /* Extra small screens: Optimize popups even more */
    .game-over {
        padding: 15px;
        margin: 10px;
        max-width: 95vw;
        max-height: 90vh;
    }
    
    .game-over h2 {
        font-size: clamp(18px, 6vw, 22px);
        margin-bottom: 12px;
    }
    
    .game-over .final-score {
        font-size: clamp(15px, 5vw, 17px);
        margin: 12px 0;
    }
    
    .game-over button {
        padding: 12px 20px;
        font-size: clamp(15px, 5vw, 17px);
        min-width: 120px;
        margin-top: 12px;
    }
    
    /* Extra small: Compact podium */
    .podium-section h3 {
        font-size: clamp(16px, 5vw, 18px);
        margin-bottom: 12px;
    }
    
    .podium {
        gap: 6px;
        margin-bottom: 12px;
    }
    
    .podium-place {
        min-width: 60px;
    }
    
    .podium-rank {
        font-size: clamp(18px, 6vw, 22px);
        margin-bottom: 5px;
    }
    
    .podium-name {
        font-size: clamp(10px, 4vw, 12px);
        max-width: 70px;
        margin-bottom: 3px;
    }
    
    .podium-score {
        font-size: clamp(11px, 4.5vw, 13px);
    }
    
    /* Extra small: Compact name overlay */
    .name-overlay-content {
        padding: 25px 20px;
        min-width: 280px;
        max-width: 95vw;
        margin: 15px;
    }
    
    .name-overlay-content h2 {
        font-size: clamp(18px, 6vw, 22px);
        margin-bottom: 18px;
    }
    
    .name-overlay-content input {
        padding: 12px;
        font-size: clamp(15px, 5vw, 17px);
        margin-bottom: 18px;
    }
    
    .name-overlay-content .name-buttons {
        gap: 10px;
    }
    
    .name-overlay-content button {
        min-width: 140px;
        padding: 12px 18px;
        font-size: clamp(13px, 4.5vw, 15px);
    }
    
    /* Extra small screens: Even more compact arrow button */
    .back-to-wedding {
        width: 35px;
        height: 35px;
        top: 10px;
        right: 10px;
    }
    
    .back-to-wedding::before {
        font-size: 18px;
    }
}

/* Ensure no scrolling on any device */
html, body {
    overflow: hidden;
    height: 100%;
    margin: 0;
    padding: 0;
}

/* Podium styles */
.podium-section {
    margin: 25px 0;
    text-align: center;
}

.podium-section h3 {
    color: #0ea5e9;
    margin: 0 0 20px 0;
    font-size: clamp(18px, 3vw, 22px);
    font-family: 'Playfair Display', serif;
}

.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 20px;
}

.podium-place {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
}

.podium-rank {
    font-size: clamp(24px, 4vw, 32px);
    margin-bottom: 8px;
}

.podium-name {
    font-size: clamp(12px, 2vw, 14px);
    font-weight: 600;
    color: #1f2937;
    text-align: center;
    margin-bottom: 5px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.podium-score {
    font-size: clamp(14px, 2.5vw, 16px);
    font-weight: 700;
    color: #059669;
}

/* Podium heights and colors */
.first-place {
    order: 2;
}

.second-place {
    order: 1;
}

.third-place {
    order: 3;
}

.first-place .podium-rank {
    font-size: clamp(32px, 5vw, 40px);
}

.first-place .podium-name {
    font-size: clamp(14px, 2.5vw, 16px);
}

.first-place .podium-score {
    font-size: clamp(16px, 3vw, 18px);
}

/* Final score styling */
.final-score {
    font-size: clamp(18px, 3vw, 22px);
    color: #0ea5e9;
    font-weight: 600;
    margin: 15px 0;
    text-align: center;
}

.final-score span {
    color: #059669;
    font-weight: 700;
}
