/* ---------- Header ---------- */
.header {
    background: linear-gradient(90deg, var(--color-primary), var(--color-primary-dark));
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    box-shadow: var(--shadow-header);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    font-weight: 700;
    font-size: 20px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-icon {
    width: 38px;
    height: 38px;
    object-fit: contain;
}

.header-nav {
    display: flex;
    gap: 6px;
    align-items: center;
}

.header-nav a {
    position: relative;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 7px 16px;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.header-nav a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.08);
}

.header-nav a.active {
    color: white;
    background: rgba(255, 255, 255, 0.15);
}

.header-nav a.active::after {
    content: '';
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 2px;
    height: 2px;
    background: white;
    border-radius: 2px;
}

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
}

/* ---------- User menu trigger + dropdown ---------- */
.user-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.12);
    border: 0.5px solid rgba(255, 255, 255, 0.25);
    border-radius: 999px;
    padding: 4px 14px 4px 4px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.2s;
}

.user-trigger:hover {
    background: rgba(255, 255, 255, 0.18);
}

.user-avatar {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-avatar svg {
    width: 15px;
    height: 15px;
}

.user-avatar-lg {
    width: 48px;
    height: 48px;
    background: var(--color-primary-tint);
    color: var(--color-primary);
}

.user-avatar-lg svg {
    width: 26px;
    height: 26px;
}

.user-trigger .user-name-text {
    font-size: 15px;
    font-weight: 600;
    color: white;
}

.user-guest-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.user-trigger .user-guest-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

.user-trigger-chevron {
    display: flex;
    color: rgba(255, 255, 255, 0.8);
    transition: transform 0.2s;
}

.user-trigger-chevron svg {
    width: 16px;
    height: 16px;
}

.user-trigger[aria-expanded="true"] .user-trigger-chevron {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 260px;
    max-width: calc(100vw - 32px);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    padding: 20px;
    z-index: 200;
}

.user-dropdown-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
}

.user-dropdown-header .user-name-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.user-dropdown-header .user-guest-badge {
    background: var(--color-primary-tint);
    color: var(--color-primary);
}

.user-dropdown-divider {
    border-top: 0.5px solid var(--color-border);
    margin: 12px 0;
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 4px;
    border: none;
    background: none;
    color: var(--color-text);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
}

.user-dropdown-item svg {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    color: var(--color-text-secondary);
}

.user-dropdown-item:hover {
    color: var(--color-primary);
}

.user-dropdown-item:hover svg {
    color: var(--color-primary);
}

/* Overrides .user-dropdown-item:hover's primary-purple color above -- same specificity (one
   class + :hover), so this wins purely by appearing later in the stylesheet. */
.user-dropdown-item-danger,
.user-dropdown-item-danger svg,
.user-dropdown-item-danger:hover,
.user-dropdown-item-danger:hover svg {
    color: var(--color-danger);
}

.user-dropdown-item-danger:hover {
    opacity: 0.8;
}

.menu-btn {
    background: white;
    border: none;
    padding: 8px 18px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    color: var(--color-primary);
    text-decoration: none;
    transition: all 0.2s;
}

.menu-btn:hover {
    background: var(--color-primary-tint);
}

.menu-btn:active {
    transform: scale(0.98);
}

@media (max-width: 640px) {
    .header {
        padding: 8px 14px;
        top: 0;
    }

    .logo {
        font-size: 16px;
    }

    .logo-icon {
        width: 26px;
        height: 26px;
    }

    .header-nav {
        display: none;
    }

    /* Collapse the trigger down to just the avatar + chevron -- name and Guest badge already
       show prominently at the top of the dropdown once it's opened, so hiding them here loses
       nothing, and it's what keeps the header on a single row instead of wrapping. */
    .user-trigger {
        gap: 4px;
        padding: 4px 8px 4px 4px;
    }

    .user-trigger .user-name-text,
    .user-trigger .user-guest-badge {
        display: none;
    }

    .menu-btn {
        font-size: 12px;
        padding: 6px 14px;
    }
}

/* ---------- Status card ---------- */
.status-card {
    background: var(--color-surface);
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 24px;
}

@media (max-width: 640px) {
    .status-card {
        padding: 16px;
    }
}

