:root {
  --bg: #0f1016;
  --bg-2: #15161f;
  --card: #1b1c28;
  --card-2: #21222f;
  --text: #f4f4f8;
  --muted: #9393a8;
  --accent: #7c6cf0;
  --accent-2: #5b4fd6;
  --success: #2aa85e;
  --danger: #e0505f;
  --border: #2a2b3a;
  --shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

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

[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Cairo", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

/* header */
#header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

#header h1 {
  flex: 1;
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border: none;
  border-radius: 11px;
  background: var(--card-2);
  color: var(--text);
  font-size: 19px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}

.icon-btn:active { transform: scale(0.92); }

.back-btn { transform: scaleX(-1); font-size: 24px; color: var(--accent); }
.back-btn:active { transform: scaleX(-1) scale(0.92); }

/* drawer */
#drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 20;
  animation: fade-in 0.15s ease;
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

#drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  width: 78%;
  max-width: 300px;
  background: var(--bg-2);
  z-index: 21;
  box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
  animation: slide-in 0.18s ease;
}

@keyframes slide-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-head {
  padding: calc(20px + env(safe-area-inset-top)) 18px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}

.drawer-logo { font-size: 26px; }
.drawer-title { font-size: 17px; font-weight: 800; }

.drawer-items {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
}

.drawer-item:active { background: var(--card-2); }
.drawer-item.active { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.drawer-item .d-icon { font-size: 19px; width: 24px; text-align: center; }

/* states */
.state-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 90px 24px;
  text-align: center;
  color: var(--muted);
}

.state-text { font-size: 15px; font-weight: 600; }
.state-icon { font-size: 44px; opacity: 0.7; }

.spinner {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-top-color: var(--accent);
  animation: spin 0.75s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* content */
#content { padding: 14px; }

.hero {
  border-radius: 18px;
  padding: 22px 18px;
  margin-bottom: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2) 70%, #3d2fae);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 85% -10%, rgba(255,255,255,0.25), transparent 55%);
}

.hero-title { font-size: 18px; font-weight: 800; margin: 0 0 4px; position: relative; }
.hero-sub { font-size: 12.5px; opacity: 0.9; position: relative; }

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 14px;
  margin-bottom: 16px;
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
}

.search-box input::placeholder { color: var(--muted); }
.search-icon { color: var(--muted); font-size: 15px; }

.section-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--muted);
  margin: 4px 2px 10px;
}

/* grid of brand tiles */
.grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 6px;
}

.tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease;
}

.tile:active { transform: scale(0.96); }

.tile-badge {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

.tile-name {
  font-size: 13.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.tile-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  padding: 3px 9px;
  border-radius: 999px;
}

/* group tiles (top-level: gift cards / games) are bigger, one per row */
.group-tile {
  grid-column: span 1;
  min-height: 84px;
  justify-content: center;
}

/* list rows (regions) */
.row {
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.1s ease;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  margin-bottom: 10px;
}

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

.row-icon-box {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
}

.row-main { flex: 1; min-width: 0; }

.row-title {
  font-size: 14.5px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-count-pill {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  padding: 4px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.chevron { color: var(--muted); font-size: 16px; flex-shrink: 0; opacity: 0.7; }

/* product rows */
.product-row {
  cursor: default;
  align-items: center;
}

.product-row:active { transform: none; }

.product-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }

.product-title {
  font-size: 14.5px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-sub { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }

.price-tag { font-size: 14px; font-weight: 800; color: var(--text); }

.stock-tag {
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--success) 22%, transparent);
  color: #6fe3a0;
}

.stock-tag.low {
  background: color-mix(in srgb, #e0a020 22%, transparent);
  color: #f0c060;
}

.buy-btn {
  border: none;
  background: linear-gradient(135deg, #45cd7f, var(--success));
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  box-shadow: 0 4px 10px rgba(30, 150, 80, 0.35);
}

.buy-btn:active { transform: scale(0.93); }
