/* ============================
   1. Design tokens (colors, sizes)
   ============================ */
:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-2: #172238;
    --text: #f8fafc;
    --muted: #94a3b8;
    --accent: #22c55e;
    --accent-hover: #4ade80;
    --on-accent: #06230f;
    --social: #facc15;
    --social-hover: #fde047;
    --live-text: #8cf5ad;
    --stars: #facc15;
    --border: rgba(255, 255, 255, .08);
    --shadow: 0 18px 50px rgba(0, 0, 0, .22);
    --radius: 18px;
    --header: 76px
}

html[data-theme="light"] {
    --bg: #f7fafc;
    --surface: #fff;
    --surface-2: #edf3f8;
    --text: #122033;
    --muted: #5d6d80;
    --live-text: #15803d;
    --stars: #d97706;
    --border: rgba(15, 23, 42, .1);
    --shadow: 0 18px 50px rgba(15, 23, 42, .1)
}

/* ============================
   2. Reset & base
   ============================ */
* {
    box-sizing: border-box
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header) + 24px)
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, system-ui, sans-serif;
    line-height: 1.65
}

a {
    color: inherit;
    text-decoration: none
}

img {
    display: block;
    max-width: 100%;
    height: auto
}

h1,
h2,
h3,
p {
    margin-top: 0
}

h1,
h2,
h3 {
    line-height: 1.12;
    letter-spacing: -.05em;
    overflow-wrap: break-word
}

h1 {
    font-size: clamp(2.8rem, 6vw, 5.25rem);
    margin-bottom: 22px;
    max-width: 730px
}

h2 {
    font-size: clamp(2rem, 4vw, 3.45rem);
    margin-bottom: 16px
}

h3 {
    font-size: 1.45rem;
    margin: 14px 0 9px
}

:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px
}

/* ============================
   3. Layout helpers
   ============================ */
.container {
    width: min(1120px, calc(100% - 40px));
    margin: auto
}

.section {
    padding: clamp(48px, 6vw, 72px) 0
}

.section-muted {
    background: var(--surface-2)
}

.section-heading {
    margin-bottom: 42px;
    max-width: 600px
}

.section-heading.split-layout {
    max-width: none
}

/* Two-column block: eyebrow spans the full width, title on the left,
   supporting copy on the right. Markup: .eyebrow, h1/h2, then a content div. */
.split-layout {
    display: grid;
    column-gap: 54px;
    align-items: center;
    grid-template-columns: .8fr 1.2fr
}

.split-layout > .eyebrow,
.hero-grid > .eyebrow {
    grid-column: 1 / -1;
    margin-bottom: 28px
}

.split-layout > h2 {
    margin-bottom: 0
}

.split-layout > div > :last-child {
    margin-bottom: 0
}

.split-layout p:not(.eyebrow) {
    color: var(--muted)
}

.eyebrow {
    color: var(--accent);
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    font-weight: 800;
    margin: 0 0 12px
}

.lead {
    font-size: clamp(1rem, 1.6vw, 1.18rem);
    color: var(--muted);
    max-width: 610px
}

/* ============================
   4. Accessibility / utility
   ============================ */
.skip-link {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 20;
    padding: 8px 15px;
    border-radius: 8px;
    background: var(--accent);
    color: var(--on-accent);
    transform: translateY(-160%)
}

.skip-link:focus {
    transform: none
}

/* Only hide reveal elements when JS is running, so content stays visible without it. */
.js .reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity .65s ease, transform .65s ease
}

.js .reveal.show {
    opacity: 1;
    transform: none
}

/* ============================
   5. Header & nav
   ============================ */
.site-header {
    height: var(--header);
    position: sticky;
    top: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--bg) 84%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid transparent;
    transition: .25s
}

.site-header.scrolled {
    border-color: var(--border)
}

.nav {
    min-height: var(--header);
    display: flex;
    align-items: center;
    justify-content: space-between
}

.brand {
    display: inline-flex;
    gap: 9px;
    align-items: center;
    font-weight: 800;
    letter-spacing: -.04em;
    font-size: 1.12rem
}

.brand img {
    width: 34px
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 25px
}

.nav-link {
    font-size: .9rem;
    color: var(--muted);
    font-weight: 600
}

.nav-link:hover,
.nav-link.active {
    color: var(--text)
}

.theme-toggle,
.menu-toggle {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer
}

.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: grid;
    place-items: center
}

.theme-toggle svg {
    width: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round
}

.menu-toggle {
    display: none;
    padding: 9px;
    border-radius: 8px
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: currentColor;
    margin: 4px
}

/* ============================
   6. Hero
   ============================ */
.hero {
    position: relative;
    overflow: hidden;
    padding-top: clamp(28px, 4vw, 48px);
    padding-bottom: 70px
}

