/* Game Kinley Telegram Mini App */
:root {
  --bg: var(--tg-theme-bg-color, #0f1115);
  --text: var(--tg-theme-text-color, #f2f4f8);
  --hint: var(--tg-theme-hint-color, #8b93a7);
  --btn: var(--tg-theme-button-color, #2aabee);
  --btn-text: var(--tg-theme-button-text-color, #fff);
  --sec: var(--tg-theme-secondary-bg-color, #1a1d24);
  --accent: #e2136e;
  --ok: #22c55e;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

#app { max-width: 520px; margin: 0 auto; padding-bottom: calc(72px + var(--safe-b)); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid color-mix(in srgb, var(--hint) 20%, transparent);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand strong, .brand small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { color: var(--hint); font-size: 12px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  background: linear-gradient(135deg, #e2136e, #2aabee); color: #fff;
}
.icon-btn {
  width: 40px; height: 40px; border: 0; border-radius: 12px;
  background: var(--sec); font-size: 20px;
}
.hidden { display: none !important; }

#view { padding: 14px; }

.search {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 0;
  background: var(--sec); margin-bottom: 14px; outline: none;
}

.cats { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 8px; }
.chip {
  flex: 0 0 auto; border: 0; border-radius: 999px;
  padding: 8px 14px; background: var(--sec); color: var(--text); font-size: 13px;
}
.chip.active { background: var(--btn); color: var(--btn-text); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  background: var(--sec); border-radius: var(--radius); overflow: hidden;
  border: 0; text-align: left; padding: 0; color: inherit;
}
.card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #111; }
.card .meta { padding: 10px; }
.card .meta strong { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.4em; }
.card .price { color: var(--accent); font-weight: 700; margin-top: 6px; font-size: 13px; }

.detail-img { width: 100%; border-radius: var(--radius); aspect-ratio: 16/10; object-fit: cover; background: #111; }
.vars { display: grid; gap: 8px; margin: 14px 0; }
.var-btn {
  text-align: left; padding: 12px 14px; border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--hint) 25%, transparent);
  background: var(--sec);
}
.var-btn.active { border-color: var(--btn); box-shadow: inset 0 0 0 1px var(--btn); }
.var-btn .row { display: flex; justify-content: space-between; gap: 8px; }
.field { margin: 12px 0; }
.field label { display: block; font-size: 13px; color: var(--hint); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 0; background: var(--sec); outline: none;
}

.btn {
  width: 100%; border: 0; border-radius: 14px; padding: 14px 16px;
  background: var(--btn); color: var(--btn-text); font-weight: 700; margin-top: 10px;
}
.btn:disabled { opacity: 0.5; }
.btn.ghost { background: var(--sec); color: var(--text); }
.btn.accent { background: var(--accent); }

.cart-line {
  display: grid; grid-template-columns: 56px 1fr auto; gap: 10px;
  background: var(--sec); border-radius: 12px; padding: 10px; margin-bottom: 10px; align-items: center;
}
.cart-line img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button { width: 28px; height: 28px; border: 0; border-radius: 8px; background: var(--bg); }

.pay-list { display: grid; gap: 8px; }
.pay-item {
  display: flex; gap: 12px; align-items: center;
  padding: 12px; border-radius: 12px; background: var(--sec);
  border: 1px solid transparent; text-align: left; width: 100%;
}
.pay-item.active { border-color: var(--btn); }
.pay-item img { width: 40px; height: 28px; object-fit: contain; }
.account-box {
  background: var(--sec); border-radius: 12px; padding: 14px; margin: 12px 0;
}
.account-box .num { font-size: 22px; font-weight: 800; letter-spacing: 0.5px; }
.copy-btn { margin-top: 8px; }

.order-card {
  background: var(--sec); border-radius: 12px; padding: 14px; margin-bottom: 10px;
}
.order-card .top { display: flex; justify-content: space-between; gap: 8px; }
.status {
  font-size: 12px; padding: 4px 8px; border-radius: 999px;
  background: color-mix(in srgb, var(--hint) 20%, transparent);
}
.status.on-hold { background: #92400e33; color: #fbbf24; }
.status.processing, .status.completed { background: #14532d44; color: #4ade80; }
.status.cancelled, .status.failed { background: #7f1d1d44; color: #f87171; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(3, 1fr);
  padding: 8px 8px calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid color-mix(in srgb, var(--hint) 20%, transparent);
  max-width: 520px; margin: 0 auto;
}
.tab {
  position: relative; border: 0; background: transparent; color: var(--hint);
  display: grid; gap: 2px; place-items: center; padding: 6px; font-size: 11px;
}
.tab.active { color: var(--text); }
.badge {
  position: absolute; top: 0; right: calc(50% - 22px);
  min-width: 18px; height: 18px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: 11px;
  display: grid; place-items: center; padding: 0 4px;
}

.empty { text-align: center; color: var(--hint); padding: 40px 16px; }
.toast {
  position: fixed; left: 50%; bottom: calc(90px + var(--safe-b));
  transform: translateX(-50%); z-index: 50;
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 999px;
  font-size: 13px; max-width: 90%; box-shadow: 0 8px 24px #0006;
}
.muted { color: var(--hint); font-size: 13px; }
.h1 { font-size: 20px; margin: 0 0 8px; }
.h2 { font-size: 16px; margin: 18px 0 8px; }
.total-row { display: flex; justify-content: space-between; font-weight: 700; font-size: 16px; margin: 12px 0; }
.loader { text-align: center; padding: 40px; color: var(--hint); }
