*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f5f0e8;
    --surface: #ffffff;
    --surface-hover: #faf7f2;
    --border: #d5cfc4;
    --border-strong: #b0a898;
    --text: #1a1a1a;
    --text-muted: #5c5647;
    --accent: #1a56a8;
    --accent-hover: #15447f;
    --accent-light: #e8f0fc;
    --success: #1a7a3a;
    --success-bg: #e6f5eb;
    --error: #c53030;
    --error-bg: #fde8e8;
    --cell-size: 34px;
    --radius: 8px;

    --grid-gap: #c4b9a8;
    --cell-highlight: #d4e4fa;
    --cell-focus: #a8c8f5;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    font-size: 18px;
}

.app {
    max-width: 1300px;
    margin: 0 auto;
    padding: 2rem 2rem 5rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

header h1 {
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 0.5rem;
    font-size: 1.2rem;
}

/* Input Section */
.input-section {
    max-width: 700px;
    margin: 0 auto 2.5rem;
}

.input-group {
    display: flex;
    gap: 1rem;
}

#topic-input {
    flex: 1;
    padding: 1rem 1.4rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1.2rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#topic-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

#topic-input::placeholder {
    color: var(--border-strong);
}

#generate-btn {
    padding: 1rem 2.2rem;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: 1.2rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    white-space: nowrap;
}

#generate-btn:hover {
    background: var(--accent-hover);
}

#generate-btn:active {
    transform: scale(0.98);
}

#generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.spinner {
    width: 22px;
    height: 22px;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════
   PUZZLE PAGE  (pz-* namespace)
   ═══════════════════════════════════════════════ */

/* Breadcrumb */
.pz-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.2rem;
    flex-wrap: wrap;
}
.pz-breadcrumb a { color: var(--accent); text-decoration: none; font-weight: 500; }
.pz-breadcrumb a:hover { text-decoration: underline; }
.pz-breadcrumb__sep { color: var(--border-strong); font-size: 0.85rem; }
.pz-breadcrumb__current { font-weight: 600; color: var(--text); }

/* Hero — stacks on mobile */
.pz-hero {
    display: flex;
    gap: 0;
    align-items: stretch;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 2rem;
}
.pz-hero__img-wrap { flex-shrink: 0; width: 220px; }
.pz-hero__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pz-hero__body {
    padding: 1.2rem 1.6rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.4rem;
    min-width: 0;
}
.pz-hero__title {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
    margin: 0;
    text-transform: capitalize;
}
.pz-hero__desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.55;
    margin: 0;
}
.pz-hero__desc a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(26,86,168,0.3);
    text-underline-offset: 2px;
}
.pz-hero__desc a:hover { text-decoration-color: var(--accent); }
.pz-hero__stats { font-size: 0.95rem; color: var(--text-muted); margin: 0; }

/* Difficulty Tabs */
.pz-diff { display: flex; gap: 0.5rem; margin-top: 0.5rem; flex-wrap: wrap; }
.pz-diff__tab {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
    padding: 0.5rem 1rem;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    transition: all 0.15s;
    cursor: pointer;
    min-width: 85px;
    text-align: center;
}
.pz-diff__tab:hover { border-color: var(--accent); background: var(--accent-light); }
.pz-diff__tab--active { pointer-events: none; }
.pz-diff__tab--active.pz-diff__tab--easy { background: var(--success-bg); border-color: var(--success); color: var(--success); }
.pz-diff__tab--active.pz-diff__tab--medium { background: #fef3c7; border-color: #d97706; color: #92400e; }
.pz-diff__tab--active.pz-diff__tab--hard { background: var(--error-bg); border-color: var(--error); color: var(--error); }
.pz-diff__label { line-height: 1.2; }
.pz-diff__words { font-size: 0.72rem; font-weight: 500; opacity: 0.6; }

/* Main puzzle area */
.pz-main {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.pz-grid-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
}

.pz-grid-container {
    position: relative;
    display: inline-block;
}

/* ─── Hint bubble (floating) ─── */
.pz-hint {
    position: absolute;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: 12px;
    padding: 0.35rem 0.4rem;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.13);
    pointer-events: auto;
    transition: top 0.2s ease, left 0.2s ease, border-color 0.25s, background 0.25s;
    max-width: calc(100% - 8px);
}

