* {
    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: 800px;
    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;
}

/* ── Game container ────────────────────────────────────────────────────────── */

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    position: relative;
}

/* ── Stats bar ─────────────────────────────────────────────────────────────── */

.stats-bar {
    display: flex;
    gap: 2rem;
    background: #1a1a2e;
    border: 1px solid #2a2a4e;
    border-radius: 8px;
    padding: 0.6rem 1.5rem;
}

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

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

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: #e0e0e0;
    min-width: 3ch;
    text-align: center;
}

.stat-value.accent {
    color: #4ecca3;
}

/* ── Puzzle grid ───────────────────────────────────────────────────────────── */

.puzzle-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    padding: 10px;
    background: #1a1a2e;
    border: 2px solid #2a2a4e;
    border-radius: 12px;
    width: 320px;
    height: 320px;
    user-select: none;
}

/* ── Tiles ─────────────────────────────────────────────────────────────────── */

.tile {
    background: #1a1a2e;
    border: 2px solid #2a2a4e;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    font-weight: 700;
    color: #4ecca3;
    cursor: pointer;
    transition: background-color 0.12s, border-color 0.12s, box-shadow 0.12s;
    line-height: 1;
}

.tile:hover {
    background: #222240;
    border-color: #4ecca3;
    box-shadow: 0 0 8px rgba(78, 204, 163, 0.3);
}

.tile:focus-visible {
    outline: 2px solid #4ecca3;
    outline-offset: 2px;
}

.tile:active {
    transform: scale(0.95);
}

.tile-empty {
    background: transparent;
    border: 2px solid transparent;
    cursor: default;
    pointer-events: none;
}

.tile-empty:hover {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
}

/* Win animation: tiles flash green */
.tile-win {
    animation: tile-glow 0.6s ease-in-out infinite alternate;
    border-color: #4ecca3;
}

@keyframes tile-glow {
    from {
        background: #1a1a2e;
        box-shadow: 0 0 0 0 rgba(78, 204, 163, 0);
    }
    to {
        background: rgba(78, 204, 163, 0.18);
        box-shadow: 0 0 14px 3px rgba(78, 204, 163, 0.45);
    }
}

/* ── 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: 0.75rem;
    z-index: 10;
    text-align: center;
    min-width: 220px;
    max-width: 300px;
}

.overlay.hidden {
    display: none;
}

.win-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: #4ecca3;
}

.win-detail {
    font-size: 1.1rem;
    font-weight: 600;
    color: #e0e0e0;
}

.win-sub {
    font-size: 0.9rem;
    color: #888;
    min-height: 1.2em;
}

.overlay button {
    padding: 0.7rem 1.8rem;
    font-size: 1rem;
    background: #4ecca3;
    color: #0f0f1a;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    width: 100%;
}

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

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

.overlay .share-btn:hover {
    background: #4ecca3;
    color: #0f0f1a;
}

/* ── 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: 600px) {
    main {
        padding: 2rem;
    }

    h1 {
        font-size: 2rem;
    }

    .puzzle-grid {
        width: 360px;
        height: 360px;
        gap: 8px;
        padding: 12px;
    }

    .tile {
        font-size: 1.75rem;
    }
}

@media (max-width: 360px) {
    .puzzle-grid {
        width: 280px;
        height: 280px;
        gap: 5px;
        padding: 8px;
    }

    .tile {
        font-size: 1.2rem;
    }

    .stats-bar {
        gap: 1.2rem;
        padding: 0.5rem 0.8rem;
    }
}

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

    .puzzle-grid {
        width: 260px;
        height: 260px;
    }

    .tile {
        font-size: 1.1rem;
    }
}
