:root {
    --bg: #1a1014;
    --bg2: #3a2218;
    --panel: rgba(255, 255, 255, 0.10);
    --panel-border: rgba(255, 255, 255, 0.22);
    --accent: #ffb43d;
    --accent2: #ff7a3d;
    --good: #6fe06f;
    --bad: #ff4d4d;
    --text: #fff7ec;
    --text-dim: #e9d3b8;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(120% 120% at 20% 0%, var(--bg2) 0%, var(--bg) 60%);
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 18px;
    z-index: 50;
    background: rgba(0, 0, 0, .35);
    backdrop-filter: blur(8px);
}
.timer {
    font-size: clamp(22px, 3vw, 34px);
    font-weight: 800;
    color: var(--accent);
}
.link-menu {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    color: var(--text);
    text-decoration: none;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 18px;
    cursor: pointer;
    font-family: inherit;
}

/* ===== Экраны ===== */
.screen {
    position: fixed;
    inset: 60px 0 0 0;
    display: none;
    flex-direction: column;
    padding: 2vmin;
}
.screen.active { display: flex; }

/* ===== Стартовый экран ===== */
.center-box { margin: auto; width: min(660px, 94vw); }
.card {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    backdrop-filter: blur(10px);
    border-radius: 24px;
    padding: 4vmin 5vmin;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
    text-align: center;
}
.title { margin: 0 0 .3em; font-size: clamp(28px, 5vw, 52px); }
.subtitle { margin: 0 0 1.2em; color: var(--text-dim); font-size: clamp(15px, 2.4vw, 22px); line-height: 1.5; }
.hint { color: var(--text-dim); margin-bottom: 1.4em; font-size: clamp(14px, 2vw, 18px); }

.recipe {
    list-style: none;
    counter-reset: step;
    margin: 0 auto 1.2em;
    padding: 0;
    max-width: 460px;
    text-align: left;
}
.recipe li {
    counter-increment: step;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 12px 50px;
    margin-bottom: 8px;
    background: rgba(0,0,0,.25);
    border-radius: 12px;
    position: relative;
    font-size: clamp(15px, 2.1vw, 19px);
    color: #fff7ec;
}
.recipe li::before {
    content: counter(step);
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    line-height: 28px;
    text-align: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #2a1206;
    font-weight: 800;
}
.r-emoji { font-size: 24px; }

.btn {
    width: 100%;
    padding: 20px 24px;
    font-size: clamp(18px, 3vw, 26px);
    font-weight: 700;
    border: none;
    border-radius: 16px;
    cursor: pointer;
    color: #2a1206;
    transition: transform .08s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    box-shadow: 0 10px 30px rgba(255, 180, 61, .4);
}

/* ===== Игровой экран ===== */
.cooktop-bg {
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,.04), transparent 45%),
        radial-gradient(circle at 50% 50%, #26262b 0%, #131316 100%);
}

/* Шапка вопроса */
.q-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.block-badge {
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #2a1206;
    font-weight: 800;
    padding: 6px 16px;
    border-radius: 10px;
    font-size: clamp(14px, 2vw, 18px);
    flex-shrink: 0;
}
.block-title {
    font-size: clamp(16px, 2.4vw, 22px);
    font-weight: 700;
    color: var(--accent);
}
.question-text {
    font-size: clamp(16px, 2.2vw, 22px);
    line-height: 1.45;
    margin-bottom: 14px;
    color: #fff7ec;
    font-weight: 500;
    background: rgba(0,0,0,.3);
    border: 1px solid var(--panel-border);
    border-radius: 14px;
    padding: 14px 18px;
}

/* Основная зона */
.play-layout {
    flex: 1;
    display: flex;
    gap: 16px;
    min-height: 0;
}