.pz-hint::after {
    content: "";
    position: absolute;
    bottom: -8px;
    left: 24px;
    width: 14px;
    height: 14px;
    background: var(--surface);
    border-right: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    transform: rotate(45deg);
    z-index: -1;
}

.pz-hint--solved {
    border-color: var(--success);
    background: var(--success-bg);
}
.pz-hint--solved::after {
    background: var(--success-bg);
    border-color: var(--success);
}

.pz-hint--below::after {
    bottom: auto;
    top: -8px;
    transform: rotate(-135deg);
}

.pz-hint__body {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    cursor: pointer;
    padding: 0.1rem 0.2rem;
    border-radius: 8px;
    transition: background 0.15s;
}

.pz-hint__body:hover {
    background: rgba(0,0,0,0.04);
}

.pz-hint__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 0.75rem;
    padding: 0.2rem 0.45rem;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
    letter-spacing: 0.02em;
    transition: background 0.2s;
}

.pz-hint__badge--down {
    background: #6366f1;
}

.pz-hint__text {
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.pz-hint__nav {
    appearance: none;
    border: 1px solid var(--border);
    background: var(--surface);
    width: 28px;
    height: 28px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: all 0.15s;
    padding: 0;
}

.pz-hint__nav:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* Action buttons */
.pz-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.pz-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    border: 2px solid transparent;
    line-height: 1;
}
.pz-btn svg { flex-shrink: 0; }
.pz-btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.pz-btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.pz-btn--outline { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.pz-btn--outline:hover { background: var(--accent-light); }
.pz-btn--ghost { background: var(--surface); color: var(--text-muted); border-color: var(--border); }
.pz-btn--ghost:hover { color: var(--text); border-color: var(--border-strong); }


/* Bottom sections */
.pz-section { margin-top: 2.5rem; }
.pz-section__title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--accent);
}

/* Chips */
.pz-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.pz-chip {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.pz-chip--answer { background: var(--success-bg); border: 1px solid #b5dfc4; color: var(--success); }
.pz-chip--letter { background: var(--accent-light); border: 1px solid #c5d9f0; color: var(--accent); }

/* Letter blocks grid */
.pz-letter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.7rem;
}
.pz-letter-block {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.8rem 1rem;
}
.pz-letter-block__title { font-size: 0.95rem; font-weight: 700; color: var(--accent); margin: 0 0 0.5rem; }

/* Related puzzles */
.pz-related {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.7rem;
}
.pz-related--inline {
    display: flex;
    gap: 0.6rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    width: 100%;
    align-self: stretch;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.pz-related--inline::-webkit-scrollbar { display: none; }
.pz-related--inline .pz-related__card {
    flex: 0 0 110px;
}
.pz-related--inline .pz-related__img { height: 65px; }
.pz-related--inline .pz-related__name { font-size: 0.72rem; padding: 0.35rem 0.5rem; }
.pz-related--inline .pz-related__card--more { min-height: 90px; flex: 0 0 110px; }
.pz-related--inline .pz-related__more-arrow { font-size: 1.1rem; }
.pz-related__card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    display: flex;
    flex-direction: column;
}
.pz-related__card:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,0.06); }
.pz-related__img { width: 100%; height: 80px; object-fit: cover; display: block; }
.pz-related__img--placeholder { background: linear-gradient(135deg, var(--accent-light) 0%, var(--border) 100%); }
.pz-related__name { padding: 0.5rem 0.65rem; font-size: 0.82rem; font-weight: 600; color: var(--text); text-transform: capitalize; }
.pz-related__card--more {
    justify-content: center; align-items: center; min-height: 110px;
    background: var(--accent-light); border-color: var(--accent); text-align: center; gap: 0.2rem;
}
.pz-related__card--more:hover { background: #d8e8fa; }
.pz-related__more-arrow { font-size: 1.4rem; color: var(--accent); }
.pz-related__card--more .pz-related__name { color: var(--accent); font-weight: 700; }

/* Category pills */
.pz-cat-pills { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.pz-cat-pill {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}
.pz-cat-pill:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.pz-cat-pill--active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* SEO content */
.pz-seo {
    margin-top: 3rem;
    padding: 2rem 2.2rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    line-height: 1.85;
}
.pz-seo h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 1.6rem;
    margin-bottom: 0.5rem;
    line-height: 1.3;
}
.pz-seo h3:first-child { margin-top: 0; }
.pz-seo p {
    color: var(--text);
    font-size: 1rem;
    margin-bottom: 1rem;
}
.pz-seo p:last-child { margin-bottom: 0; }
.pz-seo a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(26,86,168,0.3);
    text-underline-offset: 3px;
    font-weight: 600;
    transition: text-decoration-color 0.15s;
}
.pz-seo a:hover { text-decoration-color: var(--accent); }
.pz-seo ul, .pz-seo ol {
    margin: 0.8rem 0 1rem 1.5rem;
    font-size: 1rem;
    color: var(--text);
}
.pz-seo li { margin-bottom: 0.3rem; }

