/* --- GLOBAL STYLES & AESTHETIC --- */
:root {
    --primary-orange: #FF6B35;
    --secondary-orange: #F7931E;
    --accent-blue: #00A8CC;
    --accent-green: #7CB342;
    --accent-pink: #E91E63;
    --accent-purple: #9C27B0;
    --accent-yellow: #FFC107;
    
    /* Gradients matching the colorful theme */
    --rainbow-gradient: linear-gradient(135deg, #FF6B35 0%, #F7931E 20%, #FFC107 40%, #7CB342 60%, #00A8CC 80%, #9C27B0 100%);
    --warm-gradient: linear-gradient(135deg, #FF6B35 0%, #F7931E 100%);
    --cool-gradient: linear-gradient(135deg, #00A8CC 0%, #7CB342 100%);
    --card-gradient: linear-gradient(145deg, #ffffff 0%, #fefefe 100%);
    --success-gradient: linear-gradient(135deg, #7CB342 0%, #689F38 100%);
    --error-gradient: linear-gradient(135deg, #E91E63 0%, #C2185B 100%);
    --warning-gradient: linear-gradient(135deg, #FFC107 0%, #F57C00 100%);
    
    /* Background and text colors */
    --bg-primary: #FFF8F0;
    --bg-secondary: #FFF3E0;
    --bg-accent: #E8F5E8;
    --text-primary: #2E2E2E;
    --text-secondary: #666666;
    --text-light: #999999;
    --white: #ffffff;
    --cream: #FFFBF7;
    
    /* Shadows with warmer tones */
    --shadow-sm: 0 1px 2px 0 rgba(255, 107, 53, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(255, 107, 53, 0.15), 0 2px 4px -1px rgba(255, 107, 53, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(255, 107, 53, 0.2), 0 4px 6px -2px rgba(255, 107, 53, 0.1);
    --shadow-xl: 0 20px 25px -5px rgba(255, 107, 53, 0.25), 0 10px 10px -5px rgba(255, 107, 53, 0.1);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --border-radius: 16px;
    --border-radius-lg: 24px;
    
    /* Typography Scale */
    --text-xs: 0.75rem;    /* 12px */
    --text-sm: 0.875rem;   /* 14px */
    --text-base: 1rem;     /* 16px */
    --text-lg: 1.125rem;   /* 18px */
    --text-xl: 1.25rem;    /* 20px */
    --text-2xl: 1.5rem;    /* 24px */
    --text-3xl: 1.875rem;  /* 30px */
    --text-4xl: 2.25rem;   /* 36px */
    --text-5xl: 3rem;      /* 48px */
    
    /* Spacing Scale */
    --space-1: 0.25rem;    /* 4px */
    --space-2: 0.5rem;     /* 8px */
    --space-3: 0.75rem;    /* 12px */
    --space-4: 1rem;       /* 16px */
    --space-5: 1.25rem;    /* 20px */
    --space-6: 1.5rem;     /* 24px */
    --space-8: 2rem;       /* 32px */
    --space-10: 2.5rem;    /* 40px */
    --space-12: 3rem;      /* 48px */
    --space-16: 4rem;      /* 64px */
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

html, body {
    height: 100%;
}

body {
    font-family: var(--font-family);
    font-size: var(--text-base);
    line-height: 1.6;
    background: linear-gradient(135deg, #FFFBF7 0%, #FFF8F0 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: var(--space-4);
    min-height: 100vh;
    position: relative;
    outline: 2px solid rgba(255, 107, 53, 0.1);
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23FF6B35' fill-opacity='0.02'%3E%3Ccircle cx='30' cy='30' r='2'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
}

.game-container {
    width: 100%;
    max-width: 650px;
    height: 95vh;
    max-height: 850px;
    background: var(--white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid var(--bg-secondary);
    position: relative;
}

header {
    background: var(--white);
    color: var(--text-primary);
    padding: var(--space-6) var(--space-8);
    text-align: center;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    border-bottom: 4px solid #D1D5DB;
    border-top: 1px solid #E5E7EB;
}

header h1 {
    font-size: var(--text-4xl);
    font-weight: 800;
    margin-bottom: var(--space-2);
    text-shadow: 0 3px 6px rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
    letter-spacing: 1px;
}

header img {
    max-height: 100px;
    max-width: 100%;
    object-fit: contain;
    margin-bottom: var(--space-2);
    position: relative;
    z-index: 1;
}

.game-stats {
    display: flex;
    justify-content: space-around;
    font-weight: 700;
    font-size: var(--text-lg);
    position: relative;
    z-index: 1;
    text-shadow: none;
}

main {
    flex-grow: 1;
    padding: var(--space-8);
    position: relative;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    background: var(--white);
}

/* --- SCREEN MANAGEMENT --- */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
    animation: slideInUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    flex-grow: 1;
    justify-content: center;
    width: 100%;
}

.screen.active {
    display: flex;
}

@keyframes slideInUp {
    from { 
        opacity: 0; 
        transform: translateY(30px) scale(0.95);
    }
    to { 
        opacity: 1; 
        transform: translateY(0) scale(1);
    }
}

/* --- COMPONENTS --- */
.card {
    background: var(--white);
    padding: var(--space-8);
    border-radius: var(--border-radius);
    border: 2px solid var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    width: 100%;
    margin-bottom: var(--space-6);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--rainbow-gradient);
}

.card h2 {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-4);
    color: var(--text-primary);
    font-weight: 700;
}

.card p {
    font-size: var(--text-lg);
    line-height: 1.7;
    margin-bottom: var(--space-4);
    color: var(--text-secondary);
}

.card p:last-child {
    margin-bottom: 0;
}

.secret-word-card {
    background: var(--warm-gradient);
    color: var(--white);
    padding: var(--space-10);
    font-size: var(--text-5xl);
    font-weight: 800;
    letter-spacing: 3px;
    text-transform: uppercase;
    text-shadow: 0 4px 8px rgba(0,0,0,0.3);
    border: 4px solid var(--white);
    word-break: break-word;
}

.secret-word-card::before {
    background: var(--rainbow-gradient);
    height: 8px;
}

button {
    background: var(--warm-gradient);
    color: var(--white);
    border: none;
    padding: var(--space-4) var(--space-8);
    font-family: var(--font-family);
    font-size: var(--text-lg);
    font-weight: 700;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
    min-width: 160px;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(255,255,255,0.3);
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: var(--shadow-xl);
}

button:active {
    transform: translateY(-1px) scale(1.02);
    box-shadow: var(--shadow-md);
}

button.secondary {
    background: var(--cool-gradient);
    border-color: rgba(255,255,255,0.4);
}

button.correct { 
    background: var(--success-gradient);
}

button.incorrect { 
    background: var(--error-gradient);
}

input[type="number"], input[type="text"] {
    font-family: var(--font-family);
    font-size: var(--text-xl);
    font-weight: 600;
    padding: var(--space-4) var(--space-6);
    width: 100%;
    max-width: 400px;
    border: 3px solid var(--bg-secondary);
    border-radius: var(--border-radius);
    text-align: center;
    margin-top: var(--space-6);
    transition: all 0.3s ease;
    background: var(--white);
    box-shadow: var(--shadow-sm);
    min-height: 56px;
    color: var(--text-primary);
}

input[type="number"]:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--primary-orange);
    box-shadow: 0 0 0 4px rgba(255, 107, 53, 0.2);
    transform: scale(1.02);
}

.player-inputs-container, .clue-display-container {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-6);
    margin-top: var(--space-6);
    margin-bottom: var(--space-6);
}

.player-input-card, .clue-card {
    border-radius: var(--border-radius);
    padding: var(--space-6);
    text-align: center;
    border: 3px solid;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    background: var(--white);
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.player-input-card::before, .clue-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: currentColor;
}

.player-input-card label {
    display: block;
    font-weight: 700;
    margin-bottom: var(--space-4);
    font-size: var(--text-lg);
}

.player-input-card input {
    font-size: var(--text-base);
    width: 100%;
    margin-top: 0;
    border-width: 2px;
    padding: var(--space-3) var(--space-4);
    min-height: 44px;
    font-weight: 500;
}

.clue-card {
    font-size: var(--text-xl);
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-break: break-word;
}

.clue-card:hover {
    transform: translateY(-6px) scale(1.05);
    box-shadow: var(--shadow-xl);
}

.clue-card.invalid {
    background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
    color: #C62828;
    border-color: #E91E63;
    text-decoration: line-through;
    opacity: 0.8;
    transform: scale(0.95);
}

.clue-card.hidden-clue {
    background: var(--bg-secondary);
    color: transparent;
}

.clue-card.invalid::after {
    content: '✖';
    position: absolute;
    top: var(--space-2);
    right: var(--space-3);
    font-size: var(--text-2xl);
    color: #C62828;
    font-weight: 900;
}

.guesser-info {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin-bottom: var(--space-6);
    color: var(--text-primary);
}

.guesser-info span {
    color: var(--white);
    padding: var(--space-2) var(--space-4);
    border-radius: 12px;
    background: var(--primary-orange);
    border: 2px solid var(--white);
    box-shadow: var(--shadow-md);
}

.instructions {
    margin-top: var(--space-4);
    color: var(--text-secondary);
    font-style: italic;
    font-size: var(--text-lg);
    line-height: 1.6;
    max-width: 500px;
    font-weight: 500;
}

.result-message {
    font-size: var(--text-4xl);
    font-weight: 800;
    margin-bottom: var(--space-8);
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.result-message.correct { 
    color: var(--accent-green);
}

.result-message.incorrect { 
    color: var(--accent-pink);
}

.result-message.pass { 
    color: var(--accent-yellow);
}

.final-score {
    font-size: var(--text-5xl);
    font-weight: 900;
    background: var(--rainbow-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: var(--space-8) 0;
    text-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.button-row {
    display: flex;
    gap: var(--space-4);
    margin-top: var(--space-6);
    flex-wrap: wrap;
    justify-content: center;
}

.end-word-display {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin: var(--space-2) 0;
    color: var(--primary-orange);
}

.end-guess-display {
    font-size: var(--text-xl);
    font-weight: 600;
    margin: var(--space-2) 0;
    color: var(--text-secondary);
}

/* Timer Styles */
.timer-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: var(--space-6) 0;
    animation: slideInUp 0.3s ease;
}

.timer-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--white);
    border: 8px solid var(--primary-orange);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
}

.timer-circle.warning {
    border-color: var(--accent-yellow);
    animation: pulse 1s ease-in-out infinite;
}

.timer-circle.critical {
    border-color: var(--accent-pink);
    animation: shake 0.5s ease-in-out infinite;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-3px); }
    75% { transform: translateX(3px); }
}

#timer-text, #timer-text-clue, #timer-text-individual, #timer-text-guess {
    font-size: var(--text-4xl);
    font-weight: 800;
    color: var(--text-primary);
    transition: color 0.3s ease;
}

.timer-circle.warning #timer-text,
.timer-circle.warning #timer-text-clue,
.timer-circle.warning #timer-text-individual,
.timer-circle.warning #timer-text-guess {
    color: var(--accent-yellow);
}

.timer-circle.critical #timer-text,
.timer-circle.critical #timer-text-clue,
.timer-circle.critical #timer-text-individual,
.timer-circle.critical #timer-text-guess {
    color: var(--accent-pink);
}

.timer-label {
    margin-top: var(--space-3);
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-6);
    border: 2px solid var(--bg-secondary);
    border-radius: var(--border-radius);
    background: var(--white);
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
    min-width: 140px;
    justify-content: center;
}

