:root {
    --qs-bg: #f7f8fb;
    --qs-surface: #ffffff;
    --qs-surface-soft: #f8fafc;
    --qs-border: #d8dee8;
    --qs-text: #16202a;
    --qs-text-muted: #5f6b7a;
    --qs-accent: #2563eb;
    --qs-accent-soft: #e8f0ff;
    --qs-radius: 16px;
    --qs-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

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

html {
    font-size: 16px;
}

body {
    margin: 0;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--qs-bg);
    color: var(--qs-text);
    line-height: 1.5;
}

a {
    color: var(--qs-accent);
}

a:hover {
    color: #1d4ed8;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

input,
select,
textarea {
    border: 1px solid var(--qs-border);
    border-radius: 10px;
    background: #fff;
    color: var(--qs-text);
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: 2px solid rgba(37, 99, 235, 0.18);
    outline-offset: 2px;
}

/* Layout */

.qs-shell {
    min-height: 100vh;
    background: var(--qs-bg);
}

.qs-topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--qs-border);
}

.qs-topbar-inner {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0.9rem 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.qs-topbar-brand {
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--qs-text);
    text-decoration: none;
    white-space: nowrap;
}

.qs-topbar-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.qs-topbar-link {
    color: var(--qs-text-muted);
    text-decoration: none;
    font-weight: 600;
    padding: 0.45rem 0.75rem;
    border-radius: 10px;
    transition: background 0.12s ease, color 0.12s ease;
}

.qs-topbar-link:hover {
    background: rgba(37, 99, 235, 0.08);
    color: var(--qs-text);
}

.qs-topbar-link.active {
    background: rgba(37, 99, 235, 0.12);
    color: var(--qs-accent);
}

.qs-topbar-user {
    color: var(--qs-text-muted);
    font-size: 0.9rem;
    padding: 0 0.4rem;
    white-space: nowrap;
}

.qs-topbar-form {
    margin: 0;
    display: inline-flex;
}

.qs-topbar-button {
    border: none;
    background: transparent;
    cursor: pointer;
    font: inherit;
}

.qs-main-content {
    width: 100%;
}

.qs-page {
    max-width: 1100px;
    padding: 1.5rem 1.25rem 3rem 1.25rem;
}

.qs-page-narrow {
    max-width: 840px;
}

.qs-page h1 {
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin: 0 0 0.5rem 0;
}

.qs-page h2 {
    font-size: 1.5rem;
    font-weight: 750;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.qs-page h3 {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
}

.qs-muted {
    color: var(--qs-text-muted);
}

.qs-empty {
    color: var(--qs-text-muted);
    font-style: italic;
}

.qs-section-link {
    margin-bottom: 1rem;
}

.qs-about-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.qs-about-table th,
.qs-about-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--qs-border);
    text-align: left;
}

.qs-about-table th {
    width: 8rem;
    color: var(--qs-text-muted);
    font-weight: 500;
}

/* Hero / cards / stats */

.qs-hero {
    background: linear-gradient(140deg, #eef4ff 0%, #f8fbff 55%, #f4f0ff 100%);
    border: 1px solid #c8dafd;
    border-radius: 24px;
    padding: 1.75rem;
    box-shadow: 0 8px 32px rgba(37, 99, 235, 0.1);
}

.qs-actions {
    display: flex;
    gap: 0.875rem;
    flex-wrap: wrap;
    margin-top: 1.25rem;
}

.qs-button {
    display: inline-block;
    padding: 0.8rem 1.05rem;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 700;
    border: 1px solid transparent;
}

.qs-button-primary {
    background: var(--qs-accent);
    color: white;
}

.qs-button-primary:hover {
    color: white;
    background: #1d4ed8;
}

.qs-button-secondary {
    background: white;
    color: var(--qs-text);
    border-color: var(--qs-border);
}

.qs-button-secondary:hover {
    color: var(--qs-text);
    background: #f8fafc;
}

.qs-button-danger {
    background: #dc2626;
    color: white;
    border-color: #dc2626;
}

.qs-button-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
}

