:root {
    --ink: #f4f1ff;
    --ink-2: #c9c4e6;
    --ink-3: #8f89b8;
    --navy: #0b0c24;
    --glass: rgba(14, 14, 40, 0.86);
    --pink: #ff5fb4;
    --cyan: #54dcff;
    --gold: #ffd24a;
    --lime: #9be15d;
    --red: #ff5b6e;
    --cut: 12px;
    --f-jp: "M PLUS Rounded 1c", system-ui, sans-serif;
    --f-dot: "DotGothic16", "M PLUS Rounded 1c", monospace;
    --px: 2;
    --app-h: 100vh;
}

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

html,
body {
    height: 100%;
    background: #05060f;
    color: var(--ink);
    font-family: var(--f-jp);
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

[hidden] {
    display: none !important;
}

#app {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    background: #05060f url("../assets/backgrounds/title.webp") center / cover;
}

#app::before {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(5, 6, 15, 0.78);
    backdrop-filter: blur(6px);
}

#game {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    background: #05060f;
    box-shadow: 0 0 0 1px rgba(84, 220, 255, 0.18), 0 0 80px rgba(84, 220, 255, 0.12);
    image-rendering: auto;
}

/* ---------------- pixel icons (24px dots, scaled with crisp edges) ---------------- */
.px {
    display: inline-block;
    flex: none;
    width: calc(24px * var(--px));
    height: calc(24px * var(--px));
    background-repeat: no-repeat;
    background-size: calc(var(--icons-w, 512px) * var(--px)) auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    vertical-align: middle;
}

.px.s1 {
    --px: 1;
}

/* ---------------- shared frames: chamfered glass, never rounded ---------------- */
.panel,
.btn,
.chip,
.slot,
.card,
.icon-btn,
#bombBtn,
.field select,
.submit input,
.tab {
    --c: var(--cut);
    clip-path: polygon(var(--c) 0, calc(100% - var(--c)) 0, 100% var(--c), 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, var(--c) 100%, 0 calc(100% - var(--c)), 0 var(--c));
}

.panel {
    position: relative;
    width: min(92vw, 520px);
    max-height: calc(var(--app-h) - 48px);
    padding: 26px 22px 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    align-items: stretch;
    background:
        linear-gradient(180deg, rgba(255, 95, 180, 0.12), transparent 90px),
        var(--frame, none),
        var(--glass);
    background-size: auto, 100% 100%, auto;
    --c: 18px;
}

/* neon edge drawn as an inner chamfered ring */
.panel::before {
    content: "";
    position: absolute;
    inset: 0;
    padding: 2px;
    background: linear-gradient(135deg, var(--pink), var(--cyan) 50%, var(--pink));
    clip-path: inherit;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

/* generated frame (9-slice): used when the image is present */
.framed .panel {
    clip-path: none;
    background: none;
    border: 30px solid transparent;
    border-image: url("../assets/ui/frame.webp") 84 fill / 30px stretch;
    padding: 4px 6px;
}

.framed .panel::before {
    display: none;
}

.panel.wide {
    width: min(94vw, 760px);
}

.panel.scroll,
.panel .scroll {
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--pink) transparent;
    touch-action: pan-y;
}

.panel h2 {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--f-dot);
    font-size: 26px;
    letter-spacing: 0.08em;
    color: #fff;
    text-shadow: 0 0 12px rgba(255, 95, 180, 0.8);
}

.sec {
    padding: 12px 14px;
    background: rgba(255, 255, 255, 0.04);
    border-left: 3px solid var(--cyan);
}

.sec h3 {
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--cyan);
    letter-spacing: 0.04em;
}

.sec p,
.sec li {
    font-size: 13.5px;
    line-height: 1.7;
    color: var(--ink-2);
}

.sec b {
    color: #fff;
}

.note {
    font-size: 12px;
    color: var(--ink-3);
    text-align: center;
}

.note.tiny {
    font-size: 10.5px;
}

