:root {
    --bg: #120c22;
    --bg-2: #1a1230;
    --ink: #f6eefe;
    --muted: #cbb9e8;
    --accent: #d7b4ff;
    --accent-2: #9b7dff;
    --card: rgba(24, 16, 42, 0.88);
    --green: #3dcc7a;
    --green-glow: rgba(61, 204, 122, 0.55);
    --red: #e4486a;
    --red-glow: rgba(228, 72, 106, 0.5);
    --gray: #3a314c;
    --gray-2: #2a2438;
    --hole-rim: #c9a6ff;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bot: env(safe-area-inset-bottom, 0px);
    --header-h: calc(64px + var(--safe-top));
    --pad-size: 72px;
    --dock-h: calc(var(--pad-size) + 28px + var(--safe-bot));
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    width: 100%;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: ui-rounded, "Segoe UI", system-ui, -apple-system, sans-serif;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

body {
    max-width: 480px;
    margin: 0 auto;
    position: relative;
    background: radial-gradient(120% 70% at 50% 0%, #2a1848 0%, transparent 55%),
    radial-gradient(80% 50% at 50% 100%, #1a0e30 0%, transparent 50%),
    var(--bg);
}

#app {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.header {
    position: relative;
    z-index: 20;
    flex: 0 0 auto;
    min-height: var(--header-h);
    padding: calc(var(--safe-top) + 8px) 10px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: linear-gradient(180deg, rgba(18, 12, 34, 0.96), rgba(18, 12, 34, 0.55) 70%, transparent);
}

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    color: var(--ink);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 12px;
    border-radius: 999px;
    background: var(--card);
    border: 1px solid rgba(215, 180, 255, 0.22);
    white-space: nowrap;
}

.btn-back:active {
    transform: scale(0.97);
}

.title {
    display: none;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--accent);
    white-space: nowrap;
    min-width: 0;
}

.hud {
    display: flex;
    gap: 8px;
    flex: 0 0 auto;
    font-variant-numeric: tabular-nums;
}

.pill {
    background: var(--card);
    border: 1px solid rgba(215, 180, 255, 0.28);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 700;
    color: var(--muted);
}

.pill b {
    color: var(--ink);
    font-weight: 800;
    font-size: 22px;
    line-height: 1;
    margin-left: 2px;
}

.pill.score b {
    color: #ffd36a;
}

.pill.score.is-neg b {
    color: var(--red);
}

.stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    z-index: 1;
}

.floor {
    position: absolute;
    inset: 18% 8% 22%;
    border-radius: 28px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 30%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.015) 0 2px, transparent 2px 28px),
    rgba(36, 24, 58, 0.35);
    border: 1px solid rgba(215, 180, 255, 0.08);
    pointer-events: none;
}

.hole-wrap {
    position: absolute;
    left: 50%;
    top: 42%;
    width: var(--hole, 124px);
    height: var(--hole, 124px);
    transform: translate(-50%, -50%);
    z-index: 4;
    pointer-events: none;
    transition: width 0.55s cubic-bezier(.2, .8, .2, 1), height 0.55s cubic-bezier(.2, .8, .2, 1);
}

.hole {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 38%, #2b1020 0%, #0a0408 42%, #000 70%);
    box-shadow: 0 0 0 4px rgba(201, 166, 255, 0.22),
    0 0 0 10px rgba(18, 12, 34, 0.9),
    0 18px 40px rgba(0, 0, 0, 0.55),
    inset 0 18px 24px rgba(0, 0, 0, 0.85),
    inset 0 -10px 16px rgba(120, 70, 180, 0.18);
    overflow: hidden;
    position: relative;
}

.hole::before {
    content: "";
    position: absolute;
    inset: 12%;
    border-radius: 50%;
    background: conic-gradient(from 0deg, transparent, rgba(215, 180, 255, .18), transparent 40%);
    animation: spin 7s linear infinite;
}

.hole::after {
    content: "";
    position: absolute;
    left: 22%;
    top: 16%;
    width: 28%;
    height: 14%;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    filter: blur(1px);
}

