:root {
    --dino-chrome: #535353;
    --dino-bg: #fff;
    --dino-text: #535353;
    --dino-muted: #535353;
    --dino-line: rgba(83, 83, 83, 0.14);
    --dino-accent: #535353;
    --dino-gutter: clamp(1.25rem, 5vw, 2rem);
    --dino-max: 42rem;
    --dino-radius: 4px;
    --dino-font: "Open Sans", system-ui, -apple-system, sans-serif;
}

html[data-theme="dark"] {
    filter: invert(1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    scrollbar-gutter: stable;
    overflow-anchor: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
}

.page {
    min-height: 100vh;
    margin: 0;
    padding: 0 var(--dino-gutter);
    overflow-x: hidden;
    background: var(--dino-bg);
    color: var(--dino-text);
    font-family: var(--dino-font);
    font-size: 1.1875rem;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -webkit-user-select: none;
    user-select: none;
}

/* Home — first screen: game + scroll hint */

.page--home .hero {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    position: relative;
    isolation: isolate;
    min-height: calc(100svh - var(--dino-gutter) * 2);
    box-sizing: border-box;
}

.page--home .scroll-hint {
    position: absolute;
    left: 50%;
    bottom: clamp(0.5rem, 2.5svh, 1rem);
    z-index: 3;
    width: 2.5rem;
    min-height: 0;
    margin: 0;
    padding: 0;
    transform: translateX(-50%);
    align-items: center;
}

.page--home .game {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    margin-top: clamp(1.25rem, 12svh, 4rem);
    margin-bottom: 0;
    min-height: 0;
}

.page--home .faq {
    padding-top: clamp(3rem, 10vw, 5rem);
}

/* Game */

.game {
    width: calc(100% + var(--dino-gutter) * 2);
    max-width: none;
    margin: 0 calc(var(--dino-gutter) * -1) clamp(3rem, 8vw, 4.5rem);
}

.game__container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 100%;
    min-height: 225px;
    visibility: hidden;
}

.game__container--ready {
    visibility: visible;
}

.game__container-icon {
    width: 88px;
    height: 94px;
    margin: 0 auto 12px;
    background-image: url('/assets/images/sprite-2x.png');
    background-repeat: no-repeat;
    background-position: -1678px -2px;
    image-rendering: pixelated;
}

.game__container-icon.icon-disabled {
    visibility: hidden;
}

.game__content {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    background: transparent;
    line-height: 0;
    overflow: hidden;
}

.game__content-canvas {
    display: block;
    max-width: 100%;
    image-rendering: pixelated;
}

.game__meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    position: relative;
    z-index: 2;
    max-width: var(--dino-max);
    margin: 2rem auto 0;
    padding: 0 var(--dino-gutter);
    opacity: .75;
}

.game__meta-spacer {
    flex: 1;
}

.controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 0.625rem;
    margin: 0;
    color: var(--dino-muted);
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1.4;
}

.controls__label {
    color: var(--dino-muted);
}

.controls__keys {
    display: inline-flex;
    flex-direction: column;
    gap: 0.125rem;
}

.controls__key {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.75rem;
    height: 1.75rem;
    padding: 0 0.375rem;
    border: 1px solid var(--dino-line);
    border-radius: var(--dino-radius);
    background: transparent;
    color: var(--dino-chrome);
    font: inherit;
    font-size: 1rem;
    line-height: 1;
}

.controls__key--space {
    min-width: 4rem;
    height: 1.75rem;
    padding: 0 0.75rem;
    font-size: 1rem;
}

.controls--mobile {
    display: none;
}

.scroll-hint {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 3;
    width: 2.5rem;
    height: 2.5rem;
    margin: 0 auto;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #535353;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.scroll-hint__icon {
    display: block;
    width: 0.45rem;
    height: 0.45rem;
    margin-top: -0.15rem;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(45deg);
}

.scroll-hint:active {
    opacity: 0.65;
}