.heart-mark {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 6px;
    background: var(--pink);
    clip-path: path("M6 11 C6 11 0 7 0 3.5 C0 1 2 0 3.3 0 C4.5 0 5.5 .8 6 2 C6.5 .8 7.5 0 8.7 0 C10 0 12 1 12 3.5 C12 7 6 11 6 11Z");
    vertical-align: -1px;
}

.faces img {
    width: 30px;
    height: 30px;
    vertical-align: middle;
}

.combo-list {
    list-style: none;
    display: grid;
    gap: 4px;
    margin: 8px 0;
}

.combo-list li {
    display: flex;
    align-items: center;
    gap: 4px;
}

.combo-list .px {
    --px: 1;
    margin: 0 4px 0 8px;
}

.orb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
    box-shadow: inset -2px -2px 0 rgba(0, 0, 0, 0.25), 0 0 6px currentColor;
}

.orb.red { background: var(--red); color: var(--red); }
.orb.blue { background: #4fb8ff; color: #4fb8ff; }
.orb.green { background: #5ee07a; color: #5ee07a; }
.orb.yellow { background: #ffd43b; color: #ffd43b; }

/* ---------------- buttons ---------------- */
.btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
    padding: 8px 22px;
    border: 0;
    font: 700 16px/1.2 var(--f-jp);
    color: #fff;
    text-decoration: none;
    letter-spacing: 0.04em;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 55%),
        linear-gradient(90deg, #2a2657, #1b1a3f);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.35);
    cursor: pointer;
    transition: transform 0.12s, filter 0.12s;
    --c: 10px;
    --px: 1.5;
}

.btn::after {
    content: "";
    position: absolute;
    inset: 0;
    padding: 2px;
    background: linear-gradient(90deg, rgba(84, 220, 255, 0.7), rgba(255, 95, 180, 0.7));
    clip-path: inherit;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.btn:hover,
.btn:focus-visible,
.btn.focus {
    filter: brightness(1.2);
    transform: translateY(-1px);
    outline: none;
}

.btn:focus-visible::before,
.btn.focus::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 50%;
    width: 8px;
    height: 8px;
    margin-top: -4px;
    background: var(--gold);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
    animation: nudge 0.6s ease-in-out infinite alternate;
}

@keyframes nudge {
    to {
        translate: 3px 0;
    }
}

.btn:active {
    transform: translateY(1px);
}

.btn.primary {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0) 55%),
        linear-gradient(90deg, #ff4fa8, #ff7a5c);
    font-size: 19px;
    min-height: 58px;
}

.btn.primary::after {
    background: linear-gradient(90deg, #ffe3f2, #ffd24a);
}

.btn.pink {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 55%),
        linear-gradient(90deg, #8b3dc9, #6b2aa6);
}

.btn.gold {
    color: #2a1600;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0) 55%),
        linear-gradient(90deg, #ffd24a, #ffb03a);
}

.btn.ghost {
    background: rgba(255, 255, 255, 0.04);
    font-size: 14px;
    min-height: 42px;
}

.btn[disabled] {
    filter: grayscale(0.8) brightness(0.7);
    pointer-events: none;
}

.icon-btn {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border: 0;
    background: rgba(14, 14, 40, 0.72);
    box-shadow: inset 0 0 0 2px rgba(84, 220, 255, 0.45);
    cursor: pointer;
    --c: 8px;
    --px: 1.5;
}

.icon-btn:active {
    transform: scale(0.94);
}

/* ---------------- screens ---------------- */
.screen {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    animation: fade 0.25s ease-out;
}

.screen.dim {
    background: rgba(4, 4, 14, 0.66);
    backdrop-filter: blur(2px);
}

@keyframes fade {
    from {
        opacity: 0;
    }
}

/* loading */
.loading {
    display: grid;
    justify-items: center;
    gap: 16px;
}

.loading-face {
    width: 96px;
    animation: rock 1.2s ease-in-out infinite alternate;
}

@keyframes rock {
    from {
        rotate: -10deg;
    }

    to {
        rotate: 10deg;
    }
}

.loading .bar {
    width: 220px;
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}

.loading .bar i {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--cyan), var(--pink));
    transition: width 0.2s;
}

.loading p {
    font-family: var(--f-dot);
    color: var(--ink-2);
    letter-spacing: 0.1em;
}

/* title */
.screen.title {
    background: url("../assets/backgrounds/title.webp") center bottom / cover no-repeat;
}

.screen.title::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(5, 6, 20, 0.35), rgba(5, 6, 20, 0) 40%, rgba(5, 6, 20, 0.55));
    pointer-events: none;
}