.hero:before {
    content: "";
    position: absolute;
    width: 600px;
    height: 600px;
    right: -250px;
    top: -250px;
    background: radial-gradient(circle, rgba(34, 197, 94, .15), transparent 65%);
    pointer-events: none
}

/* Markup: .eyebrow, .hero-copy (h1, lead, buttons), .hero-art. */
.hero-grid {
    display: grid;
    column-gap: 54px;
    align-items: center;
    grid-template-columns: 1.03fr .97fr
}

.hero-copy {
    grid-column: 1
}

.hero-art {
    grid-column: 2;
    grid-row: 2;
    border-radius: 24px;
    overflow: hidden
}

.hero-art img {
    width: 100%
}

.scroll-cue {
    display: flex;
    width: max-content;
    gap: 9px;
    align-items: center;
    margin: 20px auto 0;
    font-size: .76rem;
    color: var(--muted)
}

.scroll-cue span {
    width: 24px;
    height: 36px;
    border: 1px solid var(--muted);
    border-radius: 12px;
    position: relative
}

.scroll-cue span:after {
    content: "";
    width: 3px;
    height: 6px;
    border-radius: 2px;
    background: var(--accent);
    position: absolute;
    left: 9px;
    top: 7px;
    animation: scroll 1.5s infinite
}

@keyframes scroll {
    50% {
        transform: translateY(10px);
        opacity: 0
    }
}

/* ============================
   7. Buttons & links
   ============================ */
.button-row {
    display: flex;
    gap: 13px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 30px
}

.button-row.social-row {
    margin-top: 16px;
    gap: 10px
}

.button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 12px 18px;
    background: var(--accent);
    color: var(--on-accent);
    border: 1px solid transparent;
    border-radius: 12px;
    font: inherit;
    font-size: .92rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform .2s, background .2s
}

.button:hover {
    background: var(--accent-hover);
    transform: translateY(-2px)
}

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

.button-secondary:hover {
    background: var(--surface)
}

.button-social {
    padding: 9px 15px;
    font-size: .85rem;
    background: var(--social)
}

.button-social:hover {
    background: var(--social-hover)
}

/* Official Google Play badge: the PNG has transparent padding built in (keep it, per
   Google's badge guidelines), so negative margins line it up with the other buttons. */
.play-badge {
    display: inline-block;
    margin: -11px -8px;
    transition: transform .2s
}

.play-badge img {
    height: 67px;
    width: auto
}

.play-badge:hover {
    transform: translateY(-2px)
}

.text-link {
    color: var(--accent);
    font-size: .9rem;
    font-weight: 800
}

.text-link:hover {
    color: var(--accent-hover)
}

.text-link.text-link-lg {
    font-size: 1.1rem
}

/* ============================
   8. Badges
   ============================ */
.badge {
    display: inline-block;
    padding: 4px 9px;
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: .69rem;
    text-transform: uppercase;
    letter-spacing: .07em;
    font-weight: 800;
    color: var(--muted)
}

.badge.live {
    color: var(--live-text);
    background: rgba(34, 197, 94, .12);
    border-color: rgba(34, 197, 94, .25)
}

/* ============================
   9. Cards (games & features)
   ============================ */
.games-grid,
.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px
}

.game-card,
.feature {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .25s, box-shadow .25s
}

.game-card-link:hover .game-card {
    transform: translateY(-6px);
    box-shadow: var(--shadow)
}

.game-card > img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: var(--surface-2);
    border-radius: var(--radius)
}

.card-body {
    padding: 23px
}

/* Compact placeholder card for games that are not released yet. */
.game-card.coming-soon {
    align-self: start;
    display: flex;
    gap: 16px;
    align-items: center;
    padding: 20px 23px;
    background: transparent;
    border-style: dashed
}

.coming-soon-icon {
    font-size: 1.8rem;
    line-height: 1
}

.coming-soon h3 {
    font-size: 1.08rem;
    margin: 8px 0 2px
}

.coming-soon p {
    margin: 0;
    font-size: .9rem;
    color: var(--muted)
}

.card-body .text-link {
    display: inline-block;
    margin-top: 10px
}

.card-body p,
.feature p {
    color: var(--muted)
}

.feature {
    padding: 25px
}

.feature:hover {
    transform: translateY(-3px)
}

.feature-icon {
    display: block;
    font-size: 1.7rem;
    line-height: 1
}

.feature h3 {
    font-size: 1.08rem
}

.feature p {
    font-size: .9rem;
    margin-bottom: 0
}

/* ============================
   10. Footer
   ============================ */
.site-footer {
    padding: 58px 0 25px;
    border-top: 1px solid var(--border)
}