.status-welcome {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 16px;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text-secondary);
    font-size: 15px;
    margin-bottom: 10px;
}

.status-row strong {
    color: var(--color-primary);
    font-weight: 600;
}

.status-icon {
    color: var(--color-primary);
    font-size: 18px;
    width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.points-display {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-top: 16px;
    padding-top: 16px;
    border-top: 0.5px solid var(--color-border);
}

.points-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-primary);
    display: inline-block;
}

.status-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 16px;
}

@media (max-width: 900px) {
    .status-stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .status-stat-card {
        padding: 16px 10px;
        gap: 8px;
    }

    .status-stat-icon-wrap {
        width: 44px;
        height: 44px;
    }

    .status-stat-icon-wrap svg {
        width: 20px;
        height: 20px;
    }

    .status-stat-label {
        font-size: 13px;
    }

    .status-stat-value {
        font-size: 22px;
    }
}

.status-stat-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 24px 16px;
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.status-stat-icon-wrap {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary-tint);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.status-stat-icon-wrap svg {
    width: 26px;
    height: 26px;
}

.status-stat-label {
    font-size: 14px;
    color: var(--color-text-secondary);
}

.status-stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--color-primary);
}

.status-divider {
    border-top: 0.5px solid var(--color-border);
    margin: 24px 0;
}

.status-highlight {
    display: flex;
    align-items: center;
    gap: 16px;
}

.status-highlight-icon-wrap {
    flex: 0 0 auto;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary-tint);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.status-highlight-icon-wrap svg {
    width: 26px;
    height: 26px;
}

.status-highlight-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 2px;
}

.status-highlight-desc {
    font-size: 14px;
    color: var(--color-text-secondary);
}

/* ---------- Ad slot (placeholder by default, admin-configurable via config/ads) ---------- */
.ad-space {
    background: linear-gradient(135deg, #F1EFE8 0%, #F9F8FC 100%);
    border: 1px dashed var(--color-border-strong);
    border-radius: var(--radius-md);
    padding: 40px 24px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
    margin-bottom: 32px;
    font-weight: 500;
}

/* Applied by applyAdSlots() when an admin sets a slot to a manual image ad. */
.ad-space.ad-image {
    background: none;
    border: none;
    padding: 0;
}

.ad-space.ad-image a {
    display: block;
}

.ad-space.ad-image img {
    display: block;
    width: 100%;
    max-width: 300px;
    height: auto;
    margin: 0 auto;
    border-radius: var(--radius-md);
}

/* ---------- Game tiles ---------- */
.game-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-bottom: 24px;
}

@media (min-width: 768px) {
    .game-grid {
        grid-template-columns: 1fr 1fr;
    }

    .game-grid > :nth-child(3) {
        grid-column: 1 / -1;
    }
}

.game-tile {
    background: white;
    border: 0.5px solid var(--color-border);
    padding: 20px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.game-tile:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-tile-hover);
    border-color: var(--color-border-strong);
}

.game-tile-logo {
    width: 100%;
    max-height: 170px;
    object-fit: contain;
    transition: opacity 0.2s;
}

.game-tile.completed .game-tile-logo {
    opacity: 0.55;
}

.completed-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--color-success);
    color: white;
    border-radius: 999px;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.game-tile.completed .completed-badge {
    display: flex;
}

@media (max-width: 640px) {
    .game-tile {
        padding: 16px;
    }

    .game-tile-logo {
        max-height: 130px;
    }
}

/* ---------- Challenge cards ---------- */
.challenge-card {
    background: var(--color-surface);
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    gap: 12px;
}

.challenge-card:hover {
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-card);
}

.challenge-info {
    flex: 1;
    min-width: 0;
}

.challenge-name {
    font-weight: 600;
    font-size: 15px;
    color: var(--color-text);
    margin-bottom: 4px;
}

.challenge-meta {
    font-size: 13px;
    color: var(--color-text-muted);
}

