:root {
    --bg: #0d0d10;
    --bg-2: #16161b;
    --ink: #f6f4f1;
    --muted: #9a9590;
    --line: rgba(255, 255, 255, 0.08);
    --hot: #ff4458;
    --gold: #ffc857;
    --gold-dim: #5a4a2a;
    --card: #22222a;
    --radius: 22px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: #070708;
    color: var(--ink);
    font-family: Outfit, system-ui, sans-serif;
}

img {
    max-width: 100%;
}

button,
input {
    font: inherit;
}

.app {
    position: relative;
    width: min(430px, 100%);
    min-height: 100dvh;
    margin: 0 auto;
    background: radial-gradient(120% 80% at 50% 0%, #1c1c24 0%, var(--bg) 55%);
    display: flex;
    flex-direction: column;
    padding:
        calc(12px + var(--safe-top))
        16px
        calc(18px + var(--safe-bottom));
    overflow: hidden;
}

.topbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.brand,
.eyebrow {
    margin: 0;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 600;
    color: var(--hot);
}

.progress {
    margin: 0;
    font-weight: 600;
    font-size: 15px;
}

.text-btn {
    justify-self: end;
    border: 0;
    background: none;
    color: var(--ink);
    padding: 8px 0;
    font-weight: 600;
}

.deck {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-stage {
    position: relative;
    width: 280px;
    height: 280px;
    flex: 0 0 auto;
}

.stack-card,
.card {
    position: absolute;
    inset: 0;
    border-radius: 0;
    background: var(--card);
}

.stack-1 {
    transform: scale(0.96) translateY(10px);
    opacity: 0.55;
}

.stack-2 {
    transform: scale(0.92) translateY(20px);
    opacity: 0.28;
}

.card {
    overflow: hidden;
    touch-action: none;
    user-select: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
}

.card.dragging {
    transition: none;
}

.card.fly-left {
    transform: translate(-130%, 18px) rotate(-18deg);
    opacity: 0;
}

.card.fly-right {
    transform: translate(130%, 18px) rotate(18deg);
    opacity: 0;
}

.card img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.heart-flash {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-items: center;
    font-size: 110px;
    line-height: 1;
    color: var(--hot);
    pointer-events: none;
    opacity: 0;
    transform: scale(0.4);
}

.heart-flash.on {
    animation: heartFlash 0.45s ease-out;
}

@keyframes heartFlash {
    0% {
        opacity: 0;
        transform: scale(0.35);
    }
    30% {
        opacity: 1;
        transform: scale(1.2);
    }
    100% {
        opacity: 0;
        transform: scale(1.45);
    }
}

.status {
    margin: 12px 0 8px;
    text-align: center;
    color: var(--muted);
    font-size: 14px;
    min-height: 1.3em;
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    justify-items: center;
}

.circle-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 2px solid #3ddc97;
    background: #15181a;
    color: #3ddc97;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.circle-btn span {
    font-size: 32px;
    line-height: 1;
    margin-top: -2px;
}

.like-btn {
    border-color: var(--hot);
    color: var(--hot);
}

.like-btn span {
    font-size: 28px;
    margin-top: 2px;
}

.done {
    position: absolute;
    inset: 0;
    background: var(--bg);
    overflow: auto;
    padding:
        calc(16px + var(--safe-top))
        16px
        calc(24px + var(--safe-bottom));
}

.done-head h1 {
    margin: 8px 0 6px;
    font-size: 32px;
}

.done-head p {
    margin: 0 0 10px;
    color: var(--muted);
}

.hang-prompt {
    margin: 0 0 8px;
    color: var(--ink);
    font-weight: 500;
}

.hang-prompt span {
    color: var(--hot);
}

.restart-end {
    display: inline-block;
    margin: 0 0 16px;
    padding: 0;
}

.results {
    columns: 2;
    column-gap: 10px;
}

.result-card {
    position: relative;
    display: block;
    break-inside: avoid;
    margin-bottom: 10px;
    padding: 0;
    border: 0;
    width: 100%;
    text-align: left;
    color: inherit;
    background: var(--card);
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
}

.result-card.picked {
    outline: 2px solid var(--hot);
    outline-offset: -2px;
}

.result-card .badge {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--hot);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 14px;
}

