/* ==========================================================================
   Word Hunt — 5x5 Word Puzzle Game
   A premium word puzzle experience inspired by Wordle / NYT Games
   ========================================================================== */

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

:root {
    --wh-blue: #2563eb;
    --wh-blue-light: #93c5fd;
    --wh-blue-bg: #eff6ff;
    --wh-green: #059669;
    --wh-green-light: #d1fae5;
    --wh-red: #e11d48;
    --wh-red-light: #ffe4e6;
    --wh-amber: #d97706;
    --wh-amber-light: #fef3c7;
    --wh-dark: #1e293b;
    --wh-dark-mid: #475569;
    --wh-gray: #94a3b8;
    --wh-gray-light: #e2e8f0;
    --wh-gray-lighter: #f1f5f9;
    --wh-bg: #f8fafc;
    --wh-white: #ffffff;
    --wh-radius: 8px;
    --wh-radius-lg: 12px;
    --wh-radius-xl: 16px;
    --wh-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --wh-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --wh-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --wh-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --wh-transition: 150ms ease;
    --wh-transition-slow: 300ms ease;
    --wh-cell-size: 62px;
    --wh-grid-gap: 4px;
    --wh-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

/* --------------------------------------------------------------------------
   1. Page Layout
   -------------------------------------------------------------------------- */
.wordhunt-page {
    margin: 0;
    padding: 0;
    font-family: var(--wh-font);
    background-color: var(--wh-bg);
    color: var(--wh-dark);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.wordhunt-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 0 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* --------------------------------------------------------------------------
   2. Header
   -------------------------------------------------------------------------- */
.wordhunt-header {
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    background-color: var(--wh-white);
    border-bottom: 1px solid var(--wh-gray-light);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    overflow: visible;
}

.wordhunt-logo {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--wh-dark);
    letter-spacing: -0.02em;
    white-space: nowrap;
    text-decoration: none;
}

.wordhunt-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-pill-wrapper {
    position: relative;
}

.user-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background-color: var(--wh-gray-lighter);
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--wh-dark);
    white-space: nowrap;
    border: none;
    cursor: pointer;
    font-family: var(--wh-font);
    transition: background-color var(--wh-transition);
}

.user-pill:hover {
    background-color: var(--wh-gray-light);
}

.user-pill-chevron {
    opacity: 0.5;
    transition: transform var(--wh-transition);
}

.user-pill-wrapper.open .user-pill-chevron {
    transform: rotate(180deg);
}

.user-pill .level-emoji {
    font-size: 1rem;
    line-height: 1;
}

/* User dropdown menu */
.user-dropdown {
    position: fixed;
    min-width: 180px;
    background: var(--wh-white);
    border-radius: var(--wh-radius-lg);
    box-shadow: var(--wh-shadow-lg);
    border: 1px solid var(--wh-gray-light);
    padding: 4px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity var(--wh-transition), transform var(--wh-transition), visibility var(--wh-transition);
}

.user-pill-wrapper.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    font-family: var(--wh-font);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--wh-dark);
    border-radius: var(--wh-radius);
    cursor: pointer;
    transition: background-color var(--wh-transition);
    text-align: left;
}

.user-dropdown-item:hover {
    background-color: var(--wh-gray-lighter);
}

.user-dropdown-item--danger {
    color: var(--wh-red);
}

.user-dropdown-item--danger:hover {
    background-color: var(--wh-red-light);
}

/* Username change hint */
.username-hint {
    font-size: 0.75rem;
    color: var(--wh-gray);
    margin-top: 4px;
}

.streak-display {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--wh-dark);
    white-space: nowrap;
}

.streak-display .streak-fire {
    font-size: 1.1rem;
}

.streak-display .streak-count {
    min-width: 1ch;
}

.header-link {
    font-size: 0.75rem;
    color: var(--wh-gray);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--wh-transition);
}

.header-link:hover {
    color: var(--wh-dark);
}

