/*
Coral Pink #FE938C
Beige #EBEBD3
Lapiz Lazuli #38618C
Dark Purple #3B1F2B
Cerulean #4281A4

*/
/*
Coral Pink #FE938C
Beige #EBEBD3
Lapiz Lazuli #38618C
Dark Purple #3B1F2B
Cerulean #4281A4
*/

* {
    box-sizing: border-box;
}

body {
    background-color: #4281A4;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: Arial, sans-serif;
    color: #3B1F2B;
    padding: 1em;
    margin: 0;
}

.game {
    background-color: #EBEBD3;
    max-width: 500px;
    width: 100%;
    border-radius: 8px;
    padding: 1.5em;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

header {
    text-align: center;
    margin-bottom: 1.5em;
}

h1 {
    margin: 0;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    color: #FE938C;
    line-height: 1.2;
}

.subtitle {
    color: #010203;
    margin-top: 0.5em;
    font-size: clamp(1rem, 4vw, 1.5rem);
    margin-bottom: 0;
}

/* Secret number container - always 4 boxes */
#number-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1.5em;
    flex-wrap: wrap;
}

/* NEW: Turn counter - made smaller */
.turn-counter {
    text-align: center;
    margin-bottom: 0.8em;
    font-weight: bold;
    font-size: 0.95em;
    color: #3B1F2B;
    background-color: rgba(255, 255, 255, 0.5);
    padding: 0.3em 0.6em;
    border-radius: 4px;
    border: 1px solid #38618C;
}

/* Game container for all guesses */
#game-container {
    width: 100%;
    margin-bottom: 1em;
    max-height: 300px;
    overflow-y: auto;
    padding: 0;
    box-sizing: border-box;
}

/* CHANGED: Removed space-between for better natural spacing */
.guess-block {
    margin: 0 0.5em 0.8em 0.5em;
    padding: 0.5em 0.8em;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    width: calc(100% - 1em);
    box-sizing: border-box;
    min-width: 0;
    /* Firefox mobile specific fixes */
    -moz-box-sizing: border-box;
    position: relative;
}

.guess-row {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

/* CHANGED: More compact feedback to ensure single row layout */
.feedback-block {
    font-size: 0.75em;
    font-weight: bold;
    color: #3B1F2B;
    white-space: nowrap;
    min-width: fit-content;
    flex-shrink: 0;
    margin-left: 0.5em;
}

.number-box {
    background-color: #38618C;
    color: white;
    width: clamp(28px, 6vw, 40px);
    height: clamp(28px, 6vw, 40px);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(0.8rem, 2vw, 1rem);
    font-weight: bold;
    border-radius: 6px;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.winning-number {
    background-color: #3B1F2B !important;
    color: white;
    animation: pulse 0.5s ease-in-out;
}

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

.message {
    margin: 1em 0;
    font-size: clamp(1rem, 4vw, 1.2rem);
    text-align: center;
    min-height: 1.5em;
    font-weight: bold;
}

.error {
    color: #FE938C;
}

.success {
    color: #3B1F2B;
    animation: bounce 0.6s ease-in-out;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
    60% { transform: translateY(-3px); }
}

.form-container {
    background-color: white;
    padding: 1.5em;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    margin-bottom: 1.5em;
}

form {
    display: flex;
    flex-direction: column;
    gap: 1em;
    align-items: center;
}

input[type="text"], input[type="number"] {
    padding: 12px 16px;
    width: 100%;
    max-width: 300px;
    font-size: 1.1em;
    border: 2px solid #ddd;
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    text-align: center;
    letter-spacing: 0.2em;
}

input[type="text"]:focus, input[type="number"]:focus {
    border-color: #4281A4;
    box-shadow: 0 0 0 3px rgba(66, 129, 164, 0.1);
}

input[type="text"]:disabled, input[type="number"]:disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

button {
    background-color: #FE938C;
    color: white;
    padding: 12px 24px;
    font-size: 1.1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px; /* Touch-friendly minimum */
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button:hover:not(:disabled) {
    background-color: #4281A4;
    transform: translateY(-1px);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

.card {
    width: 100%;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 8px;
    padding: 1em;
}

.help {
    display: block;
    font-size: 1rem;
    color: #4281A4;
    text-decoration: underline;
    text-align: center;
    cursor: pointer;
    font-weight: bold;
    transition: color 0.2s;
}

.help:hover {
    color: #3B1F2B;
}

.instructions-back {
    display: none;
    line-height: 1.4;
    margin-top: 1em;
    font-size: 0.9rem;
    text-align: left;
    background-color: rgba(255, 255, 255, 0.8);
    padding: 1em;
    border-radius: 6px;
    border-left: 4px solid #4281A4;
}

.instructions-back ol {
    margin: 0;
    padding-left: 1.2em;
}

.instructions-back li {
    margin-bottom: 0.5em;
}

/* Share functionality styles */
.share-container {
    background-color: rgba(255, 255, 255, 0.8);
    padding: 1.5em;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    margin-bottom: 1.5em;
    text-align: center;
    border: 2px solid #FE938C;
}

.share-container h3 {
    margin: 0 0 1em 0;
    color: #3B1F2B;
    font-size: 1.2em;
}

.share-button {
    background-color: #4281A4;
    color: white;
    padding: 10px 16px;
    font-size: 0.9em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0.25em;
    font-weight: bold;
    min-width: 120px;
}

.share-button:hover:not(:disabled) {
    background-color: #38618C;
    transform: translateY(-1px);
}

.share-button:active {
    transform: translateY(0);
}

/* WhatsApp button specific styling */
#whatsapp-btn {
    background-color: #25D366; /* WhatsApp green */
}

#whatsapp-btn:hover:not(:disabled) {
    background-color: #1DA851; /* Darker WhatsApp green on hover */
}

/* Copy button specific styling */
#copy-btn {
    background-color: #6c757d; /* Gray for copy */
}

#copy-btn:hover:not(:disabled) {
    background-color: #5a6268; /* Darker gray on hover */
}

