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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    line-height: 1.6;
    min-height: 100vh;
}

main {
    max-width: 960px;
    margin: 0 auto;
    padding: 1rem;
}

.breadcrumb {
    font-size: 0.85rem;
    color: #888;
    margin-bottom: 0.75rem;
}

.breadcrumb a {
    color: #4ecca3;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

h1 {
    text-align: center;
    color: #4ecca3;
    font-size: 1.75rem;
    margin-bottom: 1rem;
}

/* ── Puzzle selector ─────────────────────────────────────────────────── */
.puzzle-selector {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.puzzle-btn {
    padding: 0.5rem 1.25rem;
    font-size: 0.9rem;
    background: #1a1a2e;
    color: #e0e0e0;
    border: 2px solid #4ecca3;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.puzzle-btn:hover {
    background: #2a2a3e;
}

.puzzle-btn.active {
    background: #4ecca3;
    color: #0f0f1a;
    font-weight: 600;
}

/* ── Status bar ──────────────────────────────────────────────────────── */
.status-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    background: #1a1a2e;
    border: 1px solid #2a2a4e;
    border-radius: 8px;
    padding: 0.6rem 1.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.1rem;
}

.status-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #4ecca3;
}

/* ── Game layout ─────────────────────────────────────────────────────── */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 2rem;
    position: relative;
}

.game-area {
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    justify-content: center;
    flex-wrap: wrap;
    width: 100%;
}

/* ── Word grid ───────────────────────────────────────────────────────── */
.grid-wrapper {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#word-grid {
    display: grid;
    grid-template-columns: repeat(12, 36px);
    grid-template-rows: repeat(12, 36px);
    gap: 2px;
    background: #1a1a2e;
    border: 2px solid #2a2a4e;
    border-radius: 10px;
    padding: 8px;
    user-select: none;
    touch-action: none;
    -webkit-touch-callout: none;
}

.grid-cell {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    border: 1px solid #2a2a4e;
    border-radius: 3px;
    cursor: default;
    transition: background-color 0.1s, border-color 0.1s, color 0.1s;
    color: #c0c0c0;
    background: #0f0f1a;
}

/* Currently dragging over this cell */
.grid-cell.selecting {
    background: rgba(78, 204, 163, 0.3);
    border-color: #4ecca3;
    color: #ffffff;
}

/* Permanently found */
.grid-cell.found {
    background: rgba(78, 204, 163, 0.18);
    color: #4ecca3;
    border-color: rgba(78, 204, 163, 0.5);
}

/* Found AND currently overlapping a new selection */
.grid-cell.found.selecting {
    background: rgba(78, 204, 163, 0.45);
    border-color: #4ecca3;
}

/* ── Word list ────────────────────────────────────────────────────────── */
.word-list-wrapper {
    flex: 1 1 160px;
    min-width: 140px;
    max-width: 280px;
}

.word-list-title {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
    margin-bottom: 0.6rem;
}

.word-list {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.word-chip {
    display: inline-block;
    padding: 0.3rem 0.7rem;
    background: #1a1a2e;
    border: 1px solid #2a2a4e;
    border-radius: 4px;
    font-size: 0.9rem;
    font-family: 'Courier New', Courier, monospace;
    font-weight: 600;
    color: #e0e0e0;
    transition: all 0.3s;
    letter-spacing: 0.05em;
}

.word-chip.found {
    text-decoration: line-through;
    color: #4a6a5c;
    border-color: #1a3a2e;
    background: #111a14;
}

/* ── Completion overlay ───────────────────────────────────────────────── */
.overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 15, 26, 0.97);
    padding: 2rem 2.5rem;
    border-radius: 12px;
    border: 2px solid #4ecca3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    z-index: 20;
    text-align: center;
    min-width: 240px;
    max-width: 340px;
    width: 90%;
}

.overlay.hidden {
    display: none;
}

.overlay h2 {
    font-size: 1.6rem;
    color: #4ecca3;
    margin: 0;
}

.overlay .result-detail {
    font-size: 1rem;
    color: #c0c0c0;
    margin: 0;
}