.radio-option:hover {
    border-color: var(--primary-orange);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.radio-option input[type="radio"] {
    margin: 0;
    accent-color: var(--primary-orange);
}

.radio-option input[type="radio"]:checked + span {
    color: var(--primary-orange);
    font-weight: 700;
}

/* Footer styles */
.setup-footer {
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-light);
    margin-top: var(--space-6);
    font-weight: 500;
    opacity: 0.8;
}

.page-footer {
    text-align: center;
    font-size: var(--text-xs);
    color: var(--text-light);
    margin-top: var(--space-4);
    font-weight: 500;
    opacity: 0.8;
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    :root {
        --text-xs: 0.7rem;
        --text-sm: 0.8rem;
        --text-base: 0.9rem;
        --text-lg: 1rem;
        --text-xl: 1.1rem;
        --text-2xl: 1.3rem;
        --text-3xl: 1.6rem;
        --text-4xl: 1.8rem;
        --text-5xl: 2.4rem;
        
        --space-1: 0.2rem;
        --space-2: 0.4rem;
        --space-3: 0.6rem;
        --space-4: 0.8rem;
        --space-5: 1rem;
        --space-6: 1.2rem;
        --space-8: 1.6rem;
        --space-10: 2rem;
        --space-12: 2.4rem;
        --space-16: 3.2rem;
    }

    body {
        padding: 0;
        overflow-y: auto;
        align-items: stretch;
        min-height: 100vh;
        justify-content: stretch;
    }

    .game-container {
        height: 100vh;
        max-height: none;
        border-radius: 0;
        min-height: 100vh;
        margin: 0;
        max-width: none;
        width: 100%;
        border: none;
        box-shadow: none;
    }
    
    main {
        padding: var(--space-2) var(--space-2);
        overflow-y: auto;
        flex: 1;
    }

    .screen {
        justify-content: center;
        min-height: 0;
        flex: 1;
        padding: var(--space-2) 0;
    }
    
    .card {
        padding: var(--space-4);
        margin-bottom: var(--space-4);
    }
    
    .secret-word-card {
        font-size: var(--text-3xl);
        padding: var(--space-6);
        letter-spacing: 1px;
    }
    
    .player-inputs-container, .clue-display-container {
        grid-template-columns: 1fr;
        gap: var(--space-4);
        margin-top: var(--space-4);
        margin-bottom: var(--space-4);
    }

    .clue-card {
        min-height: 60px;
        font-size: var(--text-base);
        padding: var(--space-3);
    }

    button {
        min-width: 120px;
        padding: var(--space-3) var(--space-5);
        font-size: var(--text-base);
        min-height: 44px;
    }

    input[type="number"], input[type="text"] {
        font-size: var(--text-base);
        padding: var(--space-3) var(--space-4);
        min-height: 44px;
        margin-top: var(--space-4);
    }

    .button-row {
        flex-direction: column;
        align-items: center;
        gap: var(--space-3);
        margin-top: var(--space-4);
    }

    .button-row button {
        width: 100%;
        max-width: 240px;
    }

    header {
        padding: var(--space-3) var(--space-4);
        border-radius: 0;
    }

    header h1 {
        font-size: var(--text-2xl);
        margin-bottom: var(--space-1);
    }

    header img {
        max-height: 60px;
        margin-bottom: var(--space-1);
    }

    .game-stats {
        font-size: var(--text-sm);
    }

    .instructions {
        font-size: var(--text-sm);
        margin-top: var(--space-3);
        line-height: 1.5;
        max-width: none;
        padding: 0 var(--space-1);
    }

    .guesser-info {
        font-size: var(--text-lg);
        margin-bottom: var(--space-4);
    }

    .result-message {
        font-size: var(--text-3xl);
        margin-bottom: var(--space-5);
    }

    .final-score {
        font-size: var(--text-4xl);
        margin: var(--space-5) 0;
    }

    .player-input-card {
        padding: var(--space-4);
    }

    .player-input-card input {
        padding: var(--space-3) var(--space-4);
        min-height: 40px;
    }

    .end-word-display, .end-guess-display {
        font-size: var(--text-lg);
        margin: var(--space-2) 0;
    }

    /* Timer styles for mobile */
    .timer-display {
        margin: var(--space-4) 0;
    }

    .timer-circle {
        width: 80px;
        height: 80px;
        border-width: 4px;
    }

    #timer-text, #timer-text-clue, #timer-text-individual, #timer-text-guess {
        font-size: var(--text-2xl);
    }

    .timer-label {
        font-size: var(--text-sm);
        margin-top: var(--space-2);
    }

    .timer-options {
        flex-direction: column;
        gap: var(--space-3);
    }

    .radio-option {
        min-width: auto;
        width: 100%;
        max-width: 280px;
        padding: var(--space-3);
        font-size: var(--text-sm);
    }

    .setup-footer, .page-footer {
        margin-top: var(--space-3);
        font-size: 0.65rem;
    }

    /* Landscape orientation adjustments */
    @media (orientation: landscape) and (max-height: 500px) {
        body {
            padding: 0;
        }

        .game-container {
            margin: 0;
            min-height: 100vh;
            height: 100vh;
        }

        header {
            padding: var(--space-2) var(--space-3);
        }

        header h1 {
            font-size: var(--text-xl);
        }

        header img {
            max-height: 40px;
        }

        main {
            padding: var(--space-1) var(--space-1);
        }

        .screen {
            padding: var(--space-1) 0;
            justify-content: flex-start;
        }

        .card {
            padding: var(--space-3);
            margin-bottom: var(--space-2);
        }

        .secret-word-card {
            padding: var(--space-4);
            font-size: var(--text-2xl);
        }

        .button-row {
            margin-top: var(--space-3);
            gap: var(--space-2);
        }
    }
}