.hole-glow {
    position: absolute;
    inset: -18%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(167, 92, 255, 0.28), transparent 68%);
    z-index: -1;
    animation: pulse 2.4s ease-in-out infinite;
}

.hole-wrap.eat .hole {
    animation: swallow 0.35s ease-out;
}

.hole-wrap.grow .hole-glow {
    animation: burst 0.6s ease-out;
}

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

@keyframes pulse {
    0%, 100% {
        opacity: 0.55;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.06);
    }
}

@keyframes swallow {
    0% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.08);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes burst {
    0% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.35);
    }
    100% {
        opacity: 0.55;
        transform: scale(1);
    }
}

.flyer {
    position: absolute;
    left: 0;
    top: 0;
    width: 56px;
    height: 56px;
    margin: -28px 0 0 -28px;
    z-index: 8;
    pointer-events: none;
    will-change: transform;
    filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .4));
}

.flyer img, .flyer .emoji {
    width: 100%;
    height: 100%;
    display: block;
    animation: wobble 0.45s ease-in-out infinite alternate;
}

.flyer .emoji {
    display: grid;
    place-items: center;
    font-size: 42px;
    line-height: 1;
}

.flyer.junk .emoji {
    font-size: 38px;
}

@keyframes wobble {
    from {
        transform: rotate(-16deg) scale(1);
    }
    to {
        transform: rotate(18deg) scale(1.05);
    }
}

.pads {
    position: relative;
    z-index: 12;
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    width: 100%;
    padding: 8px 16px calc(16px + var(--safe-bot));
    pointer-events: none;
}