/* ===== Варочная панель (плита) ===== */
.cooktop {
    flex: 1;
    border-radius: 22px;
    background:
        radial-gradient(circle at 30% 20%, rgba(255,255,255,.05), transparent 40%),
        radial-gradient(circle at 50% 50%, #2a2a2f 0%, #131316 100%);
    border: 8px solid #0a0a0c;
    box-shadow: inset 0 4px 24px rgba(0,0,0,.7), 0 14px 36px rgba(0,0,0,.5);
    padding: clamp(14px, 2.5vw, 32px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: clamp(12px, 2vw, 24px);
    min-height: 0;
}

/* Конфорка */
.burner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}
/* Чугунная конфорка со спиралями */
.burner::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background:
        repeating-radial-gradient(circle at 50% 50%,
            #161616 0px, #161616 3px,
            #2c2c2c 3px, #2c2c2c 6px),
        radial-gradient(circle at 50% 50%, #3a3a3e, #0d0d10);
    box-shadow:
        inset 0 0 0 3px #1d1d20,
        inset 0 0 18px rgba(0,0,0,.9),
        0 2px 8px rgba(0,0,0,.6);
    aspect-ratio: 1 / 1;
    margin: auto;
    max-width: 100%;
    max-height: 100%;
    width: min(100%, 260px);
    height: min(100%, 260px);
    transition: box-shadow .25s ease;
}
/* Горящая конфорка */
.burner.hot::before {
    box-shadow:
        inset 0 0 0 3px #2a1206,
        inset 0 0 24px rgba(255,90,0,.55),
        0 0 36px rgba(255,80,0,.35);
}
/* Конфорка под правильным ответом */
.burner.burn-good::before {
    box-shadow:
        inset 0 0 0 3px #0a3a16,
        inset 0 0 24px rgba(56,224,138,.6),
        0 0 36px rgba(56,224,138,.4);
}
/* Конфорка под неправильным ответом */
.burner.burn-bad::before {
    box-shadow:
        inset 0 0 0 3px #3a0a0a,
        inset 0 0 24px rgba(255,77,77,.6),
        0 0 36px rgba(255,77,77,.4);
}

/* Карточка-ответ на конфорке */
.ingredient {
    position: relative;
    z-index: 2;
    width: 82%;
    max-width: 260px;
    min-height: clamp(90px, 12vw, 130px);
    border-radius: 16px;
    background: linear-gradient(145deg, #ffffff, #ffe9c7);
    color: #4a2e12;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    text-align: left;
    padding: 12px 16px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .5);
    cursor: pointer;
    transition: transform .1s ease, background .2s ease, border-color .2s ease;
    touch-action: manipulation;
    border: 3px solid rgba(255,180,61,.55);
}
.ingredient:active { transform: scale(.95); }

.opt-letter {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent2));
    color: #2a1206;
    font-weight: 800;
    font-size: 20px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.opt-text { flex: 1; font-size: clamp(14px, 1.9vw, 18px); line-height: 1.3; }

.ingredient.correct {
    background: linear-gradient(145deg, #d8ffe9, #b6f5cf);
    border-color: var(--good);
}
.ingredient.wrong {
    background: linear-gradient(145deg, #ffd0d0, #ff9b9b);
    border-color: var(--bad);
    animation: wrongShake .4s ease;
}
.ingredient.disabled { pointer-events: none; }

@keyframes wrongShake {
    0%,100% { transform: translateX(0); }
    20% { transform: translateX(-7px); }
    40% { transform: translateX(7px); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}

/* ===== Панель бутерброда ===== */
.sandwich-panel {
    width: clamp(230px, 25vw, 300px);
    flex-shrink: 0;
    background: rgba(0,0,0,.3);
    border: 1px solid var(--panel-border);
    border-radius: 22px;
    padding: clamp(14px, 2vw, 22px);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.sandwich-title {
    text-align: center;
    font-size: clamp(16px, 2.2vw, 20px);
    font-weight: 700;
    color: var(--text-dim);
    margin-bottom: 10px;
}

.sandwich-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 14px;
}
.sandwich {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
}

/* Тарелка (объёмная керамическая) */
.sandwich-plate {
    width: clamp(170px, 18vw, 224px);
    height: 22px;
    background:
        radial-gradient(ellipse at 50% 30%, #f0f0f0, #c8c8c8 55%, #9a9a9a 100%);
    border-radius: 50%;
    box-shadow:
        0 8px 18px rgba(0,0,0,.45),
        inset 0 2px 3px rgba(255,255,255,.7),
        inset 0 -3px 5px rgba(0,0,0,.25);
    margin-top: 2px;
    position: relative;
    z-index: 0;
}

/* Слои бутерброда (SVG-текстуры) */
.sw-layer {
    width: clamp(155px, 16vw, 200px);
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 3px 4px rgba(0,0,0,.35));
    transition: all .3s ease;
}

.layer-bread {
    height: 46px;
    background-image: url("../img/layer-bread.svg");
}
.layer-sausage {
    width: clamp(148px, 15.2vw, 188px);
    height: 34px;
    background-image: url("../img/layer-sausage.svg");
}
.layer-veggie {
    width: clamp(140px, 14.4vw, 176px);
    height: 36px;
    background-image: url("../img/layer-veggie.svg");
    margin-bottom: -4px; /* листья салата слегка накладываются вниз */
}
.layer-cheese {
    width: clamp(150px, 15.5vw, 190px);
    height: 38px;
    background-image: url("../img/layer-cheese.svg");
}
/* Верхняя булка (перевёрнутая) */
.layer-bread-top {
    height: 46px;
    background-image: url("../img/layer-bread-top.svg");
    margin-top: -2px;
}

/* Заблокированный слой (призрак) */
.sw-layer.locked {
    opacity: 0.15;
    filter: grayscale(1) blur(.5px);
    height: 8px !important;
    overflow: hidden;
}

/* Разблокированный слой */
.sw-layer.unlocked {
    opacity: 1;
    filter: drop-shadow(0 3px 4px rgba(0,0,0,.35));
    animation: layerDrop .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes layerDrop {
    0% { transform: translateY(-50px) scale(.6) rotate(-3deg); opacity: 0; }
    60% { transform: translateY(6px) scale(1.08) rotate(1deg); opacity: 1; }
    100% { transform: translateY(0) scale(1) rotate(0); opacity: 1; }
}

/* Список шагов */
.steps { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: clamp(13px, 1.6vw, 15px);
    color: var(--text-dim);
    transition: all .25s ease;
}
.step .step-ico { font-size: 16px; flex-shrink: 0; }
.step.completed {
    background: rgba(56,224,138,.15);
    color: var(--good);
    font-weight: 700;
}

.progress-text {
    text-align: center;
    color: var(--text-dim);
    font-size: clamp(14px, 1.8vw, 17px);
}
.progress-text span { color: var(--accent); font-weight: 800; font-size: 1.2em; }

/* ===== Эффекты ===== */
.shake { animation: screenShake .4s ease; }
@keyframes screenShake {
    0%,100% { transform: translate(0,0); }
    20% { transform: translate(-8px,3px); }
    40% { transform: translate(8px,-3px); }
    60% { transform: translate(-6px,2px); }
    80% { transform: translate(6px,-2px); }
}

.flash-bad-screen::after {
    content: "";
    position: fixed;
    inset: 0;
    background: rgba(255,0,0,.2);
    pointer-events: none;
    z-index: 100;
    animation: flashFade .4s ease forwards;
}
@keyframes flashFade { from { opacity: 1; } to { opacity: 0; } }

/* ===== Оверлей результата ===== */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 4, 0, .82);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(6px);
}
.overlay.show { display: flex; }
.overlay-box {
    text-align: center;
    padding: 36px 44px 30px;
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    max-width: 560px;
}

/* Анимационный бутерброд на экране результата */
.result-burger {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    margin: 0 auto 18px;
    min-height: 220px;
}
.rb-plate {
    width: clamp(190px, 20vw, 244px);
    height: 24px;
    background: radial-gradient(ellipse at 50% 30%, #f0f0f0, #c8c8c8 55%, #9a9a9a 100%);
    border-radius: 50%;
    box-shadow: 0 8px 18px rgba(0,0,0,.45), inset 0 2px 3px rgba(255,255,255,.7), inset 0 -3px 5px rgba(0,0,0,.25);
}
.rb-layer {
    /* переопределяем размеры под крупный показ на оверлее */
    width: 200px !important;
    opacity: 0;
    transform: translateY(-160px) scale(.5) rotate(-12deg);
}
.rb-layer.layer-bread { height: 56px !important; }
.rb-layer.layer-sausage { width: 188px !important; height: 42px !important; }
.rb-layer.layer-veggie { width: 176px !important; height: 44px !important; margin-bottom: -4px; }
.rb-layer.layer-cheese { width: 190px !important; height: 46px !important; }
.rb-layer.layer-bread-top { height: 56px !important; margin-top: -2px; }
.rb-layer.show {
    animation: rbDrop .6s cubic-bezier(.34,1.56,.64,1) forwards;
}
@keyframes rbDrop {
    0%   { opacity: 0; transform: translateY(-160px) scale(.5) rotate(-12deg); }
    60%  { opacity: 1; transform: translateY(10px) scale(1.08) rotate(2deg); }
    100% { opacity: 1; transform: translateY(0) scale(1) rotate(0); }
}

/* Вспышка-конфетти при финальном слое */
.result-spark {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}
.spark-dot {
    position: absolute;
    width: 10px; height: 10px;
    border-radius: 50%;
    opacity: 0;
}
.result-spark.fire .spark-dot {
    animation: sparkFly 1s ease-out forwards;
}
@keyframes sparkFly {
    0% { opacity: 1; transform: translate(0,0) scale(1); }
    100% { opacity: 0; transform: translate(var(--tx), var(--ty)) scale(.2); }
}

.result-title { margin: .2em 0; font-size: clamp(26px, 5vw, 46px); color: var(--accent); }
.result-text { color: var(--text-dim); font-size: clamp(16px, 2.4vw, 22px); margin-bottom: 1.2em; }

/* ===== Адаптив ===== */
@media (max-width: 880px) {
    .play-layout { flex-direction: column; }
    .sandwich-panel { width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; }
    .sandwich-title { width: 100%; }
    .sandwich-wrap { margin-bottom: 0; }
    .steps { flex: 1; min-width: 130px; }
    .progress-text { width: 100%; }
    .burner::before { width: min(100%, 180px); height: min(100%, 180px); }
}