.header-link-back {
    font-size: 0.75rem;
    color: var(--wh-gray);
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--wh-transition);
}

.header-link-back:hover {
    color: var(--wh-blue);
}

/* --------------------------------------------------------------------------
   3. Score Display (Hero + Pills)
   -------------------------------------------------------------------------- */
.wh-score-hero {
    text-align: center;
    padding: 10px 0 2px;
}

.wh-score-number {
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--wh-blue);
    line-height: 1;
    letter-spacing: -0.02em;
    transition: color var(--wh-transition);
}

.wh-score-label {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--wh-gray);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 2px;
}

.wh-stats-row {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 6px 0 8px;
}

.wh-stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 12px;
    background-color: var(--wh-white);
    border: 1px solid var(--wh-gray-light);
    border-radius: 999px;
    font-size: 0.78rem;
}

.wh-stat-icon {
    font-size: 0.7rem;
    line-height: 1;
}

.wh-stat-val {
    font-weight: 700;
    color: var(--wh-dark);
}

.wh-stat-lbl {
    font-weight: 400;
    color: var(--wh-gray);
    font-size: 0.72rem;
}

/* --------------------------------------------------------------------------
   4. Game Grid
   -------------------------------------------------------------------------- */
#game-grid {
    display: grid;
    grid-template-columns: repeat(5, var(--wh-cell-size));
    grid-template-rows: repeat(5, var(--wh-cell-size));
    gap: var(--wh-grid-gap);
    margin: 8px auto 16px;
    position: relative;
    touch-action: manipulation;
}

#game-grid.loading {
    pointer-events: none;
}

#game-grid.loading::after {
    content: '';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