.qs-summary-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.9rem;
    margin: 1.25rem 0 1.75rem 0;
}

.qs-stat {
    background: var(--qs-surface);
    border: 1px solid var(--qs-border);
    border-radius: 14px;
    padding: 0.9rem 1rem;
    min-width: 150px;
    box-shadow: var(--qs-shadow);
}

.qs-stat-label {
    font-size: 0.78rem;
    color: var(--qs-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.2rem;
}

.qs-stat-value {
    font-size: 1.35rem;
    font-weight: 800;
}

/* Generic cards */

.qs-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

.qs-card {
    background: var(--qs-surface);
    border: 1px solid var(--qs-border);
    border-radius: var(--qs-radius);
    padding: 1rem 1rem 1.1rem 1rem;
    box-shadow: var(--qs-shadow);
}

.qs-card-title {
    font-size: 1.35rem;
    font-weight: 750;
    margin-bottom: 0.5rem;
}

.qs-meta {
    color: var(--qs-text-muted);
    font-size: 0.96rem;
    line-height: 1.5;
}

/* Chips */

.qs-chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.9rem;
}

.qs-chip {
    padding: 0.55rem 0.8rem;
    border-radius: 999px;
    background: var(--qs-accent-soft);
    border: 1px solid #c8dafd;
    font-weight: 600;
    font-size: 0.95rem;
}

/* Hint slider */

.qs-hint-control {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background: var(--qs-surface);
    border: 1px solid var(--qs-border);
    border-radius: 12px;
}

.qs-hint-label {
    font-size: 0.9rem;
    color: var(--qs-text-muted);
    white-space: nowrap;
}

.qs-hint-buttons {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.qs-hint-btn {
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--qs-border);
    background: var(--qs-surface);
    color: var(--qs-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.qs-hint-btn-active {
    background: var(--qs-accent);
    border-color: var(--qs-accent);
    color: #fff;
    font-weight: 600;
}

.qs-word-tile {
    display: inline;
}

/* Blur tiles that are beyond the selected hint level */
#hint-word-list[data-hint="1"] .qs-word-tile[data-tile-index="1"],
#hint-word-list[data-hint="1"] .qs-word-tile[data-tile-index="2"],
#hint-word-list[data-hint="1"] .qs-word-tile[data-tile-index="3"],
#hint-word-list[data-hint="2"] .qs-word-tile[data-tile-index="2"],
#hint-word-list[data-hint="2"] .qs-word-tile[data-tile-index="3"],
#hint-word-list[data-hint="3"] .qs-word-tile[data-tile-index="3"] {
    filter: blur(4px);
    user-select: none;
    -webkit-user-select: none;
}

/* Puzzle detail word list */

.qs-public-word-list {
    list-style: none;
    padding-left: 0;
    margin: 0;
    column-count: 2;
    column-gap: 1.5rem;
}

.qs-public-word-list li {
    break-inside: avoid;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(216, 222, 232, 0.5);
}

.qs-public-word-list li span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.qs-score-badge {
    flex-shrink: 0;
    min-width: 2rem;
    text-align: center;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
    border: 1px solid transparent;
}

.qs-score-badge-1 {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: var(--qs-text-muted);
}

.qs-score-badge-2 {
    background: #f0fdf4;
    border-color: #86efac;
    color: #166534;
}

.qs-score-badge-3 {
    background: #faf5ff;
    border-color: #d8b4fe;
    color: #7e22ce;
}

.qs-score-badge-4 {
    background: var(--qs-accent-soft);
    border-color: #93c5fd;
    color: var(--qs-accent);
}

/* Tiles */

.qs-tile-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(110px, 150px));
    gap: 1rem;
    margin-bottom: 2rem;
}

.qs-tile {
    background: var(--qs-surface);
    border: 1px solid var(--qs-border);
    border-radius: 14px;
    padding: 1rem 0.75rem;
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
    box-shadow: var(--qs-shadow);
}

.qs-tile-grid-compact {
    display: grid;
    grid-template-columns: repeat(4, minmax(64px, 90px));
    gap: 0.65rem;
    margin-bottom: 1.5rem;
    max-width: 420px;
}