.title-inner {
    position: relative;
    display: grid;
    justify-items: center;
    gap: 12px;
    width: min(92vw, 440px);
}

.logo {
    position: relative;
    display: grid;
    place-items: center;
    width: 100%;
}

.logo img {
    width: min(92vw, 440px);
    height: auto;
    filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.5));
}

.logo img+.logo-text {
    display: none;
}

.logo-text {
    display: grid;
    justify-items: center;
    line-height: 1;
    font-weight: 900;
    letter-spacing: 0.02em;
    transform: rotate(-3deg);
}

.logo-text .l1 {
    font-size: clamp(56px, 17vw, 84px);
    color: #fff;
    -webkit-text-stroke: 6px #2b0c3a;
    paint-order: stroke fill;
    text-shadow: 0 6px 0 #ff4fa8, 0 10px 24px rgba(255, 79, 168, 0.6);
}

.logo-text .l2 {
    margin-top: 6px;
    font-size: clamp(26px, 8vw, 40px);
    color: var(--gold);
    -webkit-text-stroke: 5px #2b0c3a;
    paint-order: stroke fill;
    text-shadow: 0 4px 0 #54dcff;
}

.sub {
    font-size: 13px;
    color: var(--ink-2);
    letter-spacing: 0.08em;
    text-shadow: 0 2px 6px #000;
}

.best {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--f-dot);
    color: var(--gold);
    --px: 1;
}

.best b {
    font-size: 20px;
    color: #fff;
}

.menu {
    display: grid;
    gap: 10px;
    width: 100%;
    margin-top: 6px;
}

.menu.row {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.keys {
    font-size: 11px;
    color: var(--ink-3);
    letter-spacing: 0.08em;
}

.pc,
.touch {
    display: none;
}

.is-pc .pc,
.is-touch .touch {
    display: block;
}

.keys.pc {
    display: none;
}

.is-pc .keys.pc {
    display: block;
}

/* dex */
.dex {
    display: grid;
    gap: 10px;
}

.dex h4 {
    font-size: 12.5px;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-left: 3px solid currentColor;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.07), transparent);
}

.dex ul {
    list-style: none;
    display: grid;
    gap: 4px;
    margin-top: 6px;
}

.dex li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    --px: 1;
}

.dex li small {
    color: var(--ink-3);
}

.dex li.unknown {
    color: var(--ink-3);
}

/* settings */
.field {
    display: grid;
    grid-template-columns: 7.5em 1fr auto;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    --px: 1;
}

.field span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.field output {
    font-family: var(--f-dot);
    min-width: 2.2em;
    text-align: right;
    color: var(--gold);
}

.field select {
    grid-column: 2 / 4;
    height: 40px;
    padding: 0 12px;
    border: 0;
    font: 700 15px var(--f-jp);
    color: #fff;
    background: #1d1b45;
    box-shadow: inset 0 0 0 2px rgba(84, 220, 255, 0.4);
    --c: 7px;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 26px;
    background: transparent;
    touch-action: pan-x;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    background: linear-gradient(90deg, var(--cyan), var(--pink));
    clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}

