/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #4d2f6f, #4C2F6F); /* The clean purple-pink gradient */
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100dvh;
    overflow: hidden;
    color: #ffffff;
}

/* The Scaling Engine (from your reference) */
#game-container {
    container-type: size; 
    position: relative; 
    width: 100vw; 
    height: 100vh;
    max-width: 177.78vh; 
    max-height: 56.25vw; 
    aspect-ratio: 16 / 9;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Screens */
.screen {
    position: absolute; width: 100%; height: 100%; display: none; 
    flex-direction: column; align-items: center; justify-content: center;
    padding: 4cqw;
}

.screen.active { 
    display: flex; 
    animation: fadeIn 0.4s ease-in-out;
}

/* Typography */
.game-title {
    font-size: 7cqw;
    font-weight: 800;
    margin-bottom: 1cqw;
    text-shadow: 0 0.5cqw 2cqw rgba(0,0,0,0.2);
}

.subtitle {
    font-size: 2.5cqw;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 4cqh;
    letter-spacing: 0.2cqw;
}

.player-tag {
    background: rgba(0, 0, 0, 0.2);
    padding: 1cqw 3cqw;
    border-radius: 4cqw;
    font-size: 2cqw;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.2cqw;
    margin-bottom: 3cqh;
}

/* UI Cards (Clean, Boxless Design) */
.card {
    background: none;
    backdrop-filter: none;
    border: none;
    border-radius: 0;
    padding: 4cqw;
    width: 50cqw;
    text-align: center;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 2cqw;
}

.card h2 {
    font-size: 3cqw;
    margin-bottom: 1cqw;
}

/* Buttons */
.btn {
    border: none;
    border-radius: 1.5cqw;
    padding: 1.5cqw 3cqw;
    font-size: 2cqw;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    transition: transform 0.1s, opacity 0.2s;
}

.btn:active { transform: scale(0.96); }
.btn:hover { opacity: 0.9; }

.primary-btn {
    background: #ffffff;
    color: #8E2DE2;
    box-shadow: 0 0.5cqw 2cqw rgba(0, 0, 0, 0.2);
}

/* Stacks icon on top, text on bottom */
#btn-invite {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1cqw;
    width: auto;
    min-width: 18cqw;
    margin: 0 auto;
    padding: 1.5cqw 3cqw;
    border-radius: 1.5cqw;
}

#btn-invite svg {
    width: 4.5cqw;
    height: 4.5cqw;
}

.secondary-btn {
    background: transparent;
    border: 2px solid #ffffff;
    color: white;
}

.button-row {
    display: flex; gap: 2cqw; width: 100%;
}

.truth-btn { background: #10b981; color: white; flex: 1; }
.dare-btn { background: #ef4444; color: white; flex: 1; }

/* Inputs */
.custom-input {
    width: 100%;
    background: transparent;
    border: none; 
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 0;
    padding: 1cqw 0; 
    font-size: 2cqw;
    color: #ffffff; 
    outline: none;
    box-shadow: none;
    text-align: center;
    transition: border-bottom 0.2s;
}

.custom-input:focus {
    border-bottom: 2px solid #ffffff;
}

.custom-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.btn-send {
    width: 50%;
    margin: 0 auto;
}

.message-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 2cqw; border-radius: 1cqw;
    width: 100%; font-size: 2.2cqw; font-style: italic;
}

.typing-text {
    color: #ffdf00;
    font-size: 2cqw;
    font-style: italic;
    margin-bottom: 1cqw;
    font-weight: bold;
}

.hidden { display: none !important; }

/* Popups */
.popup-overlay {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; 
    background: rgba(0, 0, 0, 0.6); display: flex; justify-content: center; align-items: center;
    z-index: 1000; backdrop-filter: blur(8px);
}
.popup-box {
    background: none; color: #ffffff;
    padding: 4cqw; width: 45cqw; border-radius: 0;
    text-align: center; box-shadow: none;
    display: flex; flex-direction: column; gap: 3cqw;
}
.popup-box h2 { font-size: 3.5cqw; margin: 0; }
.popup-buttons { display: flex; gap: 2cqw; justify-content: center; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(1cqw); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================
   MOBILE PORTRAIT REARRANGEMENT
   ========================================== */
@media screen and (orientation: portrait) {
    #game-container { aspect-ratio: 9 / 16 !important; max-width: 100vw !important; max-height: 100dvh !important; }
    
    /* Make text and cards bigger for mobile */
    .game-title { font-size: 14cqw !important; margin-bottom: 2cqw !important; }
    .subtitle { font-size: 5cqw !important; margin-bottom: 8cqh !important; }
    .player-tag { font-size: 4cqw !important; padding: 2cqw 5cqw !important; border-radius: 8cqw !important; margin-bottom: 4cqh !important;}
    
    .card { width: 85cqw !important; padding: 6cqw !important; border-radius: 4cqw !important; gap: 4cqw !important; }
    .card h2 { font-size: 6cqw !important; margin-bottom: 2cqw !important; }
    
    /* Stacked button scaling for mobile portrait */
    #btn-invite {
        min-width: 40cqw !important;
        gap: 1.5cqw !important;
        padding: 4cqw 6cqw !important;
        border-radius: 3cqw !important;
    }
    #btn-invite svg {
        width: 10cqw !important;
        height: 10cqw !important;
    }
    
    .btn { font-size: 4.5cqw !important; padding: 3.5cqw 4cqw !important; border-radius: 3cqw !important; }
    
    .button-row { flex-direction: column !important; }
    
    .typing-text { font-size: 4.5cqw !important; }
    .custom-input { font-size: 5cqw !important; padding: 2cqw 0 !important; }
    .btn-send { width: 60% !important; }
    .message-box { font-size: 5cqw !important; padding: 4cqw !important; border-radius: 2cqw !important; }
    
    .popup-box { width: 85cqw !important; padding: 6cqw !important; border-radius: 4cqw !important; gap: 5cqw !important;}
    .popup-box h2 { font-size: 7cqw !important; }
}