#game-grid.loading .grid-cell {
    background: linear-gradient(90deg,
        var(--wh-gray-lighter) 25%,
        var(--wh-gray-light) 50%,
        var(--wh-gray-lighter) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-color: transparent;
    color: transparent;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 32px;
    height: 32px;
    border: 3px solid var(--wh-gray-light);
    border-top-color: var(--wh-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    z-index: 11;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* --------------------------------------------------------------------------
   5. Grid Cells
   -------------------------------------------------------------------------- */
.grid-cell {
    width: var(--wh-cell-size);
    height: var(--wh-cell-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    font-weight: 700;
    text-transform: uppercase;
    border-radius: var(--wh-radius);
    transition:
        background-color var(--wh-transition),
        border-color var(--wh-transition),
        color var(--wh-transition),
        transform var(--wh-transition),
        box-shadow var(--wh-transition);
    user-select: none;
    -webkit-user-select: none;
    line-height: 1;
    letter-spacing: 0.02em;
}

/* Border cells — the playable outer ring */
.border-cell {
    background-color: var(--wh-white);
    border: 2px solid var(--wh-gray-light);
    color: var(--wh-dark);
    cursor: pointer;
}

.border-cell:hover {
    border-color: var(--wh-blue-light);
    box-shadow: var(--wh-shadow-sm);
}

.border-cell:active {
    transform: scale(0.95);
}

/* Revealed — correct letter found */
.border-cell.revealed {
    background-color: var(--wh-green);
    border-color: var(--wh-green);
    color: var(--wh-white);
    font-weight: 800;
    cursor: default;
    animation: pop 300ms ease;
}

.border-cell.revealed:hover {
    border-color: var(--wh-green);
    box-shadow: none;
}

/* Active word — currently selected word path */
.border-cell.active-word {
    border-color: var(--wh-blue);
    background-color: var(--wh-blue-bg);
    color: var(--wh-blue);
    font-weight: 800;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

/* Typing cursor — the cell currently being typed into */
.border-cell.typing-cursor {
    border-color: var(--wh-blue);
    border-width: 2.5px;
    background-color: var(--wh-white);
    color: var(--wh-blue);
    font-weight: 800;
    animation: pulse 1.2s ease-in-out infinite;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Incorrect guess */
.border-cell.incorrect {
    animation: shake 400ms ease;
    border-color: var(--wh-red);
    background-color: var(--wh-red-light);
}

/* Center cells — the non-playable inner area */
.center-cell {
    background-color: transparent;
    border: none;
    color: var(--wh-gray);
    cursor: default;
    font-size: 0.75rem;
    font-weight: 400;
}

/* --------------------------------------------------------------------------
   6. Alphabet Overlay
   -------------------------------------------------------------------------- */
#alphabet-overlay {
    position: absolute;
    /* Inset inside the 3x3 center area */
    top: calc(var(--wh-cell-size) + var(--wh-grid-gap) + 10px);
    left: calc(var(--wh-cell-size) + var(--wh-grid-gap) + 10px);
    width: calc(3 * var(--wh-cell-size) + 2 * var(--wh-grid-gap) - 20px);
    height: calc(3 * var(--wh-cell-size) + 2 * var(--wh-grid-gap) - 20px);
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    gap: 4px;
    padding: 2px;
    z-index: 5;
    pointer-events: auto;
}

.alphabet-tile {
    /* 6 per row: (100% - 5 gaps) / 6 */
    width: calc((100% - 20px) / 6);
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    font-family: var(--wh-font);
    text-transform: uppercase;
    background-color: var(--wh-gray-lighter);
    color: var(--wh-dark);
    border: 1px solid var(--wh-gray-light);
    border-radius: 6px;
    cursor: default;
    transition:
        background-color var(--wh-transition),
        color var(--wh-transition),
        transform var(--wh-transition),
        box-shadow var(--wh-transition),
        opacity var(--wh-transition);
    user-select: none;
    -webkit-user-select: none;
    line-height: 1;
}

.alphabet-tile:hover {
    transform: translateY(-1px);
    box-shadow: var(--wh-shadow-sm);
}

.alphabet-tile.used-correct {
    background-color: var(--wh-green);
    border-color: var(--wh-green);
    color: var(--wh-white);
}

.alphabet-tile.used-wrong {
    background-color: var(--wh-dark-mid);
    border-color: var(--wh-dark-mid);
    color: var(--wh-white);
    opacity: 0.5;
}

/* --------------------------------------------------------------------------
   7. Word Action Bar
   -------------------------------------------------------------------------- */
#word-action-bar {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 0;
    width: 100%;
    max-width: 500px;
}

#word-action-bar.visible {
    display: flex;
}

.action-btn {
    padding: 10px 24px;
    border: none;
    border-radius: var(--wh-radius);
    font-family: var(--wh-font);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition:
        background-color var(--wh-transition),
        transform var(--wh-transition),
        box-shadow var(--wh-transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.action-btn:active {
    transform: scale(0.96);
}

.action-btn-backspace {
    background-color: var(--wh-gray-lighter);
    color: var(--wh-dark-mid);
    border: 1px solid var(--wh-gray-light);
}

.action-btn-backspace:hover {
    background-color: var(--wh-gray-light);
}

.action-btn-submit {
    background-color: var(--wh-blue);
    color: var(--wh-white);
    box-shadow: var(--wh-shadow-sm);
}

.action-btn-submit:hover {
    background-color: #1d4ed8;
    box-shadow: var(--wh-shadow);
}

.action-btn-submit:disabled {
    background-color: var(--wh-gray-light);
    color: var(--wh-gray);
    cursor: not-allowed;
    box-shadow: none;
}

/* --------------------------------------------------------------------------
   8. Message Area
   -------------------------------------------------------------------------- */
#message-area {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.message-toast {
    padding: 10px 20px;
    border-radius: var(--wh-radius);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--wh-font);
    box-shadow: var(--wh-shadow-md);
    animation: slideDown 300ms ease forwards;
    pointer-events: auto;
    white-space: nowrap;
}

.message-toast.message-fade-out {
    animation: fadeOut 300ms ease forwards;
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-10px); }
}

