/* ============================================================ base ==== */

:root {
    --bg:        #06080a;
    --bg-soft:   #0b0f12;
    --panel:     rgba(255, 255, 255, .038);
    --panel-2:   rgba(255, 255, 255, .06);
    --line:      rgba(255, 255, 255, .10);
    --fg:        #e9efec;
    --muted:     #8f9c97;
    --green:     #19e27e;
    --green-dim: #0e7f47;
    --cyan:      #63d9ff;
    --amber:     #ffb020;
    --gold:      #ffd166;
    --warn:      #ff8a4c;

    --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--fg);
}

body {
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overflow-x: hidden;
    min-height: 100svh;
}

/* фон: технічна сітка + мʼяке світло */

.bg-grid {
    position: fixed;
    inset: 0;
    z-index: -2;
    background-image:
        linear-gradient(rgba(255, 255, 255, .028) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .028) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(ellipse 90% 60% at 50% 0%, #000 30%, transparent 100%);
}

.bg-glow {
    position: fixed;
    inset: -20% -20% auto -20%;
    height: 70vh;
    z-index: -1;
    background: radial-gradient(ellipse at 50% 0%, rgba(25, 226, 126, .16), transparent 62%);
    pointer-events: none;
}

.wrap {
    max-width: 560px;
    margin: 0 auto;
    padding: max(22px, env(safe-area-inset-top)) 20px calc(36px + env(safe-area-inset-bottom));
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* ========================================================= elements ==== */

.topbar {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--green);
    background: rgba(25, 226, 126, .08);
    border: 1px solid rgba(25, 226, 126, .28);
    border-radius: 999px;
    padding: 7px 14px;
}

.chip::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 10px var(--green);
    animation: pulse 2s ease-in-out infinite;
}

.chip--warn {
    color: var(--warn);
    background: rgba(255, 138, 76, .08);
    border-color: rgba(255, 138, 76, .3);
}

.chip--warn::before { background: var(--warn); box-shadow: 0 0 10px var(--warn); }

.chip--idle {
    color: var(--muted);
    background: rgba(255, 255, 255, .04);
    border-color: var(--line);
}

.chip--idle::before { background: var(--muted); box-shadow: none; animation: none; }

.panel {
    position: relative;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 20px;
    overflow: hidden;
}

.panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(25, 226, 126, .7), transparent);
}

.panel--warn::before {
    background: linear-gradient(90deg, transparent, rgba(255, 138, 76, .7), transparent);
}

.eyebrow {
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--green);
    margin-bottom: 10px;
}

.title {
    font-size: 22px;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: -.01em;
    margin: 0 0 14px;
}

.panel .title {
    font-family: var(--mono);
    font-size: 19px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #fff;
}

.title--intro {
    font-family: var(--sans);
    font-size: clamp(28px, 8.5vw, 38px);
    text-align: center;
    text-transform: none;
    letter-spacing: -.02em;
    margin-bottom: 22px;
    background: linear-gradient(180deg, #fff, #b9f5d5);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

/* --------------------------------------------------------- проза ----- */

.prose p {
    margin: 0 0 13px;
    color: #dbe4e0;
}

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

.prose strong {
    color: #fff;
    font-weight: 700;
}

.prose ul {
    list-style: none;
    margin: 4px 0 15px;
    padding: 0;
}

.prose ul li {
    position: relative;
    padding-left: 22px;
    margin-bottom: 6px;
    color: #cfdad6;
}

.prose ul.dash li::before {
    content: "—";
    position: absolute;
    left: 0;
    color: var(--green);
}

.prose ul.check li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--green);
    font-weight: 700;
}

.footnote {
    margin: 20px 0 0;
    text-align: center;
    font-family: var(--mono);
    font-size: 11px;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: rgba(143, 156, 151, .75);
}

/* --------------------------------------------------------- кнопки ---- */