/* New Game button container */
.new-game-container {
    width: 100%;
    text-align: center;
    margin-bottom: 1.5em;
}

.new-game-button {
    background-color: #28a745; /* Green for new game */
    color: white;
    padding: 12px 24px;
    font-size: 1.1em;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.new-game-button:hover:not(:disabled) {
    background-color: #218838; /* Darker green on hover */
    transform: translateY(-1px);
}

.new-game-button:active {
    transform: translateY(0);
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    body {
        padding: 0.5em;
    }
    
    .game {
        padding: 1em;
        border-radius: 0;
        min-height: 100vh;
        justify-content: flex-start;
    }
    
    header {
        margin-bottom: 1em;
    }
    
    .form-container {
        padding: 1em;
        margin-bottom: 1em;
    }
    
    form {
        gap: 0.8em;
    }
    
    input[type="text"], input[type="number"] {
        font-size: 1rem;
        padding: 10px 12px;
    }
    
    button {
        width: 100%;
        padding: 12px;
        font-size: 1rem;
    }
    
    .number-box {
        min-width: 25px;
        min-height: 25px;
        font-size: 0.75rem;
    }
    
    #number-container {
        gap: 4px;
        margin-bottom: 1em;
    }
    
    .guess-row {
        gap: 3px;
    }
    
    .message {
        margin: 0.5em 0;
    }
    
    .instructions-back {
        font-size: 0.85rem;
        padding: 0.8em;
    }
    
    .share-container {
        padding: 1em;
        margin-bottom: 1em;
    }
    
    .share-button {
        width: auto;
        margin: 0.25em 0;
        font-size: 0.9em;
        padding: 12px 24px;
        min-width: 180px;
    }
    
    .new-game-button {
        width: 90%;
        margin: 0.5em 0;
        font-size: 1rem;
        padding: 12px;
    }
    
    /* CHANGED: Keep horizontal layout on mobile too */
    .guess-block {
        flex-direction: row;
        gap: 0.5em;
        align-items: center;
    }
    
    .feedback-block {
        font-size: 0.75em;
        min-width: auto;
    }
    
    #game-container {
        max-height: 250px;
    }
}

/* Landscape mobile optimization */
@media (max-width: 768px) and (orientation: landscape) {
    .game {
        max-width: 600px;
        padding: 1em 2em;
    }
    
    #game-container {
        max-height: 200px;
    }
    
    form {
        flex-direction: row;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    input[type="text"], input[type="number"] {
        max-width: 200px;
    }
    
    button {
        width: auto;
        min-width: 100px;
    }
}

/* Very small screens */
@media (max-width: 320px) {
    .number-box {
        min-width: 28px;
        min-height: 28px;
        font-size: 0.8rem;
    }
    
    #number-container {
        gap: 4px;
    }
    
    .guess-row {
        gap: 3px;
    }
    
    .form-container {
        padding: 0.8em;
    }
    
    .feedback-block {
        font-size: 0.7em;
    }
}

/* Keep horizontal layout across all screen sizes */
@media (min-width: 481px) {
    .guess-block {
        flex-direction: row;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .number-box {
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
}

/* Firefox mobile specific fixes */
@supports (-moz-appearance: none) {
    @media (max-width: 768px) {
        .guess-block {
            width: auto !important;
            left: 0.5em;
            right: 0.5em;
            margin-left: 0;
            margin-right: 0;
            position: relative;
        }
        
        #game-container {
            padding: 0 0.5em;
        }
    }
}