:root {
    --bg: #f4f5f7;
    --card: #ffffff;
    --card-soft: #f0f2f5;
    --text: #111318;
    --muted: #667085;
    --border: #e4e7ec;
    --gold: #f5b400;
    --blue: #229ed9;
    --shadow: 0 18px 48px rgba(16, 24, 40, .14);
}

body.dark-mode {
    --bg: #070707;
    --card: #131313;
    --card-soft: #1a1a1a;
    --text: #ffffff;
    --muted: #a3a3a3;
    --border: #262626;
    --shadow: 0 18px 54px rgba(0, 0, 0, .42);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    overflow-x: hidden;
}

body.loyalcard-body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Exo 2', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    transition: background .22s ease, color .22s ease;
}

button,
input,
select {
    font: inherit;
}

button {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
}

.topbar {
    position: fixed;
    z-index: 100;
    top: 0;
    left: 0;
    right: 0;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: color-mix(in srgb, var(--card) 94%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(18px);
}

.brand {
    border: 0;
    background: transparent;
    color: var(--text);
    font-size: 21px;
    font-weight: 900;
    cursor: pointer;
    padding: 8px 0;
}

.top-actions {
    display: flex;
    gap: 10px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--card-soft);
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
}

.content {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 78px 12px 96px;
}

.card-wrap {
    perspective: none;
    padding: 0;
}

.flip {
    position: relative;
    height: 240px;
    transform-style: flat;
    transition: none;
    transform-origin: center;
}

.flip.active {
    transform: none;
}

.flip.is-flipping {
    animation: loyalcardFlip .42s cubic-bezier(.2, .75, .2, 1);
}

@keyframes loyalcardFlip {
    0% {
        transform: scaleX(1);
        filter: brightness(1);
    }

    46% {
        transform: scaleX(.045);
        filter: brightness(.82);
    }

    54% {
        transform: scaleX(.045);
        filter: brightness(.82);
    }

    100% {
        transform: scaleX(1);
        filter: brightness(1);
    }
}

.loyal-card {
    position: absolute;
    inset: 0;
    border-radius: 28px;
    overflow: hidden;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    box-shadow: var(--shadow);
    transition: opacity .18s ease, visibility .18s ease;
}

.front {
    background: #151515 center / cover no-repeat;
    color: #fff;
    padding: 22px;
}

.front .card-shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, .14), rgba(0, 0, 0, .76));
    z-index: 1;
}

.front > *:not(.card-shade) {
    position: relative;
    z-index: 2;
}

.business-chip {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    max-width: calc(100% - 118px);
    min-height: 42px;
    padding: 5px 12px 5px 5px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .16);
    backdrop-filter: blur(12px);
    font-size: 13px;
    font-weight: 800;
}

.business-chip img {
    width: 32px;
    height: 32px;
    border-radius: 12px;
    object-fit: cover;
    background: #fff;
}

.timer {
    position: absolute;
    top: 16px;
    right: 16px;
    min-width: 92px;
    height: 42px;
    padding: 0 14px;
    border-radius: 18px;
    background: rgba(255, 255, 255, .16);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
}

/* Hard overrides: the site may still have old snippets/custom CSS with generic
   names like .front, .timer or .username. These ID-scoped rules keep the card
   layout stable inside WordPress. */
.loyalcard-body #card {
    position: absolute !important;
    display: block !important;
    padding: 0 !important;
    transform: none !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
}

.loyalcard-body #backCard {
    transform: none !important;
    backface-visibility: hidden !important;
    -webkit-backface-visibility: hidden !important;
    z-index: 3;
}

.loyalcard-body #flip.active #card {
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.loyalcard-body #flip.active #backCard {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
}

.loyalcard-body #timerBadge {
    position: absolute !important;
    top: 18px !important;
    right: 18px !important;
    left: auto !important;
    bottom: auto !important;
    width: auto !important;
    min-width: 94px !important;
    max-width: 130px !important;
    height: 40px !important;
    padding: 0 12px !important;
    border-radius: 18px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    line-height: 1 !important;
}