.qs-tile-compact {
    background: var(--qs-surface);
    border: 1px solid var(--qs-border);
    border-radius: 10px;
    padding: 0.65rem 0.4rem;
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    box-shadow: var(--qs-shadow);
}

/* Admin/detail cards */

.qs-word-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.qs-word-card {
    background: var(--qs-surface);
    border: 1px solid var(--qs-border);
    border-radius: var(--qs-radius);
    padding: 0.9rem 1rem;
    box-shadow: var(--qs-shadow);
}

.qs-word-card h3 {
    margin-top: 0;
    margin-bottom: 0.65rem;
    font-size: 1rem;
}

.qs-word-card ul {
    margin: 0;
    padding-left: 1.05rem;
    line-height: 1.45;
}

.qs-word-card li {
    margin-bottom: 0.2rem;
}

.qs-word-list {
    margin: 0;
    padding-left: 1.05rem;
    line-height: 1.4;
}

.qs-word-list li {
    margin-bottom: 0.18rem;
    break-inside: avoid;
}

.qs-word-list-2col {
    column-count: 2;
    column-gap: 1.5rem;
}

.qs-word-list-3col {
    column-count: 3;
    column-gap: 1.5rem;
}

/* Archive */

.qs-archive-section {
    margin-top: 2rem;
}

.qs-archive-heading {
    margin-bottom: 0.6rem;
    font-size: 1.15rem;
    font-weight: 800;
}

.qs-archive-list-lite {
    display: flex;
    flex-direction: column;
}

.qs-archive-row-lite {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--qs-border);
    text-decoration: none;
    color: inherit;
}

.qs-archive-row-lite:hover {
    background: rgba(37, 99, 235, 0.03);
}

.qs-archive-row-main {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-bottom: 0;
}

.qs-archive-date-lite {
    font-weight: 700;
    font-size: 1rem;
}

.qs-archive-row-sub {
    color: var(--qs-text);
    font-size: 0.93rem;
    font-weight: 500;
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
    white-space: nowrap;
}

.qs-archive-badge-lite {
    padding: 0.18rem 0.5rem;
    border-radius: 999px;
    background: var(--qs-accent-soft);
    border: 1px solid #c8dafd;
    color: var(--qs-accent);
    font-size: 0.75rem;
    font-weight: 700;
}

/* Remove template leftovers */

.sidebar,
.top-row,
.navbar-toggler,
.nav-scrollable,
.navbar-brand {
    all: unset;
}

/* Validation helpers for forms if Identity uses them */

.valid.modified:not([type=checkbox]) {
    outline: 2px solid #16a34a;
    outline-offset: 1px;
}

.invalid {
    outline: 2px solid #dc2626;
    outline-offset: 1px;
}

.validation-message {
    color: #dc2626;
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* Responsive */

@media (min-width: 1000px) {
    .qs-public-word-list {
        column-count: 3;
    }
}

@media (max-width: 900px) {
    .qs-word-list-3col {
        column-count: 2;
    }
}

@media (max-width: 760px) {
    .qs-topbar-inner {
        align-items: flex-start;
        flex-direction: column;
        padding: 0.9rem 0.9rem;
    }

    .qs-topbar-nav {
        width: 100%;
        justify-content: flex-start;
    }

    .qs-topbar-user {
        width: 100%;
        padding-left: 0.75rem;
    }
}

@media (max-width: 700px) {
    .qs-page {
        padding: 1rem 0.9rem 2rem 0.9rem;
    }

    .qs-page h1 {
        font-size: 1.8rem;
    }

    .qs-archive-row-lite {
        display: block;
        padding: 0.8rem 0;
    }

    .qs-archive-row-main {
        margin-bottom: 0.18rem;
    }

    .qs-archive-row-sub {
        justify-content: flex-start;
        white-space: normal;
    }

    .qs-tile-grid {
        grid-template-columns: repeat(4, minmax(72px, 1fr));
        gap: 0.65rem;
    }

    .qs-tile {
        font-size: 1.2rem;
        padding: 0.8rem 0.4rem;
    }
}

@media (max-width: 640px) {
    .qs-public-word-list {
        column-count: 1;
    }

    .qs-word-list-2col,
    .qs-word-list-3col {
        column-count: 1;
    }
}

/* =========================
   Admin Page
   ========================= */

.qs-admin-tile-input {
    width: 100%;
    padding: 0.4rem 0.25rem;
    font-size: 0.95rem;
    text-align: center;
    border-radius: 8px;
}

.qs-add-word-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.5rem;
}

