:root {
    --bg: #222831;
    --text: #f2f2f2;
    --muted: #a8b0bd;
    --accent: #4b003c;
    --ok: #2e9e6b;
    --paper: #f4e7c8;
    /* безопасные зоны iPhone: чёлка снизу-сверху и полоска дома */
    --safe-t: env(safe-area-inset-top, 0px);
    --safe-b: env(safe-area-inset-bottom, 0px);
    --safe-l: env(safe-area-inset-left, 0px);
    --safe-r: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
    -webkit-text-size-adjust: 100%;
}

[hidden] {
    display: none !important;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* fallback для старых Safari -> svh -> dvh (учитывает панель Safari) */
    min-height: 100vh;
    min-height: 100svh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    padding: calc(var(--safe-t) + 24px) calc(var(--safe-r) + 18px) calc(var(--safe-b) + 24px) calc(var(--safe-l) + 18px);
}

.page {
    width: 100%;
    max-width: 560px;
}

/* ---------- Шапка ---------- */
.head {
    text-align: center;
    margin-bottom: 14px;
}

.head h1 {
    font-size: clamp(1.25rem, 5vw, 2rem);
    line-height: 1.2;
    margin: 0 0 8px;
}

.head .sub {
    margin: 0;
    color: var(--muted);
    font-size: .9rem;
    line-height: 1.4;
}

/* ---------- Арена: внутри неё бегает кнопка ---------- */
.arena {
    position: relative;
    height: 300px; /* fallback */
    height: clamp(200px, 38svh, 330px);
    border: 1px dashed rgba(255, 255, 255, .13);
    border-radius: 20px;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none; /* нет меню при долгом тапе на iOS */
}

.btn {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 15px 24px;
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 40px;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
    touch-action: manipulation; /* убирает задержку двойного тапа */
    -webkit-tap-highlight-color: transparent;
    /* летает плавно; transform НЕ переопределяем в :hover */
    transition: transform .2s ease-out, background .25s, box-shadow .25s;
}

.btn.caught {
    background: var(--ok);
    box-shadow: 0 6px 22px rgba(46, 158, 107, .35);
}

.btn:focus-visible {
    outline: 3px solid #ffd166;
    outline-offset: 4px;
}

@media (hover: hover) {
    .btn:hover {
        box-shadow: 0 8px 26px rgba(0, 0, 0, .5);
        filter: brightness(1.08);
    }
}

.hint {
    text-align: center;
    font-size: .95rem;
    margin: 14px 0 6px;
    min-height: 1.4em;
}

.note {
    text-align: center;
    color: var(--muted);
    font-size: .8rem;
    margin: 0 0 12px;
    line-height: 1.4;
}

.mouse-only {
    display: inline;
}

.touch-only {
    display: none;
}

@media (hover: none),(pointer: coarse) {
    .mouse-only {
        display: none;
    }

    .touch-only {
        display: inline;
    }
}

.progress {
    height: 4px;
    max-width: 180px;
    margin: 0 auto;
    background: rgba(255, 255, 255, .12);
    border-radius: 4px;
    overflow: hidden;
}

.progress i {
    display: block;
    height: 100%;
    width: 0;
    background: #ffd166;
    transition: width .25s ease;
}

/* ---------- Свиток ---------- */
.wrap {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height .9s ease, opacity .6s ease;
    scroll-margin-top: calc(var(--safe-t) + 16px);
}

.wrap.open {
    opacity: 1;
}

.wrap-inner {
    padding: 20px 0 8px;
}

.scroll {
    position: relative;
    max-width: 520px;
    margin: 0 auto;
    padding: 32px 24px;
    background: var(--paper);
    background-image: linear-gradient(to right, rgba(0, 0, 0, .08), transparent 12%, transparent 88%, rgba(0, 0, 0, .08));
    color: #3e2b21;
    border-radius: 6px;
    text-align: center;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
}

/* валики свитка — чисто CSS, без картинок */
.scroll::before, .scroll::after {
    content: '';
    position: absolute;
    left: -8px;
    right: -8px;
    height: 20px;
    background: #d9c69c;
    border-radius: 10px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, .3);
}

.scroll::before {
    top: -10px;
}

.scroll::after {
    bottom: -10px;
}

.scroll h2 {
    margin: 0 0 14px;
    font-size: 1.4rem;
    color: #8b4513;
    line-height: 1.3;
}

.scroll p {
    font-size: 1rem;
    line-height: 1.65;
    margin: 12px 0;
}

.scroll .ps {
    font-size: .92rem;
}

.scroll .sign {
    margin-top: 22px;
    font-style: italic;
    font-weight: 600;
    color: #6d4c33;
}

.block-kapi{
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}
.img-kapi{
    width: 200px;
    height: 100px;
    background-image: url("3.jpg");
    background-size: cover;
    background-position: center;
    border-radius: 20px;
}

/* ---------- Планшет (iPad Air 10.9: 820px в портрете) ---------- */
@media (min-width: 768px) {
    .page {
        max-width: 720px;
    }

    .head h1 {
        font-size: 2.1rem;
    }

    .head .sub {
        font-size: 1rem;
    }

    .arena {
        height: 380px;
    }

    .btn {
        font-size: 1.1rem;
        padding: 17px 30px;
    }

    .scroll {
        max-width: 620px;
        padding: 44px 40px;
    }

    .scroll h2 {
        font-size: 1.7rem;
    }

    .scroll p {
        font-size: 1.08rem;
    }
}

/* ---------- Компьютер ---------- */
@media (min-width: 1024px) {
    .page {
        max-width: 820px;
    }

    .arena {
        height: 400px;
    }
}

/* ---------- Ландшафт телефона (например iPhone 844×390) ---------- */
@media (max-height: 560px) {
    body {
        padding-top: calc(var(--safe-t) + 12px);
    }

    .head {
        margin-bottom: 8px;
    }

    .head h1 {
        font-size: 1.15rem;
        margin-bottom: 4px;
    }

    .head .sub, .note {
        display: none;
    }

    .arena {
        height: 170px;
    }

    .hint {
        margin-top: 10px;
    }
}

/* ---------- Если человек отключил анимации в настройках ОС ---------- */
@media (prefers-reduced-motion: reduce) {
    * {
        transition-duration: .01ms !important;
        animation: none !important;
    }
}