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

html {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-attachment: fixed;
    background-repeat: no-repeat;
    background-size: cover;
    min-height: 100vh;
    min-height: calc(var(--vh, 1vh) * 100); /* Dynamic viewport height for mobile */
    overflow: hidden;
    margin: 0;
    padding: 0;
    /* Prevent pull-to-refresh and overscroll */
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
    /* Force full height and hide address bars */
    width: 100%;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
    position: fixed;
    top: 0;
    left: 0;
}

.container {
    width: 100vw;
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100); /* Dynamic viewport height for mobile */
    position: relative;
    /* Ensure full coverage on mobile with notches */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    /* Fallback background */
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease-in-out;
    padding: 2rem;
}

.screen.active {
    opacity: 1;
    visibility: visible;
}

/* Home Screen */
.game-title {
    font-size: clamp(3rem, 8vw, 6rem);
    color: white;
    font-weight: 900;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    margin-bottom: 1rem;
    text-align: center;
}

.game-subtitle {
    font-size: clamp(1.2rem, 3vw, 1.8rem);
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 3rem;
    text-align: center;
}

.button-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    max-width: 400px;
}

.action-btn {
    padding: 1.2rem 2rem;
    font-size: clamp(1.1rem, 2.5vw, 1.4rem);
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.action-btn.primary {
    background: #ff6b6b;
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.action-btn.primary:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.6);
}

.action-btn.secondary {
    background: #4ecdc4;
    color: white;
    box-shadow: 0 4px 15px rgba(78, 205, 196, 0.4);
}

.action-btn.secondary:hover {
    background: #45b7b8;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(78, 205, 196, 0.6);
}

/* Countdown Screen */
.countdown-display {
    text-align: center;
}

#countdown-number {
    font-size: clamp(8rem, 20vw, 15rem);
    font-weight: 900;
    color: #ff6b6b;
    text-shadow: 0 0 20px rgba(255, 107, 107, 0.5);
    margin-bottom: 2rem;
    animation: pulse 1s ease-in-out;
}

.countdown-display p {
    font-size: clamp(1.5rem, 4vw, 2.5rem);
    color: white;
    font-weight: 300;
}

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

/* Word and Clue Display */
.word-display,
.clue-display {
    width: 100%;
    height: 85%;
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 1rem;
}

#random-word,
#clue-text {
    font-size: 15rem;
    font-weight: 900;
    color: white;
    text-shadow: 4px 4px 12px rgba(0, 0, 0, 0.5);
    line-height: 1.1;
    word-wrap: break-word;
    max-width: 95%;
    text-align: center;
    /* Try much larger viewport percentages */
    font-size: min(15rem, 40vw, 35vh);
}

/* Clue Input Screen */
.clue-input-container {
    width: 100%;
    max-width: 500px;
    text-align: center;
}

.clue-input-container h2 {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    color: white;
    margin-bottom: 2rem;
    font-weight: 300;
}

#clue-input {
    width: 100%;
    padding: 1.5rem;
    font-size: clamp(1.2rem, 3vw, 1.6rem);
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.95);
    text-align: center;
    margin-bottom: 2rem;
    outline: none;
    font-weight: 500;
}

#clue-input:focus {
    background: white;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

.button-group {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* Fullscreen Button */
.fullscreen-btn {
    margin-top: 2rem;
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    min-width: 160px;
    text-align: center;
}

.fullscreen-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
}

.fullscreen-btn:active {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.3);
}

/* Back Button */
.back-btn {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateX(-50%) translateY(-2px);
}

/* Landscape Optimization */
@media screen and (orientation: landscape) {
    .screen {
        justify-content: center;
        align-items: center;
        padding: 1rem 2rem;
    }
    
    .game-title {
        font-size: clamp(2.5rem, 6vh, 4rem);
        margin-bottom: 0.5rem;
    }
    
    .game-subtitle {
        font-size: clamp(1rem, 2.5vh, 1.4rem);
        margin-bottom: 2rem;
    }
    
    .button-container {
        flex-direction: row;
        gap: 2rem;
        max-width: 600px;
    }
    
    .action-btn {
        flex: 1;
        padding: 1rem 1.5rem;
        font-size: clamp(1rem, 2vh, 1.2rem);
    }
    
    #countdown-number {
        font-size: clamp(6rem, 15vh, 10rem);
    }
    
    .countdown-display p {
        font-size: clamp(1.2rem, 3vh, 2rem);
    }
    
    #random-word,
    #clue-text {
        font-size: 12rem;
        font-size: min(12rem, 35vw, 30vh);
    }
    
    .clue-input-container h2 {
        font-size: clamp(1.4rem, 3vh, 2rem);
        margin-bottom: 1.5rem;
    }
    
    #clue-input {
        font-size: clamp(1rem, 2.5vh, 1.4rem);
        padding: 1rem 1.5rem;
        margin-bottom: 1.5rem;
    }
    
    .button-group {
        flex-direction: row;
        gap: 1.5rem;
    }
}

/* Portrait/Mobile Responsive Design */
@media screen and (orientation: portrait) and (max-width: 768px) {
    .screen {
        padding: 1rem;
    }
    
    .button-container {
        max-width: 300px;
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .action-btn {
        padding: 1rem 1.5rem;
    }
}

/* Very small screens */
@media (max-height: 500px) and (orientation: landscape) {
    .game-title {
        font-size: clamp(2rem, 5vh, 3rem);
        margin-bottom: 0.25rem;
    }
    
    .game-subtitle {
        font-size: clamp(0.9rem, 2vh, 1.2rem);
        margin-bottom: 1rem;
    }
    
    .button-container {
        gap: 1rem;
    }
    
    .action-btn {
        padding: 0.75rem 1rem;
        font-size: clamp(0.9rem, 1.8vh, 1.1rem);
    }
    
    #countdown-number {
        font-size: clamp(4rem, 12vh, 7rem);
    }
    
    #random-word,
    #clue-text {
        font-size: 8rem;
        font-size: min(8rem, 30vw, 25vh);
    }
}