.message-success {
    background-color: var(--wh-green);
    color: var(--wh-white);
}

.message-error {
    background-color: var(--wh-red);
    color: var(--wh-white);
}

.message-warning {
    background-color: var(--wh-amber);
    color: var(--wh-white);
}

.message-info {
    background-color: var(--wh-blue);
    color: var(--wh-white);
}

/* --------------------------------------------------------------------------
   9. Overlays — shared
   -------------------------------------------------------------------------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    animation: fadeIn 250ms ease;
    padding: 16px;
}

.overlay.visible {
    display: flex;
}

.overlay-card {
    background-color: var(--wh-white);
    border-radius: var(--wh-radius-xl);
    box-shadow: var(--wh-shadow-lg);
    padding: 32px 28px;
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
    width: 100%;
    max-width: 420px;
    animation: slideDown 300ms ease;
    position: relative;
}

.overlay-close {
    position: absolute;
    top: 12px;
    right: 14px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--wh-gray);
    cursor: pointer;
    border-radius: 50%;
    transition: background-color var(--wh-transition), color var(--wh-transition);
    font-family: var(--wh-font);
    line-height: 1;
}

.overlay-close:hover {
    background-color: var(--wh-gray-lighter);
    color: var(--wh-dark);
}

/* --------------------------------------------------------------------------
   10. Auth Overlay
   -------------------------------------------------------------------------- */
#auth-overlay .overlay-card {
    max-width: 400px;
    padding: 28px 24px;
}

.auth-tabs {
    display: flex;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--wh-gray-light);
}

.auth-tab {
    flex: 1;
    padding: 10px 0;
    background: none;
    border: none;
    font-family: var(--wh-font);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--wh-gray);
    cursor: pointer;
    position: relative;
    transition: color var(--wh-transition);
}

.auth-tab.active {
    color: var(--wh-blue);
}

.auth-tab.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--wh-blue);
    border-radius: 1px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-field label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--wh-dark-mid);
}

.auth-field input {
    padding: 10px 14px;
    border: 1.5px solid var(--wh-gray-light);
    border-radius: var(--wh-radius);
    font-family: var(--wh-font);
    font-size: 0.95rem;
    color: var(--wh-dark);
    background-color: var(--wh-white);
    transition: border-color var(--wh-transition), box-shadow var(--wh-transition);
    outline: none;
}

.auth-field input:focus {
    border-color: var(--wh-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.auth-field input::placeholder {
    color: var(--wh-gray);
}

.auth-submit {
    padding: 11px 20px;
    background-color: var(--wh-blue);
    color: var(--wh-white);
    border: none;
    border-radius: var(--wh-radius);
    font-family: var(--wh-font);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--wh-transition), transform var(--wh-transition);
}

.auth-submit:hover {
    background-color: #1d4ed8;
}

.auth-submit:active {
    transform: scale(0.98);
}

.auth-submit:disabled {
    background-color: var(--wh-gray-light);
    color: var(--wh-gray);
    cursor: not-allowed;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--wh-gray);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background-color: var(--wh-gray-light);
}

.auth-google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 20px;
    background-color: var(--wh-white);
    border: 1.5px solid var(--wh-gray-light);
    border-radius: var(--wh-radius);
    font-family: var(--wh-font);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--wh-dark);
    cursor: pointer;
    transition: background-color var(--wh-transition), border-color var(--wh-transition), box-shadow var(--wh-transition);
}

.auth-google-btn:hover {
    background-color: var(--wh-gray-lighter);
    border-color: var(--wh-gray);
    box-shadow: var(--wh-shadow-sm);
}

.auth-google-btn img,
.auth-google-btn svg {
    width: 18px;
    height: 18px;
}

.auth-error {
    padding: 10px 14px;
    background-color: var(--wh-red-light);
    color: var(--wh-red);
    border-radius: var(--wh-radius);
    font-size: 0.8rem;
    font-weight: 500;
    display: none;
}

.auth-error.visible {
    display: block;
}

