/* css/pages/wordmaxxing.css */

#wordmaxxing-page {
    max-width: 800px;
    margin: 0 auto;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
}

.game-header h2 {
    margin: 0;
}

.score-badge {
    background-color: var(--nav-hover-bg);
    color: var(--nav-hover-text);
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 1.2em;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.game-instructions {
    opacity: 0.8;
    font-style: italic;
    margin-bottom: 30px;
}

/* Word Display Tiles */
.word-display-container {
    display: flex;
    justify-content: center;
    gap: 5px; /* Reduced gap */
    margin-bottom: 40px;
    flex-wrap: nowrap; /* Prevent wrapping */
    width: 100%; /* Ensure container takes full width */
}

.letter-tile {
    /* Use flex-grow/shrink to allow scaling, but keep a max-width */
    flex: 0 1 40px; 
    
    /* Aspect ratio helps maintain shape as width shrinks */
    aspect-ratio: 4 / 5; 
    height: auto; /* Let height adjust based on width */
    
    /* Border and styling */
    border-bottom: 4px solid var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    
    /* Dynamic font size: 
       - Preferred: 2em (desktop)
       - Minimum: 1em (to prevent tiny text)
       - Viewport-based: 5vw (scales with screen width)
    */
    font-size: clamp(1em, 5vw, 2em);
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-color);
    
    /* Ensure minimum tap target size/visibility but allow shrinking */
    min-width: 20px; 
}

.letter-tile.revealed {
    border-bottom-color: var(--accent-pink);
    animation: popIn 0.3s ease forwards;
}

@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    80% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Virtual Keyboard */
.keyboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(35px, 1fr));
    gap: 8px;
    margin-bottom: 20px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.key-btn {
    aspect-ratio: 1/1;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-weight: 700;
    cursor: pointer;
    color: var(--text-color);
    transition: all 0.2s ease;
    font-family: 'Nunito', sans-serif;
    font-size: 1.1em;
}

.key-btn:hover:not(:disabled) {
    background-color: var(--nav-hover-bg);
    color: white;
    transform: translateY(-2px);
}

.key-btn:disabled {
    opacity: 0.5;
    cursor: default;
    background-color: rgba(0,0,0,0.1);
    transform: none;
}

.key-btn.used {
    background-color: rgba(0,0,0,0.2);
    border-color: transparent;
}

.key-btn.correct {
    background-color: var(--completed-color) !important; /* Force Green */
    color: white !important;
    border-color: var(--completed-color) !important;
    opacity: 1 !important; 
}

/* Ensure used (incorrect) keys stay grey */
.key-btn.used {
    background-color: rgba(0,0,0,0.2);
    border-color: transparent;
    opacity: 0.5;
}


html.dark-mode .key-btn.used {
    background-color: rgba(255,255,255,0.1);
}

/* Full Word Guess Form */
.separator-text {
    margin: 20px 0;
    font-weight: 700;
    opacity: 0.5;
    display: flex;
    align-items: center;
}

.separator-text::before, .separator-text::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
    margin: 0 10px;
}

#full-guess-form {
    display: flex;
    gap: 10px;
    justify-content: center;
    max-width: 500px;
    margin: 0 auto;
}

#full-word-input {
    flex-grow: 1;
    padding: 10px;
    border-radius: 20px;
    border: 2px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    text-transform: uppercase;
    font-weight: 700;
    text-align: center;
}

/* Status Messages */
.game-status-message {
    min-height: 1.5em;
    margin-bottom: 20px;
    font-weight: 700;
    font-size: 1.2em;
}
.game-status-message.win { color: var(--completed-color); }
.game-status-message.error { color: var(--danger-color); }

.history-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.history-pill {
    background-color: rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.9em;
    cursor: default;
    transition: transform 0.2s;
}

html.dark-mode .history-pill {
    background-color: rgba(255,255,255,0.05);
}

.history-pill:hover {
    transform: translateY(-2px);
    border-color: var(--nav-hover-bg);
    background-color: var(--nav-hover-bg);
    color: white;
}

.victory-sentence {
    background-color: rgba(0,0,0,0.05);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 1.1em;
    line-height: 1.4;
    border-left: 4px solid var(--accent-pink);
}

.highlight-word {
    font-weight: 900;
    color: var(--accent-pink);
    text-transform: uppercase;
}

/* Tooltip for History Pills */
.history-pill {
    position: relative;
}

/* Custom tooltip logic */
.history-pill:hover::after {
    content: attr(data-sentence);
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85em;
    width: max-content;
    max-width: 250px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    white-space: pre-wrap; /* This allows the \n to create a new line */
    text-align: center;    /* Optional: Centers the text nicely */
}

/* Tooltip arrow */
.history-pill:hover::before {
    content: '';
    position: absolute;
    bottom: 110%; /* Just below the tooltip */
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
    z-index: 10;
}

.prize-note {
    font-weight: 700;
    color: var(--completed-color); /* Green */
    font-size: 0.9em;
    margin-top: -20px; /* Pull it up closer to instructions */
    margin-bottom: 30px;
    background-color: rgba(0, 200, 0, 0.1);
    padding: 5px 15px;
    border-radius: 15px;
    display: inline-block;
}

#current-score {
    display: inline-block !important; /* Critical for transform to work */
    transition: color 0.2s; /* Smooth color transition base */
}

@keyframes damage-flash {
    0% { 
        transform: scale(1) rotate(0deg); 
        /* No background color set here, uses default */
    }
    10% { 
        transform: scale(1.25) rotate(-3deg); 
        background-color: #ff0000 !important; /* Bright Red */
        box-shadow: 0 0 20px rgba(255, 0, 0, 0.8); /* Red Glow */
        color: white;
        border-color: #ff0000;
    }
    30% { 
        transform: scale(1.25) rotate(3deg); 
        background-color: #ff0000 !important;
    }
    50% { 
        transform: scale(1.25) rotate(-3deg); 
        background-color: #ff0000 !important;
    }
    100% { 
        transform: scale(1) rotate(0deg); 
        /* Returns to default styles */
    }
}

.score-drop-anim {
    animation: damage-flash 0.5s ease-out forwards;
    will-change: transform, background-color, box-shadow;
}