* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #e0e0e0;
    background: #1a1a1a;
    padding: 2rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 400;
    margin-bottom: 0.5rem;
    color: #f5f5f5;
}

.subtitle {
    font-size: 1rem;
    color: #a0a0a0;
}

.nav-back {
    margin-bottom: 2rem;
}

.nav-back a {
    color: var(--ember-accent-strong);
    text-decoration: none;
    font-weight: 500;
    transition: opacity 0.2s;
}

.nav-back a:hover {
    opacity: 0.8;
}

.filters-card {
    background: #252525;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 2rem;
}

.filter-labels {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-labels h2 {
    font-size: 1.2rem;
    color: #d0d0d0;
    font-weight: 500;
}

.count {
    font-size: 0.95rem;
    color: #a0a0a0;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 0.75rem;
}

.search-row {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.75rem;
    align-items: center;
    margin-top: 1rem;
}

.search-row label {
    color: var(--ember-accent-strong);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.search-row input {
    padding: 0.65rem;
    background: #1a1a1a;
    color: #e0e0e0;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 0.95rem;
}

.search-row input:focus {
    outline: none;
    border-color: var(--ember-accent-strong);
}

.action-row {
    margin-top: 1rem;
    display: flex;
    justify-content: flex-start;
}

.secondary-btn {
    border: 1px solid #444;
    background: #333;
    color: #e0e0e0;
    padding: 0.6rem 1.1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.secondary-btn:hover,
.secondary-btn:focus-visible {
    background: #444;
    border-color: var(--ember-accent-strong);
    color: var(--ember-accent-strong);
}

.filter-btn {
    border: 1px solid #333;
    background: #1a1a1a;
    color: #e0e0e0;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.05em;
    line-height: 1.2;
    white-space: nowrap;
}

.filter-btn:hover,
.filter-btn:focus-visible {
    border-color: var(--ember-accent-strong);
    color: var(--ember-accent-strong);
}

.filter-btn.active {
    background: var(--ember-accent-strong);
    color: #ffffff;
    border-color: var(--ember-accent-strong);
}

.grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1.5rem;
}

.puzzle-card {
    background: #252525;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    border: 1px solid #333;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-height: 260px;
}

.puzzle-card.highlight {
    border-color: var(--ember-accent-strong);
    box-shadow: 0 0 0 2px rgba(107, 155, 209, 0.25);
}

.puzzle-title {
    font-size: 1.3rem;
    color: #f0f0f0;
    font-weight: 500;
}

.puzzle-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.5rem 0.55rem;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ember-accent-strong);
    line-height: 1.2;
}

.puzzle-tags span {
    border: 1px solid #333;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    line-height: 1;
    white-space: nowrap;
}

.puzzle-text {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #c0c0c0;
}

.puzzle-footer {
    display: grid;
    gap: 0.75rem;
    margin-top: auto;
}

.answer {
    background: #1a1a1a;
    border: 1px solid #333;
    padding: 0.75rem 0.9rem;
    border-radius: 6px;
    color: #e0e0e0;
    display: none;
    width: 100%;
}

.answer.show {
    display: block;
}

.reveal-btn {
    border: 1px solid #444;
    background: #333;
    color: #e0e0e0;
    padding: 0.55rem 1rem;
    border-radius: 4px;
    font-size: 0.85rem;
    cursor: pointer;
    align-self: stretch;
    transition: all 0.2s;
    font-weight: 500;
}

.reveal-btn:hover,
.reveal-btn:focus-visible {
    background: #444;
    border-color: var(--ember-accent-strong);
    color: var(--ember-accent-strong);
}

.empty {
    display: none;
    margin-top: 2rem;
    color: #a0a0a0;
    text-align: center;
}

.empty.show {
    display: block;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 50;
}

.modal.show {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(10, 10, 10, 0.75);
}

.modal-card {
    position: relative;
    background: #252525;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 2rem;
    max-width: 640px;
    width: 100%;
    box-shadow: 0 12px 30px rgba(0,0,0,0.45);
    z-index: 1;
    display: grid;
    gap: 0.85rem;
}

.modal-close {
    position: absolute;
    top: 0.85rem;
    right: 0.85rem;
    background: none;
    border: 1px solid #333;
    color: #e0e0e0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover,
.modal-close:focus-visible {
    border-color: var(--ember-accent-strong);
    color: var(--ember-accent-strong);
}

.modal-eyebrow {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ember-accent-strong);
    font-weight: 600;
}

.modal-title {
    font-size: 1.6rem;
    color: #f0f0f0;
    font-weight: 500;
}

.modal-text {
    font-size: 1rem;
    line-height: 1.6;
    color: #c0c0c0;
}

@media (max-width: 768px) {
    .grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .search-row {
        grid-template-columns: 1fr;
        gap: 0.4rem;
    }

    h1 {
        font-size: 2rem;
    }

    .filters-card {
        padding: 1.25rem;
    }

    .filter-labels {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.35rem;
    }
}

@media (max-width: 480px) {
    .grid {
        grid-template-columns: 1fr;
    }

    body {
        padding: 1.5rem 1rem;
    }

    .filters-card {
        padding: 1rem;
    }

    .modal-card {
        padding: 1.5rem;
    }
}