/* --------------------------------------------------------------------------
   11. Win Overlay
   -------------------------------------------------------------------------- */
#win-overlay .overlay-card {
    text-align: center;
    padding: 36px 28px 28px;
}

.win-title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--wh-dark);
    margin-bottom: 4px;
}

.win-subtitle {
    font-size: 0.9rem;
    color: var(--wh-gray);
    margin-bottom: 20px;
}

.win-score-display {
    font-size: 3.5rem;
    font-weight: 800;
    color: var(--wh-blue);
    line-height: 1;
    margin-bottom: 4px;
    animation: pop 500ms ease;
}

.win-score-label {
    font-size: 0.8rem;
    color: var(--wh-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 16px;
}

.win-xp {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    background-color: var(--wh-amber-light);
    color: var(--wh-amber);
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 20px;
    animation: pop 600ms ease 200ms both;
}

.win-sync-notice {
    margin: 0 auto 16px;
    max-width: 320px;
    padding: 8px 14px;
    background-color: var(--wh-amber-light);
    color: var(--wh-amber);
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
}

.win-stats-grid {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
}

.win-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.win-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--wh-dark);
}

.win-stat-label {
    font-size: 0.7rem;
    color: var(--wh-gray);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.win-share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 32px;
    background-color: var(--wh-blue);
    color: var(--wh-white);
    border: none;
    border-radius: var(--wh-radius);
    font-family: var(--wh-font);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--wh-transition), transform var(--wh-transition);
    margin-bottom: 24px;
    box-shadow: var(--wh-shadow);
}

.win-share-btn:hover {
    background-color: #1d4ed8;
}

.win-share-btn:active {
    transform: scale(0.97);
}

.win-leaderboard-section {
    text-align: left;
}

.win-leaderboard-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--wh-dark);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
}

/* --------------------------------------------------------------------------
   12. Already Played Overlay
   -------------------------------------------------------------------------- */
#already-played-overlay .overlay-card {
    text-align: center;
    padding: 36px 28px;
}

.already-played-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--wh-dark);
    margin-bottom: 4px;
}

.already-played-subtitle {
    font-size: 0.9rem;
    color: var(--wh-gray);
    margin-bottom: 20px;
}

.already-played-score {
    font-size: 3rem;
    font-weight: 800;
    color: var(--wh-dark-mid);
    line-height: 1;
    margin-bottom: 4px;
}

.already-played-label {
    font-size: 0.8rem;
    color: var(--wh-gray);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.already-played-time {
    font-size: 0.95rem;
    color: var(--wh-dark-mid);
    font-weight: 500;
    margin-bottom: 20px;
}

.already-played-message {
    font-size: 0.9rem;
    color: var(--wh-gray);
    padding: 12px 16px;
    background-color: var(--wh-gray-lighter);
    border-radius: var(--wh-radius);
}

/* --------------------------------------------------------------------------
   13. Leaderboard Table
   -------------------------------------------------------------------------- */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.leaderboard-table th {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--wh-gray);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 6px 8px;
    text-align: left;
    border-bottom: 1px solid var(--wh-gray-light);
}

.leaderboard-table th:last-child,
.leaderboard-table td:last-child {
    text-align: right;
}

.leaderboard-table td {
    padding: 8px;
    vertical-align: middle;
    border-bottom: 1px solid var(--wh-gray-lighter);
}

.leaderboard-table tr:nth-child(even) td {
    background-color: var(--wh-gray-lighter);
}

.leaderboard-table tr.current-player td {
    background-color: var(--wh-blue-bg);
    font-weight: 600;
}

.leaderboard-rank {
    font-weight: 700;
    min-width: 2ch;
}

.leaderboard-name {
    display: flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.leaderboard-name .level-emoji {
    font-size: 0.9rem;
}

.leaderboard-medal {
    font-size: 1rem;
    line-height: 1;
}

/* --------------------------------------------------------------------------
   14. All-Time Stats Modal
   -------------------------------------------------------------------------- */
#alltime-modal .overlay-card {
    max-width: 480px;
    padding: 28px 24px;
}