input[type="range"]::-moz-range-track {
    height: 8px;
    background: linear-gradient(90deg, var(--cyan), var(--pink));
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    margin-top: -7px;
    background: #fff;
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border: 0;
    background: #fff;
    clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

/* ranking */
.tabs {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
}

.tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 36px;
    padding: 0 14px;
    border: 0;
    font: 700 13.5px var(--f-jp);
    color: var(--ink-2);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    --c: 7px;
    --px: 1;
}

.tab.on {
    color: #1a1030;
    background: linear-gradient(90deg, var(--cyan), #9ff0ff);
}

.rank-list {
    display: grid;
    gap: 4px;
    max-height: calc(var(--app-h) - 300px);
    overflow-y: auto;
    touch-action: pan-y;
}

.rank-row {
    display: grid;
    grid-template-columns: 38px 1fr auto;
    grid-template-areas: "rank name score" "rank build build";
    align-items: center;
    gap: 2px 10px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    cursor: pointer;
    --px: 1;
}

.rank-row:hover {
    background: rgba(84, 220, 255, 0.1);
}

.rank-row .r {
    grid-area: rank;
    display: grid;
    place-items: center;
    font-family: var(--f-dot);
    font-size: 18px;
    color: var(--ink-3);
}

.rank-row .n {
    grid-area: name;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 4px;
}

.rank-row .s {
    grid-area: score;
    font-family: var(--f-dot);
    font-size: 17px;
    color: var(--gold);
    text-align: right;
}

.rank-row .s small {
    display: block;
    font-size: 11px;
    color: var(--ink-3);
}

.rank-row .b {
    grid-area: build;
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    min-height: 26px;
}

.wicon {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    background: var(--rc, #444);
    clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px);
    --px: 1;
}

.wicon b {
    position: absolute;
    right: 1px;
    bottom: -1px;
    font: 10px var(--f-dot);
    color: #fff;
    text-shadow: 0 0 2px #000, 0 0 2px #000;
}

.pages {
    display: flex;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pages button {
    width: 34px;
    height: 32px;
    border: 0;
    font: 14px var(--f-dot);
    color: var(--ink-2);
    background: rgba(255, 255, 255, 0.06);
    cursor: pointer;
    clip-path: polygon(5px 0, 100% 0, calc(100% - 5px) 100%, 0 100%);
}

.pages button.on {
    color: #1a1030;
    background: var(--gold);
}

/* gallery */
.gallery {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.tile {
    position: relative;
    aspect-ratio: 1;
    display: grid;
    place-items: center;
    background: rgba(155, 89, 182, 0.14);
    box-shadow: inset 0 0 0 2px rgba(190, 120, 255, 0.6);
    clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
    overflow: hidden;
    cursor: pointer;
    --px: 1.5;
}

.tile.adult {
    background: rgba(255, 105, 180, 0.14);
    box-shadow: inset 0 0 0 3px rgba(255, 105, 180, 0.8);
}

.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tile.adult img {
    filter: blur(8px);
}

.tile .lock {
    display: grid;
    justify-items: center;
    gap: 4px;
    font: 11px var(--f-dot);
    color: var(--ink-3);
    text-align: center;
}

/* upgrade */
.upgrade {
    display: grid;
    justify-items: center;
    gap: 16px;
    width: min(94vw, 760px);
}

.power {
    font-family: var(--f-dot);
    font-size: 40px;
    letter-spacing: 0.12em;
    color: #fff;
    text-shadow: 0 0 16px var(--gold), 0 4px 0 #ff4fa8;
    animation: pop 0.4s cubic-bezier(.3, 1.6, .5, 1);
}

@keyframes pop {
    from {
        transform: scale(0.4);
        opacity: 0;
    }
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    width: 100%;
}

.card {
    position: relative;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-areas: "icon rar" "icon name" "desc desc";
    align-items: center;
    gap: 2px 12px;
    padding: 14px 16px;
    text-align: left;
    border: 0;
    color: #fff;
    font-family: var(--f-jp);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.1), transparent 60%),
        rgba(20, 20, 50, 0.95);
    cursor: pointer;
    animation: deal 0.35s backwards cubic-bezier(.2, 1.4, .4, 1);
    --c: 14px;
    --px: 2;
}

.card::after {
    content: "";
    position: absolute;
    inset: 0;
    padding: 3px;
    background: var(--rc);
    clip-path: inherit;
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.card.ultra {
    background:
        linear-gradient(180deg, rgba(255, 210, 74, 0.25), transparent 60%),
        rgba(40, 28, 10, 0.95);
}

.card:hover,
.card:focus-visible,
.card.focus {
    transform: translateY(-4px);
    filter: brightness(1.15);
    outline: none;
}

@keyframes deal {
    from {
        transform: translateY(30px) rotate(-3deg);
        opacity: 0;
    }
}

.card .px {
    grid-area: icon;
    filter: drop-shadow(0 0 8px var(--rc));
}

.card .rar {
    grid-area: rar;
    font: 11px var(--f-dot);
    color: var(--rc);
    letter-spacing: 0.1em;
}

.card .nm {
    grid-area: name;
    font-weight: 900;
    font-size: 17px;
}

.card .ds {
    grid-area: desc;
    margin-top: 8px;
    font-size: 13px;
    color: var(--ink-2);
}

/* game over */
.over h2.go {
    font-size: 40px;
    color: var(--red);
    text-shadow: 0 0 16px rgba(255, 91, 110, 0.8);
}

.result {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 16px;
    font-family: var(--f-dot);
    --px: 1;
}

.result dt {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink-2);
}

.result dd {
    text-align: right;
    font-size: 22px;
    color: #fff;
}

.new-best {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    font-weight: 900;
    color: var(--gold);
    animation: pop 0.5s;
    --px: 1;
}

.submit {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.submit .btn {
    white-space: nowrap;
}

.submit input {
    width: 100%;
    min-width: 0;
    height: 50px;
    padding: 0 14px;
    border: 0;
    font: 700 16px var(--f-jp);
    color: #fff;
    background: #1d1b45;
    box-shadow: inset 0 0 0 2px rgba(84, 220, 255, 0.4);
    user-select: text;
    -webkit-user-select: text;
    --c: 9px;
}

.submit-result {
    min-height: 1.4em;
    text-align: center;
    font-weight: 700;
}

/* ---------------- HUD ---------------- */
#hud,
#status {
    position: absolute;
    z-index: 10;
    left: 50%;
    translate: -50% 0;
    width: var(--game-w, 100%);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: max(8px, env(safe-area-inset-top)) 10px 8px;
    pointer-events: none;
    font-family: var(--f-dot);
    text-shadow: 0 2px 0 #0a0616, 0 0 6px #0a0616;
}

#hud {
    top: 0;
    /* the reels sit in a fixed centre column: long scores never push them sideways */
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    column-gap: 8px;
}