/* ─── RESPONSIVE: MOBILE (<= 700px) ─── */
@media (max-width: 700px) {
    .pz-hero { flex-direction: column; }
    .pz-hero__img-wrap { width: 100%; height: 180px; }
    .pz-hero__body { padding: 1rem 1.2rem; }
    .pz-hero__title { font-size: 1.35rem; }

    .pz-actions { width: 100%; }
    .pz-btn { flex: 1; justify-content: center; font-size: 0.85rem; padding: 0.6rem 0.5rem; }

    .pz-hint { white-space: normal; }
    .pz-hint__text { font-size: 0.8rem; }

    .pz-section__title { font-size: 1.1rem; }
    .pz-related { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
    .pz-letter-grid { grid-template-columns: 1fr 1fr; }
    .pz-seo { padding: 1.1rem 1rem; }
}

@media (max-width: 420px) {
    .pz-diff__tab { padding: 0.4rem 0.7rem; font-size: 0.82rem; min-width: 72px; }
    .pz-letter-grid { grid-template-columns: 1fr; }
}

/* Grid */

.crossword-grid {
    display: inline-grid;
    gap: 1.5px;
    background: var(--grid-gap);
    border: 2px solid var(--grid-gap);
    border-radius: 6px;
    padding: 1.5px;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    position: relative;
    background: var(--surface);
    border-radius: 2px;
    transition: background 0.15s;
}

.cell--black {
    background: var(--grid-gap);
}

.cell__number {
    position: absolute;
    top: 1px;
    left: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    color: var(--accent);
    pointer-events: none;
    line-height: 1;
}

.cell__input {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    color: var(--text);
    outline: none;
    text-transform: uppercase;
    caret-color: var(--accent);
    cursor: pointer;
    padding-top: 4px;
}

.cell__input:focus {
    background: var(--cell-focus);
}

.cell--highlighted {
    background: var(--cell-highlight);
}

.cell--highlighted .cell__input:focus {
    background: var(--cell-focus);
}

.cell--correct .cell__input {
    color: var(--success);
}

.cell--solved {
    background: var(--success-bg);
}

.cell--solved .cell__input {
    color: var(--success);
    cursor: default;
}

.cell--wrong .cell__input {
    color: #fff;
    background: var(--error);
    border-radius: 2px;
    cursor: pointer;
}

.cell--revealed .cell__input {
    color: var(--accent);
}

/* (Grid actions moved to pz-actions / pz-btn) */

/* Clues */
.clues-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    min-width: 0;
}

.clue-section h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 0.8rem;
    color: var(--accent);
    border-bottom: 2px solid var(--border);
    padding-bottom: 0.5rem;
}

.clue-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.clue-item {
    padding: 0.75rem 1rem;
    background: var(--surface);
    border-radius: var(--radius);
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    border: 2px solid transparent;
    display: flex;
    gap: 0.75rem;
    line-height: 1.5;
}

.clue-item:hover {
    background: var(--surface-hover);
    border-color: var(--border);
}

.clue-item--active {
    border-color: var(--accent);
    background: var(--accent-light);
}

.clue-item--solved {
    opacity: 0.55;
}

.clue-item--solved .clue-text {
    text-decoration: line-through;
}