.alltime-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--wh-dark);
    margin-bottom: 16px;
}

.period-filter {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
}

.period-btn {
    padding: 6px 16px;
    border: 1.5px solid var(--wh-gray-light);
    border-radius: 999px;
    background: none;
    font-family: var(--wh-font);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--wh-dark-mid);
    cursor: pointer;
    transition: all var(--wh-transition);
}

.period-btn:hover {
    border-color: var(--wh-blue-light);
}

.period-btn.active {
    background-color: var(--wh-blue);
    border-color: var(--wh-blue);
    color: var(--wh-white);
}

.alltime-summary {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.alltime-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 14px;
    background-color: var(--wh-gray-lighter);
    border-radius: var(--wh-radius);
    flex: 1;
    min-width: 80px;
}

.alltime-chip-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--wh-dark);
}

.alltime-chip-label {
    font-size: 0.65rem;
    color: var(--wh-gray);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.alltime-table-wrapper {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--wh-gray-light);
    border-radius: var(--wh-radius);
}

.alltime-table-wrapper::-webkit-scrollbar {
    width: 6px;
}

.alltime-table-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.alltime-table-wrapper::-webkit-scrollbar-thumb {
    background: var(--wh-gray-light);
    border-radius: 3px;
}

/* --------------------------------------------------------------------------
   14a. Hint text
   -------------------------------------------------------------------------- */
.wh-hint {
    font-size: 0.72rem;
    color: var(--wh-gray);
    text-align: center;
    margin: 0 0 6px;
    line-height: 1.4;
    max-width: 340px;
}

/* --------------------------------------------------------------------------
   14b. Scoring Guide
   -------------------------------------------------------------------------- */
.wh-scoring {
    display: flex;
    justify-content: center;
    gap: 6px;
    width: 100%;
    max-width: 500px;
    margin: 4px 0 8px;
    flex-wrap: wrap;
}

.wh-scoring-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--wh-dark-mid);
    white-space: nowrap;
}

.wh-scoring-item strong {
    font-weight: 700;
}

.wh-scoring-icon {
    font-size: 0.7rem;
    line-height: 1;
}

.wh-scoring-good {
    background: var(--wh-green-light);
    color: #065f46;
}

.wh-scoring-bad {
    background: var(--wh-red-light);
    color: #9f1239;
}

/* --------------------------------------------------------------------------
   14c. Friends UI
   -------------------------------------------------------------------------- */
.wh-friends-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--wh-gray-light);
    border-radius: 50%;
    background: var(--wh-white);
    cursor: pointer;
    color: var(--wh-dark-mid);
    transition: all var(--wh-transition);
}

.wh-friends-btn:hover {
    border-color: var(--wh-blue-light);
    color: var(--wh-blue);
}

.wh-friends-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--wh-red);
    color: var(--wh-white);
    font-size: 0.6rem;
    font-weight: 700;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.wh-friends-badge-inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--wh-red);
    color: var(--wh-white);
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 999px;
    margin-left: 6px;
}

.wh-friend-search {
    margin-bottom: 16px;
}

.wh-friend-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--wh-gray-light);
    border-radius: var(--wh-radius);
    font-family: var(--wh-font);
    font-size: 0.85rem;
    color: var(--wh-dark);
    outline: none;
    transition: border-color var(--wh-transition);
}