#status {
    bottom: 0;
    align-items: flex-end;
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
}

.hud-left {
    display: grid;
    gap: 2px;
    min-width: 0;
    justify-self: stretch;
    --px: 1;
}

.hud-row {
    display: flex;
    align-items: center;
    gap: 5px;
    width: max-content;
    white-space: nowrap;
    /* shrunk from JS when the numbers get longer than the column (see fitHud) */
    transform-origin: left center;
}

.hud-row b {
    font-size: 22px;
    letter-spacing: 0.02em;
}

.hud-row.small {
    font-size: 13px;
    color: var(--ink-2);
}

.hud-row.small .px {
    margin-left: 4px;
}

.hud-right {
    display: flex;
    gap: 6px;
    justify-self: end;
    pointer-events: auto;
}

.slots {
    position: relative;
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

.slot {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    background: rgba(10, 8, 30, 0.72);
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
    --c: 8px;
    transition: box-shadow 0.2s;
}

.slot::after {
    content: "";
    width: 34px;
    height: 34px;
    background: center / contain no-repeat;
    scale: 0;
    transition: scale 0.2s;
}

.slot[data-c="yellow"]::after { background-image: url("../assets/ui/slot-yellow.webp"); }
.slot[data-c="red"]::after { background-image: url("../assets/ui/slot-red.webp"); }
.slot[data-c="blue"]::after { background-image: url("../assets/ui/slot-blue.webp"); }
.slot[data-c="green"]::after { background-image: url("../assets/ui/slot-green.webp"); }
.slot[data-c="yellow"] { --sc: #ffd43b; }
.slot[data-c="red"] { --sc: #ff5b6e; }
.slot[data-c="blue"] { --sc: #4fb8ff; }
.slot[data-c="green"] { --sc: #5ee07a; }

.slot.on::after {
    scale: 1;
}

.slot.pop::after {
    animation: slotpop 0.4s cubic-bezier(.2, 1.8, .4, 1);
}

.slot.pop {
    box-shadow: inset 0 0 0 2px var(--sc), 0 0 16px var(--sc);
}

@keyframes slotpop {
    from {
        scale: 1.8;
    }
}

.slot.reach {
    box-shadow: inset 0 0 0 2px #fff;
    animation: reach 0.35s steps(2) infinite;
}

@keyframes reach {
    50% {
        box-shadow: inset 0 0 0 2px var(--gold);
    }
}

.slot.win {
    box-shadow: inset 0 0 0 3px var(--sc), 0 0 18px var(--sc);
    animation: win 0.25s 6 alternate;
}

.slot.miss {
    animation: miss 0.12s 4;
}

@keyframes win {
    to {
        filter: brightness(1.8);
    }
}

@keyframes miss {
    50% {
        translate: 3px 0;
    }
}

.hp {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    max-width: 50%;
    --px: 1.25;
}

.stat-right {
    display: flex;
    gap: 6px;
    --px: 1;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px 3px 4px;
    background: rgba(10, 8, 30, 0.7);
    box-shadow: inset 0 0 0 1px rgba(84, 220, 255, 0.35);
    font-size: 15px;
    --c: 6px;
}

.chip.zero {
    opacity: 0.45;
}

#bombBtn {
    position: absolute;
    z-index: 11;
    right: max(18px, calc(50% - var(--game-w, 100%) / 2 + 18px));
    bottom: max(70px, calc(env(safe-area-inset-bottom) + 64px));
    width: 76px;
    height: 76px;
    display: grid;
    place-items: center;
    border: 0;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.25), transparent 60%),
        linear-gradient(135deg, #ff4f79, #b0204f);
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.6);
    font-family: var(--f-dot);
    color: #fff;
    --c: 18px;
    --px: 2;
}

#bombBtn b {
    position: absolute;
    bottom: 4px;
    right: 10px;
    font-size: 15px;
}

#bombBtn.left {
    right: auto;
    left: max(18px, calc(50% - var(--game-w, 100%) / 2 + 18px));
}