.actions {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 58px;
    padding: 16px 20px;
    border: 0;
    border-radius: 14px;
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    text-decoration: none;
    color: #04140c;
    background: linear-gradient(180deg, #29f593, var(--green) 55%, #0fbb67);
    box-shadow: 0 10px 30px -12px rgba(25, 226, 126, .85), inset 0 1px 0 rgba(255, 255, 255, .35);
    cursor: pointer;
    transition: transform .12s ease, filter .12s ease;
}

.btn:active { transform: scale(.975); filter: brightness(1.08); }

.btn--ghost {
    color: var(--fg);
    background: rgba(255, 255, 255, .05);
    border: 1px solid var(--line);
    box-shadow: none;
    min-height: 52px;
    font-size: 13px;
}

.btn--gold {
    color: #241a04;
    background: linear-gradient(180deg, #ffe6a3, var(--gold) 55%, #e8ac3a);
    box-shadow: 0 10px 30px -12px rgba(255, 209, 102, .8), inset 0 1px 0 rgba(255, 255, 255, .45);
}

/* -------------------------------------------------------- підказки --- */

.hints {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.hint {
    background: rgba(255, 176, 32, .07);
    border: 1px solid rgba(255, 176, 32, .25);
    border-radius: 14px;
    padding: 14px 16px;
    animation: rise .35s ease both;
}

.hint__label {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: .2em;
    color: var(--amber);
    margin-bottom: 6px;
}

.hint p { margin: 0; color: #f0e3cd; }

/* ============================================================ екран === */

.screen { animation: rise .5s cubic-bezier(.2, .8, .3, 1) both; }

.screen.is-pending { opacity: 0; animation: none; }

.screen--notice .panel { text-align: left; }

/* ======================================================= flash / fx === */

.flash {
    position: fixed;
    inset: 0;
    z-index: 60;
    background: var(--bg);
    display: grid;
    place-items: center;
    overflow: hidden;
    transition: opacity .38s ease;
}

.flash.is-out { opacity: 0; pointer-events: none; }

.flash__text {
    position: relative;
    z-index: 2;
    font-family: var(--mono);
    font-size: clamp(26px, 8vw, 40px);
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--green);
    text-shadow: 0 0 26px rgba(25, 226, 126, .55);
    text-align: center;
    padding: 0 24px;
    animation: flashPop .5s cubic-bezier(.2, 1.3, .4, 1) both;
}

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

/* сканування */
.flash[data-fx="scan"] .flash__fx::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--green), transparent);
    box-shadow: 0 0 24px rgba(25, 226, 126, .8);
    animation: sweep 1.1s ease-in-out infinite;
}

/* котушка філаменту */
.flash[data-fx="filament"] .flash__fx::before,
.flash[data-fx="filament"] .flash__fx::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
}

.flash[data-fx="filament"] .flash__fx::before {
    width: 260px;
    height: 260px;
    margin: -130px 0 0 -130px;
    border: 10px dashed rgba(25, 226, 126, .35);
    animation: spin 3s linear infinite;
}

.flash[data-fx="filament"] .flash__fx::after {
    width: 170px;
    height: 170px;
    margin: -85px 0 0 -85px;
    border: 4px solid rgba(25, 226, 126, .18);
    animation: spin 2s linear infinite reverse;
}

/* frostbite */
.flash[data-fx="frost"] .flash__text {
    color: var(--cyan);
    text-shadow: 0 0 26px rgba(99, 217, 255, .55);
}

.flash[data-fx="frost"] .flash__fx::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 50% 50%, rgba(99, 217, 255, .22), transparent 55%),
        conic-gradient(from 0deg, transparent 0 20%, rgba(99, 217, 255, .16) 25%, transparent 30% 50%,
                       rgba(99, 217, 255, .16) 55%, transparent 60% 80%, rgba(99, 217, 255, .16) 85%, transparent 90%);
    animation: spin 9s linear infinite;
}

/* сушарка */
.flash[data-fx="dry"] .flash__text {
    color: var(--amber);
    text-shadow: 0 0 26px rgba(255, 176, 32, .5);
}

.flash[data-fx="dry"] .flash__fx::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg, rgba(255, 176, 32, .12) 0 2px, transparent 2px 22px);
    animation: heat 1.6s linear infinite;
}

/* пральна машина */
.flash[data-fx="washer"] .flash__fx::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 240px;
    height: 240px;
    margin: -120px 0 0 -120px;
    border-radius: 50%;
    border: 8px solid rgba(25, 226, 126, .22);
    border-top-color: rgba(25, 226, 126, .75);
    animation: spin 1.1s linear infinite;
}

/* ============================================================ фінал === */

.final {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.final__title {
    font-family: var(--mono);
    font-size: clamp(24px, 8vw, 48px);
    font-weight: 800;
    letter-spacing: .02em;
    line-height: 1.05;
    margin: 6px 0 8px;
    background: linear-gradient(180deg, #ffffff, var(--green));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 34px rgba(25, 226, 126, .45));
}

.final__block {
    width: 100%;
    background: linear-gradient(180deg, var(--panel-2), var(--panel));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    text-align: left;
}

.prose--final p { text-align: center; }
.prose--final ul { max-width: 260px; margin-inline: auto; }

.prose--ps p { color: var(--muted); font-size: 15px; }
.prose--ps p:first-child {
    font-family: var(--mono);
    letter-spacing: .18em;
    color: var(--green);
    font-size: 12px;
}

.final.is-sequence .final__title,
.final.is-sequence .final__block { opacity: 0; transform: translateY(14px); }

.final .final__title.is-in,
.final .final__block.is-in {
    opacity: 1;
    transform: none;
    transition: opacity .7s ease, transform .7s cubic-bezier(.2, .8, .3, 1);
}

.final.is-compact .final__title { animation: none; }

#confetti {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 40;
    display: none;
}

#confetti.is-on { display: block; }

/* ======================================================== анімації ==== */

@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: none; }
}

@keyframes flashPop {
    0%   { opacity: 0; transform: scale(.86); }
    60%  { opacity: 1; transform: scale(1.04); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes sweep {
    0%   { top: 12%; opacity: 0; }
    20%  { opacity: 1; }
    80%  { opacity: 1; }
    100% { top: 88%; opacity: 0; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes heat {
    to { background-position: 0 22px; }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: .35; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001s !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001s !important;
    }
}