.wh-friend-search input:focus {
    border-color: var(--wh-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.wh-friend-search-results {
    margin-top: 6px;
    max-height: 200px;
    overflow-y: auto;
}

.wh-friend-result, .wh-friend-item, .wh-pending-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: var(--wh-radius);
    transition: background var(--wh-transition);
}

.wh-friend-result:hover, .wh-friend-item:hover {
    background: var(--wh-gray-lighter);
}

.wh-friend-info {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.wh-friend-name {
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--wh-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wh-friend-meta {
    font-size: 0.7rem;
    color: var(--wh-gray);
}

.wh-friend-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.wh-friend-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 6px;
    font-family: var(--wh-font);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--wh-transition);
}

.wh-friend-btn-add {
    background: var(--wh-blue);
    color: var(--wh-white);
}

.wh-friend-btn-add:hover {
    background: #1d4ed8;
}

.wh-friend-btn-accept {
    background: var(--wh-green);
    color: var(--wh-white);
}

.wh-friend-btn-decline, .wh-friend-btn-remove {
    background: var(--wh-gray-lighter);
    color: var(--wh-dark-mid);
}

.wh-friend-btn-decline:hover, .wh-friend-btn-remove:hover {
    background: var(--wh-red-light);
    color: var(--wh-red);
}

.wh-friend-btn-pending {
    background: var(--wh-gray-lighter);
    color: var(--wh-gray);
    cursor: default;
}

.wh-friend-btn-friends {
    background: var(--wh-green-light);
    color: #065f46;
    cursor: default;
}

.wh-friend-code-section {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: var(--wh-gray-lighter);
    border-radius: var(--wh-radius);
    margin-bottom: 16px;
}

.wh-friend-code-label {
    font-size: 0.75rem;
    color: var(--wh-gray);
}

.wh-friend-code {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--wh-blue);
    letter-spacing: 0.05em;
}

.wh-friend-code-copy {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--wh-gray);
    padding: 2px;
    transition: color var(--wh-transition);
}

.wh-friend-code-copy:hover {
    color: var(--wh-blue);
}

.wh-friend-section-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--wh-dark-mid);
    margin: 0 0 8px;
    display: flex;
    align-items: center;
}

.wh-friend-empty {
    font-size: 0.8rem;
    color: var(--wh-gray);
    text-align: center;
    padding: 16px;
}

.wh-friend-score {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--wh-green);
}

.wh-friend-score.not-played {
    color: var(--wh-gray);
    font-weight: 400;
}

/* Leaderboard filter tabs */
.wh-lb-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 8px;
    border: 1px solid var(--wh-gray-light);
    border-radius: var(--wh-radius);
    overflow: hidden;
}

.wh-lb-tab {
    flex: 1;
    padding: 6px 0;
    background: var(--wh-white);
    border: none;
    font-family: var(--wh-font);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--wh-dark-mid);
    cursor: pointer;
    transition: all var(--wh-transition);
}

.wh-lb-tab.active {
    background: var(--wh-blue);
    color: var(--wh-white);
}

.wh-lb-tab:not(.active):hover {
    background: var(--wh-gray-lighter);
}

/* --------------------------------------------------------------------------
   15. Animations
   -------------------------------------------------------------------------- */