#bombBtn:active {
    transform: scale(0.92);
}

#bombBtn.empty {
    filter: grayscale(1) brightness(0.6);
}

#banner {
    position: absolute;
    z-index: 12;
    top: 28%;
    left: 50%;
    translate: -50% 0;
    display: grid;
    justify-items: center;
    pointer-events: none;
    text-align: center;
    font-family: var(--f-dot);
    opacity: 0;
}

#banner .b1 {
    font-size: clamp(30px, 8vw, 48px);
    letter-spacing: 0.1em;
    color: #fff;
    text-shadow: 0 0 18px var(--pink), 0 4px 0 #3a0e44;
}

#banner .b2 {
    margin-top: 6px;
    padding: 4px 18px;
    font-size: 16px;
    color: var(--gold);
    background: rgba(10, 8, 30, 0.7);
    clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}

#banner.show {
    animation: banner 2.4s ease-out forwards;
}

@keyframes banner {
    0% {
        opacity: 0;
        transform: scaleX(1.6) scaleY(0.2);
    }

    10% {
        opacity: 1;
        transform: none;
    }

    80% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* ---------------- viewers ---------------- */
.viewer {
    position: absolute;
    inset: 0;
    z-index: 40;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 10px;
    padding: 20px;
    background: rgba(2, 2, 10, 0.94);
}

.viewer img {
    max-width: 92vw;
    max-height: 70vh;
    object-fit: contain;
}

.viewer #viewerTitle {
    font-weight: 900;
    color: var(--gold);
    text-align: center;
}