.overlay .result-score {
    font-size: 2rem;
    font-weight: 700;
    color: #4ecca3;
}

.overlay .best-note {
    font-size: 0.85rem;
    color: #ffcc44;
}

.overlay-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    justify-content: center;
}

.overlay button {
    padding: 0.65rem 1.5rem;
    font-size: 0.95rem;
    background: #4ecca3;
    color: #0f0f1a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
}

.overlay button:hover {
    background: #3db892;
}

.overlay .share-btn {
    background: #2a2a4e;
    color: #4ecca3;
    border: 1px solid #4ecca3;
}

.overlay .share-btn:hover {
    background: #3a3a5e;
}

/* ── New game button ─────────────────────────────────────────────────── */
.new-game-btn {
    padding: 0.5rem 1.5rem;
    font-size: 0.9rem;
    background: #1a1a2e;
    color: #4ecca3;
    border: 2px solid #4ecca3;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.new-game-btn:hover {
    background: #4ecca3;
    color: #0f0f1a;
}

/* ── Article / SEO content ───────────────────────────────────────────── */
.content {
    padding-top: 1.5rem;
    border-top: 1px solid #2a2a4e;
}

.last-updated {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 0.5rem;
}

.content h2 {
    color: #4ecca3;
    font-size: 1.25rem;
    margin: 1.5rem 0 0.75rem;
}

.content h2:first-of-type {
    margin-top: 1rem;
}

.content p {
    margin-bottom: 0.75rem;
    color: #c0c0c0;
}

.content ul {
    margin: 0.5rem 0 1rem 1.5rem;
    color: #c0c0c0;
}

.content li {
    margin-bottom: 0.5rem;
}

.faq {
    margin: 0.5rem 0 1rem;
}

.faq dt {
    font-weight: 600;
    color: #e0e0e0;
    margin-top: 1rem;
}

.faq dd {
    color: #c0c0c0;
    margin-left: 1rem;
    margin-top: 0.25rem;
}

.related-games {
    margin-top: 2rem;
    padding: 1rem;
    background: #1a1a2e;
    border: 1px solid #2a2a4e;
    border-radius: 8px;
}

.related-games h3 {
    color: #4ecca3;
    font-size: 1rem;
    margin-bottom: 0.75rem;
}

.game-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.game-links a {
    display: inline-block;
    padding: 0.4rem 0.9rem;
    background: #0f0f1a;
    color: #4ecca3;
    border: 1px solid #2a2a4e;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.game-links a:hover {
    background: #4ecca3;
    color: #0f0f1a;
    border-color: #4ecca3;
}

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (min-width: 640px) {
    main {
        padding: 2rem;
    }

    h1 {
        font-size: 2rem;
    }
}

/* On wide screens keep grid + word-list side by side */
@media (min-width: 560px) {
    .game-area {
        flex-wrap: nowrap;
        align-items: flex-start;
    }

    .word-list-wrapper {
        max-width: 200px;
    }
}

/* Shrink grid on narrow screens */
@media (max-width: 500px) {
    #word-grid {
        grid-template-columns: repeat(12, 28px);
        grid-template-rows: repeat(12, 28px);
        gap: 1px;
        padding: 6px;
    }

    .grid-cell {
        width: 28px;
        height: 28px;
        font-size: 0.78rem;
    }

    .game-area {
        flex-direction: column;
        align-items: center;
    }

    .word-list-wrapper {
        max-width: 100%;
        width: 100%;
    }

    .word-list {
        flex-direction: row;
        flex-wrap: wrap;
    }
}

@media (max-width: 360px) {
    #word-grid {
        grid-template-columns: repeat(12, 23px);
        grid-template-rows: repeat(12, 23px);
        gap: 1px;
        padding: 4px;
    }

    .grid-cell {
        width: 23px;
        height: 23px;
        font-size: 0.65rem;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    main { padding-top: 0.5rem; }
    h1 { font-size: 1.4rem; margin-bottom: 0.5rem; }
}