.challenge-btn {
    background: var(--color-primary);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.challenge-btn:hover {
    background: var(--color-primary-dark);
}

.challenge-btn:active {
    transform: scale(0.95);
}

.empty-state {
    background: var(--color-surface);
    border: 0.5px dashed var(--color-border-strong);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* ---------- Buttons ---------- */
.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

@media (max-width: 640px) {
    .action-buttons {
        flex-direction: column;
    }
}

.btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    display: block;
    transition: all 0.2s;
    border: 0.5px solid var(--color-border);
    background: white;
    color: var(--color-primary);
}

.btn:hover {
    background: var(--color-bg);
    border-color: var(--color-border-strong);
}

.btn.primary {
    background: var(--color-primary);
    color: white;
    border: none;
}

.btn.primary:hover {
    background: var(--color-primary-dark);
}

.btn:active {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn.danger {
    color: var(--color-danger);
}

/* ---------- Leaderboard rows ----------
   Shared by the home page's top-5 preview (its own .hlb-card wrapper, see pages/home.css) and
   leaderboard.html's full paginated table (.leaderboard-table wrapper, same row classes) -- both
   want the identical medal/badge/score treatment, so the row-level styling lives here once. */
.leaderboard-table {
    width: 100%;
    background: var(--color-surface);
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.hlb-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-bottom: 0.5px solid var(--color-border);
}

.hlb-row:last-child {
    border-bottom: none;
}

.hlb-you {
    background: var(--color-primary-tint);
}

.hlb-rank {
    flex: 0 0 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hlb-medal {
    font-size: 22px;
    line-height: 1;
}

.hlb-rank-number {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
}

.hlb-divider {
    flex: 0 0 auto;
    width: 1px;
    height: 18px;
    background: var(--color-border-strong);
}

.hlb-name {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hlb-badge {
    flex: 0 0 auto;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--color-primary-tint);
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.hlb-score {
    margin-left: auto;
    flex: 0 0 auto;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.hlb-score-num {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-primary);
}

.hlb-score-label {
    font-size: 13px;
    color: var(--color-text-secondary);
}

@media (max-width: 640px) {
    .hlb-row {
        padding: 8px 14px;
        gap: 10px;
    }

    .hlb-name {
        font-size: 15px;
    }

    .hlb-medal {
        font-size: 20px;
    }

    .hlb-score-num {
        font-size: 18px;
    }
}

/* ---------- Footer ---------- */
.footer {
    display: flex;
    gap: 20px;
    padding: 14px 24px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    border-top: 0.5px solid var(--color-primary-dark);
    background: var(--color-primary);
    flex-wrap: wrap;
    justify-content: center;
    box-shadow: 0 -4px 12px rgba(83, 74, 183, 0.15);
}

.footer a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}

.footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ---------- Misc shared ---------- */
.card {
    background: var(--color-surface);
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.form-field {
    margin-bottom: 16px;
}

.form-field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    margin-bottom: 6px;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 10px 12px;
    border: 0.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    color: var(--color-text);
    background: white;
}

/* Plain <textarea> defaults to a ~2-row browser sizing with no width/resize behavior --
   .form-field never had to account for one until admin forms started collecting word lists
   (Word Search's Daily/Classic puzzle words), so this fills that gap for every .form-field
   textarea going forward. */
.form-field textarea {
    min-height: 90px;
    resize: vertical;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: 2px solid var(--color-primary-light);
    outline-offset: 1px;
}

.form-hint {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 6px;
    margin-bottom: 14px;
}

/* Pull the hint in closer when it directly follows a form field (e.g. a password rule right
   under the password input) -- but NOT when it follows a button, which has no bottom margin of
   its own to absorb the pull and would otherwise get overlapped by the hint text. */
.form-field + .form-hint {
    margin-top: -10px;
}

/* ---------- Auth tabs (guest / log in / sign up), used inline on the home page ---------- */
.auth-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: 0.5px solid var(--color-border);
    background: white;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
}

.auth-tab.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.auth-panel {
    display: none;
}

.auth-panel.active {
    display: block;
}

.auth-error {
    background: #FCEBE9;
    color: var(--color-danger);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 13px;
    margin-bottom: 14px;
    display: none;
}

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

.auth-forgot {
    text-align: center;
    margin-top: 12px;
}

.auth-forgot a {
    font-size: 13px;
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-forgot a:hover {
    text-decoration: underline;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: var(--color-text);
    color: white;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-8px);
}

.loading-text {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 14px;
    padding: 24px;
}