.clue-item--solved .clue-number {
    color: var(--success);
}

.clue-number {
    font-weight: 800;
    color: var(--accent);
    min-width: 2rem;
    font-size: 1.1rem;
}

.clue-text {
    color: var(--text);
}

/* Message */
.message {
    max-width: 700px;
    margin: 1.5rem auto 0;
    padding: 1.1rem 1.5rem;
    border-radius: var(--radius);
    text-align: center;
    font-weight: 600;
    font-size: 1.15rem;
}

.message--error {
    background: var(--error-bg);
    color: var(--error);
    border: 2px solid #f5c6c6;
}

.message--success {
    background: var(--success-bg);
    color: var(--success);
    border: 2px solid #b5dfc4;
}

/* History Section */
.history-empty {
    color: var(--text-muted);
    font-size: 1.1rem;
    grid-column: 1 / -1;
}

/* (Puzzle header moved to pz-hero) */

/* Header link */
.header-link {
    text-decoration: none;
    color: inherit;
}

.site-title {
    display: block;
    font-size: 2.8rem;
    font-weight: 700;
    color: var(--accent);
    letter-spacing: -0.02em;
    text-align: center;
}

/* Back button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent);
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 1.4rem;
    font-size: 1.05rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    margin-bottom: 1.5rem;
    transition: border-color 0.2s, background 0.2s;
    text-decoration: none;
}

.back-btn:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* ═══════════════════════════════════════════════
   HOMEPAGE (idx-* namespace)
   ═══════════════════════════════════════════════ */

.idx-hero {
    text-align: center;
    margin-bottom: 2.5rem;
}

.idx-hero h1 {
    font-size: 2.6rem;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.idx-hero__intro {
    color: var(--text-muted);
    margin-top: 0.75rem;
    font-size: 1.15rem;
    max-width: 680px;
    margin-left: auto;
    margin-right: auto;
    line-height: 1.65;
}

.idx-hero__intro strong {
    color: var(--text);
    font-weight: 700;
}

/* Homepage sections */
.idx-section {
    margin-bottom: 3rem;
}

.idx-section__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.3rem;
    padding-bottom: 0.5rem;
    border-bottom: 3px solid var(--accent);
}

.idx-section__desc {
    color: var(--text-muted);
    font-size: 1.02rem;
    margin-bottom: 1.2rem;
    max-width: 650px;
}

/* Neue Rätsel grid */
.idx-recent-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.2rem;
}

.idx-recent-card {
    position: relative;
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    aspect-ratio: 4 / 3;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    color: inherit;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.idx-recent-card:hover {
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    transform: translateY(-3px);
}

.idx-recent-card__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.idx-recent-card:hover .idx-recent-card__img {
    transform: scale(1.05);
}

.idx-recent-card__img--placeholder {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--border) 100%);
}

.idx-recent-card__body {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2.5rem 1rem 1rem;
    background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.0) 100%);
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.idx-recent-card__topic {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.idx-recent-card__cat {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.8);
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Homepage responsive */
@media (max-width: 900px) {
    .idx-recent-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 700px) {
    .idx-hero h1 { font-size: 1.9rem; }
    .idx-hero__intro { font-size: 1.02rem; }
    .idx-recent-grid { grid-template-columns: repeat(2, 1fr); gap: 0.8rem; }
    .idx-section__title { font-size: 1.25rem; }
    .idx-recent-card__topic { font-size: 0.92rem; }
    .idx-recent-card__cat { font-size: 0.72rem; }
    .idx-recent-card__body { padding: 2rem 0.75rem 0.75rem; }
}

/* Category Explorer (homepage) */
.cat-explorer {
    margin-top: 3rem;
    margin-bottom: 2rem;
}

.cat-explorer__title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
}

.cat-explorer__count {
    font-weight: 500;
    color: var(--text-muted);
    font-size: 1.1rem;
}

.cat-explorer__search-wrap {
    margin-bottom: 1.5rem;
    max-width: 420px;
}

.cat-explorer__search {
    width: 100%;
    padding: 0.75rem 1.2rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1.05rem;
    font-family: inherit;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cat-explorer__search:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.cat-explorer__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.2rem;
}

