:root {
    --bg: var(--tg-theme-bg-color, #0e0e13);
    --surface: #1a1a22;
    --surface-2: #232330;
    --text: var(--tg-theme-text-color, #f2f2f5);
    --muted: #9a9aa5;
    --accent: #fc21a3;
    --accent-2: #ff6ec7;
    --danger: #ff4d6a;
    --success: #28a745;
    --border: #2c2c38;
    --radius: 14px;
    --radius-sm: 8px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    padding-bottom: calc(90px + var(--safe-bottom));
}

a { color: inherit; text-decoration: none; }

header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(12px + var(--safe-top)) 16px 12px;
    background: rgba(14, 14, 19, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

header h1 {
    font-size: 18px;
    margin: 0;
    padding: calc(8px + var(--safe-top)) 16px 8px;
}

.logo {
    height: 34px;
    width: auto;
    flex-shrink: 0;
}

.search-form {
    flex: 1;
}

.text-input {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 14px;
    outline: none;
}

.text-input::placeholder { color: var(--muted); }
.text-input:focus { border-color: var(--accent); }

main {
    padding: 12px 16px 24px;
}

.form-select {
    width: 100%;
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    padding: 10px 14px !important;
    margin-bottom: 14px;
}

.form-select option { background: var(--surface); color: var(--text); }
.new-option { color: var(--accent) !important; font-weight: bold; }

main h1 {
    font-size: 20px;
    margin: 4px 0 14px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

@media (min-width: 560px) {
    .cards { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 860px) {
    .cards { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1180px) {
    .cards { grid-template-columns: repeat(5, 1fr); }
}

.card {
    position: relative;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    transition: transform .15s ease, border-color .15s ease;
}

.card:active { transform: scale(0.98); }

.card-photo {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    background: var(--surface-2);
    display: block;
}

.discount-badge,
.new-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .03em;
    padding: 3px 8px;
    border-radius: 999px;
    color: #fff;
}

.discount-badge { background: var(--accent); }
.new-badge { background: var(--success); left: auto; right: 8px; }

.card-name {
    margin: 10px 10px 0;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
    min-height: 2.6em;
}

.card-flavor {
    margin: 2px 10px 0;
    font-size: 12px;
    color: var(--muted);
}

.card-price,
.card-price-container {
    margin: 8px 10px 0;
    font-size: 15px;
    font-weight: 700;
}

.card-price-container {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.card-price-old {
    font-size: 12px;
    color: var(--muted);
    text-decoration: line-through;
    font-weight: 400;
    margin: 0;
}

.card-price-new {
    color: var(--accent);
    margin: 0;
}

.card .button,
a.button {
    display: block;
    text-align: center;
    margin: 10px;
    margin-top: auto;
    padding: 9px 8px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
}

.error-category {
    text-align: center;
    color: var(--muted);
    margin: 40px 16px;
}

.cart-count {
    position: fixed;
    right: calc(16px + 42px);
    bottom: calc(30px + var(--safe-bottom));
    z-index: 21;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.button-footer {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(16px + var(--safe-bottom));
    z-index: 20;
    display: block;
    text-align: center;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 15px;
    padding: 15px;
    border-radius: var(--radius);
    border: none;
    box-shadow: 0 8px 24px rgba(252, 33, 163, 0.35);
}

.button-footer.disabled,
.button-footer[disabled] {
    background: var(--surface-2);
    color: var(--muted);
    box-shadow: none;
    pointer-events: none;
}

.preorder-btn { background: var(--surface-2); color: var(--text); }

.button-footer-button {
    background: none;
    border: none;
    color: var(--text);
}