@keyframes popIn {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.border-cell.pop-in {
    animation: popIn 350ms ease;
}

@keyframes pop {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

@keyframes pulse {
    0%, 100% { border-color: var(--wh-blue); }
    50% { border-color: var(--wh-blue-light); }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------------------
   16. Ad Containers
   -------------------------------------------------------------------------- */
.ad-side-left,
.ad-side-right {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 160px;
    min-height: 600px;
    display: none;
    flex-direction: column;
    align-items: center;
    padding-top: 12px;
}

.ad-side-left {
    left: 20px;
}

.ad-side-right {
    right: 20px;
}

.ad-top,
.ad-bottom {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 8px 0;
}

.ad-completion {
    margin-top: 20px;
    display: flex;
    justify-content: center;
    width: 100%;
}

.ad-label {
    font-size: 0.6rem;
    color: var(--wh-gray);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
    text-align: center;
}

/* Hide all ads when user has no-ads */
body.no-ads .ad-side-left,
body.no-ads .ad-side-right,
body.no-ads .ad-top,
body.no-ads .ad-bottom,
body.no-ads .ad-completion {
    display: none !important;
}

/* --------------------------------------------------------------------------
   17. Responsive Design
   -------------------------------------------------------------------------- */

/* Mobile (up to 767px) — fill screen width */
@media (max-width: 767px) {
    #alphabet-overlay {
        top: calc(var(--wh-cell-size) + var(--wh-grid-gap) + 6px);
        left: calc(var(--wh-cell-size) + var(--wh-grid-gap) + 6px);
        width: calc(3 * var(--wh-cell-size) + 2 * var(--wh-grid-gap) - 12px);
        height: calc(3 * var(--wh-cell-size) + 2 * var(--wh-grid-gap) - 12px);
        gap: 5px;
    }

    :root {
        /* 5 cells + 4 gaps, with 12px padding each side */
        --wh-cell-size: calc((100vw - 24px - 16px) / 5);
        --wh-grid-gap: 4px;
    }

    .wordhunt-container {
        padding: 0 12px;
    }

    .wordhunt-header {
        padding: 8px 12px;
    }

    .wordhunt-logo {
        font-size: 1.05rem;
    }

    .user-pill {
        padding: 3px 8px;
        font-size: 0.72rem;
    }

    .wh-score-number {
        font-size: 2.2rem;
    }

    .wh-stats-row {
        gap: 5px;
    }

    .wh-stat-pill {
        padding: 4px 8px;
        font-size: 0.7rem;
        gap: 3px;
    }

    .grid-cell {
        font-size: 1.2rem;
    }

    .alphabet-tile {
        font-size: 0.6rem;
    }

    .overlay-card {
        padding: 24px 20px;
    }

    #auth-overlay .overlay-card {
        width: 90vw;
        max-width: none;
    }

    .win-score-display {
        font-size: 2.8rem;
    }

    .action-btn {
        padding: 8px 18px;
        font-size: 0.85rem;
    }
}

/* Larger phones (480px – 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .grid-cell {
        font-size: 1.4rem;
    }

    .alphabet-tile {
        font-size: 0.7rem;
    }
}

/* Tablets (768px+) */
@media (min-width: 768px) {
    :root {
        --wh-cell-size: 76px;
    }

    .wordhunt-container {
        padding: 0 24px;
    }

    .alphabet-tile {
        font-size: 0.7rem;
    }

    .grid-cell {
        font-size: 1.5rem;
    }

    .ad-top,
    .ad-bottom {
        display: none;
    }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
    :root {
        --wh-cell-size: 80px;
    }

    .grid-cell {
        font-size: 1.6rem;
        border-radius: 10px;
    }

    .alphabet-tile {
        font-size: 0.75rem;
    }
}

/* Wide desktop — show side ads (1200px+) */
@media (min-width: 1200px) {
    .ad-side-left,
    .ad-side-right {
        display: flex;
    }

    .ad-top,
    .ad-bottom {
        display: none;
    }
}

/* --------------------------------------------------------------------------
   18. Loading State (handled above in #game-grid.loading)
   -------------------------------------------------------------------------- */

/* --------------------------------------------------------------------------
   19. Utility Classes
   -------------------------------------------------------------------------- */
.hidden {
    display: none !important;
}

.visible {
    display: flex;
}

.visible-block {
    display: block;
}

/* --------------------------------------------------------------------------
   20. Miscellaneous Polish
   -------------------------------------------------------------------------- */

/* Smooth scrolling for overlays */
.overlay-card {
    scrollbar-width: thin;
    scrollbar-color: var(--wh-gray-light) transparent;
}

/* Focus-visible outlines for accessibility */
.border-cell:focus-visible,
.action-btn:focus-visible,
.auth-tab:focus-visible,
.auth-submit:focus-visible,
.period-btn:focus-visible,
.win-share-btn:focus-visible,
.auth-google-btn:focus-visible {
    outline: 2px solid var(--wh-blue);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Selection color */
.wordhunt-page ::selection {
    background-color: var(--wh-blue-light);
    color: var(--wh-dark);
}