.result-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}

.result-card p {
    margin: 0;
    padding: 8px 10px 10px;
    font-size: 13px;
    color: var(--hot);
    letter-spacing: 0.08em;
}

.hidden {
    display: none;
}

.busy {
    pointer-events: none;
}

.admin-body {
    background: #0b0b0d;
    min-height: 100dvh;
}

.admin-wrap {
    width: min(960px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 64px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: end;
    margin-bottom: 24px;
}

.admin-header h1 {
    margin: 6px 0 0;
}

.admin-nav {
    display: flex;
    gap: 16px;
}

.admin-nav a {
    color: var(--ink);
}

.admin-login {
    display: grid;
    gap: 10px;
    max-width: 320px;
}

.admin-login input,
.admin-login button {
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--bg-2);
    color: var(--ink);
}

.admin-login button {
    background: var(--hot);
    border: 0;
    font-weight: 600;
}

.admin-error {
    color: var(--hot);
    margin: 0;
}

.admin-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.admin-stats div {
    background: var(--bg-2);
    border-radius: 16px;
    padding: 14px 18px;
    min-width: 110px;
}

.admin-stats strong {
    display: block;
    font-size: 28px;
}

.admin-stats span {
    color: var(--muted);
    font-size: 13px;
}

.admin-table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th,
.admin-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

.admin-file {
    display: flex;
    align-items: center;
    gap: 10px;
}

.admin-table img {
    width: 56px;
    height: 56px;
    max-width: none;
    min-width: 56px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    flex: 0 0 56px;
}

.wall-body {
    margin: 0;
    min-height: 100dvh;
    background: #111216;
    overflow: hidden;
}

.wall-body model-viewer {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 50% 40%, #2a2a32, #0d0d10 70%);
}

.wall-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: calc(12px + var(--safe-top)) 16px 12px;
}

.wall-bar a,
.wall-start,
.wall-link {
    color: #fff;
    text-decoration: none;
    font-weight: 600;
}

.wall-bar p,
.wall-status {
    margin: 0;
    color: rgba(255, 255, 255, 0.82);
    font-size: 13px;
}

.wall-status {
    position: fixed;
    top: calc(56px + var(--safe-top));
    left: 16px;
    right: 16px;
    z-index: 3;
    text-align: center;
}

.wall-start {
    position: absolute;
    left: 50%;
    bottom: calc(108px + var(--safe-bottom));
    z-index: 4;
    transform: translateX(-50%);
    border: 0;
    background: var(--hot);
    color: #fff;
    padding: 14px 22px;
    border-radius: 999px;
}

.wall-start.ios-ar {
    position: fixed;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.wall-start.ios-ar::after {
    content: "Place on wall";
    font-weight: 600;
}

.wall-start.ios-ar img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    display: block;
    border-radius: 6px;
}

.wall-start.ios-ar.hidden {
    display: none;
}

.wall-picks {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding: 12px 16px calc(16px + var(--safe-bottom));
}

.wall-picks button {
    position: relative;
    flex: 0 0 64px;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 2px solid transparent;
    background: #111;
}

.wall-picks button.on {
    border-color: var(--hot);
}

.wall-picks img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.wall-picks span {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--hot);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: grid;
    place-items: center;
}

.wall-link {
    display: inline-block;
    margin: 0 12px 16px 0;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--hot);
}

@media (min-width: 800px) {
    body:not(.admin-body):not(.wall-body) {
        background:
            radial-gradient(circle at 20% 10%, rgba(255, 68, 88, 0.12), transparent 28%),
            #070708;
    }

    .app {
        margin: 18px auto;
        min-height: calc(100dvh - 36px);
        border: 1px solid var(--line);
        border-radius: 28px;
        box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
    }
}