.qs-add-word-row input {
    flex: 1;
    min-width: 0;
    padding: 0.6rem 0.75rem;
}

.qs-status-accepted {
    background: #d1fae5;
    color: #065f46;
}

.qs-status-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.qs-status-unknown {
    background: #e5e7eb;
    color: #374151;
}

.qs-candidate-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.qs-candidate-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--qs-border);
    border-radius: 6px;
}

.qs-candidate-row-accepted {
    background: #f0fdf9;
}

.qs-candidate-row-rejected {
    background: #fff5f5;
    opacity: 0.7;
}

.qs-candidate-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.qs-candidate-word {
    font-weight: 700;
}

.qs-candidate-tiles {
    color: var(--qs-text-muted);
    font-size: 0.85rem;
}

.qs-status-badge {
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.qs-candidate-actions {
    display: flex;
    gap: 0.4rem;
}

.qs-admin-puzzle-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.qs-admin-puzzle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--qs-border);
    background: white;
    cursor: pointer;
    text-align: left;
    width: 100%;
    font-size: 1rem;
}

.qs-admin-puzzle-row:hover {
    background: #f8fafc;
}

.qs-admin-puzzle-row-active {
    border-color: #2563eb;
    background: #eff6ff;
}

.qs-admin-puzzle-date {
    font-weight: 500;
    color: var(--qs-text);
}

.qs-admin-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 8px;
    border: 1px solid var(--qs-border);
    font-size: 0.85rem;
    font-weight: 600;
    background: white;
    min-height: 36px;
    cursor: pointer;
}

.qs-admin-btn-accept {
    border-color: #6ee7b7;
    color: #065f46;
    background: #f0fdf9;
}

.qs-admin-btn-reject {
    border-color: #fca5a5;
    color: #991b1b;
    background: #fff5f5;
}

.qs-admin-btn-clear {
    color: var(--qs-text-muted);
}

/* =========================
   Auth / Login Page
   ========================= */

.qs-auth-panel {
    max-width: 520px;
    background: var(--qs-surface);
    border: 1px solid var(--qs-border);
    border-radius: 18px;
    padding: 1.4rem 1.4rem 1.25rem 1.4rem;
    box-shadow: var(--qs-shadow);
}

.qs-form-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.qs-label {
    font-weight: 600;
    font-size: 0.9rem;
}

.qs-input {
    width: 100%;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--qs-border);
    border-radius: 12px;
    background: #fff;
    font-size: 0.95rem;
}

.qs-input:focus {
    border-color: var(--qs-accent);
    outline: none;
}

.qs-checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.1rem;
    font-size: 0.9rem;
    color: var(--qs-text-muted);
}

.qs-auth-submit {
    width: 100%;
    text-align: center;
    padding: 0.9rem;
    font-size: 0.95rem;
    font-weight: 700;
}

.qs-auth-links {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
    font-size: 0.9rem;
}

.qs-auth-links a {
    color: var(--qs-text-muted);
    text-decoration: none;
}

.qs-auth-links a:hover {
    color: var(--qs-accent);
}

/* tighten page spacing for auth pages */
.qs-page-narrow {
    max-width: 640px;
}

/* Only show focus outlines for keyboard navigation */
:focus:not(:focus-visible) {
    outline: none;
}

/* Remove focus outline for mouse clicks, keep for keyboard */
:focus:not(:focus-visible) {
    outline: none;
}

/* Softer, modern focus style for keyboard navigation */
:focus-visible {
    outline: 2px solid rgba(37, 99, 235, 0.35);
    outline-offset: 2px;
    border-radius: 6px;
}