/* BOS MOD Mini App - dark base with gold accents, following Telegram's theme
   for text colours so light-theme clients stay readable. */
:root {
  --bg: #0a0a0c;
  --bg-2: #101014;
  --surface: rgba(255,255,255,.05);
  --surface-2: rgba(255,255,255,.08);
  --border: rgba(255,255,255,.10);
  --gold-3: #f5e28a;
  --gold: #e3c341;
  --gold-6: #c9a227;
  --text: #f4f4f2;
  --muted: #a3a39d;
  --green: #35c759;
  --danger: #e35341;
  --radius: 16px;
  /* Telegram reports two insets: the system one and the area its own header
     buttons occupy. Taking the larger keeps content clear of both. */
  --safe-t: max(var(--tg-safe-area-inset-top, 0px), var(--tg-content-safe-area-inset-top, 0px));
  --safe-b: max(env(safe-area-inset-bottom, 0px),
                var(--tg-safe-area-inset-bottom, 0px),
                var(--tg-content-safe-area-inset-bottom, 0px));
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* Several blocks below set an explicit display, which would otherwise win over
   the hidden attribute and leave "hidden" elements on screen - that is how the
   quantity stepper stayed usable on one-per-order packs. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: contain;
}

body[dir="rtl"] { direction: rtl; }

/* Telegram publishes the real visible height as a CSS variable. Using 100vh
   instead measures the whole screen, so a Mini App opened from a deep link -
   which starts collapsed and expands a moment later - lays itself out against
   a height it does not have yet. */
.app {
  min-height: var(--tg-viewport-stable-height, 100vh);
  padding-top: var(--safe-t);
  padding-bottom: calc(96px + var(--safe-b));
}

/* boot spinner */
.boot {
  display: grid; place-items: center;
  min-height: calc(var(--tg-viewport-stable-height, 100vh) * 0.7);
}
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.15); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* top bar */
.topbar {
  position: sticky; top: var(--safe-t); z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(10,10,12,.92);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .04em; }
.brand img { width: 26px; height: 26px; border-radius: 50%; }
.linkbtn {
  margin-inline-start: auto; background: none; border: 0;
  color: var(--gold); font: 600 14px var(--font); cursor: pointer; padding: 6px;
}

/* game switch */
.games { display: flex; gap: 8px; padding: 12px 14px 4px; }
.games button {
  flex: 1; padding: 11px 10px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: 700 14px var(--font); cursor: pointer;
}
.games button.on {
  background: linear-gradient(135deg, var(--gold-3), var(--gold) 55%, var(--gold-6));
  color: #171307; border-color: transparent;
}

/* search */
.search { padding: 10px 14px 4px; }
.search input {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: 500 15px var(--font);
}
.search input::placeholder { color: var(--muted); }
.search input:focus { outline: none; border-color: rgba(227,195,65,.55); }