.cat-explorer__empty {
    color: var(--text-muted);
    font-size: 1.05rem;
    padding: 1rem 0;
}

.cat-group {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
}

.cat-group__letter {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--accent);
    margin-bottom: 0.6rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid var(--border);
}

.cat-group__links {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.cat-group__link {
    display: block;
    padding: 0.35rem 0.5rem;
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 4px;
    transition: background 0.1s, color 0.1s;
}

.cat-group__link:hover {
    background: var(--accent-light);
    color: var(--accent);
}

/* Compact Category Grid (category & puzzle pages) */
.compact-cat-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.compact-cat-link {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
    white-space: nowrap;
}

.compact-cat-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

.compact-cat-link--active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.compact-cat-more {
    margin-top: 0.8rem;
}

.compact-cat-more__link {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
}

.compact-cat-more__link:hover {
    text-decoration: underline;
}

/* Category Empty State */
.cat-empty-state {
    text-align: center;
    padding: 3rem 2rem;
    background: var(--surface);
    border: 2px dashed var(--border);
    border-radius: var(--radius);
}

.cat-empty-state__text {
    font-size: 1.15rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.cat-empty-state__btn {
    display: inline-block;
    padding: 0.8rem 1.8rem;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    transition: background 0.15s;
}

.cat-empty-state__btn:hover {
    background: var(--accent-hover);
}

/* (Breadcrumb moved to pz-breadcrumb) */

/* Category Hero */
.category-hero {
    margin-bottom: 2rem;
}

.category-hero h2 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.category-hero__desc {
    color: var(--text-muted);
    font-size: 1.1rem;
    max-width: 700px;
}

/* Hub Sections */
.hub-section {
    margin-top: 3rem;
}

.hub-heading {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.6rem;
    border-bottom: 3px solid var(--accent);
}

.hub-intro {
    color: var(--text-muted);
    font-size: 1.05rem;
    margin-bottom: 1.2rem;
    max-width: 700px;
}

/* Keyword Capture Blocks */
.keyword-blocks {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.keyword-block {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.2rem 1.5rem;
}

.keyword-block__title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.keyword-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.keyword-chip {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    background: var(--accent-light);
    border: 1px solid #c5d9f0;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Answer Grid */
.answer-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.answer-chip {
    display: inline-block;
    padding: 0.45rem 1rem;
    background: var(--success-bg);
    border: 1px solid #b5dfc4;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--success);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Related Sections (legacy compat) */
.related-section {
    margin-top: 2.5rem;
}

.related-section h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.8rem;
}

.related-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
}

.related-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.related-card__img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    display: block;
}

.related-card__img--placeholder {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--border) 100%);
}

.related-card__topic {
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    text-transform: capitalize;
}

.related-card--more {
    justify-content: center;
    align-items: center;
    min-height: 130px;
    background: var(--accent-light);
    border-color: var(--accent);
    text-align: center;
    gap: 0.3rem;
}

.related-card--more:hover {
    background: #d8e8fa;
}

.related-card__more-icon {
    font-size: 1.5rem;
    color: var(--accent);
}

.related-card--more .related-card__topic {
    color: var(--accent);
    font-weight: 700;
}

.related-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.related-link {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 100px;
    color: var(--accent);
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.15s;
}

.related-link:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.related-link--generate {
    border-style: dashed;
    color: var(--text-muted);
}

.related-link--generate:hover {
    color: var(--accent);
    border-style: solid;
}

.related-link--active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.related-link--active:hover {
    background: var(--accent-hover);
    color: #fff;
}

/* SEO Content */
.seo-content {
    margin-top: 3rem;
    padding: 2rem 2.2rem;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    max-width: 800px;
    line-height: 1.8;
}

.seo-content h3 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
}

.seo-content h3:first-child {
    margin-top: 0;
}

.seo-content p {
    color: var(--text);
    font-size: 1.05rem;
    margin-bottom: 1rem;
}

.seo-content p:last-child {
    margin-bottom: 0;
}

.seo-content a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-color: rgba(26, 86, 168, 0.3);
    text-underline-offset: 2px;
    font-weight: 500;
    transition: text-decoration-color 0.15s;
}