.footer-grid {
    display: flex;
    justify-content: space-between;
    gap: 28px;
    align-items: start
}

.footer-grid p {
    font-size: .9rem;
    margin: 13px 0;
    color: var(--muted)
}

.footer-links {
    display: grid;
    grid-template-columns: repeat(2, auto);
    gap: 8px 38px;
    font-size: .87rem;
    color: var(--muted)
}

.footer-links a:hover {
    color: var(--accent)
}

/* Game pages show a second footer column with the game's legal links. */
.footer-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 24px 56px
}

.footer-links.footer-links-game {
    grid-template-columns: auto
}

.copyright {
    margin-top: 35px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    font-size: .78rem;
    color: var(--muted)
}

.copyright p {
    margin: 0 0 4px
}

.back-to-top {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 43px;
    height: 43px;
    border: 1px solid var(--border);
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--surface);
    box-shadow: var(--shadow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: .2s
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: none
}

/* ============================
   11. Homepage privacy section
   ============================ */
.policy-block > h3 {
    margin-top: 0
}

.privacy-contact {
    margin-top: 34px;
    color: var(--muted)
}

/* Plain-text email address; one click selects the whole address, without the surrounding text. */
.email {
    color: var(--accent);
    font-weight: 600;
    overflow-wrap: anywhere;
    -webkit-user-select: all;
    user-select: all
}

.footer-links .email {
    color: inherit;
    font-weight: inherit
}

/* ============================
   12. Game page components (e.g. puzzleme)
   ============================ */
/* Screenshot carousel: shows --per-view images, arrows move one image at a time.
   Without JS it is still a swipeable/scrollable row; arrows and dots are added by script.js. */
.carousel {
    --per-view: 3;
    --gap: 28px;
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px 16px
}

/* Landscape screenshots need more width per image. */
.carousel-landscape {
    --per-view: 2
}

.carousel-track {
    grid-column: 2;
    display: flex;
    gap: var(--gap);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scroll-padding-inline: 4px;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 12px 4px 24px
}

.carousel-track::-webkit-scrollbar {
    display: none
}

.carousel-track img {
    flex: 0 0 calc((100% - (var(--per-view) - 1) * var(--gap)) / var(--per-view));
    min-width: 0;
    height: auto;
    scroll-snap-align: start;
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: .25s
}

.carousel-track img:hover {
    transform: translateY(-8px)
}

.carousel-btn,
.carousel-dots {
    display: none
}

.js .carousel-btn {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    padding: 0 0 4px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: .2s
}

.js .carousel-btn:hover {
    border-color: var(--accent);
    color: var(--accent)
}

.js .carousel-dots {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    gap: 10px
}

.js .carousel-dots[hidden] {
    display: none
}

.carousel-dots button {
    width: 10px;
    height: 10px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: var(--muted);
    opacity: .4;
    cursor: pointer;
    transition: .25s
}

.carousel-dots button[aria-current="true"] {
    width: 28px;
    background: var(--accent);
    opacity: 1
}

.stars {
    color: var(--stars);
    letter-spacing: .08em
}

.app-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 22px;
    margin: 22px 0 0;
    font-size: .92rem;
    color: var(--muted)
}

.app-stats strong {
    color: var(--text)
}

.rating-score {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 8px
}

.rating-score strong {
    font-size: 3rem;
    line-height: 1;
    color: var(--text);
    letter-spacing: -.04em
}

.rating-score .stars {
    font-size: 1.5rem
}

.reviews-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px
}

.review {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 25px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius)
}

.review blockquote {
    margin: 0;
    flex: 1
}

.review figcaption {
    font-size: .85rem;
    color: var(--muted)
}

.review figcaption strong {
    color: var(--text)
}

.faq {
    display: flex;
    flex-direction: column;
    gap: 14px
}

.faq details {
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 16px;
    padding: 0 22px
}

.faq summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
    font-weight: 700;
    cursor: pointer;
    list-style: none
}

.faq summary::-webkit-details-marker {
    display: none
}

.faq summary::after {
    content: "+";
    flex-shrink: 0;
    color: var(--accent);
    font-size: 1.3rem;
    font-weight: 800;
    transition: transform .2s
}

.faq details[open] summary::after {
    transform: rotate(45deg)
}

.faq details p {
    margin: -4px 0 20px;
    color: var(--muted)
}

/* ============================
   13. Legal pages (Terms / Privacy)
   ============================ */
.page-title {
    font-size: clamp(2.1rem, 4.2vw, 3.4rem)
}

.legal-meta {
    font-size: .9rem;
    color: var(--muted);
    margin-bottom: 0
}

.legal-content {
    max-width: 760px;
    color: var(--muted)
}