.game__actions {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
    margin-left: auto;
    position: relative;
    z-index: 3;
    color: #535353;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.375rem;
    height: 2.375rem;
    padding: 0;
    border: none;
    border-radius: var(--dino-radius);
    background: transparent;
    color: #535353;
    cursor: pointer;
    outline: none;
    pointer-events: auto;
    transition: opacity 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.icon-btn:hover {
    opacity: 0.75;
}

.icon-btn:focus,
.icon-btn:focus-visible {
    outline: none;
}

.icon {
    display: block;
    width: 1.375rem;
    height: 1.375rem;
    background-color: #535353;
    -webkit-mask: center / contain no-repeat;
    mask: center / contain no-repeat;
    -webkit-mask-source-type: alpha;
    mask-mode: alpha;
}

.icon--sound-on {
    -webkit-mask-image: url('/assets/images/sound-on.png');
    mask-image: url('/assets/images/sound-on.png');
}

.icon--sound-off {
    display: none;
    -webkit-mask-image: url('/assets/images/sound-off.png');
    mask-image: url('/assets/images/sound-off.png');
}

.icon--theme-moon {
    display: none;
    -webkit-mask-image: url('/assets/images/theme-moon.png');
    mask-image: url('/assets/images/theme-moon.png');
}

.icon--theme-sun {
    -webkit-mask-image: url('/assets/images/theme-sun.png');
    mask-image: url('/assets/images/theme-sun.png');
}

.icon-btn--theme-dark .icon--theme-sun {
    display: none;
}

.icon-btn--theme-dark .icon--theme-moon {
    display: block;
}

.icon-btn--sound.icon-btn--muted .icon--sound-on {
    display: none;
}

.icon-btn--sound.icon-btn--muted .icon--sound-off {
    display: block;
}

/* FAQ */

.faq {
    max-width: var(--dino-max);
    margin: 0 auto;
    padding: 0 0 clamp(3.5rem, 10vw, 5rem);
}

.faq__title {
    margin: 0 0 2rem;
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.35;
    text-align: center;
    color: var(--dino-chrome);
}

.faq__list {
    display: flex;
    flex-direction: column;
}

.faq__item {
    border: none;
    border-radius: 0;
    background: transparent;
}

.faq__question {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1.125rem 0;
    font-size: 1.125rem;
    font-weight: 400;
    line-height: 1.5;
    color: var(--dino-chrome);
    cursor: pointer;
    list-style: none;
}

.faq__question::-webkit-details-marker {
    display: none;
}

.faq__question::after {
    content: '';
    flex-shrink: 0;
    width: 0.4rem;
    height: 0.4rem;
    margin-top: 0.15rem;
    border-right: 1.5px solid var(--dino-chrome);
    border-bottom: 1.5px solid var(--dino-chrome);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

.faq__item[open] .faq__question::after {
    margin-top: 0.35rem;
    transform: rotate(-135deg);
}

.faq__answer {
    padding: 0 0 1.375rem;
    color: var(--dino-muted);
    font-size: 1.125rem;
    line-height: 1.7;
}

.faq__answer p {
    margin: 0;
    opacity: .75;
}

/* Static pages */

.header {
    max-width: var(--dino-max);
    margin: 0 auto;
    padding: clamp(1.25rem, 5vw, 2rem) 0 clamp(1rem, 4vw, 1.75rem);
    text-align: center;
}

.header__logo {
    display: inline-block;
    line-height: 0;
    text-decoration: none;
}

.header__logo img {
    display: block;
    width: auto;
    height: clamp(1.375rem, 4vw, 1.75rem);
}

.content__title {
    max-width: var(--dino-max);
    margin: 0 auto 1.75rem;
    padding: 0;
    font-size: 1.5rem;
    font-weight: 400;
    letter-spacing: -0.01em;
    line-height: 1.35;
    text-align: center;
    color: var(--dino-chrome);
}

.page--static {
    padding-bottom: clamp(2.5rem, 8vw, 4rem);
}

.content {
    max-width: var(--dino-max);
    margin: 0 auto;
    padding: 0 0 clamp(3rem, 8vw, 4.5rem);
    color: var(--dino-text);
    font-size: 1.1875rem;
    line-height: 1.75;
}

.content p {
    margin: 0 0 1.375rem;
    color: var(--dino-muted);
}

.content p:last-child {
    margin-bottom: 0;
}

.content h2 {
    margin: 2.75rem 0 1rem;
    font-size: 1.125rem;
    font-weight: 400;
    letter-spacing: 0.06em;
    line-height: 1.4;
    text-transform: uppercase;
    color: var(--dino-chrome);
}

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

.content ul {
    margin: 0 0 1.375rem;
    padding-left: 1.25rem;
    color: var(--dino-muted);
}

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

.content code {
    padding: 0.1em 0.35em;
    border-radius: var(--dino-radius);
    background: rgba(83, 83, 83, 0.06);
    font-size: 0.85em;
    color: var(--dino-chrome);
}

.content a {
    color: var(--dino-chrome);
    text-decoration: underline;
    text-decoration-color: var(--dino-line);
    text-underline-offset: 0.2em;
    transition: text-decoration-color 0.15s ease;
}

.content a:hover {
    text-decoration-color: var(--dino-chrome);
}

.content--legal > p:first-child {
    font-size: 1.125rem;
    color: var(--dino-muted);
}

.content--404 {
    text-align: center;
}

/* Footer */

.footer {
    margin: 0 auto;
    padding: clamp(2.5rem, 8vw, 3.5rem) 0 clamp(4rem, 12vw, 6rem);
    border-top: 1px solid var(--dino-line);
}

.footer__nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.625rem 1.375rem;
}

.footer__link {
    color: var(--dino-chrome);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 0;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.footer__link:hover {
    opacity: 0.75;
}

.footer__languages {
    margin-top: 1.5rem;
    opacity: .75;
}

.footer__languages-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 0.875rem;
    margin: 0;
    padding: 0;
    list-style: none;
    line-height: 1.65;
}

.footer__languages-item {
    display: inline-flex;
    align-items: center;
}

.footer__languages-label,
.footer__languages-link {
    display: inline;
    padding: 0;
    color: var(--dino-muted);
    font-size: 0.875rem;
    line-height: inherit;
}

.footer__languages-item--current .footer__languages-label {
    color: var(--dino-chrome);
}

.footer__languages-link {
    text-decoration: none;
    transition: color 0.15s ease;
}

.footer__languages-link:hover {
    color: var(--dino-chrome);
}

.faq,
.footer {
    position: relative;
    z-index: 2;
}

/* Hidden / game internals */

.hero > .controller {
    position: absolute;
    inset: 0;
    z-index: 1;
    touch-action: pan-y;
    pointer-events: auto;
}

.hero--playing > .controller {
    touch-action: none;
}

.controller {
    touch-action: pan-y;
    pointer-events: auto;
}

.game__container .controller {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.game__container--playing .controller {
    touch-action: none;
}

.interstitial-wrapper {
    display: none;
}

.sprites {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
}

/* RTL */

html[dir="rtl"] .controls {
    direction: rtl;
}

html[dir="rtl"] .faq__question {
    text-align: right;
}

html[dir="rtl"] .content ul {
    padding-right: 1.125rem;
    padding-left: 0;
}

html[dir="rtl"] .footer__nav,
html[dir="rtl"] .footer__languages-list {
    direction: rtl;
}

@media (max-width: 640px) {
    html {
        scrollbar-gutter: auto;
    }

    .page {
        padding-inline: 0;
        padding-block: 0 var(--dino-gutter);
    }

    .game {
        width: 100%;
        margin-inline: 0;
    }

    .faq,
    .footer,
    .content,
    .content__title,
    .header {
        padding-inline: var(--dino-gutter);
    }

    .page--home .hero {
        min-height: calc(100svh - var(--dino-gutter) * 2);
    }

    .controls--desktop {
        display: none;
    }

    .controls--mobile {
        display: flex;
    }

    /* Hero overlay captures taps; icon buttons stay interactive. */
    .page--home .hero > .game {
        pointer-events: none;
    }

    .page--home .game__actions,
    .page--home .scroll-hint {
        pointer-events: auto;
    }
}