.loyalcard-body #card .business-chip {
    position: absolute !important;
    top: 18px !important;
    left: 18px !important;
    right: auto !important;
    bottom: auto !important;
    max-width: calc(100% - 170px) !important;
}

.loyalcard-body #cardBusinessName {
    position: absolute !important;
    left: 22px !important;
    right: 22px !important;
    top: auto !important;
    bottom: 66px !important;
    margin: 0 !important;
    max-width: calc(100% - 44px) !important;
    font-size: 30px !important;
    line-height: 1.02 !important;
    font-weight: 900 !important;
}

.loyalcard-body #cardBusinessDescription {
    position: absolute !important;
    left: 22px !important;
    right: 22px !important;
    top: auto !important;
    bottom: 44px !important;
    margin: 0 !important;
    max-width: calc(100% - 44px) !important;
    font-size: 14px !important;
    line-height: 1.35 !important;
}

.loyalcard-body #username {
    position: absolute !important;
    left: 22px !important;
    right: 22px !important;
    top: auto !important;
    bottom: 20px !important;
    font-size: 17px !important;
    line-height: 1.1 !important;
    font-weight: 800 !important;
}

.front h1 {
    position: absolute;
    left: 22px;
    right: 22px;
    top: 82px;
    margin: 0;
    max-width: 320px;
    font-size: 27px;
    line-height: 1.04;
    font-weight: 900;
}

.front p {
    position: absolute;
    left: 22px;
    right: 22px;
    top: 144px;
    margin: 0;
    max-width: 300px;
    font-size: 14px;
    line-height: 1.42;
    opacity: .86;
}

.username {
    position: absolute;
    left: 22px;
    bottom: 20px;
    font-size: 18px;
    font-weight: 800;
}