.seo-content a:hover {
    text-decoration-color: var(--accent);
}

.seo-content--top {
    margin-top: 0;
    margin-bottom: 2rem;
}

.seo-content--hub {
    margin-top: 0;
    max-width: 100%;
}

/* Hub Hero (above the fold) */
.hub-hero {
    margin-bottom: 2rem;
}

.hub-hero__h1 {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1.2;
    margin-bottom: 0.6rem;
}

.hub-hero__intro {
    color: var(--text-muted);
    font-size: 1.15rem;
    max-width: 750px;
    line-height: 1.6;
}

/* Featured Puzzle Grid */
.featured-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1rem;
}

.featured-card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
    display: flex;
    flex-direction: column;
}

.featured-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

.featured-card__img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.featured-card__img--placeholder {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--border) 100%);
    height: 140px;
}

.featured-card__body {
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.featured-card__topic {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    text-transform: capitalize;
}

.featured-card__meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.featured-card__words {
    color: var(--text-muted);
    font-weight: 500;
}

/* Difficulty Badge */
.difficulty-badge {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.difficulty-badge--easy {
    background: var(--success-bg);
    color: var(--success);
}

.difficulty-badge--medium {
    background: #fef3c7;
    color: #92400e;
}

.difficulty-badge--hard {
    background: var(--error-bg);
    color: var(--error);
}

.difficulty-badge--sm {
    padding: 0.15rem 0.55rem;
    font-size: 0.75rem;
}

/* Letter-Based Solution Blocks */
.letter-blocks {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.letter-block {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem 1.4rem;
}

.letter-block__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 0.7rem;
}

.letter-block__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.letter-chip {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    background: var(--accent-light);
    border: 1px solid #c5d9f0;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--accent);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.letter-chip--more {
    background: transparent;
    border-style: dashed;
    font-family: inherit;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-muted);
    font-weight: 600;
}

/* All Puzzles List */
.all-puzzles-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.all-puzzles-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.8rem 1.2rem;
    background: var(--surface);
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.all-puzzles-item:last-child {
    border-bottom: none;
}

.all-puzzles-item:hover {
    background: var(--accent-light);
}

.all-puzzles-item--hidden {
    display: none;
}

.all-puzzles-item__num {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 2rem;
}

.all-puzzles-item__topic {
    font-weight: 600;
    font-size: 1.05rem;
    color: var(--text);
    flex: 1;
    text-transform: capitalize;
}

.all-puzzles-item__words {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Load More Button */
.load-more-btn {
    display: block;
    width: 100%;
    max-width: 400px;
    margin: 1.2rem auto 0;
    padding: 0.9rem 2rem;
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    color: var(--accent);
    font-size: 1.05rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
}

.load-more-btn:hover {
    background: var(--accent);
    color: #fff;
}

/* (category-link-grid replaced by compact-cat-grid) */

/* FAQ Accordion */
.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.faq-item {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-item__q {
    padding: 1rem 1.4rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: background 0.1s;
}

.faq-item__q:hover {
    background: var(--surface-hover);
}

.faq-item__q::after {
    content: '+';
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.faq-item[open] .faq-item__q::after {
    content: '−';
}

.faq-item__q::-webkit-details-marker {
    display: none;
}

.faq-item__a {
    padding: 0 1.4rem 1.2rem;
    font-size: 1.05rem;
    color: var(--text-muted);
    line-height: 1.7;
}

/* Fade-in animation */
#puzzle-area {
    animation: fadeIn 0.35s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive cell sizes */
@media (max-width: 700px) {
    :root { --cell-size: 30px; }
    .cell__number { font-size: 0.55rem; top: 1px; left: 2px; }
    .cell__input { font-size: 0.95rem; padding-top: 3px; }
}
@media (max-width: 420px) {
    :root { --cell-size: 26px; }
    .cell__number { font-size: 0.5rem; }
    .cell__input { font-size: 0.8rem; padding-top: 2px; }
}

/* Global mobile padding */
@media (max-width: 700px) {
    .app { padding: 1rem 1rem 3rem; }
    header h1 { font-size: 2rem; }
    header { margin-bottom: 1.5rem; }
}