.pad {
    pointer-events: auto;
    width: var(--pad-size);
    height: var(--pad-size);
    border-radius: 22px;
    border: 2px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, #4a415c, var(--gray-2));
    box-shadow: 0 10px 0 #1a1524, 0 16px 24px rgba(0, 0, 0, .35);
    position: relative;
    color: transparent;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.pad::after {
    content: "";
    position: absolute;
    inset: 10px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
}

.pad[data-state="gray"] {
    pointer-events: none;
}

.pad[data-state="green"] {
    background: linear-gradient(180deg, #63e896, #1ea85a);
    border-color: rgba(180, 255, 210, 0.45);
    box-shadow: 0 10px 0 #0d6b38, 0 0 24px var(--green-glow);
}

.pad[data-state="red"] {
    background: linear-gradient(180deg, #ff6d8a, #c2274a);
    border-color: rgba(255, 190, 205, 0.4);
    box-shadow: 0 10px 0 #7a1230, 0 0 24px var(--red-glow);
}

.pad[data-state="cyan"] {
    background: linear-gradient(180deg, #9aecff, rgb(121, 222, 242));
    border-color: rgba(200, 250, 255, 0.7);
    box-shadow: 0 10px 0 #2a8aa0, 0 0 26px rgba(121, 222, 242, 0.7);
}

.pad[data-state="blue"] {
    background: linear-gradient(180deg, #3a44e0, #0003a8);
    border-color: rgba(160, 170, 255, 0.45);
    box-shadow: 0 10px 0 #00025c, 0 0 26px rgba(0, 3, 168, 0.65);
}

.pad[data-state="purple"] {
    background: linear-gradient(180deg, #f0dcff, #d7b4ff);
    border-color: rgba(255, 240, 255, 0.55);
    box-shadow: 0 10px 0 #7a58b0, 0 0 26px rgba(215, 180, 255, 0.7);
}

.pad[data-state="black"] {
    background: linear-gradient(180deg, #2a2a32, #050508);
    border-color: rgba(215, 180, 255, 0.55);
    box-shadow: 0 10px 0 #000, 0 0 22px rgba(255, 255, 255, 0.18);
}

.pad[data-state="yellow"] {
    background: linear-gradient(180deg, #ffe789, #f0c400);
    border-color: rgba(255, 240, 180, 0.7);
    box-shadow: 0 10px 0 #9a7a00, 0 0 26px rgba(240, 196, 0, 0.65);
}

.pad[data-state="pink"] {
    background: linear-gradient(180deg, #ffd0ea, #ff6fb7);
    border-color: rgba(255, 210, 235, 0.8);
    box-shadow: 0 10px 0 #b03070, 0 0 28px rgba(255, 111, 183, 0.75);
}

.pad:active {
    transform: translateY(4px);
    box-shadow: 0 6px 0 #1a1524;
}

.pad[data-state="green"]:active {
    box-shadow: 0 6px 0 #0d6b38, 0 0 16px var(--green-glow);
}

.pad[data-state="red"]:active {
    box-shadow: 0 6px 0 #7a1230, 0 0 16px var(--red-glow);
}

.pad.deny {
    animation: deny 0.28s ease;
}

@keyframes deny {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

.hint {
    position: absolute;
    left: 50%;
    bottom: 10px;
    transform: translateX(-50%);
    z-index: 11;
    font-size: 12px;
    color: var(--muted);
    text-align: center;
    width: min(78%, 280px);
    line-height: 1.35;
    opacity: 0.9;
    pointer-events: none;
}

.how-to {
    text-align: left;
    padding-top: 18px;
}

.how-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 10px;
}

.how-duck {
    width: 56px;
    height: 56px;
    filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .35));
    animation: wobble .45s ease-in-out infinite alternate;
}

.how-hole {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: radial-gradient(circle at 50% 38%, #2b1020 0%, #000 70%);
    box-shadow: 0 0 0 3px rgba(201, 166, 255, .28),
    0 10px 18px rgba(0, 0, 0, .4),
    inset 0 10px 12px rgba(0, 0, 0, .75);
}

.how-lead {
    margin-bottom: 12px !important;
}

.how-rules {
    list-style: none;
    display: grid;
    gap: 8px;
    margin: 0 0 16px;
}

.how-rules li {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
}

.how-rules b {
    color: var(--ink);
}

.how-pad {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    flex: 0 0 28px;
    border: 1px solid rgba(255, 255, 255, .12);
}

.how-pad--green {
    background: linear-gradient(180deg, #63e896, #1ea85a);
    box-shadow: 0 0 10px var(--green-glow);
}

.how-pad--red {
    background: linear-gradient(180deg, #ff6d8a, #c2274a);
    box-shadow: 0 0 10px var(--red-glow);
}

.how-pad--gray {
    background: linear-gradient(180deg, #4a415c, var(--gray-2));
}

.how-ico {
    width: 28px;
    text-align: center;
    font-size: 20px;
    flex: 0 0 28px;
}

.overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    background: rgba(10, 6, 20, 0.72);
    backdrop-filter: blur(8px);
    display: none;
    place-items: center;
    padding: 24px;
}

.overlay.show {
    display: grid;
}

.modal {
    width: min(100%, 340px);
    background: var(--card);
    border: 1px solid rgba(215, 180, 255, 0.28);
    border-radius: 22px;
    padding: 26px 22px 22px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.modal h2 {
    font-size: 22px;
    margin-bottom: 8px;
    color: var(--accent);
}

.modal p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
    margin-bottom: 18px;
}

.modal .big {
    font-size: 34px;
    margin: 4px 0 12px;
}

.modal button {
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 14px 16px;
    font-size: 16px;
    font-weight: 800;
    color: #1a1028;
    background: linear-gradient(180deg, #e8d0ff, var(--accent));
    cursor: pointer;
}

.modal button:active {
    transform: scale(0.98);
}

.rotate {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: #120c22;
    color: var(--ink);
    place-items: center;
    text-align: center;
    padding: 24px;
    font-weight: 700;
}

@media (orientation: landscape) and (max-height: 480px) {
    .rotate {
        display: grid;
    }
}

@media (min-width: 400px) {
    .title {
        display: block;
    }
}

@media (max-width: 360px) {
    :root {
        --pad-size: 64px;
    }

    .btn-back {
        padding: 6px 8px;
        font-size: 12px;
    }

    .pill {
        padding: 5px 8px;
        font-size: 11px;
    }
}

@media (max-height: 620px) {
    :root {
        --pad-size: 62px;
    }

    .hole-wrap {
        top: 38%;
    }
}