.viewer .close {
    position: absolute;
    top: max(14px, env(safe-area-inset-top));
    right: 14px;
}

.build-stats {
    display: flex;
    justify-content: center;
    gap: 14px;
    font-family: var(--f-dot);
    color: var(--ink-2);
}

.build-list {
    display: grid;
    gap: 6px;
    max-height: 50vh;
    overflow-y: auto;
    touch-action: pan-y;
}

.build-list .w {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-left: 4px solid var(--rc);
    font-size: 13px;
    --px: 1;
}

.build-list .w small {
    display: block;
    color: var(--ink-3);
}

.build-list .w b {
    font-family: var(--f-dot);
    color: var(--gold);
}

@media (max-width: 420px) {
    .btn {
        min-height: 46px;
        font-size: 15px;
    }

    .btn.primary {
        min-height: 54px;
    }

    .gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
    }
}

/* menu buttons: icon pinned to the left edge, label truly centred */
.menu .btn {
    padding-left: 56px;
    padding-right: 56px;
}

.menu .btn > .px {
    position: absolute;
    left: 16px;
    top: 50%;
    translate: 0 -50%;
}

.menu.row .btn {
    padding-left: 44px;
    padding-right: 16px;
}

.menu.row .btn > .px {
    left: 10px;
}

.mini-v {
    width: 22px;
    height: 22px;
}

/* each menu screen has its own waiting-room background (never the last game frame) */
#screenManual,
#screenSettings,
#screenRanking,
#screenBonus {
    background: #070817 center / cover no-repeat;
}

#screenManual { background-image: linear-gradient(rgba(5, 6, 20, 0.35), rgba(5, 6, 20, 0.35)), url("../assets/backgrounds/scr-manual.webp"); }
#screenRanking { background-image: linear-gradient(rgba(5, 6, 20, 0.35), rgba(5, 6, 20, 0.35)), url("../assets/backgrounds/scr-ranking.webp"); }
#screenSettings { background-image: linear-gradient(rgba(5, 6, 20, 0.35), rgba(5, 6, 20, 0.35)), url("../assets/backgrounds/scr-settings.webp"), url("../assets/backgrounds/title.webp"); }
#screenBonus { background-image: linear-gradient(rgba(5, 6, 20, 0.3), rgba(5, 6, 20, 0.3)), url("../assets/backgrounds/scr-bonus.webp"); }

/* opened from the pause menu the settings keep the game visible underneath */
.in-game #screenSettings {
    background: rgba(4, 4, 14, 0.66);
}

/* score bounces when a big chunk lands */
#hudScore.bump {
    display: inline-block;
    animation: scorebump 0.35s ease-out;
}

@keyframes scorebump {
    0% { transform: scale(1); color: #fff; }
    30% { transform: scale(1.35); color: var(--gold); }
    100% { transform: scale(1); }
}

/* two slots filled: REACH!! flashes under the reels */
.slots.reaching::after {
    content: "REACH!!";
    position: absolute;
    top: 100%;
    left: 50%;
    translate: -50% 4px;
    font-family: var(--f-dot);
    font-size: 15px;
    letter-spacing: 0.08em;
    color: #ff5b6e;
    text-shadow: 0 0 8px #ff5b6e, 0 2px 0 #1a0b24;
    white-space: nowrap;
    pointer-events: none;
    animation: reachblink 0.3s steps(2) infinite;
}

@keyframes reachblink {
    50% { color: #ffd43b; text-shadow: 0 0 10px #ffd43b, 0 2px 0 #1a0b24; }
}