.legal-content h2 {
    color: var(--text);
    font-size: 1.5rem;
    margin: 34px 0 10px
}

.legal-content h2:first-child {
    margin-top: 0
}

.legal-content p {
    margin-bottom: 16px
}

.legal-content ul,
.legal-content ol {
    margin: 0 0 16px;
    padding-left: 22px
}

.legal-content li {
    margin-bottom: 8px
}

.legal-content a {
    color: var(--accent);
    word-break: break-word
}

/* ============================
   14. 404 page
   ============================ */
.error-section {
    min-height: calc(100vh - var(--header));
    display: flex;
    align-items: center
}

.error-grid {
    display: grid;
    gap: 40px;
    align-items: center;
    grid-template-columns: .9fr 1.1fr
}

.error-code {
    font-size: clamp(6rem, 16vw, 11rem);
    font-weight: 800;
    letter-spacing: -.05em;
    line-height: .9;
    color: var(--accent);
    margin: 0
}

.error-copy h1 {
    font-size: clamp(1.8rem, 3.4vw, 2.6rem);
    max-width: none;
    margin-bottom: 14px
}

.error-art {
    display: grid;
    place-items: center
}

.error-art svg {
    width: 100%;
    max-width: 360px;
    height: auto
}

/* ============================
   15. Responsive
   ============================ */
@media (max-width: 760px) {
    .menu-toggle {
        display: block
    }

    .nav-actions {
        position: absolute;
        left: 0;
        right: 0;
        top: calc(100% + 1px);
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding: 13px 20px 20px;
        background: var(--bg);
        border-bottom: 1px solid var(--border)
    }

    .nav-actions.open {
        display: flex
    }

    .nav-link {
        padding: 10px 0
    }

    .theme-toggle {
        margin-top: 7px
    }

    .split-layout,
    .hero-grid,
    .error-grid {
        grid-template-columns: minmax(0, 1fr)
    }

    .split-layout > .eyebrow,
    .hero-grid > .eyebrow {
        margin-bottom: 12px
    }

    .split-layout > h2 {
        margin-bottom: 16px
    }

    .hero-grid {
        text-align: center
    }

    .hero-grid > .eyebrow,
    .hero-copy,
    .hero-art {
        grid-column: auto;
        grid-row: auto
    }

    /* Phones: keep the logo/app icons from filling the whole screen width. */
    .hero-art {
        width: min(280px, 72vw);
        margin: 0 auto 28px;
        order: -1
    }

    .game-card > img {
        width: min(280px, 72vw);
        margin: 24px auto 0
    }

    .hero-copy .lead {
        margin-inline: auto
    }

    .hero-copy .button-row,
    .hero-copy .app-stats,
    .error-copy .button-row {
        justify-content: center
    }

    .scroll-cue {
        margin-top: 45px
    }

    .games-grid,
    .features-grid,
    .reviews-grid {
        grid-template-columns: 1fr
    }

    .section-heading {
        margin-bottom: 30px
    }

    .footer-grid {
        flex-direction: column
    }

    .footer-links {
        width: 100%
    }

    .footer-nav {
        flex-direction: column;
        width: 100%
    }

    /* Phones: one screenshot at a time; arrows sit under the image, around the dots: ‹ • • • › */
    .carousel {
        --per-view: 1;
        --gap: 16px;
        max-width: 340px;
        margin: auto
    }

    .carousel-landscape {
        max-width: none
    }

    .carousel-track {
        grid-column: 1 / -1;
        grid-row: 1
    }

    .js .carousel-btn {
        grid-row: 2;
        width: 40px;
        height: 40px;
        font-size: 1.7rem
    }

    .js .carousel-dots {
        grid-column: 2;
        grid-row: 2;
        flex-wrap: wrap;
        gap: 6px
    }

    .carousel-dots button {
        width: 8px;
        height: 8px
    }

    .carousel-dots button[aria-current="true"] {
        width: 20px
    }

    .faq summary {
        font-size: .95rem
    }

    .error-copy {
        text-align: center
    }

    .error-art {
        order: -1
    }
}

@media (min-width: 761px) and (max-width: 980px) {
    .games-grid,
    .features-grid {
        grid-template-columns: repeat(2, 1fr)
    }

    .carousel {
        --per-view: 2
    }

    .carousel-landscape {
        --per-view: 1
    }

    .reviews-grid {
        grid-template-columns: 1fr
    }
}

@media (prefers-reduced-motion: reduce) {
    html,
    .carousel-track {
        scroll-behavior: auto
    }

    *,
    *:before,
    *:after {
        animation-duration: .01ms !important;
        transition-duration: .01ms !important
    }

    .js .reveal {
        opacity: 1;
        transform: none
    }
}