.back {
    transform: none;
    background: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 14px 18px;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.flip.active .front {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.flip.active .back {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.qr-box {
    width: clamp(154px, 43vw, 184px);
    height: clamp(154px, 43vw, 184px);
    max-width: 184px;
    max-height: 184px;
    background: #fff;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
}

.qr-box img,
.qr-box canvas {
    width: 100% !important;
    height: 100% !important;
}

.qr-state {
    min-height: 20px;
    margin-top: 10px;
    color: #555;
    font-size: 12px;
    font-weight: 700;
}

.primary-action {
    width: 100%;
    height: 58px;
    margin-top: 14px;
    border: 0;
    border-radius: 20px;
    background: var(--text);
    color: var(--bg);
    display: grid;
    grid-template-columns: 32px 1fr 32px;
    align-items: center;
    padding: 0 18px;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
}

.primary-action span {
    text-align: center;
    white-space: nowrap;
}

.points-card {
    margin-top: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--card);
}

.points-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.muted-label {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.35;
    font-weight: 800;
}

.small-hint {
    margin-top: 4px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.points-count {
    flex: 0 0 auto;
    font-size: 22px;
    line-height: 1;
    font-weight: 900;
}

.stars-wrap {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 9px;
    margin-bottom: 14px;
}

.point-dot {
    aspect-ratio: 1;
    min-width: 0;
    border-radius: 50%;
    border: 2px dashed color-mix(in srgb, var(--text) 20%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 900;
}

.point-dot.active {
    background: #fff;
    color: #111;
    border-color: #fff;
}

body:not(.dark-mode) .point-dot.active {
    background: #111;
    color: #fff;
    border-color: #111;
}

.info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}

.info-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.info-row i {
    margin-right: 8px;
    color: var(--muted);
}

.gold {
    color: var(--gold);
    font-weight: 900;
}

.bottom-nav {
    position: fixed;
    z-index: 100;
    left: 0;
    right: 0;
    bottom: 0;
    height: 76px;
    background: color-mix(in srgb, var(--card) 96%, transparent);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(18px);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
}

.bottom-item {
    border: 0;
    background: transparent;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
}

.bottom-item i {
    font-size: 20px;
}

.bottom-item.active {
    color: var(--gold);
}

.modal {
    position: fixed;
    z-index: 1000;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, .66);
    backdrop-filter: blur(8px);
}

.modal.active {
    display: flex;
}

.modal-box {
    width: 100%;
    max-width: 400px;
    max-height: calc(100vh - 32px);
    overflow: auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 26px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.modal-box.center {
    text-align: center;
}

.modal-box.tall {
    height: min(80vh, 680px);
    display: flex;
    flex-direction: column;
}

.modal-box h2 {
    margin: 0 0 18px;
    font-size: 26px;
    line-height: 1.1;
    font-weight: 900;
}

.modal-copy {
    margin: 0 0 18px;
    color: var(--muted);
    line-height: 1.55;
}

.stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.offer-item {
    padding: 15px;
    border-radius: 18px;
    background: var(--card-soft);
}

.offer-item strong {
    display: block;
    margin-bottom: 7px;
}

.offer-item span {
    display: block;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.45;
}

.review-stars {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 18px;
}

.review-star {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 14px;
    background: var(--card-soft);
    color: var(--gold);
    font-size: 26px;
    cursor: pointer;
}

.muted-text {
    color: var(--muted);
    font-size: 14px;
}

.menu-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
    margin-bottom: 14px;
}

.menu-tab {
    flex: 0 0 auto;
    border: 0;
    border-radius: 14px;
    padding: 9px 13px;
    background: var(--card-soft);
    color: var(--text);
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
}

.menu-tab.active {
    background: var(--gold);
    color: #000;
}

.menu-content {
    display: none;
    overflow-y: auto;
    padding-right: 4px;
}

.menu-content.active {
    display: block;
}

.menu-category {
    font-size: 22px;
    font-weight: 900;
    margin-bottom: 8px;
}

.telegram-cta,
.login-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 56px;
    border-radius: 18px;
    background: var(--blue);
    color: #fff;
    text-decoration: none;
    font-weight: 900;
}

.field-label {
    display: block;
    margin-bottom: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.input {
    width: 100%;
    height: 54px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card-soft);
    color: var(--text);
    padding: 0 14px;
    font-size: 16px;
    margin-bottom: 14px;
}

.business-select {
    width: 100%;
    min-height: 66px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card-soft);
    color: var(--text);
    padding: 10px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    cursor: pointer;
    margin-bottom: 14px;
}

.business-select-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    text-align: left;
}

.business-select-main img {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 14px;
    object-fit: cover;
    background: #fff;
}

.business-select-main strong,
.business-select-main small {
    display: block;
}

.business-select-main strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
}

.business-select-main small {
    color: var(--muted);
    margin-top: 2px;
}

.save-btn {
    width: 100%;
    height: 56px;
    border: 0;
    border-radius: 18px;
    background: var(--text);
    color: var(--bg);
    font-size: 17px;
    font-weight: 900;
    cursor: pointer;
    margin-bottom: 14px;
}

.business-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.business-item {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--card-soft);
    color: var(--text);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    cursor: pointer;
}

.business-item img {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    object-fit: cover;
    background: #fff;
}

.business-item strong,
.business-item small {
    display: block;
}

.business-item small {
    margin-top: 3px;
    color: var(--muted);
}

.toast {
    position: fixed;
    z-index: 1200;
    left: 50%;
    bottom: 92px;
    transform: translateX(-50%) translateY(16px);
    min-width: min(320px, calc(100vw - 32px));
    max-width: calc(100vw - 32px);
    padding: 13px 16px;
    border-radius: 16px;
    background: #111;
    color: #fff;
    text-align: center;
    font-weight: 800;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s ease, transform .18s ease;
}

.toast.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@media (max-width: 380px) {
    .front h1 {
        font-size: 24px;
    }

    .front p {
        top: 138px;
        font-size: 13px;
    }

    .timer {
        min-width: 78px;
        padding: 0 10px;
    }

    .business-chip {
        max-width: calc(100% - 96px);
    }
}
