/* ============================================================
   SCREW POP — style.css  (workshop theme)
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
html,
body {
    height: 100%;
    overflow: hidden;
}
body {
    font-family: "Segoe UI", Roboto, Arial, sans-serif;
    background: #17110c;
    color: #f3ece3;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
img {
    -webkit-user-drag: none;
}
.hidden {
    display: none !important;
}

.screen {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: none;
    flex-direction: column;
    overflow: hidden;
}
.screen.active {
    display: flex;
}
#screen-menu,
#screen-levels,
#screen-howto,
#screen-settings {
    background:
        radial-gradient(1100px 520px at 75% -8%, rgba(245, 179, 1, 0.13), transparent 60%),
        radial-gradient(900px 600px at 5% 110%, rgba(226, 69, 60, 0.1), transparent 60%),
        linear-gradient(160deg, #221812 0%, #17110c 60%, #1b140e 100%);
}
#screen-game {
    background: #100c09;
}

/* ---------------- glossy 3D buttons ---------------- */
.btn3d {
    position: relative;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow:
        0 6px 0 rgba(0, 0, 0, 0.5),
        0 10px 18px rgba(0, 0, 0, 0.35),
        inset 0 2px 0 rgba(255, 255, 255, 0.45);
    top: 0;
    transition:
        top 0.06s,
        box-shadow 0.06s;
    overflow: hidden;
}
.btn3d::after {
    content: "";
    position: absolute;
    left: 6%;
    right: 6%;
    top: 5%;
    height: 42%;
    background: linear-gradient(rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.08));
    border-radius: 12px 12px 40% 40%/16px 16px 100% 100%;
    pointer-events: none;
}
.btn3d:active {
    top: 5px;
    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.5),
        0 4px 10px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.btn3d img {
    width: 1.35em;
    height: 1.35em;
    position: relative;
    z-index: 1;
}
.btn3d span {
    position: relative;
    z-index: 1;
}
.btn3d .arr {
    margin-left: auto;
    padding-right: 0.4em;
    font-size: 1.2em;
}
.btn3d.xl {
    font-size: clamp(17px, 2.4vw, 24px);
    padding: 18px 30px;
    border-radius: 18px;
    width: 100%;
}
.btn3d.l {
    font-size: clamp(14px, 1.8vw, 18px);
    padding: 15px 22px;
    width: 100%;
}
.btn3d.s {
    font-size: clamp(11px, 1.4vw, 14px);
    padding: 13px 14px;
    flex: 1;
}
.btn3d.xs {
    font-size: 13px;
    padding: 11px 16px;
    width: auto;
}
.btn3d.orange {
    background: linear-gradient(#f9a825, #e8890c 55%, #cf7503);
}
.btn3d.blue {
    background: linear-gradient(#4e9be8, #2e7bd6 55%, #1f62b4);
}
.btn3d.green {
    background: linear-gradient(#7ed957, #4caf45 55%, #3b8f36);
}
.btn3d.silver {
    background: linear-gradient(#9aa3b0, #6e7684 55%, #5a616d);
}
.btn3d.red {
    background: linear-gradient(#f0655e, #e23c3c 55%, #c22b2b);
}

/* ---------------- loading ---------------- */
#screen-loading {
    z-index: 60;
    background: radial-gradient(1000px 700px at 50% 25%, #4a3422 0%, #2a1b0e 55%, #150e08 100%);
    align-items: center;
    justify-content: center;
}
.load-card {
    position: relative;
    text-align: center;
    padding: 40px 50px;
    background: rgba(24, 17, 11, 0.82);
    border: 2px solid #f5b301;
    border-radius: 22px;
    box-shadow:
        0 14px 0 rgba(0, 0, 0, 0.4),
        0 30px 60px rgba(0, 0, 0, 0.5);
    min-width: min(420px, 86vw);
}
.load-screw {
    width: 84px;
    height: 84px;
    animation: spin 1.4s linear infinite;
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.5));
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
.load-logo {
    font-size: clamp(36px, 7vw, 54px);
    font-weight: 900;
    font-style: italic;
    margin-top: 8px;
    text-shadow:
        0 4px 0 #7a5100,
        0 8px 18px rgba(0, 0, 0, 0.6);
}
.load-logo span {
    color: #f5b301;
}
.load-sub {
    margin-top: 6px;
    font-size: 11.5px;
    letter-spacing: 0.3em;
    color: #c9bba6;
}
.bar {
    margin: 24px auto 0;
    height: 16px;
    width: 100%;
    background: #0f0a06;
    border: 2px solid #f5b301;
    border-radius: 10px;
    overflow: hidden;
}
.bar i {
    display: block;
    height: 100%;
    width: 0%;
    background: linear-gradient(#ffd34d, #f5b301 60%, #e8890c);
    box-shadow: 0 0 12px rgba(245, 179, 1, 0.8);
    transition: width 0.18s ease-out;
}
.load-pct {
    margin-top: 10px;
    font-size: 26px;
    font-weight: 900;
    color: #f5b301;
}
.load-tip {
    margin-top: 6px;
    font-size: 13px;
    color: #a8998a;
    min-height: 17px;
}

/* ---------------- top bars / chips ---------------- */
.topbar {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px clamp(12px, 3vw, 26px);
    background: linear-gradient(rgba(14, 10, 7, 0.9), rgba(14, 10, 7, 0.68));
    border-bottom: 1px solid rgba(245, 179, 1, 0.35);
    flex-wrap: wrap;
}
.logo-mini {
    font-size: clamp(22px, 3.4vw, 30px);
    font-weight: 900;
    font-style: italic;
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
}
.logo-mini span {
    color: #f5b301;
}
.logo-mini.small {
    font-size: clamp(17px, 2.4vw, 22px);
    letter-spacing: 0.06em;
}
.chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}
.chip {
    display: flex;
    align-items: center;
    gap: 7px;
    background: rgba(24, 20, 15, 0.92);
    border: 1.5px solid #4a4038;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 11px;
    letter-spacing: 0.1em;
    color: #beb2a2;
    font-weight: 700;
}
.chip b {
    color: #fff;
    font-size: 14px;
    letter-spacing: 0;
}
.chip.gold {
    border-color: rgba(245, 179, 1, 0.7);
}
.chip.gold b {
    color: #f5b301;
}
.chip img {
    width: 16px;
    height: 16px;
}
.hchip img {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    margin-left: 3px;
}
.chip.tall {
    flex-direction: column;
    gap: 0;
    border-radius: 14px;
    align-items: flex-start;
    padding: 10px 18px;
}
.chip.tall b {
    font-size: 15px;
    color: #f5b301;
}
.chip.tall span {
    font-size: 10px;
}
.foot {
    padding: 10px 16px;
    text-align: center;
    font-size: 10.5px;
    letter-spacing: 0.12em;
    color: #7e7264;
    background: rgba(14, 10, 7, 0.75);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

/* ---------------- menu (v2.1: plaque + giant PLAY + live demo board) ---------------- */
.m-wrap {
    flex: 1;
    min-height: 0;
    display: grid;
    gap: 12px;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: max(12px, env(safe-area-inset-top)) clamp(12px, 3vw, 28px) max(14px, env(safe-area-inset-bottom));
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto auto;
}
.m-left,
.m-right {
    display: contents;
}
.m-top {
    grid-row: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}
.m-top .roundbtn {
    margin-left: auto;
}
.roundbtn {
    position: relative;
    top: 0;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 2px solid rgba(245, 179, 1, 0.7);
    background: #1e1710;
    padding: 8px;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
    transition:
        top 0.06s,
        box-shadow 0.06s;
    flex: none;
}
.roundbtn:active {
    top: 3px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}
.roundbtn img {
    width: 100%;
    height: 100%;
}
.m-plaque {
    grid-row: 2;
    position: relative;
    text-align: center;
    padding: 14px 18px 12px;
    border-radius: 18px;
    border: 3px solid #f5b301;
    outline: 2px solid rgba(0, 0, 0, 0.6);
    outline-offset: -8px;
    background: linear-gradient(165deg, #3a2b1f, #1d150e 70%);
    box-shadow:
        0 8px 0 rgba(0, 0, 0, 0.45),
        0 16px 26px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.12);
}
.m-plaque h1 {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 0.22em;
    font-size: clamp(36px, 11vw, 64px);
    line-height: 1;
    font-style: italic;
    font-weight: 900;
    letter-spacing: 0.01em;
}
.m-plaque .w1 {
    color: #f5b301;
    text-shadow:
        0 4px 0 #7a5100,
        0 7px 14px rgba(0, 0, 0, 0.6);
}
.m-plaque .w2 {
    color: #ff5a4d;
    text-shadow:
        0 4px 0 #8e1e18,
        0 7px 14px rgba(0, 0, 0, 0.6);
}
.m-plaque p {
    margin-top: 8px;
    font-size: clamp(10px, 2.9vw, 13px);
    letter-spacing: 0.24em;
    color: #c9bba6;
    font-weight: 800;
}
.rv {
    position: absolute;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffe9a0, #f5b301 55%, #8a5b00);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.rv.tl {
    left: 9px;
    top: 9px;
}
.rv.tr {
    right: 9px;
    top: 9px;
}
.rv.bl {
    left: 9px;
    bottom: 9px;
}
.rv.br {
    right: 9px;
    bottom: 9px;
}
.m-frame {
    grid-row: 3;
    position: relative;
    min-height: 0;
    border-radius: 22px;
    border: 4px solid #f5b301;
    background: #120c07;
    overflow: hidden;
    box-shadow:
        0 10px 0 rgba(0, 0, 0, 0.45),
        0 20px 34px rgba(0, 0, 0, 0.45),
        inset 0 0 0 2px rgba(0, 0, 0, 0.6);
}
#mCanvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.m-play {
    grid-row: 4;
    position: relative;
    top: 0;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 10px 22px 10px 12px;
    border: 0;
    border-radius: 22px;
    cursor: pointer;
    font-family: inherit;
    color: #fff;
    text-align: left;
    background: linear-gradient(#ffb830, #e8890c 55%, #c56c00);
    box-shadow:
        0 7px 0 #8e4b00,
        0 14px 22px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.55);
    transition:
        top 0.06s,
        box-shadow 0.06s;
}
.m-play:active {
    top: 6px;
    box-shadow:
        0 1px 0 #8e4b00,
        0 4px 8px rgba(0, 0, 0, 0.4),
        inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.m-play-head {
    flex: none;
    width: clamp(54px, 15vw, 74px);
    height: clamp(54px, 15vw, 74px);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #ff8a80, #e2453c 55%, #a5241d);
    border: 4px solid #2a1a0c;
    box-shadow:
        inset 0 3px 0 rgba(255, 255, 255, 0.4),
        0 3px 0 rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
}
.m-play-head img {
    width: 52%;
    height: 52%;
}
.m-play-txt {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.m-play-txt b {
    font-size: clamp(30px, 8.5vw, 46px);
    line-height: 1;
    font-style: italic;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-shadow: 0 3px 0 rgba(0, 0, 0, 0.3);
}
.m-play-txt small {
    margin-top: 3px;
    font-size: clamp(10px, 2.8vw, 13px);
    letter-spacing: 0.14em;
    font-weight: 800;
    color: #fff3d0;
}
.m-tiles {
    grid-row: 5;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.m-tile {
    position: relative;
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 4px 10px;
    border: 0;
    border-radius: 16px;
    cursor: pointer;
    font-family: inherit;
    font-weight: 800;
    color: #fff;
    letter-spacing: 0.08em;
    font-size: clamp(10px, 2.9vw, 13px);
    box-shadow:
        0 5px 0 rgba(0, 0, 0, 0.5),
        0 9px 14px rgba(0, 0, 0, 0.3),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
    transition:
        top 0.06s,
        box-shadow 0.06s;
}
.m-tile:active {
    top: 4px;
    box-shadow:
        0 1px 0 rgba(0, 0, 0, 0.5),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.m-tile img {
    width: 30px;
    height: 30px;
}
.m-tile.blue {
    background: linear-gradient(#4e9be8, #2e7bd6 55%, #1f62b4);
}
.m-tile.green {
    background: linear-gradient(#7ed957, #4caf45 55%, #3b8f36);
}
.m-tile.silver {
    background: linear-gradient(#9aa3b0, #6e7684 55%, #5a616d);
}

/* ---------------- levels (10 per page, never scrolls) ---------------- */
.lv-tabs {
    display: flex;
    gap: 8px;
    justify-content: center;
    padding: 12px clamp(12px, 3vw, 26px) 0;
}
.lv-tab {
    flex: 1;
    max-width: 120px;
    position: relative;
    top: 0;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: 900;
    font-size: 15px;
    color: #beb2a2;
    padding: 9px 4px 7px;
    border-radius: 12px;
    background: #2a2018;
    box-shadow:
        0 4px 0 #0e0a07,
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    transition: top 0.06s;
}
.lv-tab small {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.8;
}
.lv-tab.on {
    background: linear-gradient(#f9a825, #e8890c);
    color: #1a1208;
    box-shadow:
        0 4px 0 #a65c02,
        inset 0 2px 0 rgba(255, 255, 255, 0.5);
}
.lv-tab:active {
    top: 3px;
}
.lv-grid {
    flex: 1;
    min-height: 0;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(5, minmax(0, 1fr));
    padding: clamp(12px, 2.5vw, 24px);
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}
.lv-cell {
    position: relative;
    top: 0;
    min-height: 0;
    max-height: 110px;
    align-self: center;
    width: 100%;
    height: 100%;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    border-radius: 16px;
    font-weight: 900;
    color: #fff;
    background: linear-gradient(#f9a825, #e8890c 55%, #cf7503);
    box-shadow:
        0 5px 0 #a65c02,
        inset 0 2px 0 rgba(255, 255, 255, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: top 0.07s;
}
.lv-cell:active {
    top: 4px;
    box-shadow:
        0 1px 0 #a65c02,
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
.lv-cell .num {
    font-size: clamp(22px, 6vw, 30px);
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.lv-cell .st {
    display: flex;
    gap: 2px;
}
.lv-cell .st img {
    width: clamp(14px, 4vw, 20px);
    height: clamp(14px, 4vw, 20px);
}
.lv-cell .st img.off {
    opacity: 0.28;
}
.lv-cell.locked {
    background: linear-gradient(#4e473f, #332e28);
    box-shadow:
        0 5px 0 #201c18,
        inset 0 2px 0 rgba(255, 255, 255, 0.12);
    color: #8e857a;
    cursor: default;
}
.lv-cell.locked .lk {
    width: clamp(18px, 5vw, 26px);
    height: auto;
    opacity: 0.9;
}
.lv-cell.current {
    outline: 3px solid #fff;
    outline-offset: 2px;
    animation: pulse 1.2s infinite;
}
@keyframes pulse {
    0%,
    100% {
        outline-color: #fff;
    }
    50% {
        outline-color: #f5b301;
    }
}

/* ---------------- how to ---------------- */
.how-wrap {
    flex: 1;
    overflow: auto;
    display: grid;
    gap: 14px;
    align-content: start;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    padding: clamp(14px, 3vw, 30px);
}
.how-card {
    background: linear-gradient(165deg, rgba(43, 34, 26, 0.94), rgba(30, 23, 17, 0.96));
    border: 1.5px solid rgba(255, 255, 255, 0.09);
    border-radius: 18px;
    padding: 20px;
}
.how-card h3 {
    color: #f5b301;
    font-size: 15px;
    letter-spacing: 0.2em;
    margin-bottom: 9px;
    font-style: italic;
}
.how-card p {
    color: #d6cbbb;
    font-size: 13.5px;
    line-height: 1.6;
}
.how-card .em {
    color: #7ed957;
    font-weight: 800;
}
.how-ok {
    margin: 0 auto 22px;
    width: min(320px, 80%);
}

/* ---------------- settings ---------------- */
.set-wrap {
    flex: 1;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 13px;
    padding: clamp(14px, 3vw, 30px);
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
}
.setrow.panel {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.setrow label {
    font-size: 12px;
    letter-spacing: 0.2em;
    color: #beb2a2;
    font-weight: 800;
}
.setrow.danger-row {
    border-color: rgba(226, 69, 60, 0.5);
}
.seg {
    display: flex;
    background: #14100b;
    border: 1.5px solid #4a4038;
    border-radius: 14px;
    padding: 5px;
    gap: 5px;
}
.seg button {
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: 800;
    letter-spacing: 0.08em;
    background: transparent;
    color: #9a8e7f;
    padding: 11px 20px;
    border-radius: 10px;
    font-size: 13px;
}
.seg button.on {
    background: linear-gradient(#f9a825, #e8890c);
    color: #17130a;
    box-shadow:
        0 3px 0 #a65c02,
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* ---------------- game ---------------- */
#screen-game .topbar {
    flex-wrap: nowrap;
}
.hud-chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    flex: 1;
}
.hchip {
    background: rgba(20, 15, 10, 0.85);
    border: 1.5px solid #4a4038;
    border-radius: 999px;
    font-size: clamp(10px, 1.5vw, 12px);
    letter-spacing: 0.1em;
    font-weight: 800;
    color: #beb2a2;
    padding: 8px 13px;
}
.hchip b {
    color: #f5b301;
    font-size: 14px;
    letter-spacing: 0;
}
.iconbtn {
    width: clamp(42px, 6vw, 52px);
    height: clamp(42px, 6vw, 52px);
    border: 0;
    background: transparent;
    cursor: pointer;
    padding: 0;
    flex: none;
    position: relative;
    top: 0;
    transition: top 0.07s;
}
.iconbtn:active {
    top: 3px;
}
.iconbtn img {
    width: 100%;
    height: 100%;
}
#field {
    flex: 1;
    min-height: 0;
    display: block;
    width: 100%;
    touch-action: none;
    cursor: pointer;
}

/* ---------------- overlays ---------------- */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(12, 8, 5, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
}
.ov-card {
    background: linear-gradient(165deg, #2b221aee, #1b140eff);
    border: 2px solid #f5b301;
    border-radius: 22px;
    box-shadow:
        0 16px 0 rgba(0, 0, 0, 0.4),
        0 40px 80px rgba(0, 0, 0, 0.6);
    padding: clamp(22px, 4vw, 34px);
    width: min(390px, 92vw);
    display: flex;
    flex-direction: column;
    gap: 13px;
    text-align: center;
}
.ov-card h2 {
    font-style: italic;
    font-size: clamp(24px, 4vw, 30px);
    color: #f5b301;
    margin-bottom: 6px;
}
.ov-card.result {
    border-color: #7ed957;
}
.ov-card.fail {
    border-color: #e23c3c;
}
.trophy {
    width: clamp(60px, 12vw, 80px);
    margin: 0 auto;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.5));
}
.fail-icon {
    font-size: clamp(46px, 9vw, 60px);
}
.res-title {
    font-weight: 900;
    letter-spacing: 0.14em;
    color: #7ed957;
    font-size: clamp(16px, 2.6vw, 20px);
}
.res-title.red {
    color: #e23c3c;
}
.stars {
    display: flex;
    justify-content: center;
    gap: 10px;
}
.stars img {
    width: clamp(38px, 7vw, 48px);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.5));
    animation: starPop 0.4s backwards;
}
.stars img:nth-child(2) {
    animation-delay: 0.15s;
}
.stars img:nth-child(3) {
    animation-delay: 0.3s;
}
.stars img.off {
    filter: grayscale(1) brightness(0.5);
}
@keyframes starPop {
    from {
        transform: scale(0);
    }
    70% {
        transform: scale(1.25);
    }
    to {
        transform: scale(1);
    }
}
.res-stats {
    color: #c9bba6;
    font-size: 13.5px;
    line-height: 1.7;
}
.res-stats b {
    color: #fff;
}

/* ---------------- toast ---------------- */
.toast {
    position: fixed;
    top: 70px;
    left: 0;
    right: 0;
    margin: 0 auto;
    width: max-content;
    max-width: 92vw;
    text-align: center;
    background: rgba(20, 15, 10, 0.94);
    border: 1.5px solid rgba(245, 179, 1, 0.75);
    color: #fff;
    font-weight: 800;
    letter-spacing: 0.1em;
    font-size: 13px;
    padding: 11px 22px;
    border-radius: 999px;
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.22s,
        top 0.22s;
}
.toast.on {
    opacity: 1;
    top: 84px;
}

/* ---------------- responsive ---------------- */
@media (max-width: 860px) {
    .menu-grid {
        grid-template-columns: 1fr;
    }
    .hero {
        min-height: 280px;
    }
}
@media (max-height: 500px) and (orientation: landscape) {
    .menu-grid {
        grid-template-columns: 1.6fr 1fr;
        padding: 10px;
        gap: 10px;
    }
    .hero {
        min-height: 0;
    }
    .hero-txt h1 {
        font-size: 28px;
    }
    .hero-txt p {
        display: none;
    }
    .btn3d.l {
        padding: 11px 16px;
    }
    .btn3d.xl {
        padding: 13px 20px;
    }
    .foot {
        display: none;
    }
    .topbar {
        padding: 8px 14px;
    }
    .how-wrap {
        grid-template-columns: repeat(4, 1fr);
        padding: 10px;
    }
    .how-card {
        padding: 12px;
    }
    .how-card p {
        font-size: 11.5px;
    }
    .lv-grid {
        grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
        gap: 8px;
        padding: 10px;
    }
}

/* ---------------- in-game boosters ---------------- */
.boostbar {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 8px clamp(10px, 3vw, 24px) max(10px, env(safe-area-inset-bottom));
    background: linear-gradient(rgba(14, 10, 7, 0.88), rgba(14, 10, 7, 0.96));
    border-top: 1px solid rgba(245, 179, 1, 0.35);
}
.boost {
    position: relative;
    top: 0;
    flex: 1;
    max-width: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 7px 8px;
    border: 1.5px solid #4a4038;
    border-radius: 14px;
    background: linear-gradient(#34291f, #221a13);
    color: #f3ece3;
    font-family: inherit;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.55);
    transition:
        top 0.06s,
        box-shadow 0.06s;
}
.boost:active {
    top: 3px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.55);
}
.boost[disabled] {
    opacity: 0.4;
    pointer-events: none;
}
.bimg {
    position: relative;
    width: 38px;
    height: 38px;
    flex: none;
}
.bimg img {
    width: 100%;
    height: 100%;
}
.bimg em {
    position: absolute;
    right: -6px;
    top: -6px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #f5b301;
    color: #1a1208;
    border: 2px solid #1a1208;
    font:
        900 11px/16px "Segoe UI",
        Arial,
        sans-serif;
    font-style: normal;
    text-align: center;
    padding: 0 3px;
}
.bl {
    font-size: clamp(10px, 2.9vw, 13px);
    letter-spacing: 0.08em;
    white-space: nowrap;
}
.fail-icon i {
    display: block;
    width: 58px;
    height: 58px;
    margin: 0 auto;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 28%, #ff8a80, #e2453c 60%, #a5241d);
    border: 4px solid #2a1a0c;
    position: relative;
}
.fail-icon i::before {
    content: "!";
    position: absolute;
    inset: 0;
    text-align: center;
    line-height: 50px;
    font-size: 34px;
    font-weight: 900;
    color: #fff;
}
.hud-chips {
    flex-wrap: nowrap;
}
.hchip {
    white-space: nowrap;
    padding: 8px clamp(8px, 2.4vw, 13px);
    font-size: clamp(10px, 2.8vw, 12px);
}
.hchip b {
    font-size: clamp(12px, 3.4vw, 14px);
}
.ov-card {
    max-height: 100%;
}
.load-screw {
    animation: spin 1.4s linear infinite;
    filter: none;
}
.stars img.off {
    filter: none;
    opacity: 0.3;
}

/* ---------------- wide menu ---------------- */
@media (min-aspect-ratio: 23/20) and (min-width: 700px) {
    .m-wrap {
        grid-template-columns: minmax(330px, 520px) minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto auto auto auto minmax(0, 1fr);
        gap: 14px 30px;
        align-content: stretch;
    }
    .m-top {
        grid-column: 1;
        grid-row: 2;
    }
    .m-plaque {
        grid-column: 1;
        grid-row: 3;
    }
    .m-play {
        grid-column: 1;
        grid-row: 4;
    }
    .m-tiles {
        grid-column: 1;
        grid-row: 5;
    }
    .m-frame {
        grid-column: 2;
        grid-row: 1 / 7;
        margin: 4px 0;
    }
    .m-plaque h1 {
        font-size: clamp(38px, 5vw, 76px);
    }
    .m-play-txt b {
        font-size: clamp(30px, 3.6vw, 52px);
    }
    .m-play-head {
        width: clamp(56px, 6vw, 84px);
        height: clamp(56px, 6vw, 84px);
    }
    .m-tile {
        padding: 16px 4px 14px;
        font-size: clamp(11px, 1.2vw, 15px);
    }
    .m-tile img {
        width: clamp(30px, 3vw, 42px);
        height: clamp(30px, 3vw, 42px);
    }
    .lv-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        grid-template-rows: repeat(2, minmax(0, 1fr));
    }
}
@media (max-height: 640px) {
    .m-wrap {
        gap: 8px;
    }
    .m-plaque {
        padding: 9px 14px 8px;
    }
    .m-plaque p {
        margin-top: 4px;
    }
    .m-tile {
        flex-direction: row;
        gap: 8px;
        padding: 10px 4px;
    }
    .m-tile img {
        width: 22px;
        height: 22px;
    }
    .m-play {
        padding: 6px 18px 6px 8px;
    }
    .m-play-head {
        width: 46px;
        height: 46px;
    }
    .m-play-txt b {
        font-size: 28px;
    }
    .boost .bl {
        display: none;
    }
    .bimg {
        width: 34px;
        height: 34px;
    }
}
@media (max-height: 520px) and (min-width: 700px) {
    .m-wrap {
        grid-template-columns: minmax(250px, 340px) minmax(0, 1fr);
        gap: 8px 16px;
        padding: 8px 14px;
    }
    .m-plaque h1 {
        font-size: 30px;
    }
    .m-plaque p {
        display: none;
    }
    .m-top .chip {
        padding: 5px 10px;
    }
    .roundbtn {
        width: 36px;
        height: 36px;
        padding: 6px;
    }
    .m-tile span {
        font-size: 10px;
        letter-spacing: 0.04em;
    }
    .m-tile img {
        display: none;
    }
    .ov-card {
        padding: 14px 18px;
        gap: 7px;
        width: min(440px, 94vw);
    }
    .ov-card h2 {
        font-size: 22px;
        margin: 0;
    }
    .trophy {
        width: 40px;
    }
    .stars img {
        width: 32px;
    }
    .res-stats {
        font-size: 12px;
        line-height: 1.4;
    }
    .btn3d.l {
        padding: 9px 14px;
        font-size: 13px;
    }
    .fail-icon i {
        width: 38px;
        height: 38px;
    }
    .fail-icon i::before {
        line-height: 30px;
        font-size: 24px;
    }
    .lv-tabs {
        padding-top: 6px;
    }
    .lv-tab {
        padding: 5px 4px 4px;
        font-size: 13px;
    }
    .lv-tab small {
        display: none;
    }
    .lv-grid {
        gap: 8px;
        padding: 8px 14px;
    }
    .lv-cell .st img {
        width: 13px;
        height: 13px;
    }
    .lv-cell .num {
        font-size: 20px;
    }
    .set-wrap {
        gap: 6px;
        padding: 8px 14px;
    }
    .setrow.panel {
        padding: 8px 14px;
    }
    .seg button {
        padding: 7px 14px;
    }
    .toast {
        top: 54px;
    }
    .toast.on {
        top: 64px;
    }
    .how-ok {
        margin-bottom: 8px;
        padding: 9px;
    }
}
@media (max-width: 359px) {
    .hchip.best {
        display: none;
    }
    .boost {
        padding: 6px 4px;
    }
    .m-tile {
        font-size: 9.5px;
        letter-spacing: 0.04em;
    }
}

@media (max-height: 520px) {
    .ov-card {
        padding: 12px 16px;
        gap: 6px;
        width: min(440px, 94vw);
    }
    .ov-card h2 {
        font-size: 20px;
        margin: 0;
    }
    .trophy {
        width: 36px;
    }
    .stars img {
        width: 30px;
    }
    .res-stats {
        font-size: 12px;
        line-height: 1.35;
    }
    .btn3d.l {
        padding: 8px 14px;
        font-size: 13px;
    }
    .fail-icon i {
        width: 34px;
        height: 34px;
    }
    .fail-icon i::before {
        line-height: 26px;
        font-size: 22px;
    }
    .set-wrap {
        gap: 6px;
        padding: 8px 14px;
    }
    .setrow.panel {
        padding: 7px 14px;
    }
    .seg button {
        padding: 6px 14px;
    }
    .how-card {
        padding: 10px;
    }
    .how-card h3 {
        margin-bottom: 4px;
    }
    .how-ok {
        margin-bottom: 8px;
        padding: 8px;
    }
    #screen-game .topbar {
        padding: 6px 12px;
    }
    .iconbtn {
        width: 38px;
        height: 38px;
    }
}
@media (max-width: 440px) {
    .hchip.best {
        display: none;
    }
    .hchip {
        padding: 8px 9px;
    }
}
@media (max-width: 359px), (max-height: 600px) {
    .how-card p {
        font-size: 11.5px;
        line-height: 1.45;
    }
    .how-card {
        padding: 10px;
    }
    .how-ok {
        margin-bottom: 8px;
    }
}

.m-ver {
    text-align: center;
    font-size: 10px;
    letter-spacing: 0.12em;
    font-weight: 700;
    color: rgba(233, 223, 208, 0.45);
    margin-top: 8px;
}
@media (max-height: 520px) and (orientation: landscape) {
    .m-ver {
        display: none;
    }
}

/* ===== how to play: illustrated step cards ===== */
.how-wrap {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 720px;
    width: 100%;
    margin: 0 auto;
    padding: clamp(12px, 3vw, 24px);
}
.how-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    counter-increment: step;
}
.how-art {
    flex: none;
    width: clamp(92px, 24vw, 130px);
    height: clamp(78px, 20vw, 100px);
    border-radius: 14px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: linear-gradient(#5a4128, #3b2a1a), url(../assets/board.png);
    box-shadow:
        inset 0 3px 8px rgba(0, 0, 0, 0.55),
        0 1px 0 rgba(255, 255, 255, 0.1);
    overflow: hidden;
}
.how-art .p {
    width: 78%;
    filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.5));
}
.how-art .s {
    width: 26%;
    filter: drop-shadow(0 3px 3px rgba(0, 0, 0, 0.5));
}
.how-art .c0 .s,
.c0 .how-art .s {
    position: absolute;
    width: 22%;
    right: 14%;
    top: 14%;
    animation: hFly 2.2s ease-in infinite;
}
.how-art .pop {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 11px;
    font-weight: 900;
    color: #fff;
    background: #e8890c;
    padding: 2px 7px;
    border-radius: 8px;
    transform: rotate(8deg);
}
.how-art .fall {
    animation: hFall 2.2s ease-in infinite;
}
.how-art .tray {
    display: flex;
    gap: 4px;
}
.how-art .tray i {
    width: 11px;
    height: 11px;
    border-radius: 50%;
    border: 2px dashed #f5b301;
}
.how-art .tray i.f {
    border: 0;
    background: #e2453c;
}
.how-art .tray i.f:nth-child(2n) {
    background: #3c8de0;
}
.how-art .tray i.f:nth-child(3n) {
    background: #3db84a;
}
.how-art .bulb {
    font-size: 40px;
    filter: drop-shadow(0 0 12px rgba(245, 179, 1, 0.8));
    animation: pulse 1.4s infinite;
}
.how-card.c3 .how-art {
    background: linear-gradient(#4a2020, #2d1313);
}
.how-txt {
    min-width: 0;
}
.how-txt small {
    display: block;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.22em;
    color: #8e8174;
    margin-bottom: 3px;
}
.how-card.c3 .how-txt small {
    color: #f0746c;
}
.how-card h3 {
    margin-bottom: 5px;
    font-size: clamp(14px, 3.6vw, 17px);
}
.how-card p {
    font-size: clamp(12px, 3.2vw, 14px);
}
@keyframes hFly {
    0%,
    25% {
        transform: translate(0, 0);
        opacity: 1;
    }
    70% {
        transform: translate(-6px, 34px);
        opacity: 0;
    }
    100% {
        opacity: 0;
    }
}
@keyframes hFall {
    0%,
    30% {
        transform: translateY(-4px) rotate(0);
    }
    100% {
        transform: translateY(70px) rotate(25deg);
        opacity: 0;
    }
}
@media (min-width: 960px) and (min-height: 600px) {
    .how-wrap {
        max-width: 980px;
        display: grid;
        grid-template-columns: 1fr 1fr;
        align-content: start;
    }
    .how-card.c4 {
        grid-column: 1 / -1;
    }
}
@media (max-height: 520px) and (orientation: landscape) {
    .how-wrap {
        max-width: none;
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        padding: 8px 12px;
        gap: 8px;
    }
    .how-card {
        flex-direction: column;
        text-align: center;
        gap: 6px;
        padding: 8px;
    }
    .how-art {
        width: 100%;
        height: 56px;
    }
    .how-card p {
        display: none;
    }
    .how-art .p {
        width: auto;
        height: 78%;
    }
    .how-art .s {
        width: auto;
        height: 62%;
    }
    .how-art .tray i {
        width: 13px;
        height: 13px;
    }
    .how-txt small {
        display: none;
    }
    .lv-row {
        grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
    }
    .lv-prog {
        padding-top: 6px;
    }
}
@media (prefers-reduced-motion: reduce) {
    .how-art .fall,
    .how-art .s,
    .lv-cell.current {
        animation: none;
    }
}

.how-wrap.how-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    align-content: start;
}
.how-foot {
    flex: none;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
    background: linear-gradient(rgba(14, 10, 7, 0), rgba(14, 10, 7, 0.92) 40%);
}
.how-foot .how-ok {
    margin: 0 auto;
    width: min(320px, 90%);
    display: block;
}
.topbar .chip:empty {
    visibility: hidden;
}
@media (min-width: 700px) {
    .lv-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        grid-template-rows: repeat(2, minmax(0, 150px));
        align-content: center;
    }
}
.lv-cell.current .st img.off {
    opacity: 0.55;
    filter: brightness(0.45);
}