/* chips */
.chips {
  display: flex; gap: 8px; padding: 10px 14px 2px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.chips::-webkit-scrollbar { display: none; }
.chips button {
  flex: 0 0 auto; white-space: nowrap;
  padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font: 600 13px var(--font); cursor: pointer;
}
.chips button.on { color: #171307; background: var(--gold); border-color: transparent; }
.chips.subs button.on { background: rgba(227,195,65,.16); color: var(--gold-3); border-color: rgba(227,195,65,.5); }

/* product grid */
.grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px 14px;
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column; cursor: pointer;
  transition: transform .15s ease, border-color .2s;
}
.card:active { transform: scale(.975); }
.card .media {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  background:
    radial-gradient(circle at center,
      rgba(218, 178, 60, .16) 0%,
      rgba(218, 178, 60, .05) 38%,
      transparent 70%),
    linear-gradient(180deg, #171719 0%, #101012 100%);
}
.card .thumb {
  width: clamp(76px, 58%, 118px);
  height: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 14px rgba(0, 0, 0, .55));
}
.card .info { padding: 9px 10px 11px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card .title { font-weight: 700; font-size: 13.5px; line-height: 1.25; }
.card .price { margin-top: auto; font-size: 12.5px; color: var(--muted); }
.card .price b { color: var(--gold); font-size: 13.5px; }
.card .was { text-decoration: line-through; opacity: .65; margin-inline-end: 4px; }
.badge {
  position: absolute; top: 8px; inset-inline-start: 8px;
  background: var(--danger); color: #fff; font: 800 11px var(--font);
  padding: 2px 7px; border-radius: 999px;
}
.card .wrap { position: relative; }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }

/* product page */
.banner { padding: 12px 14px 0; }
.banner .media {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at center,
      rgba(218, 178, 60, .18) 0%,
      rgba(218, 178, 60, .05) 40%,
      transparent 72%),
    linear-gradient(180deg, #171719 0%, #101012 100%);
}
.banner img {
  width: clamp(110px, 34%, 168px);
  height: auto;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, .6));
}
.pbody { padding: 14px; }
.pbody h1 { font-size: 20px; margin: 0 0 4px; line-height: 1.2; }
.muted { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.desc { font-size: 14.5px; margin: 0 0 14px; white-space: pre-line; }
.note {
  background: rgba(227,195,65,.08); border: 1px solid rgba(227,195,65,.3);
  color: var(--gold-3); border-radius: 12px; padding: 9px 12px;
  font-size: 13px; margin: 0 0 14px;
}
.pricebox {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px;
}
.row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 3px 0; font-size: 14px; }
.row span { color: var(--muted); }
.row.total b { color: var(--gold); font-size: 18px; }
.row .was { text-decoration: line-through; color: var(--muted); font-weight: 400; margin-inline-end: 6px; }

.stepper { display: flex; align-items: center; justify-content: center; gap: 0; }
.stepper button {
  width: 52px; height: 44px; font-size: 22px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer;
}
.stepper button:first-child { border-radius: 12px 0 0 12px; }
.stepper button:last-child { border-radius: 0 12px 12px 0; }
.stepper button:disabled { opacity: .35; }
.stepper span {
  min-width: 68px; height: 44px; display: grid; place-items: center;
  border-top: 1px solid var(--border); border-bottom: 1px solid var(--border);
  background: var(--bg-2); font-weight: 700;
}

/* checkout */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 6px; letter-spacing: .04em; }
.field input {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text); font: 600 15px var(--font);
}
.field input:focus { outline: none; border-color: var(--gold); }
.err { color: var(--danger); font-size: 13.5px; margin: 0 0 14px; }
.summary {
  background: var(--surface); border: 1px solid rgba(227,195,65,.3);
  border-radius: var(--radius); padding: 12px 14px; margin-top: 4px;
}

/* orders */
.order {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; margin-bottom: 10px;
}
.order .head { display: flex; justify-content: space-between; gap: 10px; font-weight: 700; }
.order .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.order .st { font-size: 12.5px; font-weight: 700; }
.st-completed { color: var(--green); }
.st-failed { color: var(--danger); }
.st-pending { color: var(--gold); }

/* sticky action */
.sticky {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 14px calc(10px + var(--safe-b));
  background: linear-gradient(180deg, rgba(10,10,12,0), rgba(10,10,12,.96) 32%);
}
.cta {
  width: 100%; padding: 15px; border: 0; border-radius: 14px;
  background: var(--green); color: #fff;
  font: 800 16px var(--font); cursor: pointer;
}
.cta:disabled { opacity: .45; }
.cta.gold { background: linear-gradient(135deg, var(--gold-3), var(--gold) 55%, var(--gold-6)); color: #171307; }

/* saved castles under the name field */
.recent { margin-top: 12px; }
.recent-head {
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  color: var(--muted); margin-bottom: 6px;
}
.castle {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); cursor: pointer;
}
.castle.on { border-color: var(--gold); background: rgba(227,195,65,.10); }
.castle .who { flex: 1; min-width: 0; }
.castle .nick { font-weight: 700; font-size: 14px; }
.castle .srv { color: var(--muted); font-size: 12px; }
.castle .rm {
  flex: 0 0 auto; width: 30px; height: 30px; line-height: 1;
  border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); font-size: 18px; cursor: pointer;
}
.castle .rm:active { background: rgba(227,83,65,.18); color: var(--danger); }
.linkdanger {
  background: none; border: 0; padding: 6px 0;
  color: var(--danger); font: 600 13px var(--font); cursor: pointer;
}
