/* attribute hidden ต้องชนะ display: ทุกตัวเสมอ (กันบั๊ก element ซ่อนไม่ได้ทั้งเว็บ) */
[hidden] { display: none !important; }

/* ════════════════════════════════════════════════════════
   ROBUX ICON  (replaces the "R$" currency prefix)
   Usage in JS/HTML: <span class="robux">123.45</span>
════════════════════════════════════════════════════════ */
.robux {
  display: inline-flex;
  align-items: center;
  gap: .32em;
  white-space: nowrap;
}
.robux::before {
  content: "";
  display: inline-block;
  width: .92em;
  height: .92em;
  flex: 0 0 auto;
  /* Official Robux 2019 logo (white) loaded from Wikimedia */
  background: url("https://upload.wikimedia.org/wikipedia/commons/9/9d/Robux_2019_Logo_white.svg") center / contain no-repeat;
}

/* ════════════════════════════════════════════════════════
   VARIABLES & RESET
════════════════════════════════════════════════════════ */
:root {
  --bg:        #100d0b;
  --card:      #181410;
  --secondary: #211b15;
  --muted:     #2e271f;
  --muted-fg:  hsl(38,12%,82%);
  --primary:   hsl(43,100%,55%);
  --accent:    hsl(5,76%,53%);
  --border:    #3a3128;
  --white:     hsl(40,18%,92%);
  --radius:    0.75rem;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
ul { list-style: none; }
button, select, input { cursor: pointer; font: inherit; }
html { background: var(--bg); }
body {
  background: transparent;
  color: var(--white);
  font-family: "Plus Jakarta Sans", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
  font-weight: 700;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted-fg); }

/* Halloween background (static), behind all content.
   Promoted to its own GPU layer so it never repaints on scroll. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: url("../img/halloween-bg.svg") center / cover no-repeat;
  opacity: 0.7;
  transform: translateZ(0);
  will-change: transform;
  contain: strict;
}

/* ════════════════════════════════════════════════════════
   LAYOUT
════════════════════════════════════════════════════════ */
.container {
    max-width: 1280px;
    margin: auto;
    padding: 0 1rem;
    padding-top: 0.75rem;
}
svg.icon { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ════════════════════════════════════════════════════════
   HEADER
════════════════════════════════════════════════════════ */
.site-header {
  position: sticky; top: 0; z-index: 50; width: 100%;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  background: var(--bg);
}
.header-inner {
  display: flex; height: 60px; align-items: center;
  justify-content: flex-start; padding: 0 1rem; gap: 1.5rem;
}
.header-inner .header-right { margin-left: auto; }
.logo { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; cursor: pointer; }
.logo span { font-size: 1.25rem; font-weight: 700; color: var(--white); }
nav { display: flex; align-items: center; gap: 0.25rem; }
nav a, nav button {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; font-size: 0.875rem; font-weight: 700;
  color: var(--muted-fg); border-radius: 0.5rem; background: none; border: none;
  transition: color .15s, background .15s; cursor: pointer;
}
.cb-mode-name,
.cb-mode-name * {
    color: #fff !important;
}
nav a:hover, nav button:hover,
nav a.active, nav button.active {
  color: var(--white);
  background: color-mix(in srgb, var(--secondary) 90%, transparent);
}
nav img { width: 16px; height: 16px; opacity: 1; filter: brightness(0) invert(1); }
/* keep header / profile-menu icons small (no global img size rule exists) */
.btn-icon img { width: 20px; height: 20px; }
.profile-action img { width: 18px; height: 18px; flex: 0 0 auto; opacity: 0.85; }
.btn-profile .avatar-initial { font-size: 1.05rem; }
.header-right { display: flex; align-items: center; gap: 0.75rem; }
.lang-select {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--secondary);
  color: var(--white);
  padding: 0 0.65rem;
  font-size: 0.82rem;
  font-weight: 800;
}
.profile-menu-wrap { position: relative; }
/* white Sign In button (white fill, dark text) */
#btnSignIn { background: var(--white); color: var(--bg)}
#btnSignIn:hover { background: color-mix(in srgb, var(--white) 88%, #000); }
.btn-icon { background: none; border: none; padding: 0.5rem; color: var(--muted-fg); transition: color .15s; display: flex; }
.btn-icon:hover { color: var(--white); }
.divider { width: 1px; height: 24px; background: var(--border); }
.btn { border: none; border-radius: var(--radius); padding: 0.5rem 1.25rem; font-size: 0.875rem; font-weight: 700; transition: background .15s, color .15s; }
.btn-ghost { background: none; color: var(--white); }
.btn-ghost:hover { background: color-mix(in srgb, var(--secondary) 50%, transparent); }
.btn-ghost.active { background: color-mix(in srgb, var(--secondary) 70%, transparent); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: color-mix(in srgb, var(--accent) 90%, transparent); }
.btn-accent.active { box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); }
.btn.btn-profile {
  position: relative;
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--primary); color: var(--bg);
  color: #fff;
  border: 3px solid color-mix(in srgb, var(--secondary) 70%, transparent);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
  overflow: hidden;
  white-space: nowrap;
}
.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 0.75rem);
  width: 240px;
  display: none;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(0,0,0,.38);
  overflow: hidden;
  z-index: 90;
}
.profile-menu.open { display: block; }
.profile-card { display: flex; align-items: center; gap: 0.85rem; width: 100%; padding: 0.95rem 1rem; cursor: pointer; transition: background .15s; }
.profile-card-info { display: flex; flex-direction: column; gap: 0.1rem; flex: 1; min-width: 0; }
.profile-card:hover,
.profile-card:focus-visible { background: color-mix(in srgb, var(--secondary) 65%, transparent); outline: none; }
.profile-avatar { position: relative; width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: var(--bg); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.avatar-initial { font-size: 1rem; font-weight: 800; line-height: 1; pointer-events: none; }
.profile-big-avatar .avatar-initial { font-size: 1.6rem; }
.profile-avatar.has-image .avatar-initial { display: none; }
.btn.btn-profile.has-image::before,
.btn.btn-profile.has-image::after,
.profile-avatar.has-image::before,
.profile-avatar.has-image::after { display: none; }
.profile-avatar-img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.profile-level { position: absolute; right: -4px; bottom: -4px; min-width: 16px; height: 16px; border-radius: 999px; background: var(--muted); border: 2px solid var(--card); color: #fff; font-size: 0.62rem; line-height: 12px; text-align: center; }
.profile-name { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; font-weight: 800; }
.profile-link { display: block; color: var(--muted-fg); font-size: 0.78rem; margin-top: -0.15rem; }
.profile-action { width: 100%; display: flex; align-items: center; gap: 0.6rem; padding: 0.85rem 1rem; border: 0; border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent); background: transparent; color: var(--white); text-align: left; font-weight: 800; }
.profile-action:hover { background: color-mix(in srgb, var(--secondary) 65%, transparent); }
.promo-row {
    display: grid;
    grid-template-columns: 1fr 34px;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-top: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}

.promo-row input {
    min-width: 0;
    height: 34px;
    padding: 0 12px;
    background: color-mix(in srgb, var(--secondary) 80%, transparent);
    border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
    border-radius: 8px;
    color: var(--white);
    outline: none;
    box-sizing: border-box;
}

.promo-row button {
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}
/* ── Player level (profile menu) ── */
.profile-xp-block { display: block; margin-top: 0.5rem; }
.profile-level-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.28rem; }
.profile-level-badge { font-size: 0.78rem; font-weight: 800; color: var(--accent); }
.profile-level-xp { font-size: 0.68rem; font-weight: 700; color: var(--muted-fg); }
.profile-level-bar { display: block; height: 5px; border-radius: 999px; background: color-mix(in srgb, var(--border) 90%, var(--white)); overflow: hidden; }
.profile-level-bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); width: 0%; transition: width .4s ease; }
.btn-secondary { background: var(--secondary); color: var(--white); padding: 0.35rem 0.85rem; font-size: 0.75rem; font-weight: 700; border-radius: 0.5rem; }
.btn-secondary:hover { background: var(--muted); }
.cookie-banner {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  width: min(720px, calc(100% - 2rem));
  transform: translate(-50%, calc(100% + 2rem));
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  z-index: 180;
  padding: 1rem;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 75%, transparent);
  border-radius: 8px;
  box-shadow: 0 18px 42px rgba(0,0,0,.42);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s ease, opacity .2s ease;
}
.cookie-banner.show {
  transform: translate(-50%, 0);
  opacity: 1;
  pointer-events: auto;
}
.cookie-title { font-size: 0.95rem; font-weight: 800; margin-bottom: 0.2rem; }
.cookie-text { color: var(--muted-fg); font-size: 0.82rem; line-height: 1.45; }
.cookie-actions { display: flex; align-items: center; gap: 0.6rem; }

/* ════════════════════════════════════════════════════════
   PAGE SWITCHING
════════════════════════════════════════════════════════ */
.page { display: none; }
.page.active { display: block; }

/* Stagger fade-up: delay ของแต่ละชิ้นถูกตั้งจาก JS (runStaggerAnimation)
   เพื่อให้ครอบคลุมทุกหน้าและทุกจำนวนชิ้นอัตโนมัติ */
@keyframes pageFadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════
   PAGE TRANSITION BAR
════════════════════════════════════════════════════════ */
#page-loader {
  display: none !important;   /* เอาแถบ progress สีขาวด้านบนออก */
  position: fixed;
  top: 0; left: 0;
  width: 0%;
  height: 2px;
  background: #ffffff;
  z-index: 9999;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px rgba(255,255,255,0.6), 0 0 20px rgba(255,255,255,0.3);
  transition: width 0.25s ease, opacity 0.3s ease;
  opacity: 0;
  pointer-events: none;
}

/* ════════════════════════════════════════════════════════
   CARD
════════════════════════════════════════════════════════ */
.card { background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 50%, transparent); border-radius: var(--radius); }

/* ════════════════════════════════════════════════════════
   HOME PAGE — MAIN LAYOUT
════════════════════════════════════════════════════════ */
main { padding: 1.5rem 1rem; }
.main-inner { display: flex; gap: 2rem; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-title { display: flex; align-items: center; gap: 0.5rem; font-size: 1.125rem; font-weight: 700; }
.section-title img { width: 20px; height: 20px; filter: brightness(0) invert(1);}
.view-all { display: flex; align-items: center; gap: 0.25rem; font-size: 0.875rem; color: var(--muted-fg); transition: color .15s; cursor: pointer; }
.view-all:hover { color: var(--white); }

/* Challenges */
.challenges-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.challenge-card { position: relative; overflow: hidden; padding: 1rem; cursor: pointer; display: flex; align-items: center; gap: 1rem; }
.challenge-gradient { position: absolute; inset: 0; opacity: 0.5; }
.challenge-gradient.amber { background: linear-gradient(to right, rgba(245,176,39,.2), transparent); }
.challenge-gradient.blue  { background: linear-gradient(to right, rgba(21,168,227,.2), transparent); }
.challenge-gradient.purple{ background: linear-gradient(to right, rgba(168,85,247,.2), transparent); }
.challenge-icon { position: relative; z-index: 1; width: 48px; height: 48px; border-radius: 0.5rem; background: color-mix(in srgb, var(--secondary) 50%, transparent); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.challenge-icon img {
    width: 32px;
    height: 32px;
    filter: brightness(0) invert(1);
}
.challenge-text { position: relative; z-index: 1; }
.challenge-label { font-size: 0.7rem; color: var(--muted-fg); text-transform: uppercase; letter-spacing: .05em; }
.challenge-title { font-size: 0.875rem; font-weight: 700; }
.challenge-bg { position: absolute; right: 0; top: 50%; transform: translateY(-50%) translateX(25%); opacity: 0.6; height: 96px; width: auto; transition: opacity .2s; }
.challenge-card:hover .challenge-bg { opacity: 0.85; }

/* Scroll row */
.scroll-row { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 0.5rem; scrollbar-width: none; -ms-overflow-style: none; }
.scroll-row::-webkit-scrollbar { display: none; }

/* Pack card (home scroll) */
.pack-card { flex-shrink: 0; width: 144px; cursor: pointer; transition: transform .2s, box-shadow .2s; }
.pack-card:hover { transform: translateY(-4px); box-shadow: 0 8px 25px rgba(0,0,0,.3); }
.pack-thumb {
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: 12px;
  background: var(--bg);
}

.pack-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;   /* โชว์รูปเต็ม ไม่ถูกครอบตัด */
  object-position: center;
  display: block;
}
.pack-price { margin-top: 0.5rem; text-align: center; font-size: 0.875rem; font-weight: 700; }

.draw-preview-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}
.draw-preview-card,
.draw-pool-card,
.random-result-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
}
.draw-preview-card {
  min-height: 118px;
  padding: 1rem;
  display: grid;
  gap: 0.35rem;
  align-content: center;
}
.draw-preview-card span,
.draw-pool-card span,
.random-rarity {
  width: fit-content;
  border-radius: 999px;
  padding: 0.22rem 0.55rem;
  background: rgba(255,255,255,.08);
  color: var(--muted-fg);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}
.draw-preview-card strong { color: var(--white); }
.draw-preview-card small { color: var(--muted-fg); font-size: 0.78rem; }
.limited { border-color: color-mix(in srgb, var(--primary) 65%, var(--border)); }
.rare { border-color: color-mix(in srgb, var(--accent) 60%, var(--border)); }
.normal { border-color: #3f7f5b; }
.low { border-color: #555; }
.random-page { padding-top: 2rem; padding-bottom: 3rem; }
.random-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 2rem;
}
.random-copy {
  display: grid;
  align-content: center;
  gap: 1rem;
  min-height: 390px;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: linear-gradient(135deg, #171717, #101010);
}
.section-kicker { color: var(--primary); font-size: 0.82rem; font-weight: 900; text-transform: uppercase; }
.random-copy h1 { font-size: 2.6rem; line-height: 1.05; }
.random-copy p { max-width: 620px; color: var(--muted-fg); }
.random-draw-btn { width: fit-content; min-width: 150px; }
.random-status { color: var(--muted-fg); font-size: 0.86rem; }
.random-result-card {
  display: grid;
  gap: 0.8rem;
  justify-items: center;
  align-content: center;
  min-height: 390px;
  padding: 1.5rem;
  text-align: center;
}
.random-image-wrap {
  width: min(240px, 80%);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--secondary);
  overflow: hidden;
}
.random-image-wrap img { width: 100%; height: 100%; object-fit: contain; }
.random-result-card h2 { font-size: 1.35rem; }
.random-result-card p { color: var(--muted-fg); }
.random-result-card strong { color: var(--primary); font-size: 1.25rem; }
.draw-pool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0.85rem;
}
.draw-pool-card {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 0.8rem;
  padding: 0.8rem;
}
.draw-pool-card img {
  width: 86px;
  height: 86px;
  object-fit: contain;
  border-radius: 6px;
  background: var(--secondary);
}
.draw-pool-card h3 { margin-top: 0.3rem; font-size: 0.98rem; }
.draw-pool-card p { margin-top: 0.25rem; color: var(--muted-fg); font-size: 0.8rem; }
.draw-pool-card strong { display: block; margin-top: 0.35rem; color: var(--primary); }
.draw-pool-card small { color: var(--muted-fg); font-size: 0.75rem; }

/* Deal card */
.deal-card { flex-shrink: 0; width: 160px; cursor: pointer; transition: transform .2s, box-shadow .2s; }
.deal-card:hover { transform: translateY(-4px); box-shadow: 0 8px 25px rgba(0,0,0,.3); }
.deal-thumb { position: relative; aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 50%, transparent); padding: 0.75rem; }
.deal-thumb img { width: 100%; height: 100%; object-fit: contain; }
.badge-multiplier { position: absolute; top: 0.5rem; left: 0.5rem; padding: 0.15rem 0.5rem; border-radius: 0.25rem; background: rgba(34,197,94,.15); color: #4ade80; font-size: 0.7rem; font-weight: 700; }
.badge-coin { position: absolute; top: 0.5rem; right: 0.5rem; width: 20px; height: 20px; border-radius: 50%; background: #eab308; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #713f12; }
.deal-name { font-size: 0.7rem; color: var(--muted-fg); margin-top: 0.5rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.deal-price { font-size: 0.875rem; font-weight: 700; margin-top: 0.25rem; }

/* Battle list */
.battle-list { display: flex; flex-direction: column; gap: 0.75rem; }
.battle-row { border-left-width: 4px; border-left-style: solid; border-radius: var(--radius); padding: 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.battle-row.amber { border-left-color: #f59e0b; }
.battle-row.blue  { border-left-color: #3b82f6; }
.battle-left { display: flex; flex-direction: column; gap: 0.5rem; }
.battle-mode { display: flex; align-items: center; gap: 0.5rem; font-size: 0.7rem; color: var(--muted-fg); text-transform: uppercase; letter-spacing: .05em; }
.zap { color: #facc15; }
.avatars { display: flex; align-items: center; }
.avatar-wrap { position: relative; }
.avatar-wrap:not(:first-child) { margin-left: -0.5rem; }
.crown { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); width: 12px; height: 12px; color: #facc15; }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--card); background: var(--secondary); overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatars-more { padding-left: 0.75rem; font-size: 0.7rem; color: var(--muted-fg); }
.battle-cost { font-size: 0.75rem; color: var(--muted-fg); }
.battle-cost span { color: var(--white); font-weight: 700; }
.battle-packs { display: flex; align-items: center; gap: 0.25rem; }
.pack-mini { width: 48px; height: 64px; border-radius: 0.5rem; overflow: hidden; background: var(--secondary); border: 1px solid color-mix(in srgb, var(--border) 30%, transparent); }
.pack-mini img { width: 100%; height: 100%; object-fit: cover; }
.pack-count-badge { display: flex; align-items: center; gap: 0.25rem; margin-left: 0.25rem; padding: 0.25rem 0.5rem; border-radius: 0.375rem; background: var(--secondary); font-size: 0.75rem; color: var(--muted-fg); }
.battle-right { display: flex; flex-direction: column; align-items: flex-end; gap: 0.5rem; }
.battle-unboxed { font-size: 0.75rem; color: var(--muted-fg); }
.battle-unboxed span { color: var(--white); font-weight: 700; }

/* How It Works */
.how-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.5rem; }
.how-card { padding: 1.5rem; text-align: center; }
.how-img { width: 120px; height: 116px; margin: 0 auto 1rem; display: flex; align-items: center; justify-content: center; }
.how-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.how-title { font-size: 1.125rem; font-weight: 700; margin-bottom: 0.5rem; }
.how-desc { font-size: 0.875rem; color: var(--muted-fg); }

/* FAQ Accordion */
.faq-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 1rem; }
.faq-col { display: flex; flex-direction: column; gap: 0.5rem; }
.accordion-item { border: 1px solid color-mix(in srgb, var(--border) 50%, transparent); border-radius: var(--radius); background: var(--card); overflow: hidden; }
.accordion-trigger { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 1rem; background: none; border: none; color: var(--white); font-size: 0.875rem; font-weight: 700; text-align: left; gap: 0.5rem; transition: color .15s; }
.accordion-trigger:hover { color: var(--muted-fg); }
.accordion-chevron { flex-shrink: 0; width: 16px; height: 16px; color: var(--muted-fg); transition: transform .25s; }
.accordion-item.open .accordion-chevron { transform: rotate(180deg); }
.accordion-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s; }
.accordion-item.open .accordion-body { grid-template-rows: 1fr; }
.accordion-content { overflow: hidden; font-size: 0.875rem; color: var(--muted-fg); padding: 0 1rem; }
.accordion-item.open .accordion-content { padding-bottom: 1rem; }

/* Sidebar chat */
.sidebar,
.packs-sidebar,
.battles-sidebar,
.chat-sidebar { width: 280px; flex-shrink: 0; }
.chat-panel {
  position: sticky;
  top: 88px;
  display: flex;
  flex-direction: column;
  height: min(680px, calc(100vh - 112px));
  min-height: 420px;
  background: color-mix(in srgb, var(--card) 88%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
  border-radius: var(--radius);
  overflow: hidden;
}
.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
}
.chat-title { display: flex; align-items: center; gap: 0.5rem; font-size: 0.95rem; font-weight: 800; }
.chat-messages { flex: 1; display: flex; flex-direction: column; gap: 0.75rem; padding: 0.9rem; overflow-y: auto; }
.chat-message { display: flex; gap: 0.55rem; align-items: flex-start; max-width: 100%; }
.chat-message .chat-bubble { max-width: 80%; }
/* ตัวเราเอง — ชิดซ้าย (avatar ซ้าย, ข้อความขวา) */
.chat-message-self  { flex-direction: row;         justify-content: flex-start; }
.chat-message-self .chat-bubble { background: color-mix(in srgb, var(--primary) 20%, var(--secondary)); }
/* คนอื่น — ชิดขวา (avatar ขวา, ข้อความซ้ายของ avatar)
   หมายเหตุ: row-reverse กลับแกนหลัก → ต้องใช้ flex-start ถึงจะดันไปขวาสุด */
.chat-message-other { flex-direction: row-reverse; justify-content: flex-start; text-align: right; }
.chat-message-other .chat-name { color: var(--accent); }
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--secondary);
  color: var(--primary);
  font-size: 0.72rem;
  font-weight: 900;
}
.chat-bubble {
  min-width: 0;
  padding: 0.55rem 0.65rem;
  border-radius: 0.6rem;
  background: color-mix(in srgb, var(--secondary) 72%, transparent);
  font-size: 0.78rem;
  line-height: 1.35;
}
.chat-name { display: block; margin-bottom: 0.12rem; color: var(--primary); font-size: 0.68rem; font-weight: 900; }
.chat-form {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--border) 45%, transparent);
}
.chat-input {
  min-width: 0;
  flex: 1;
  height: 38px;
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 0.55rem;
  background: var(--bg);
  color: var(--white);
  padding: 0 0.75rem;
  font: inherit;
  font-size: 0.8rem;
  outline: none;
}
.chat-input::placeholder { color: color-mix(in srgb, var(--white) 70%, transparent); }
.chat-send {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 0.55rem;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--accent);
  color: #fff;
}
.chat-send:disabled,
.chat-input:disabled { opacity: 0.55; cursor: not-allowed; }
.chat-system { color: var(--muted-fg); font-size: 0.76rem; line-height: 1.35; text-align: center; padding: 0.35rem 0.5rem; }
.sidebar-section-title { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; font-weight: 700; margin-bottom: 1rem; }
.sidebar-section-title img { width: 20px; height: 20px; }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; animation: pulse-glow 2s ease-in-out infinite; }
@keyframes pulse-glow {
  0%,100% { opacity:1; box-shadow: 0 0 8px 2px rgba(239,68,68,.6); }
  50%      { opacity:.7; box-shadow: 0 0 12px 4px rgba(239,68,68,.8); }
}
.modal-pw-wrap input {
    margin-bottom: 10px;
}
.sidebar-cards { display: flex; flex-direction: column; gap: 0.75rem; }
.sidebar-scroll { max-height: 500px; overflow-y: auto; }
.item-card { position: relative; border-radius: 0.75rem; background: transparent; border: 0; padding: 0.75rem; cursor: pointer; transition: transform .2s, box-shadow .2s; }
.item-card:hover { transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,.25); }
.item-pack-thumb { position: absolute; top: -8px; right: -8px; width: 40px; height: 48px; border-radius: 0.5rem; overflow: hidden; border: 2px solid var(--card); box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.item-pack-thumb img { width: 100%; height: 100%; object-fit: cover; }
.live-badge { position: absolute; top: -4px; right: -4px; width: 10px; height: 10px; border-radius: 50%; background: #eab308; border: 2px solid var(--card); }
.item-img { width: 100%; aspect-ratio: 4/3; border-radius: 0.5rem; overflow: hidden; background: var(--secondary); display: flex; align-items: center; justify-content: center; margin-bottom: 0.5rem; }
.item-img img { max-width: 100%; max-height: 100%; object-fit: contain; }
.item-name { font-size: 0.7rem; color: var(--muted-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-price { font-size: 0.875rem; font-weight: 700; }

/* ════════════════════════════════════════════════════════
   PACKS PAGE
════════════════════════════════════════════════════════ */
.packs-page { display: flex; gap: 1.5rem; padding: 1.5rem 1rem; max-width: 1280px; margin: 0 auto; }
.packs-main { flex: 1; min-width: 0; }

/* Toolbar */
.packs-toolbar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.search-wrap { position: relative; flex: 1; min-width: 200px; }
.search-icon { position: absolute; left: 0.75rem; top: 50%; transform: translateY(-50%); color: var(--muted-fg); pointer-events: none; }
.search-input { width: 100%; background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius); padding: 0.6rem 1rem 0.6rem 2.5rem; font-size: 0.875rem; color: var(--white); outline: none; transition: border-color .15s, box-shadow .15s; }
.search-input::placeholder { color: var(--muted-fg); }
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.btn-reset { background: none; border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius); padding: 0.6rem 1rem; font-size: 0.875rem; color: var(--muted-fg); transition: color .15s, border-color .15s; white-space: nowrap; }
.btn-reset:hover { color: var(--white); border-color: var(--muted-fg); }
.btn-create { display: flex; align-items: center; gap: 0.4rem; background: var(--accent); border: none; border-radius: var(--radius); padding: 0.6rem 1.1rem; font-size: 0.875rem; font-weight: 700; color: #fff; white-space: nowrap; transition: background .15s, transform .1s; }
.btn-create:hover { background: color-mix(in srgb, var(--accent) 85%, white); }
.btn-create:active { transform: scale(.97); }

/* Filters */
.filters-row { display: flex; gap: 0.6rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.filter-select-wrap { position: relative; display: flex; align-items: center; }
.filter-select-wrap .filter-icon { position: absolute; left: 0.65rem; color: var(--muted-fg); pointer-events: none; font-size: 0.75rem; display: flex; align-items: center; }
.filter-select { appearance: none; background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius); padding: 0.5rem 2rem 0.5rem 2.1rem; font-size: 0.8rem; color: var(--white); outline: none; transition: border-color .15s; cursor: pointer; }
.filter-select:hover, .filter-select:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.filter-caret { position: absolute; right: 0.6rem; pointer-events: none; color: var(--muted-fg); }

/* Pack grid */
.packs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.pack-grid-item { cursor: pointer; transition: transform .2s, box-shadow .2s; }
.pack-grid-item:hover { transform: translateY(-5px); box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.pack-cover img { width: 100%; height: 100%; object-fit: cover; /* เต็มกรอบ */ object-position: center; transition: transform .3s ease; } .pack-cover:hover img { transform: scale(1.05); }
.pack-grid-item:hover .pack-cover img { transform: scale(1.04); }
.pack-cover-label { position: absolute; top: 0; left: 0; right: 0; padding: 0.5rem 0.6rem; font-size: 0.7rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.pack-cover-badge { position: absolute; top: 0.5rem; right: 0.5rem; padding: 0.15rem 0.45rem; border-radius: 0.25rem; font-size: 0.65rem; font-weight: 700; text-transform: uppercase; }
.badge-new      { background: rgba(34,197,94,.2);  color: #4ade80; }
.badge-hot      { background: rgba(239,68,68,.2);   color: #f87171; }
.badge-featured { background: rgba(245,176,39,.2);  color: #f5b027; }
.pack-info { margin-top: 0.5rem; text-align: center; }
.pack-name { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 0.2rem; }
.pack-grid-price { font-size: 0.875rem; font-weight: 700; color: var(--white); }

/* Packs Sidebar */
.packs-sidebar-section { margin-bottom: 1.5rem; }
.packs-sidebar-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-fg); margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.4rem; }
.packs-sidebar-title .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 6px var(--primary); animation: pulse 2s infinite; }
.packs-sidebar-title .dot-live { background: #ef4444; box-shadow: 0 0 6px #ef4444; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ════════════════════════════════════════════════════════
   FOOTER
════════════════════════════════════════════════════════ */
footer { border-top: 1px solid color-mix(in srgb, var(--border) 40%, transparent); background: var(--bg); margin-top: 3rem; }
.footer-inner { padding: 3rem 1rem; }
.footer-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 2rem; }
.footer-logo { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; }
.footer-logo span { font-size: 1.25rem; font-weight: 700; }
.footer-desc { font-size: 0.875rem; color: var(--muted-fg); }
.footer-heading { font-size: 0.875rem; font-weight: 700; margin-bottom: 1rem; }
.footer-links { display: flex; flex-direction: column; gap: 0.5rem; }
.footer-links a { font-size: 0.875rem; color: var(--muted-fg); transition: color .15s; }
.footer-links a:hover { color: var(--white); }
.social-row { display: flex; gap: 0.75rem; margin-bottom: 1.5rem; }
.social-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--secondary); display: flex; align-items: center; justify-content: center; transition: background .15s; }
.social-btn:hover { background: color-mix(in srgb, var(--secondary) 80%, transparent); }
.social-btn svg { width: 20px; height: 20px; color: var(--muted-fg); }
.lang-label { font-size: 0.7rem; color: var(--muted-fg); display: block; margin-bottom: 0.5rem; }
.lang-select { width: 100%; background: var(--secondary); border: 1px solid var(--border); border-radius: 0.5rem; padding: 0.5rem 0.75rem; font-size: 0.875rem; color: var(--white); margin-bottom: 1rem; }
.support-title { font-size: 0.875rem; font-weight: 700; margin-bottom: 0.5rem; }
.support-email { font-size: 0.875rem; color: var(--muted-fg); transition: color .15s; }
.support-email:hover { color: var(--white); }
.footer-copy { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid color-mix(in srgb, var(--border) 40%, transparent); font-size: 0.7rem; color: var(--muted-fg); }

/* ════════════════════════════════════════════════════════
   MODAL
════════════════════════════════════════════════════════ */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.65); backdrop-filter: blur(4px); align-items: center; justify-content: center; padding: 1rem; }
.modal-overlay.active { display: flex; }
.modal { position: relative; background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: 1rem; padding: 2rem 2rem 1.75rem; width: 100%; max-width: 420px; max-height: 90vh; overflow-y: auto; display: flex; flex-direction: column; gap: 0.85rem; animation: modal-in .2s ease; }
@keyframes modal-in { from { opacity:0; transform: translateY(-16px) scale(.97); } to { opacity:1; transform: none; } }
.modal-close { position: absolute; top: 1rem; right: 1rem; background: none; border: none; color: var(--muted-fg); font-size: 1.5rem; line-height: 1; padding: 0.25rem 0.5rem; border-radius: 0.375rem; transition: color .15s, background .15s; }
.modal-close:hover { color: var(--white); background: color-mix(in srgb, var(--secondary) 60%, transparent); }
.modal-title { font-size: 1.5rem; font-weight: 700; text-align: center; }
.modal-subtitle { font-size: 0.875rem; color: var(--muted-fg); text-align: center; margin-top: -0.4rem; }
.btn-roblox { display: flex; align-items: center; justify-content: center; gap: 0.75rem; width: 100%; padding: 0.65rem 1rem; background: var(--secondary); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius); color: var(--white); font-size: 0.9rem; font-weight: 700; transition: background .15s; }
.btn-roblox:hover { background: var(--muted); }
.btn-roblox:disabled,
.btn-modal-submit:disabled { cursor: not-allowed; opacity: 0.48; transform: none; }
.btn-roblox:disabled:hover { background: var(--secondary); }
.btn-modal-submit:disabled:hover { background: var(--accent); }
.modal-check { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.8rem; color: var(--muted-fg); cursor: pointer; line-height: 1.4; }
.modal-check input[type=checkbox] { margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); width: 15px; height: 15px; }
.modal-divider { display: flex; align-items: center; gap: 0.75rem; color: var(--muted-fg); font-size: 0.8rem; margin: 0.1rem 0; }
.modal-divider::before, .modal-divider::after { content: ''; flex: 1; height: 1px; background: color-mix(in srgb, var(--border) 60%, transparent); }
.modal-label { font-size: 0.875rem; font-weight: 700; margin-bottom: -0.4rem; }
.modal-input { width: 100%; background: color-mix(in srgb, var(--secondary) 70%, transparent); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: var(--radius); padding: 0.65rem 0.9rem; font-size: 0.9rem; color: var(--white); outline: none; transition: border-color .15s, box-shadow .15s; }
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
.modal-pw-wrap { position: relative; }
.modal-pw-wrap .modal-input { padding-right: 2.75rem; }
.pw-toggle { position: absolute; right: 0.65rem; top: 50%; transform: translateY(-50%); background: none; border: none; color: var(--muted-fg); display: flex; align-items: center; transition: color .15s; }
.pw-toggle:hover { color: var(--white); }
.modal-row { display: flex; align-items: center; justify-content: space-between; }
.modal-check-inline { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--muted-fg); cursor: pointer; }
.modal-check-inline input[type=checkbox] { accent-color: var(--accent); width: 15px; height: 15px; }
.modal-link { font-size: 0.85rem; color: var(--accent); transition: color .15s; }
.modal-link:hover { color: color-mix(in srgb, var(--accent) 80%, white); }
.btn-modal-submit { width: 100%; padding: 0.7rem 1rem; background: var(--accent); border: none; border-radius: var(--radius); color: #fff; font-size: 1rem; font-weight: 700; margin-top: 0.25rem; transition: background .15s, transform .1s; }
.btn-modal-submit:hover { background: color-mix(in srgb, var(--accent) 85%, white); }
.btn-modal-submit:active { transform: scale(.98); }
.modal-switch { text-align: center; font-size: 0.875rem; color: var(--muted-fg); }

/* ════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .sidebar, .packs-sidebar, .battles-sidebar { display: none; }
  .main-inner,
  .packs-page,
  .battles-page { flex-direction: column; }
  .chat-sidebar { width: 100%; }
  .chat-panel {
    position: static;
    height: auto;
    min-height: 360px;
    max-height: 460px;
  }
  .header-inner {
    position: relative;
    height: auto;
    min-height: 60px;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
  }
  .header-inner > div:first-child {
    width: 100%;
    min-width: 0;
    padding-right: 12rem;
    flex-wrap: wrap;
    gap: 0.75rem !important;
  }
  nav {
    display: flex;
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  nav button { flex: 0 0 auto; }
  .header-right {
    position: absolute;
    top: 0.75rem;
    right: 1rem;
    gap: 0.5rem;
  }
}
@media (max-width: 768px) {
  .challenges-grid { grid-template-columns: 1fr; }
  .draw-preview-row { grid-template-columns: 1fr 1fr; }
  .random-hero { grid-template-columns: 1fr; }
  .how-grid { grid-template-columns: 1fr; }
  .faq-grid { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .packs-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@media (max-width: 480px) {
  .draw-preview-row { grid-template-columns: 1fr; }
  .random-copy { min-height: 0; padding: 1.25rem; }
  .random-copy h1 { font-size: 2rem; }
  .footer-grid { grid-template-columns: 1fr; }
  .header-inner { padding: 0.65rem 0.75rem; }
  .header-inner > div:first-child { padding-right: 6.5rem; }
  .logo span { font-size: 1rem; }
  .header-right { right: 0.75rem; }
  .header-right .divider { display: none; }
  .btn { padding: 0.45rem 0.65rem; font-size: 0.78rem; }
  nav button { padding: 0.45rem 0.6rem; font-size: 0.8rem; }
}

/*
   BATTLES PAGE  - redesigned (blue-led, compact)
 */
.battles-page { display: flex; gap: 1.25rem; padding: 1.25rem 1rem; max-width: 1280px; margin: 0 auto; }
.battles-main { flex: 1; min-width: 0; }

/* Header */
.battles-header { margin-bottom: 0.9rem; position: relative; padding-left: 0.8rem; }
.battles-header::before {
  content: ""; position: absolute; left: 0; top: 0.15rem; bottom: 0.15rem; width: 4px; border-radius: 4px;
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 30%, transparent));
}
.battles-title { font-size: 1.35rem; font-weight: 900; letter-spacing: -0.02em; line-height: 1.1; }
.battles-subtitle { font-size: 0.8rem; color: var(--muted-fg); opacity: .65; margin-top: 0.15rem; }

/* Toolbar */
.battles-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.7rem; margin-bottom: 1rem; flex-wrap: wrap; }
.battles-toolbar-left { display: flex; align-items: center; gap: 0.5rem; }
.battles-sort-wrap { position: relative; }
.battles-sort {
  appearance: none; background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius); padding: 0.48rem 1.9rem 0.48rem 0.8rem;
  font-size: 0.78rem; font-weight: 700; color: var(--white); outline: none; cursor: pointer; transition: border-color .15s;
}
.battles-sort:hover, .battles-sort:focus { border-color: color-mix(in srgb, var(--accent) 70%, transparent); }
.sort-caret { position: absolute; right: 0.55rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted-fg); }
.btn-create-battle {
  display: flex; align-items: center; gap: 0.4rem;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, white) 0%, var(--accent) 100%);
  border: none; border-radius: var(--radius); padding: 0.54rem 1.05rem;
  font-size: 0.82rem; font-weight: 800; color: #fff; white-space: nowrap; cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn-create-battle:hover { filter: brightness(1.07); }
.btn-create-battle:active { transform: scale(.97); }

/* Cards */
.battles-list { display: flex; flex-direction: column; gap: 0.7rem; }
.battle-card-full {
  position: relative; border-radius: var(--radius);
  background: linear-gradient(180deg, color-mix(in srgb, var(--card) 96%, white) 0%, var(--card) 100%);
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  padding: 0.9rem 1.1rem 0.9rem 1.25rem;
  display: grid; grid-template-columns: 184px 1fr auto auto; align-items: center; gap: 1rem;
  overflow: hidden; cursor: pointer;
  transition: border-color .2s, box-shadow .2s, transform .15s;
}
.battle-card-full::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.battle-card-full:hover {
  box-shadow: 0 8px 24px rgba(0,0,0,.4); transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.battle-card-full.jackpot::before    { background: var(--primary); }
.battle-card-full.share-mode::before { background: #818cf8; }
.battle-card-full.normal::before     { background: var(--accent); }

/* Left: mode + players */
.bcf-left { display: flex; flex-direction: column; gap: 0.5rem; }
.bcf-mode { display: flex; align-items: center; gap: 0.45rem; font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted-fg); }
.bcf-mode-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.22rem 0.55rem; border-radius: 999px; font-size: 0.6rem; font-weight: 900; letter-spacing: .06em; border: 1px solid transparent; }
.badge-jackpot { background: rgba(245,158,11,.14); color: #fbbf24; border-color: rgba(245,158,11,.28); }
.badge-share   { background: rgba(99,102,241,.16); color: #a5b4fc; border-color: rgba(99,102,241,.28); }
.badge-normal  { background: color-mix(in srgb, var(--accent) 16%, transparent); color: hsl(40,90%,66%); border-color: color-mix(in srgb, var(--accent) 32%, transparent); }
.bcf-players { display: flex; align-items: center; gap: 0; padding-top: 1px; }
.bcf-avatar-wrap { position: relative; }
.bcf-avatar-wrap:not(:first-child) { margin-left: -7px; }
.bcf-avatar { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--card); background: var(--secondary); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.bcf-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bcf-crown { position: absolute; top: -7px; left: 50%; transform: translateX(-50%); width: 11px; height: 11px; color: var(--primary); z-index: 1; filter: drop-shadow(0 1px 2px rgba(0,0,0,.6)); }
.bcf-empty-slot { width: 28px; height: 28px; border-radius: 50%; border: 2px dashed color-mix(in srgb, var(--accent) 35%, transparent); background: transparent; margin-left: -7px; }
.bcf-cost { font-size: 0.72rem; color: var(--muted-fg); opacity: .85; }
.bcf-cost span { color: var(--white); font-weight: 800; opacity: 1; }

/* Centre: packs strip */
.bcf-packs { display: flex; align-items: center; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.bcf-pack { width: 42px; height: 54px; border-radius: 0.45rem; overflow: hidden; background: var(--secondary); border: 1px solid color-mix(in srgb, var(--border) 45%, transparent); flex-shrink: 0; transition: transform .15s, border-color .15s; }
.bcf-pack img { width: 100%; height: 100%; object-fit: cover; }
.battle-card-full:hover .bcf-pack { border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.bcf-pack-more { display: flex; align-items: center; gap: 0.25rem; padding: 0.28rem 0.5rem; border-radius: 999px; background: var(--secondary); border: 1px solid color-mix(in srgb, var(--border) 45%, transparent); font-size: 0.66rem; font-weight: 800; color: var(--muted-fg); white-space: nowrap; flex-shrink: 0; }

/* Right: unboxed + cta */
.bcf-unboxed { font-size: 0.68rem; color: var(--muted-fg); opacity: .85; text-align: right; white-space: nowrap; }
.bcf-unboxed span { display: block; color: var(--white); font-weight: 900; font-size: 0.92rem; opacity: 1; margin-top: 1px; }
.bcf-action { display: flex; flex-direction: column; align-items: flex-end; gap: 0.4rem; }
.btn-view-battle { background: var(--secondary); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: 0.55rem; padding: 0.48rem 0.95rem; font-size: 0.72rem; font-weight: 800; color: var(--white); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn-view-battle:hover { background: var(--muted); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.btn-join-battle {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, white) 0%, var(--accent) 100%);
  border: none; border-radius: 0.55rem; padding: 0.48rem 1.05rem; font-size: 0.72rem; font-weight: 900; color: #fff; cursor: pointer; white-space: nowrap;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 32%, transparent);
  transition: filter .15s, transform .1s;
}
.btn-join-battle:hover { filter: brightness(1.08); }
.btn-join-battle:active { transform: scale(.97); }

/* Empty state */
.battles-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3rem; padding: 3.2rem 1rem; text-align: center; background: var(--card); border: 1px dashed color-mix(in srgb, var(--border) 80%, transparent); border-radius: var(--radius); }
.battles-empty-icon { width: 58px; height: 58px; border-radius: 50%; display: flex; align-items: center; justify-content: center; margin-bottom: 0.4rem; background: color-mix(in srgb, var(--accent) 12%, transparent); color: hsl(40,90%,62%); }
.battles-empty-title { font-size: 1rem; font-weight: 900; }
.battles-empty-sub { font-size: 0.78rem; color: var(--muted-fg); opacity: .7; }

/* Sidebar section */
.battles-sidebar-section { margin-bottom: 1.5rem; }

/* Waiting dot */
@keyframes waiting-pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.battle-card-full.waiting { animation: none; }
.bcf-waiting-dot { width: 7px; height: 7px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 8px #22c55e; animation: waiting-pulse 1.5s ease-in-out infinite; }

/*  User avatars (letter + gradient) - used on Home highlights & Battles  */
.usr-av { width: 100%; height: 100%; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.6rem; font-weight: 800; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); user-select: none; }
.uav-1  { background: linear-gradient(135deg,#8b5cf6,#6d28d9); }
.uav-2  { background: linear-gradient(135deg,#3b82f6,#1d4ed8); }
.uav-3  { background: linear-gradient(135deg,#10b981,#047857); }
.uav-4  { background: linear-gradient(135deg,#f43f5e,#be123c); }
.uav-5  { background: linear-gradient(135deg,#f59e0b,#b45309); }
.uav-6  { background: linear-gradient(135deg,#06b6d4,#0e7490); }
.uav-7  { background: linear-gradient(135deg,#d946ef,#a21caf); }
.uav-8  { background: linear-gradient(135deg,#84cc16,#4d7c0f); }
.uav-9  { background: linear-gradient(135deg,#f97316,#c2410c); }
.uav-10 { background: linear-gradient(135deg,#6366f1,#4338ca); }
.uav-11 { background: linear-gradient(135deg,#14b8a6,#0f766e); }
.uav-12 { background: linear-gradient(135deg,#ef4444,#b91c1c); }
.avatar .usr-av { font-size: 0.7rem; }

@media (max-width: 1024px) { .battles-sidebar { display: none; } }
@media (max-width: 768px) {
  .battle-card-full { grid-template-columns: 1fr auto; gap: 0.7rem; }
  .bcf-packs { display: none; }
}
/* ════════════════════════════════════════════════════════
   DEALS PAGE
════════════════════════════════════════════════════════ */
.deals-page {
  display: flex;
  flex-direction: column;
  gap: 3.2rem;
  max-width: 1280px;
  margin: 0 auto;
  padding: 3.5rem 1rem 0.5rem;
}
.deals-main { min-width: 0; }
.deals-sidebar { display: none; }

/* ── Sidebar Wheel Preview ── */
.wheel-preview-card {
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: var(--radius);
  padding: 1rem;
}
.wheel-preview-title { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-fg); margin-bottom: 0.75rem; }
.wheel-track {
  position: relative;
  height: 80px;
  overflow: hidden;
  border-radius: 0.5rem;
  background: var(--secondary);
  display: flex; align-items: center;
  margin-bottom: 0.75rem;
}
.wheel-track::before, .wheel-track::after {
  content: ''; position: absolute; top: 0; bottom: 0; width: 40px; z-index: 2; pointer-events: none;
}
.wheel-track::before { left: 0; background: linear-gradient(to right, var(--card), transparent); }
.wheel-track::after  { right: 0; background: linear-gradient(to left, var(--card), transparent); }
.wheel-indicator {
  position: absolute; left: 50%; top: 0; bottom: 0;
  width: 2px; background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  transform: translateX(-50%); z-index: 3;
}
.wheel-items-row {
  display: flex; gap: 6px; padding: 0 8px;
  animation: wheel-slide 8s linear infinite;
}
@keyframes wheel-slide {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}
.wheel-item {
  flex-shrink: 0; width: 64px; height: 64px;
  border-radius: 0.4rem; overflow: hidden;
  background: var(--bg);
  border: 1px solid color-mix(in srgb, var(--border) 40%, transparent);
  display: flex; align-items: center; justify-content: center;
}
.wheel-item img { width: 100%; height: 100%; object-fit: cover; }
.wheel-item.rarity-gold   { border-color: rgba(245,176,39,.5); box-shadow: 0 0 6px rgba(245,176,39,.2); }
.wheel-item.rarity-blue   { border-color: rgba(59,130,246,.5); box-shadow: 0 0 6px rgba(59,130,246,.2); }
.wheel-item.rarity-purple { border-color: rgba(168,85,247,.5); box-shadow: 0 0 6px rgba(168,85,247,.2); }

.wheel-btn-row { display: flex; gap: 0.5rem; }
.btn-demo-spin {
  flex: 1; background: none; border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 0.5rem; padding: 0.5rem; font-size: 0.75rem; font-weight: 700; color: var(--muted-fg);
  transition: color .15s, border-color .15s; cursor: pointer;
}
.btn-demo-spin:hover { color: var(--white); border-color: var(--muted-fg); }
.btn-select-product {
  flex: 1; background: var(--accent); border: none; border-radius: 0.5rem;
  padding: 0.5rem; font-size: 0.75rem; font-weight: 700; color: #fff;
  transition: background .15s; cursor: pointer;
}
.btn-select-product:hover { background: color-mix(in srgb, var(--accent) 85%, white); }

/* ── Sidebar Filters ── */
.deals-filter-card {
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex; flex-direction: column; gap: 1rem;
}
.deals-filter-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted-fg); margin-bottom: 0.25rem; display: block; }

/* Price range */
.price-inputs { display: flex; align-items: center; gap: 0.4rem; }
.price-input-wrap { position: relative; flex: 1; }
.price-input-wrap span { position: absolute; left: 0.55rem; top: 50%; transform: translateY(-50%); font-size: 0.75rem; color: var(--muted-fg); pointer-events: none; }
.price-input {
  width: 100%; background: var(--secondary); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 0.4rem; padding: 0.4rem 0.4rem 0.4rem 1.4rem;
  font-size: 0.8rem; color: var(--white); outline: none; transition: border-color .15s;
}
.price-input:focus { border-color: var(--accent); }
.price-dash { color: var(--muted-fg); font-size: 0.75rem; }

/* Outcome slider */
.outcome-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.35rem; }
.outcome-value { font-size: 0.8rem; font-weight: 700; color: var(--primary); }
.range-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 2px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) 0%, var(--secondary) 0%);
  outline: none; cursor: pointer;
}
.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
  cursor: pointer; transition: box-shadow .15s;
}
.range-slider::-webkit-slider-thumb:hover { box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 25%, transparent); }
.range-ticks { display: flex; justify-content: space-between; font-size: 0.65rem; color: var(--muted-fg); margin-top: 0.2rem; }

/* Multiplier range */
.mult-inputs { display: flex; align-items: center; gap: 0.4rem; }
.mult-input {
  width: 100%; background: var(--secondary); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 0.4rem; padding: 0.4rem 0.5rem;
  font-size: 0.8rem; color: var(--white); outline: none; transition: border-color .15s;
}
.mult-input:focus { border-color: var(--accent); }
.mult-label { font-size: 0.7rem; color: var(--muted-fg); white-space: nowrap; }

.btn-deals-reset {
  width: 100%; background: none; border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: 0.5rem; padding: 0.5rem; font-size: 0.8rem; font-weight: 700; color: var(--muted-fg);
  transition: color .15s, border-color .15s; cursor: pointer;
}
.btn-deals-reset:hover { color: var(--white); border-color: var(--muted-fg); }

/* ── Main toolbar ── */
.deals-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.deals-toolbar-left { display: flex; align-items: center; gap: 0.5rem; }
.deals-count { font-size: 0.8rem; color: var(--muted-fg); white-space: nowrap; }
.deals-count span { color: var(--white); font-weight: 700; }
.deals-sort-wrap { position: relative; }
.deals-sort {
  appearance: none; background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius); padding: 0.5rem 2rem 0.5rem 0.85rem;
  font-size: 0.8rem; color: var(--white); outline: none; cursor: pointer; transition: border-color .15s;
}
.deals-sort:hover, .deals-sort:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.deals-sort-caret { position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%); pointer-events: none; color: var(--muted-fg); }
.deals-pagination { display: flex; align-items: center; gap: 0.4rem; }
.pg-btn {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 0.4rem;
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  color: var(--muted-fg); font-size: 0.75rem; cursor: pointer; transition: color .15s, background .15s;
}
.pg-btn:hover { color: var(--white); background: var(--secondary); }
.pg-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Deals grid ── */
.deals-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));   /* 7 ช่องต่อแถว */
  gap: 0.6rem;
}
.deal-grid-card{
  position: relative;
  cursor: pointer;
  overflow: hidden;

  border-radius: 10px;
  background: transparent;
  border: 0;

  padding: 8px;
  min-height: 0;

  transition: .2s ease;
}
.deal-grid-card:hover { transform: translateY(-4px); }
.deal-grid-img {
  position: relative; aspect-ratio: 1;
  background: var(--secondary);
  display: flex; align-items: center; justify-content: center;
  padding: 0.75rem;
}
.deal-grid-img img { width: 100%; height: 100%; object-fit: contain; transition: transform .3s; }
.deal-grid-card:hover .deal-grid-img img { transform: scale(1.06); }

.deal-badge-mult {
  position: absolute; top: 0.5rem; left: 0.5rem;
  padding: 0.18rem 0.45rem; border-radius: 0.3rem;
  background: rgba(34,197,94,.15); color: #4ade80;
  font-size: 0.65rem; font-weight: 700;
}
.deal-badge-coin {
  position: absolute; top: 0.5rem; right: 0.5rem;
  width: 20px; height: 20px; border-radius: 50%;
  background: #eab308; display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: #713f12;
}
.deal-grid-eye { display: none; }   /* ซ่อนปุ่มตา — เลือก item ได้โดยคลิกการ์ดทั้งใบอยู่แล้ว */
.deal-grid-info { padding: 0.4rem 0.3rem 0.2rem; text-align: center; }
.deal-grid-name {
  font-size: 0.62rem; color: var(--muted-fg);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  line-height: 1.3; margin-bottom: 0.2rem;
}
.deal-grid-price { font-size: 0.74rem; font-weight: 700; color: var(--white); }

/* Rarity glow on card */
/* เอา glow สีตอน hover/select ออก */

@media (max-width: 1024px) { .deals-sidebar { display: none; } }
@media (max-width: 640px)  { .deals-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }

/* Redesigned Deals page */
.deals-stage {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(420px, 1fr) minmax(280px, 340px);
  align-items: stretch;
  gap: 1.5rem;
}
.deals-panel {
  background: color-mix(in srgb, var(--card) 82%, var(--bg));
  border: 1px solid color-mix(in srgb, var(--border) 28%, transparent);
  border-radius: 8px;
  min-height: 448px;
}
.deals-control-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.75rem 1.5rem 1.5rem;
}
.deals-control-stack { display: flex; flex-direction: column; gap: 1.4rem; }
.deals-filter-label {
  display: block;
  margin-bottom: 0.4rem;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: .01em;
}
.deals-money-input,
.deals-range-input,
.deals-search,
.deals-filter-sort,
.deals-filter-box {
  height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--bg);
  color: #fff;
}
.deals-money-input { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; }
.deals-money-prefix {
  display: grid;
  place-items: center;
  height: 40px;
  border-radius: 6px 0 0 6px;
  background: #242424;
  font-weight: 900;
}
.deals-money-input input,
.deals-range-input input,
.deals-filter-box input,
.deals-search input {
  width: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 800;
}
.deals-money-input input { padding: 0 0.75rem; color: #8f979d; }
.deals-mini-btn {
  margin-right: 0.5rem;
  border: 0;
  border-radius: 6px;
  background: var(--muted);
  color: #9ca5ac;
  padding: 0.25rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 900;
}
.range-slider {
  height: 40px;
  border-radius: 6px;
  /* fill ตาม --fill% (ตั้งจาก JS) — โทนเว็บ (var(--accent)) */
  --fill: 0%;
  background:
    linear-gradient(90deg, var(--accent) 0%, var(--accent) 100%) no-repeat,
    var(--bg);
  background-size: var(--fill) 100%, 100% 100%;
  transition: background-size .08s linear;   /* ลื่นตอนเลื่อน */
}
.range-slider::-webkit-slider-thumb {
  width: 16px;
  height: 32px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.range-slider::-moz-range-thumb {
  width: 16px;
  height: 32px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 4px rgba(0,0,0,.45);
}
.outcome-value { color: #fff; font-size: 0.88rem; font-weight: 900; }
.range-ticks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.4rem; margin-top: 0.7rem; }
.range-ticks button {
  border: 0;
  border-radius: 6px;
  background: #242424;
  color: #8f979d;
  padding: 0.55rem 0.35rem;
  font-size: 0.78rem;
  font-weight: 900;
}
.btn-deals-reset {
  height: 44px;
  border: 0;
  border-radius: 6px;
  background: #242424;
  color: #8f979d;
  font-size: 0.9rem;
  font-weight: 900;
}
.deals-wheel-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 1.5rem 1.5rem;
}
.wheel-brand {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: .01em;
}
.wheel-brand svg { transform: rotate(-18deg); }
.wheel-ring {
  position: relative;
  display: grid;
  place-items: center;
  width: min(58vw, 272px);
  max-width: 100%;
  aspect-ratio: 1;
  border: none;                 /* ใช้ ::arc วาดวงแหวนแทนเส้นขอบ */
  border-radius: 50%;
  color: #fff;
  font-size: 1.6rem;
  font-weight: 900;
  overflow: visible;
}
.wheel-actions {
  display: grid;
  grid-template-columns: 1fr 150px;
  gap: 0.6rem;
  width: 100%;
}
.btn-select-product,
.btn-demo-spin {
  height: 44px;
  border: 0;
  border-radius: 6px;
  font-weight: 900;
}
.btn-select-product { background: var(--accent); color: #fff; }
.btn-demo-spin {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: #242424;
  color: #8f979d;
}
.deals-summary-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem 1.5rem 1.5rem;
  overflow: hidden;
}
.summary-card-mark {
  position: absolute;
  top: 7.6rem;
  left: 50%;
  width: 188px;
  height: 188px;
  transform: translateX(-50%) rotate(-23deg);
  border-radius: 16px;
  background: var(--card);
  opacity: 0.72;
}
.summary-card-mark::before,
.summary-card-mark::after {
  content: "";
  position: absolute;
  border-radius: 14px;
  background: #121212;
}
.summary-card-mark::before { width: 54px; height: 138px; right: -28px; top: 8px; transform: rotate(23deg); }
.summary-card-mark::after { width: 52px; height: 126px; right: -58px; top: 18px; transform: rotate(45deg); }
/* รูป item ที่เลือก แสดงบนการ์ด (หมุนกลับให้ตั้งตรง) */
.summary-card-img {
  position: absolute; inset: 3%;
  width: 94%; height: 94%;
  object-fit: contain;
  transform: rotate(23deg);
  z-index: 2;
  opacity: 0;
  transition: opacity .2s ease;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.5));
}
.summary-card-mark.has-item { opacity: 1; background: color-mix(in srgb, var(--card) 80%, var(--secondary)); }
.summary-card-mark.has-item .summary-card-img { opacity: 1; }
.summary-copy { position: relative; z-index: 1; }
.summary-copy p:first-child { color: var(--muted-fg); font-size: 0.72rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 0.55rem; }
.summary-values { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; }
.summary-values strong { color: #fff; font-size: 1.25rem; font-weight: 900; }
.summary-values span { color: var(--muted-fg); font-size: 0.95rem; font-weight: 900; }
.deals-filter-bar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr) minmax(300px, 1fr) minmax(300px, 1fr);
  gap: 0.5rem;
  margin-bottom: 2.5rem;
}
.deals-search,
.deals-filter-sort,
.deals-filter-box {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0 0.75rem;
  font-size: 0.95rem;
}
.deals-search svg,
.deals-filter-sort svg { color: #fff; flex: 0 0 auto; }
.deals-search input::placeholder { color: #8f979d; opacity: 1; }
.deals-filter-sort { justify-content: space-between; font-weight: 800; }
.deals-filter-box { display: grid; grid-template-columns: 44px 1fr auto auto; padding: 0; overflow: hidden; }
.deals-filter-tag {
  display: grid;
  place-items: center;
  height: 40px;
  background: #242424;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
}
.deals-filter-box input { padding: 0 0.75rem; }
.deals-filter-box .deals-mini-btn { margin: 0; }
.deals-filter-box .deals-mini-btn:last-child { margin-right: 0.5rem; }
.deals-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.4rem;
}
.deals-toolbar { display: none !important; }
.deals-grid + div[style] { display: none !important; }
.deals-count { color: #fff; font-size: 0.82rem; font-weight: 900; }
.deals-pagination { display: flex; align-items: center; gap: 0.5rem; }
.pg-btn {
  min-width: 62px;
  width: auto;
  height: 28px;
  border: 0;
  border-radius: 6px;
  padding: 0 0.85rem;
  background: #242424;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 900;
}
.pg-btn:disabled { color: #808991; cursor: not-allowed; opacity: 1; }
.deals-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));   /* 7 ช่องต่อแถว */
  gap: 0.6rem;
}
.deal-grid-card:hover{
  transform: translateY(-2px);
}
.deal-grid-img {
  aspect-ratio: 1.25;
  background: transparent;
  padding: 2.2rem 1.4rem 0.75rem;
}
.deal-badge-mult { display: none; }
.deal-badge-coin {
  top: 0.55rem;
  right: 0.55rem;
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  border-radius: 7px;
  background: #242424;
  color: #8f979d;
  font-size: 0;
}
.deal-badge-coin svg { width: 16px; height: 16px; }
.deal-badge-coin::before,
.deal-badge-coin::after {
  content: "";
  position: absolute;
}
.deal-badge-coin::before {
  width: 16px;
  height: 10px;
  border: 2px solid #8f979d;
  border-radius: 50%;
}
.deal-badge-coin::after {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #8f979d;
}
.deal-grid-info { padding: 0 1rem 1.05rem; text-align: center; }
.deal-grid-name {
  font-size: 0.92rem;
  color: #8f979d;
  line-height: 1.25;
  margin-bottom: 0.35rem;
}
.deal-grid-price { color: #fff; font-size: 0.95rem; font-weight: 900; }
@media (max-width: 1100px) {
  .deals-stage { grid-template-columns: 1fr; }
  .deals-panel { min-height: auto; }
  .deals-control-panel,
  .deals-wheel-panel,
  .deals-summary-panel { min-height: 320px; }
  .deals-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deals-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .deals-page { padding-top: 1.5rem; gap: 1.5rem; }
  .deals-filter-bar,
  .deals-grid { grid-template-columns: 1fr; }
  .deals-list-head { align-items: flex-start; flex-direction: column; gap: 1rem; }
  .wheel-actions { grid-template-columns: 1fr; }
}

/* UI balance pass */
body { font-size: 15px; }
.container { max-width: 1200px; padding-inline: 1.25rem; }
.site-header { min-height: 60px; }
.header-inner { height: 60px; gap: 1rem; padding-inline: 1.25rem; }
.logo span,
.footer-logo span { font-size: 1.12rem; }
nav a,
nav button,
.btn,
.btn-create,
.btn-create-battle,
.btn-reset,
.search-input { font-size: 0.82rem; }
nav a,
nav button { padding: 0.46rem 0.65rem; }
.btn,
.btn-create,
.btn-create-battle,
.btn-reset { padding: 0.52rem 0.95rem; }
main { padding: 1.25rem 1rem; }
.main-inner,
.packs-page,
.battles-page { gap: 1.25rem; }
.content { gap: 1.55rem; }
.section-header { margin-bottom: 0.8rem; }
.section-title { font-size: 1rem; }
.section-title img,
.sidebar-section-title img { width: 18px; height: 18px; }
.card,
.accordion-item,
.pack-cover,
.pack-thumb,
.deal-thumb,
.item-card,
.deal-grid-card,
.deals-panel { border-radius: 8px; }
.challenges-grid,
.faq-grid,
.scroll-row,
.packs-grid,
.deals-grid { gap: 0.85rem; }
.challenge-card { min-height: 84px; padding: 0.85rem; gap: 0.75rem; }
.challenge-icon { width: 42px; height: 42px; }
.challenge-icon img { width: 28px; height: 28px; }
.challenge-bg { height: 82px; }
.pack-card { width: 132px; }
.deal-card { width: 144px; }
.deal-thumb,
.item-card { padding: 0.65rem; }
.pack-price,
.deal-price,
.item-price,
.pack-grid-price { font-size: 0.82rem; }
.deal-name,
.item-name,
.pack-name { font-size: 0.7rem; }
.battle-row,
.battle-card-full { padding: 0.85rem 1rem; }
.pack-mini { width: 42px; height: 56px; }
.bcf-pack { width: 40px; height: 52px; }
.avatar,
.bcf-avatar,
.bcf-empty-slot { width: 28px; height: 28px; }
.how-grid { gap: 1rem; }
.how-card { padding: 1.15rem; }
.how-img { width: 112px; height: 82px; margin-bottom: 0.75rem; }
.how-title { font-size: 1rem; }
.accordion-trigger { padding: 0.85rem; font-size: 0.82rem; }
.accordion-content { font-size: 0.82rem; padding-inline: 0.85rem; }
.sidebar,
.packs-sidebar,
.battles-sidebar,
.chat-sidebar { width: 260px; }
.chat-panel {
  top: 80px;
  width: 350px;          /* ความกว้าง */
  max-width: 60vw;       /* ป้องกันล้นจอ */
  height: min(900px, calc(100vh - 100px));
  min-height: 350px;
}
.chat-head { padding: 0.75rem 0.85rem; }
.chat-messages { gap: 0.6rem; padding: 0.75rem; }
.chat-bubble { padding: 0.48rem 0.6rem; font-size: 0.74rem; }
.chat-avatar { width: 26px; height: 26px; }
.chat-input,
.chat-send { height: 42px; }
.packs-grid { grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
.packs-toolbar,
.filters-row,
.battles-toolbar,
.deals-toolbar { margin-bottom: 1rem; }
.filter-select,
.battles-sort,
.deals-sort { font-size: 0.76rem; padding-block: 0.46rem; }
.battles-list { gap: 0.65rem; }
.battle-card-full { grid-template-columns: 178px 1fr auto auto; gap: 1rem; }
.deals-page { gap: 2rem; max-width: 1200px; padding-top: 2.25rem; }
.deals-stage {
  grid-template-columns: minmax(248px, 300px) minmax(340px, 1fr) minmax(248px, 300px);
  gap: 1rem;
}
.deals-panel { min-height: 392px; }
.deals-control-panel { padding: 1.5rem 1.35rem 1.25rem; gap: 1.25rem; }
.deals-control-stack { gap: 1.35rem; }
.deals-filter-label { font-size: 0.72rem; margin-bottom: 0.35rem; }
.deals-money-input,
.deals-range-input,
.deals-search,
.deals-filter-sort,
.deals-filter-box,
.range-slider { height: 36px; }
.deals-money-input { grid-template-columns: 36px 1fr auto; }
.deals-money-prefix,
.deals-filter-tag { height: 36px; }
.btn-deals-reset,
.btn-select-product,
.btn-demo-spin { height: 40px; }
.deals-wheel-panel { padding: 1rem 1.35rem 1.15rem; }
.wheel-ring { width: min(44vw, 220px); border-width: 12px; font-size: 1.05rem; }
.wheel-actions { grid-template-columns: 1fr 128px; }
.deals-summary-panel { padding: 1.4rem 1.25rem; }
.summary-card-mark { top: 7.25rem; width: 124px; height: 124px; }
.summary-card-mark::before { width: 44px; height: 112px; right: -22px; }
.summary-card-mark::after { width: 42px; height: 104px; right: -48px; }
.deals-filter-bar {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  margin-bottom: 1.6rem;
}
.deals-search,
.deals-filter-sort,
.deals-filter-box { font-size: 0.82rem; }
.deals-list-head { margin-bottom: 1.4rem; }
.deals-grid {
  grid-template-columns: repeat(7, minmax(0, 1fr));   /* 7 ช่องต่อแถว */
  gap: 0.6rem;
}
.deal-grid-img { padding: 0.8rem 0.6rem 0.4rem; }
.deal-grid-info { padding: 0 0.4rem 0.5rem; text-align: center; }
.deal-grid-name { font-size: 0.62rem; line-height: 1.3; }
.deal-grid-price { font-size: 0.72rem; }

/* ════════ DAILY REWARD PAGE ════════ */
.rewards-wrap { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1rem; }
.rewards-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.rewards-title { font-size: 1.6rem; font-weight: 900; color: var(--white); margin: 0; }
.rewards-sub { color: var(--muted-fg); font-size: 0.85rem; margin: 0.25rem 0 0; }
.rewards-claim-box { display: flex; align-items: center; gap: 1rem; background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 50%, transparent); border-radius: 12px; padding: 0.8rem 1rem; }
.rewards-claim-info { display: flex; flex-direction: column; gap: 0.15rem; }
.rewards-claim-tier { font-weight: 900; color: var(--primary); font-size: 0.9rem; }
.rewards-claim-level { font-size: 0.75rem; color: var(--muted-fg); }
.rewards-claim-btn { background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 0.7rem 1.4rem; font-weight: 900; font-size: 0.9rem; cursor: pointer; min-width: 150px; transition: filter .15s; }
.rewards-claim-btn:hover:not(:disabled) { filter: brightness(1.08); }
.rewards-claim-btn:disabled { opacity: .55; cursor: not-allowed; background: var(--secondary); color: var(--muted-fg); }

.rewards-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 0.85rem; }
.rewards-tier { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0.4rem; padding: 0.9rem 0.6rem; border-radius: 12px; background: transparent; border: 0; text-align: center; }
.rewards-tier.is-locked { opacity: .5; filter: grayscale(.6); }
.rewards-tier.is-current { border: 0; box-shadow: none; }
.rewards-tier-level { font-weight: 900; font-size: 0.8rem; color: var(--white); }
.rewards-tier-img { width: 100%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; }
.rewards-tier-img img { width: 70%; height: 70%; object-fit: contain; }
.rewards-tier-noimg { width: 48px; height: 48px; border-radius: 10px; background: var(--secondary); display: flex; align-items: center; justify-content: center; color: var(--muted-fg); font-weight: 900; }
.rewards-tier-pack { font-size: 0.68rem; color: var(--muted-fg); font-weight: 700; min-height: 1.6em; }
.rewards-tier-empty { color: color-mix(in srgb, var(--accent) 70%, var(--muted-fg)); }
.rewards-tier-badge { font-size: 0.6rem; font-weight: 800; color: #fff; background: color-mix(in srgb, var(--primary) 80%, #000); padding: 2px 8px; border-radius: 999px; }
.rewards-tier-lock { font-size: 0.6rem; color: var(--muted-fg); }
.rewards-tier-claim {
  width: 100%; margin-top: 0.1rem;
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 0.5rem 0.4rem; font-weight: 900; font-size: 0.74rem; cursor: pointer;
  font-variant-numeric: tabular-nums; transition: filter .15s;
}
.rewards-tier-claim:hover:not(:disabled) { filter: brightness(1.1); }
.rewards-tier-claim:disabled { background: var(--secondary); color: var(--muted-fg); cursor: not-allowed; }
.rewards-empty { grid-column: 1/-1; text-align: center; color: var(--muted-fg); padding: 3rem 0; }
.rewards-spinner { display: inline-block; width: 34px; height: 34px; border-radius: 50%; border: 3px solid color-mix(in srgb, var(--primary) 25%, transparent); border-top-color: var(--primary); animation: bplay-spin .7s linear infinite; }

.rewards-result-overlay { position: fixed; inset: 0; z-index: 400; background: rgba(0,0,0,.8); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.rewards-result-overlay[hidden] { display: none; }
.rewards-result-card { background: var(--card); border: 1px solid color-mix(in srgb, var(--primary) 40%, transparent); border-radius: 16px; padding: 2rem; text-align: center; max-width: 340px; width: 100%; animation: modal-in .25s ease; }
.rewards-result-card h2 { color: var(--primary); margin: 0 0 1rem; }
.rewards-result-card img { width: 120px; height: 120px; object-fit: contain; margin: 0 auto; }
.rewards-result-name { font-weight: 900; color: var(--white); margin-top: 0.75rem; }
.rewards-result-val { color: var(--primary); font-weight: 900; font-size: 1.1rem; margin-top: 0.25rem; }
.rewards-result-ok { margin-top: 1.25rem; background: var(--accent); color: #fff; border: 0; border-radius: 10px; padding: 0.7rem 1.5rem; font-weight: 900; cursor: pointer; }
@media (max-width: 1024px) { .rewards-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .rewards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.footer-inner { padding-block: 2.25rem; }
.footer-grid { gap: 1.4rem; }
.modal { max-width: 390px; padding: 1.6rem 1.5rem 1.4rem; gap: 0.72rem; }
.modal-title { font-size: 1.3rem; }
.modal-input,
.btn-roblox,
.btn-modal-submit { padding-block: 0.58rem; font-size: 0.84rem; }
.auth-status {
  display: none;
  padding: 0.65rem 0.75rem;
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
  color: var(--muted-fg);
  font-size: 0.8rem;
  line-height: 1.4;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
}
.auth-status.show { display: block; }
.auth-status.error {
  border-color: rgba(239,68,68,.45);
  background: rgba(239,68,68,.12);
  color: #fca5a5;
}
.auth-status.success {
  border-color: rgba(34,197,94,.4);
  background: rgba(34,197,94,.12);
  color: #86efac;
}
.otp-step { display: none; }
.otp-step.active { display: contents; }
.modal-input[name="otp"] {
  text-align: center;
  letter-spacing: 0.35em;
  font-size: 1rem;
}
.account-page { padding-block: 2rem 3rem; }
.account-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.account-title { font-size: 1.35rem; font-weight: 800; }
.account-subtitle { color: var(--muted-fg); font-size: 0.86rem; margin-top: 0.25rem; }
.account-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.account-panel { background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 65%, transparent); border-radius: 8px; padding: 1rem; }
.empty-cart { min-height: 260px; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted-fg); }
.empty-cart h2 { color: var(--white); font-size: 1.05rem; margin-bottom: 0.35rem; }
.summary-row { display: flex; align-items: center; justify-content: space-between; padding: 0.72rem 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 55%, transparent); color: var(--muted-fg); font-size: 0.84rem; }
.summary-row strong { color: var(--white); }
.summary-row.total { border-bottom: 0; font-size: 1rem; color: var(--white); }
.deposit-amounts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; margin-bottom: 1rem; }
.amount-btn,
.method-btn { border: 1px solid color-mix(in srgb, var(--border) 70%, transparent); border-radius: 8px; background: color-mix(in srgb, var(--secondary) 78%, transparent); color: var(--white); padding: 0.75rem; font-weight: 800; transition: border-color .15s, background .15s; }
.amount-btn:hover,
.amount-btn.active,
.method-btn:hover,
.method-btn.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--secondary)); }
.deposit-input { width: 100%; margin-bottom: 1rem; }
.deposit-methods { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
.method-btn { text-align: left; }
.method-btn span { display: block; color: var(--muted-fg); font-size: 0.72rem; margin-top: 0.2rem; }
/* Robux top-up steps */
.deposit-steps { margin: 0 0 1rem; padding-left: 1.2rem; display: grid; gap: 0.45rem; color: var(--muted-fg); font-size: 0.85rem; line-height: 1.4; }
.deposit-steps li { padding-left: 0.2rem; }
.deposit-game-link { text-decoration: none; }
.account-actions { display: grid; gap: 0.65rem; margin-top: 1rem; }
.profile-page { max-width: 1280px; margin: 0 auto; padding-inline: 1rem; padding-block: 3rem 5rem; }
.profile-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 2.5rem; align-items: start; }
.profile-sidebar { display: grid; gap: 1.2rem; color: var(--muted-fg); }
.profile-nav-group { display: grid; gap: 0.45rem; }
.profile-nav-label { width: 100%; border: 0; background: transparent; color: var(--muted-fg); display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0; font-size: 0.78rem; font-weight: 800; text-align: left; }
.profile-nav-label:hover { color: var(--white); }
.profile-nav-chevron { transition: transform .16s ease; }
.profile-nav-group.collapsed .profile-nav-chevron { transform: rotate(-90deg); }
.profile-nav-items { display: grid; gap: 0.45rem; }
.profile-nav-group.collapsed .profile-nav-items { display: none; }
.profile-nav-item { display: flex; align-items: center; min-height: 40px; padding: 0.65rem 1.4rem; border-radius: 6px; color: var(--muted-fg); font-size: 0.9rem; font-weight: 800; }
.profile-nav-item.active { background: var(--muted); color: var(--white); }
.profile-nav-item:not(.active):hover { color: var(--white); background: rgba(255,255,255,.04); }
.profile-content { min-width: 0; }
.profile-topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.profile-title { font-size: 1.45rem; font-weight: 900; }
.profile-wallet { display: flex; align-items: center; gap: 0.45rem; color: var(--white); font-size: 0.88rem; font-weight: 900; }
.profile-copy { width: 26px; height: 26px; border: 0; background: transparent; color: var(--muted-fg); display: inline-flex; align-items: center; justify-content: center; border-radius: 6px; }
.profile-copy:hover { background: rgba(255,255,255,.07); color: var(--white); }
.profile-card-large { background: var(--card); border-radius: 8px; padding: 1.5rem; margin-bottom: 1rem; }
.profile-section-title { font-size: 1.08rem; font-weight: 900; margin-bottom: 1rem; }
.profile-divider { height: 1px; background: rgba(255,255,255,.06); margin-bottom: 1.35rem; }
.profile-form-row { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 1.25rem; align-items: center; padding-bottom: 1.45rem; margin-bottom: 1.45rem; border-bottom: 1px solid rgba(255,255,255,.05); }
.profile-form-row:last-child { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
.profile-label { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--white); font-size: 0.9rem; font-weight: 900; }
.profile-help-icon { width: 15px; height: 15px; border-radius: 50%; border: 1.5px solid var(--muted-fg); color: var(--muted-fg); display: inline-flex; align-items: center; justify-content: center; font-size: 0.62rem; line-height: 1; }
.avatar-settings { display: flex; align-items: center; gap: 1rem; }
.profile-big-avatar { position: relative; width: 64px; height: 64px; border-radius: 50%; background: var(--primary); color: var(--bg); color: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; flex: 0 0 64px; border: 0; }
.profile-big-avatar.has-image .avatar-initial { display: none; }
.profile-big-avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.profile-avatar-camera { position: absolute; left: 0; right: 0; bottom: 0; height: 22px; display: flex; align-items: center; justify-content: center; background: rgba(52,60,64,.75); color: #fff; z-index: 2; }
.profile-muted { color: var(--muted-fg); font-weight: 500; line-height: 1.55; }
.profile-small-btn { display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: var(--muted); color: var(--white); padding: 0.55rem 1.45rem; font-weight: 900; margin-top: 0.55rem; }
.profile-small-btn:hover { background: var(--border); }
.profile-file-input { position: fixed; left: -9999px; top: -9999px; width: 1px; height: 1px; opacity: 0; }
.profile-image-status { min-height: 1.1rem; margin-top: 0.45rem; color: var(--muted-fg); font-size: 0.78rem; font-weight: 700; }
.profile-image-status.error { color: #fca5a5; }
.profile-input-line { display: grid; grid-template-columns: minmax(0, 1fr) 144px; gap: 1rem; align-items: center; }
.profile-input { width: 100%; border: 0; border-radius: 7px; background: var(--card); color: var(--white); padding: 0.72rem 0.85rem; font-weight: 800; outline: none; }
.profile-save { width: 144px; justify-self: end; border: 0; border-radius: 7px; background: var(--muted); color: var(--white); padding: 0.72rem 1rem; font-weight: 900; }
.profile-save:hover { background: var(--border); }
.profile-personal-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.profile-reveal { display: inline-flex; align-items: center; gap: 0.45rem; border: 0; background: transparent; color: var(--white); font-weight: 900; }
.profile-reveal-box { display: flex; align-items: center; gap: 0.6rem; min-height: 56px; margin-top: 2rem; border-radius: 7px; background: var(--secondary); color: var(--white); padding: 0.9rem 1rem; font-size: 0.9rem; }
.history-empty { min-height: 220px; border-radius: 7px; background: var(--secondary); display: flex; align-items: center; justify-content: center; color: var(--muted-fg); text-align: center; font-size: 0.9rem; font-weight: 700; }
.history-empty[hidden] { display: none; }   /* กัน display:flex ทับ hidden */
.history-list { display: flex; flex-direction: column; gap: 0.5rem; }
.history-list[hidden] { display: none; }
.history-pagebar[hidden] { display: none; }
.history-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.7rem 0.95rem; border-radius: 8px; background: var(--secondary); border-left: 3px solid transparent; }
.history-row--won  { background: color-mix(in srgb, var(--secondary) 82%, #22c55e 18%); border-left-color: #22c55e; }
.history-row--lost { background: color-mix(in srgb, var(--secondary) 86%, #ef4444 14%); border-left-color: #ef4444; }
.history-row-thumb { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 8px; background: rgba(0,0,0,.25); display: grid; place-items: center; overflow: hidden; }
.history-row-thumb img { width: 100%; height: 100%; object-fit: contain; }
.history-row-badge { font-size: 0.62rem; font-weight: 900; padding: 1px 6px; border-radius: 999px; vertical-align: middle; margin-left: 0.3rem; }
.history-row-badge.won  { background: #22c55e; color: #04210f; }
.history-row-badge.lost { background: #ef4444; color: #2a0606; }
.history-row-main { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1; }
.history-row-label { font-weight: 800; font-size: 0.9rem; color: var(--white); }
.history-row-detail { font-size: 0.78rem; color: var(--muted-fg); }
.history-row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 0.15rem; flex-shrink: 0; }
.history-row-amount { font-weight: 800; font-size: 0.9rem; color: var(--primary); }
.history-row-time { font-size: 0.74rem; color: var(--muted-fg); }
.history-row--click { cursor: pointer; }
.history-row--click:hover { filter: brightness(1.12); }
/* Deal detail modal (wheel + info) */
.deal-detail-overlay { position: fixed; inset: 0; z-index: 1400; background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center; padding: 1rem; animation: modal-in .2s ease; }
.deal-detail-card { position: relative; width: 380px; max-width: 100%; max-height: 90vh; overflow-y: auto; background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: 16px; padding: 1.4rem 1.3rem; }
.deal-detail-close { position: absolute; top: 0.7rem; right: 0.8rem; background: none; border: 0; color: var(--muted-fg); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.dd-title { text-align: center; font-size: 1.1rem; margin-bottom: 0.6rem; }
.dd-win { color: #22c55e; } .dd-lose { color: #ef4444; }
.dd-wheel-wrap { text-align: center; margin-bottom: 1rem; }
.dd-wheel { width: 170px; height: 190px; }   /* viewBox 120x134 → คงสัดส่วน ไม่ letterbox */
.dd-wheel-pct { fill: var(--white); font-size: 13px; font-weight: 900; }
.dd-wheel-sub { fill: var(--muted-fg); font-size: 7px; font-weight: 700; }
.dd-roll { font-size: 0.82rem; color: var(--muted-fg); margin-top: 0.4rem; }
.dd-roll strong { color: var(--white); }
.dd-rows { display: flex; flex-direction: column; gap: 0.35rem; }
.dd-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-size: 0.84rem; }
.dd-row span { color: var(--muted-fg); }
.dd-row strong { color: var(--white); }
.dd-row code { font-size: 0.72rem; color: var(--muted-fg); word-break: break-all; text-align: right; }
.dd-hash { font-size: 0.62rem !important; }
.dd-fair { margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent); display: flex; flex-direction: column; gap: 0.3rem; }
.dd-fair-title { font-size: 0.68rem; font-weight: 800; color: var(--muted-fg); text-transform: uppercase; letter-spacing: .05em; }
/* History toolbar (search + date filter + per page) */
.history-toolbar { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; justify-content: space-between; margin-bottom: 0.9rem; }
.history-search-wrap { display: flex; gap: 0.4rem; flex: 1 1 260px; min-width: 220px; }
.history-search-input { flex: 1; min-width: 0; height: 38px; padding: 0 0.8rem; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); background: var(--secondary); color: var(--white); font-size: 0.85rem; }
.history-search-input::placeholder { color: var(--muted-fg); }
.history-search-btn { height: 38px; padding: 0 1rem; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 800; font-size: 0.82rem; cursor: pointer; white-space: nowrap; }
.history-filters { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.history-sel { height: 38px; padding: 0 0.5rem; border-radius: 8px; border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); background: var(--secondary); color: var(--white); font-size: 0.82rem; font-weight: 700; }
.history-perpage { display: flex; align-items: center; gap: 0.4rem; font-size: 0.78rem; color: var(--muted-fg); font-weight: 700; white-space: nowrap; }
/* History pagination */
.history-pagebar { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; justify-content: space-between; margin-top: 1rem; }
.history-total { font-size: 0.82rem; color: var(--muted-fg); font-weight: 700; }
.history-pager { display: flex; align-items: center; gap: 0.45rem; }
.history-page-info { font-size: 0.8rem; color: var(--muted-fg); font-weight: 700; display: flex; align-items: center; gap: 0.3rem; }
.history-page-input { width: 52px; height: 32px; text-align: center; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); background: var(--secondary); color: var(--white); font-weight: 800; }
.history-pager .pg-btn:disabled { opacity: .4; cursor: not-allowed; }
.profile-editor-overlay { position: fixed; inset: 0; z-index: 220; display: none; align-items: center; justify-content: center; padding: 1rem; background: rgba(0,0,0,.68); }
.profile-editor-overlay.active { display: flex; }
.profile-editor-modal { width: min(480px, 100%); background: var(--secondary); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; box-shadow: 0 24px 70px rgba(0,0,0,.55); overflow: hidden; }
.profile-editor-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.35rem 1.5rem 1rem; }
.profile-editor-title { font-size: 1.25rem; font-weight: 900; }
.profile-editor-close { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted-fg); display: inline-flex; align-items: center; justify-content: center; }
.profile-editor-close:hover { background: rgba(255,255,255,.07); color: var(--white); }
.profile-editor-body { padding: 0 1.5rem 1.5rem; }
.profile-editor-stage { position: relative; width: min(320px, 100%); aspect-ratio: 1; margin: 0 auto; overflow: hidden; border-radius: 6px; background: var(--card); cursor: grab; touch-action: none; user-select: none; }
.profile-editor-stage.dragging { cursor: grabbing; }
.profile-editor-img { position: absolute; left: 50%; top: 50%; max-width: none; transform-origin: center; will-change: transform; pointer-events: none; }
.profile-editor-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: rgba(0,0,0,.48);
  -webkit-mask: radial-gradient(circle at center, transparent 0 36.5%, #000 36.75% 100%);
  mask: radial-gradient(circle at center, transparent 0 36.5%, #000 36.75% 100%);
}
.profile-editor-ring { position: absolute; left: 50%; top: 50%; width: 74%; aspect-ratio: 1; border: 6px solid rgba(255,255,255,.92); border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.profile-editor-controls { display: grid; grid-template-columns: 28px 1fr 36px 36px; align-items: center; gap: 0.75rem; margin: 1.25rem auto 1rem; width: min(320px, 100%); color: var(--muted-fg); }
.profile-editor-controls input[type="range"] { width: 100%; accent-color: var(--primary); cursor: pointer; }
.profile-editor-icon-btn { width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent; color: var(--muted-fg); display: inline-flex; align-items: center; justify-content: center; }
.profile-editor-icon-btn:hover { background: rgba(255,255,255,.07); color: var(--white); }
.profile-editor-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; padding-top: 0.5rem; }
.profile-editor-actions .btn { min-width: 96px; border-radius: 8px; }
.profile-editor-actions .btn-ghost { background: var(--secondary); }
.profile-editor-actions .btn-ghost:hover { background: var(--muted); }
.profile-editor-actions .btn-accent { background: var(--accent); }

@media (max-width: 1024px) {
  .header-inner {
    height: auto;
    min-height: 60px;
    flex-wrap: wrap;
    padding: 0.7rem 1rem;
  }
  .header-inner > div:first-child {
    width: 100%;
    padding-right: 11rem;
    flex-wrap: wrap;
    gap: 0.65rem !important;
  }
  nav { width: 100%; overflow-x: auto; }
  .header-right {
    position: absolute;
    top: 0.7rem;
    right: 1rem;
  }
  .chat-sidebar { width: 100%; }
  .chat-panel {
    position: static;
    height: auto;
    min-height: 340px;
    max-height: 430px;
  }
  .account-layout { grid-template-columns: 1fr; }
  .profile-shell { grid-template-columns: 1fr; gap: 1.5rem; }
  .profile-sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
  .deals-stage { grid-template-columns: 1fr; }
  .deals-panel { min-height: auto; }
  .deals-control-panel,
  .deals-wheel-panel,
  .deals-summary-panel { min-height: 280px; }
  .deals-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  body { font-size: 14px; }
  .container { padding-inline: 1rem; }
  .header-inner { padding-inline: 1rem; }
  .pack-card,
  .deal-card { width: 124px; }
  .battle-card-full { grid-template-columns: 1fr auto; }
  .bcf-packs { display: none; }
  .deals-filter-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .profile-page { padding-block: 1.5rem 3rem; }
  .profile-sidebar { grid-template-columns: 1fr; gap: 0.9rem; }
  .profile-topbar,
  .profile-personal-head { align-items: flex-start; flex-direction: column; }
  .profile-form-row { grid-template-columns: 1fr; gap: 0.8rem; }
  .profile-input-line { grid-template-columns: 1fr; }
  .profile-save { width: 100%; }
  .profile-editor-head { padding-inline: 1rem; }
  .profile-editor-body { padding-inline: 1rem; }
}

@media (max-width: 640px) {
  .packs-grid,
  .deals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .deals-filter-bar { grid-template-columns: 1fr; }
  .wheel-actions { grid-template-columns: 1fr; }
  .battle-card-full { grid-template-columns: 1fr; }
  .bcf-action { align-items: stretch; }
  .bcf-unboxed { text-align: left; }
  .account-head { align-items: flex-start; flex-direction: column; }
  .deposit-amounts,
  .deposit-methods { grid-template-columns: 1fr; }
  .cookie-banner { grid-template-columns: 1fr; }
  .cookie-actions { justify-content: stretch; }
  .cookie-actions .btn { width: 100%; }
}

@media (max-width: 480px) {
  main { padding-inline: 0.75rem; }
  .container { padding-inline: 0.75rem; }
  .packs-grid,
  .deals-grid { grid-template-columns: 1fr; }
  .challenge-card { min-height: 78px; }
  .modal { padding-inline: 1.15rem; }
}

/* ════════════════════════════════════════════════════════
   PACKS PAGE
════════════════════════════════════════════════════════ */
.packs-page {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 1.5rem;
  padding-top: 1.5rem;
  padding-bottom: 3rem;
  align-items: start;
}

/* Packs main area */
.packs-main { min-width: 0; }

.packs-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.packs-search-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.45rem 0.75rem;
  width: 160px;
  flex-shrink: 1;
  color: var(--muted-fg);
}
.packs-search {
  background: none;
  border: none;
  outline: none;
  color: var(--white);
  font-size: 0.85rem;
  width: 100%;
}
.packs-filter-reset {
  background: none;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--accent);
  font-size: 0.82rem;
  padding: 0.45rem 0.85rem;
  font-weight: 700;
  transition: background .15s;
}
.packs-filter-reset:hover { background: var(--card); }
.packs-filter-group {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
  flex: 1;
}
.packs-filter-select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.packs-filter-select {
  appearance: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--white);
  font-size: 0.79rem;
  font-weight: 700;
  padding: 0.45rem 1.6rem 0.45rem 0.6rem;
  cursor: pointer;
  white-space: nowrap;
}
.packs-select-caret {
  position: absolute;
  right: 0.5rem;
  pointer-events: none;
  color: var(--muted-fg);
}
.packs-create-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  font-weight: 700;
  transition: opacity .15s;
  margin-left: auto;
  white-space: nowrap;
  flex-shrink: 0;
}
.packs-create-btn:hover { opacity: 0.88; }

.packs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 1rem;
}

/* Home packs row */
.home-packs-row {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 0.5rem;
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;      /* IE/Edge */
}
.home-packs-row::-webkit-scrollbar { display: none; }   /* Chrome/Safari */
.home-packs-row .pack-card {
  flex-shrink: 0;
  cursor: pointer;
  transition: transform .2s;
}
.home-packs-row .pack-card:hover { transform: translateY(-4px); }
.pack-price { font-size: 0.875rem; font-weight: 700; color: var(--primary); text-align: center; margin-top: 0.3rem; }


/* ════════════════════════════════════════════════════════
   PACK DETAIL / SPIN PAGE
════════════════════════════════════════════════════════ */
.pack-detail-page {
  padding-top: 1.15rem;
  padding-bottom: 3rem;
}
.random-spin-page {
  max-width: 1260px;
}
.pack-detail-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2.2rem;
}
.pack-detail-back {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: none;
  color: var(--muted-fg);
  font-size: 0.875rem;
  font-weight: 700;
  transition: color .15s;
  padding: 0;
}
.pack-detail-back:hover { color: var(--white); }

/* Spin Reel */
.spin-reel-wrap {
  width: 100%;
  margin-left: 0;
  overflow: hidden;
  margin-bottom: 2.15rem;
  position: relative;
}
.spin-reel-wrap::before,
.spin-reel-wrap::after { display: none; }   /* ใช้ mask แทน (ไม่ทับสีดำบนพื้นหลัง) */
.spin-reel {
  width: 100%;
  height: 150px;            /* ลดความสูง — รูป+glow ยังไม่ถูกตัด */
  overflow: hidden;
  position: relative;
  border-radius: 0;
  background: transparent;
  border: 0;
}
/* ขอบซ้าย-ขวาจางเป็นโปร่งใสจริง — ใส่ mask ที่ wrap (ไม่มี will-change) เลี่ยง bug รูปหาย */
.spin-reel-wrap {
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 8%, #000 92%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 8%, #000 92%, transparent 100%);
}
.spin-reel-track {
  display: flex;
  align-items: center;      /* จัดไอเทมกลางแนวตั้ง */
  gap: 1.5rem;              /* 24px — ตรงกับ ITEM_GAP ใน JS */
  padding: 0;
  transition: none;
}
.reel-item {
  position: relative;
  flex-shrink: 0;
  width: 126px;            /* ตรงกับ ITEM_W ใน JS → โชว์ ~8 ชิ้น */
  height: 160px;
  border-radius: 8px;
  display: grid;
  grid-template-rows: 1fr;        /* รูปครองทั้งช่อง → อยู่กึ่งกลางเสมอ (meta เป็น absolute) */
  justify-items: center;
  align-items: center;
  overflow: visible;
  background: transparent;
  border: 1px solid transparent;
  transition: border-color .3s, filter .3s, transform .3s;
}
.reel-item {
  /* สี glow ตามระดับความหายาก (default = ฟ้าเดิม) */
  --reel-glow: var(--accent);
}
.reel-item.limited { --reel-glow: #f5b027; }  /* Limited — ทอง */
.reel-item.rare    { --reel-glow: #a855f7; }  /* Rare — ม่วง */
.reel-item.normal  { --reel-glow: #3b82f6; }  /* Normal — ฟ้า */
.reel-item.low     { --reel-glow: #9ca3af; }  /* Low — เทา */
.reel-item img {
  width: 104px;
  height: 104px;
  object-fit: contain;
  filter: drop-shadow(0 0 12px color-mix(in srgb, var(--reel-glow) 58%, transparent));   /* ลด spread กัน glow ล้นทับช่องข้างๆ */
}
/* พื้นหลังเรืองจางๆ หลังตัว item ตามสีระดับ
   ใช้วงกลมรัศมีจำกัด (จางหมดก่อนถึงขอบ cell) — ไม่เกิดขอบตัดสี่เหลี่ยม */
.reel-item::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle 64px at 50% 40%,
    color-mix(in srgb, var(--reel-glow) 20%, transparent) 0%,
    color-mix(in srgb, var(--reel-glow) 8%, transparent) 55%,
    transparent 100%);
  pointer-events: none;
}
.reel-item-meta {
  position: absolute;            /* ลอยใต้รูป ไม่กินพื้นที่ → รูปอยู่กลางเสมอ */
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 116px;
  display: grid;
  gap: 0.05rem;
  justify-items: center;
  padding: 0.22rem 0.3rem;
  text-align: center;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
/* ผู้ชนะ: ดันรูปขึ้นให้มีที่ว่างวางชื่อด้านล่าง ไม่ซ้อนกัน */
.reel-item.reel-winner img { transform: translateY(-14px); }
.reel-item-meta--hidden {
  opacity: 0;
  pointer-events: none;
}
.reel-item-meta--reveal {
  animation: meta-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes meta-pop {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.reel-item-meta strong,
.reel-item-meta span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reel-item-meta strong {
  color: var(--white);
  font-size: 0.82rem;
  font-weight: 900;
}
.reel-item-meta span {
  color: var(--white);
  font-size: 0.86rem;
  font-weight: 900;
}
.reel-item.reel-winner {
  transform: translateY(-4px);
  border-color: transparent;
  filter: brightness(1.1);
}
.spin-reel-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  
  background: transparent;

  border-radius: 2px;
  z-index: 2;
  pointer-events: none;
}
.spin-reel-indicator::before {
  content: '';
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  top: 0;
  border-top: 9px solid rgba(255,255,255,.8);
}

/* Open controls */
.pack-open-row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.6rem;
}
.pack-open-btn {
  grid-column: 2;
  min-width: 100px;
  min-height: 30px;
  border-radius: 16px;
  background: var(--accent);
  font-size: 0.85rem;
  padding: 0.72rem 2rem;
  color: #fff;
}
.pack-open-controls {
  grid-column: 3;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  justify-self: end;
}
.pack-demo-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.65rem 1rem;
  border-radius: 6px;
  background: var(--muted);
  font-size: 0.85rem;
}
.pack-quick-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--muted);
  border: 0;
  border-radius: 6px;
  color: var(--primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pack-quick-btn.active {
  background: color-mix(in srgb, var(--primary) 24%, var(--muted));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 58%, transparent);
  color: #ffd24a;
}

/* Multi-open slots */
.pack-multiopen-panel {
  max-width: 100%;
  min-height: 160px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 2.2rem;
  padding: 1rem;
  border-radius: 8px;
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
}
.pack-multiopen-row {
  width: min(790px, 100%);
  display: grid;
  grid-template-columns: repeat(6, minmax(92px, 1fr));
  gap: 0.75rem;
  justify-content: center;
}
.pack-multiopen-slot {
  width: 100%;
  height: 128px;
  border-radius: 8px;
  border: 1px dashed color-mix(in srgb, var(--border) 90%, #fff 10%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  background: color-mix(in srgb, var(--bg) 30%, transparent);
  color: var(--white);
  font-size: 1.7rem;
  font-weight: 300;
}
.pack-multiopen-slot:hover { border-color: var(--accent); background: var(--secondary); }
.pack-multiopen-slot.selected {
  position: relative;
  max-width: 128px;
  justify-self: center;
  border-style: solid;
  border-color: color-mix(in srgb, var(--border) 90%, transparent);
  background: var(--secondary);
  overflow: visible;
}
.pack-multiopen-slot.selected::after {
  content: '+';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: var(--muted);
  color: var(--white);
  font-size: 1.35rem;
  font-weight: 700;
}
.pack-slot-thumb { width: 100%; height: 100%; overflow: hidden; border-radius: 0.35rem; display: flex; align-items: center; justify-content: center; }
.pack-slot-thumb img { width: 100%; height: 100%; object-fit: contain; }

/* Pack detail info */
.pack-detail-info {
  max-width: 100%;
  margin: 0 auto;
}
.pack-detail-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.5rem;
  padding-bottom: 0;
  border-bottom: 0;
}
.pack-detail-thumb {
  width: 36px; height: 52px;
  border-radius: 4px;
  object-fit: cover;
  background: var(--secondary);
  flex-shrink: 0;
}
.pack-detail-header h2 { font-size: 1.1rem; font-weight: 900; }
.pack-detail-sub { color: var(--muted-fg); font-size: 0.85rem; margin-top: 0.15rem; }
.pack-fav-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--muted-fg);
  padding: 0.4rem;
  transition: color .15s;
}
.pack-fav-btn:hover { color: var(--primary); }
.pack-items-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));   /* 7 ช่องต่อแถว */
  gap: 0.6rem;
}
.pack-item-card {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 58px auto auto;
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 8px;
  overflow: hidden;
  text-align: center;
  padding: 0.5rem 0.45rem 0.55rem;
  gap: 0.2rem;
}
.pack-item-chance {
  font-size: 0.66rem;
  color: var(--muted-fg);
  padding: 0;
  text-align: center;
}
.pack-item-card img {
  width: 100%;
  height: 58px;
  object-fit: contain;
  filter: drop-shadow(0 8px 14px rgba(0,0,0,.32));
}
.pack-item-name {
  font-size: 0.66rem;
  color: var(--muted-fg);
  padding: 0.1rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pack-item-price {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--white);
}

@media (max-width: 900px) {
  .packs-page { grid-template-columns: 1fr; }
  .pack-open-row {
    grid-template-columns: 1fr;
    justify-items: center;
  }
  .pack-open-btn,
  .pack-open-controls {
    grid-column: 1;
    justify-self: center;
  }
  .pack-multiopen-row {
    grid-template-columns: repeat(3, minmax(84px, 1fr));
  }
}
@media (max-width: 640px) {
  .packs-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
  .spin-reel { height: 172px; }
  .spin-reel-track { gap: 1rem; }
  .reel-item {
    width: 132px;
    height: 170px;
    grid-template-rows: 108px auto;
  }
  .reel-item img {
    width: 108px;
    height: 108px;
  }
  .pack-items-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .pack-multiopen-panel { min-height: 0; padding: 0.75rem; }
  .pack-multiopen-row {
    grid-template-columns: repeat(2, minmax(96px, 1fr));
    gap: 0.5rem;
  }
  .pack-multiopen-slot { height: 104px; }
}

/* ════════════════════════════════════════════════════════
   CART BADGE & ITEMS
════════════════════════════════════════════════════════ */
.cart-badge {
  position: absolute;
  top: -6px; right: -8px;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  min-width: 18px; height: 18px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}

.cart-items-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
}
.cart-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.cart-item:last-child { border-bottom: none; }
.cart-item-img {
  width: 56px; height: 56px;
  border-radius: 0.5rem;
  object-fit: cover;
  background: var(--secondary);
  flex-shrink: 0;
}
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name {
  font-size: 0.875rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-item-pack {
  font-size: 0.75rem;
  color: var(--muted-fg);
  margin-top: 0.15rem;
}
.cart-item-price {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}
.cart-item-remove {
  background: none;
  border: none;
  color: var(--muted-fg);
  padding: 0.3rem;
  transition: color .15s;
  flex-shrink: 0;
}
.cart-item-remove:hover { color: #ef4444; }

/* Toast */
.cart-toast {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  z-index: 9999;
  transform: translateY(120%);
  opacity: 0;
  transition: transform .3s ease, opacity .3s ease;
  min-width: 280px;
  max-width: 340px;
}
.cart-toast.show { transform: translateY(0); opacity: 1; }
.cart-toast img {
  width: 48px; height: 48px;
  border-radius: 0.4rem;
  object-fit: cover;
  background: var(--secondary);
  flex-shrink: 0;
}
.cart-toast > div { flex: 1; min-width: 0; }
.cart-toast-label {
  font-size: 0.7rem;
  color: var(--primary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cart-toast-name {
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.1rem;
}
.cart-toast-price {
  font-size: 0.8rem;
  color: var(--muted-fg);
  margin-top: 0.1rem;
}
.cart-toast-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0.4rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  transition: opacity .15s;
}
.cart-toast-btn:hover { opacity: 0.85; }
/* ════════════════════════════════════════════════════════
   CART & DEPOSIT DRAWER
════════════════════════════════════════════════════════ */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,.82);   /* เอา backdrop blur ออก (ตัวการแลค) ใช้พื้นทึบแทน */
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.drawer-overlay.active { display: flex; }

.drawer {
  position: relative;
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in .2s ease;
}

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}
.drawer-close {
  background: none;
  border: none;
  color: var(--muted-fg);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 0.375rem;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}
.drawer-close:hover { color: var(--white); background: color-mix(in srgb, var(--secondary) 60%, transparent); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.drawer-account-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.drawer-summary {
  background: color-mix(in srgb, var(--secondary) 40%, transparent);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
}

.drawer-amounts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.drawer-methods {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
}

#cartDrawerOverlay {
  align-items: flex-start;
  padding-top: 1.45rem;
}

#cartDrawer {
  max-width: 715px;
  min-height: min(495px, calc(100vh - 2.9rem));
  max-height: calc(100vh - 2.9rem);
  background: var(--card);
  border: 1px solid rgba(255,255,255,.03);
  border-radius: 6px;
  box-shadow: 0 24px 70px rgba(0,0,0,.52);
}

#cartDrawer .drawer-head {
  min-height: 49px;
  padding: 0 0.85rem;
  border-bottom-color: var(--secondary);
}

#cartDrawer .drawer-title {
  display: flex;
  align-items: center;
  gap: 1.4rem;
  font-size: 0.78rem;
  font-weight: 900;
}

#cartDrawer .drawer-title span {
  color: #fff;
  font-size: 0.8rem;
}

#cartDrawer .drawer-close {
  color: #8d969d;
}

#cartDrawer .drawer-body {
  padding: 0;
  overflow-y: auto;
}

#cartDrawer .drawer-account-layout {
  display: block;
  min-height: 100%;
  padding: 1rem 1.15rem 0.8rem;
}

.cart-modal-selected {
  display: grid;
  gap: 0.75rem;
}

.cart-modal-selected-head,
.cart-modal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
}

.cart-modal-selected-total {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 32px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 900;
}

.cart-modal-clear {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: #fff;
  padding: 0;
}

.cart-modal-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.cart-action-primary,
.cart-action-secondary {
  min-width: 89px;
  height: 32px;
  border: 0;
  border-radius: 5px;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
}

.cart-action-primary {
  background: var(--accent);
}

.cart-action-secondary {
  background: var(--muted);
}

.cart-modal-selected-tray {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));   /* เท่ากับ grid หลัก */
  gap: 0.85rem;
  padding: 0.8rem;
  border-radius: 6px;
  background: var(--secondary);
  max-height: 340px;
  overflow-y: auto;
}

.cart-selected-card {
  position: relative;
  width: auto;
  aspect-ratio: 1 / 1;  /* สี่เหลี่ยมจัตุรัส: สูง = กว้าง */
  display: grid;
  grid-template-rows: auto auto auto;
  align-content: center;
  justify-items: center;
  gap: 0.18rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--card) 80%, var(--bg));
  color: #fff;
  text-align: center;
  padding: 0.55rem 0.45rem;
  content-visibility: auto;
  contain-intrinsic-size: 158px 158px;
}

.cart-selected-card img,
.cart-grid-card img {
  width: 52px;
  height: 50px;
  object-fit: contain;
  filter: grayscale(1) brightness(.92);
}

.cart-selected-card span,
.cart-grid-card span {
  max-width: 100%;
  color: #909aa2;
  font-size: 0.76rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cart-selected-card strong,
.cart-grid-card strong {
  color: #fff;
  font-size: 0.79rem;
  font-weight: 900;
}

.cart-selected-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 19px;
  height: 19px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: var(--border);
  color: #fff;
  padding: 0;
}

.cart-modal-toolbar {
  justify-content: flex-end;
  margin-top: 1.15rem;
}

.cart-sort-btn,
.cart-deselect-btn {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  border: 0;
  border-radius: 5px;
  background: var(--secondary);
  color: #fff;
  padding: 0 0.65rem;
  font-size: 0.72rem;
  font-weight: 900;
}

.cart-checkmark {
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
}

.cart-modal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));   /* 4 ช่องต่อแถว */
  gap: 0.85rem;
  margin-top: 1.15rem;
  padding-bottom: 0.3rem;
}

.cart-grid-card {
  position: relative;
  width: auto;          /* ยืดเต็มช่อง grid (4 คอลัมน์) */
  aspect-ratio: 1 / 1;  /* สี่เหลี่ยมจัตุรัส: สูง = กว้าง */
  display: grid;
  grid-template-rows: auto auto auto auto;
  align-content: center;
  justify-items: center;
  gap: 0.18rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--card);
  color: #fff;
  padding: 0.55rem 0.45rem;
  text-align: center;
  transition: border-color .15s, background .15s;
  content-visibility: auto;          /* การ์ดนอกจอไม่ถูก render → ลื่นขึ้นมากเมื่อมีของเยอะ */
  contain-intrinsic-size: 158px 158px;
}

.cart-grid-card.selected {
  border-color: var(--accent);
  background: var(--secondary);
}

.cart-card-menu {
  position: absolute;
  top: 9px;
  left: 10px;
  display: inline-flex;
  gap: 3px;
  border: 0;
  background: transparent;
  padding: 0;
}

.cart-card-menu span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #87919a;
}

.cart-card-check {
  position: absolute;
  top: 7px;
  right: 7px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  padding: 0;
}

.cart-grid-card:not(.selected) .cart-card-check {
  background: var(--muted);
}

.cart-card-sell {
  width: calc(100% - 0.42rem);
  height: 28px;
  align-self: end;
  border: 0;
  border-radius: 5px;
  background: var(--muted);
  color: #fff;
  font-size: 0.74rem;
  font-weight: 900;
}

.cart-modal-empty {
  min-height: 360px;
  display: grid;
  place-items: center;
  color: #909aa2;
  text-align: center;
}

.cart-modal-empty h2 {
  color: #fff;
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

@media (max-width: 760px) {
  #cartDrawerOverlay {
    align-items: center;
    padding: 0.75rem;
  }

  #cartDrawer {
    min-height: min(620px, calc(100vh - 1.5rem));
    max-height: calc(100vh - 1.5rem);
  }

  .cart-modal-selected-head {
    align-items: stretch;
    flex-direction: column;
  }

  .cart-modal-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .cart-action-primary,
  .cart-action-secondary {
    min-width: 0;
  }

  .cart-modal-toolbar {
    justify-content: space-between;
  }

  .cart-modal-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cart-grid-card {
    width: 100%;
  }
}

/* ── Affiliate Page Styles — matched to "Change your password" modal ──────── */

/* Make the Invite Friends drawer feel like the password modal:
   centered title, narrower card, generous padding. */
#affiliateDrawer { max-width: 420px; }
#affiliateDrawer .drawer-head {
  justify-content: center;
  position: relative;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  padding: 1.25rem 1.5rem 1rem;
}
#affiliateDrawer .drawer-title {
  font-size: 1.4rem;
  font-weight: 700;
  text-align: center;
}
#affiliateDrawer .drawer-close {
  position: absolute;
  top: 50%;
  right: 1.25rem;
  transform: translateY(-50%);
  color: var(--muted-fg);
  font-size: 1.4rem;
}
#affiliateDrawer .drawer-body { padding: 1.25rem 1.5rem 1.5rem; }
#affiliateDrawer .account-subtitle {
  font-size: 0.875rem;
  color: var(--muted-fg);
  text-align: center;
  margin-bottom: 1.1rem !important;
}

/* Status messages */
.aff-msg {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .875rem;
  display: none;
}
.aff-msg.error   { background: color-mix(in srgb, #ef4444 18%, transparent); color: #fca5a5; }
.aff-msg.success { background: color-mix(in srgb, #10b981 18%, transparent); color: #6ee7b7; }

.aff-loading { color: var(--muted-fg); text-align: center; padding: 2rem; }
.aff-error   { color: #fca5a5; text-align: center; padding: 1rem; }

/* Stats grid */
.aff-stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: .6rem;
  margin-bottom: .85rem;
}
.aff-stat-card {
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius);
  padding: .8rem .9rem;
}
.aff-stat-label {
  font-size: .72rem;
  color: var(--muted-fg);
  opacity: .7;
  margin-bottom: .3rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.aff-stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.1;
}
.aff-stat-value.highlight { color: var(--accent); }

/* Referral link box — styled like a modal field group */
.aff-ref-box {
  background: color-mix(in srgb, var(--secondary) 45%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius);
  padding: .9rem 1rem;
  margin-bottom: 1rem;
}
.aff-ref-label {
  font-size: .875rem;
  font-weight: 700;
  color: var(--white);
  margin-bottom: .5rem;
}
.aff-ref-row {
  display: flex;
  gap: .5rem;
}
.aff-ref-input {
  flex: 1;
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--radius);
  padding: .65rem .9rem;
  color: var(--white);
  font-size: .875rem;
  min-width: 0;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.aff-ref-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.aff-ref-hint {
  font-size: .78rem;
  color: var(--muted-fg);
  opacity: .65;
  margin-top: .5rem;
}

/* Withdraw block */
.aff-withdraw-box { margin-bottom: 0; }
.aff-hint {
  font-size: .78rem;
  color: var(--muted-fg);
  opacity: .65;
  margin-top: .5rem;
  text-align: center;
}

/* Buttons */
.aff-btn {
  padding: .65rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
  color: var(--white);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.aff-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--secondary) 90%, white);
}
.aff-btn:disabled { opacity: .48; cursor: not-allowed; }

/* Primary actions adopt the modal's blue accent, full-width submit look */
.aff-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
}
.aff-btn.primary:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent) 85%, white);
}
.aff-btn.primary:active:not(:disabled) { transform: scale(.98); }

/* Withdraw button = full-width primary submit, like "Update Password".
   Covers both .aff-withdraw-box .aff-btn and a standalone

/* ══ Deals — วงแหวน SVG + ลูกศรนิ่ง (PackDraw style) ══════════════ */
.wheel-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(0deg);     /* 0% = ด้านบน (12 นาฬิกา) */
  overflow: visible;
}
.wheel-track { stroke: var(--secondary); }
.wheel-win {
  stroke: var(--accent);   /* โทนเว็บ — เข้าชุดกับ slider + แบรนด์ */
  transition: box-shadow .3s;
}
/* กลุ่มที่หมุน (โซนเขียว) — หมุนรอบจุดศูนย์กลาง 110,110
   SVG stroke เริ่มที่ 3 นาฬิกา (ขวา) กวาดตามเข็มในพิกัด y-down อยู่แล้ว
   → rotate(-90deg) ย้ายจุดเริ่มไป 12 นาฬิกา (บน) ให้ตรงกับลูกศร
     ที่เริ่มจากบนแล้วหมุนตามเข็ม (verified ด้วยการจำลองเชิงเรขาคณิต) */
.wheel-arc-rot {
  transform-box: view-box;
  transform-origin: 110px 110px;
  transform: rotate(-90deg);
  will-change: transform;
}
/* ตัวหมุนลูกศร — หมุนรอบจุดศูนย์กลางวง ทำให้ลูกศร orbit รอบวงแหวน */
.wheel-pointer-rot {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  transform: rotate(0deg);
  will-change: transform;
  pointer-events: none;
  z-index: 3;
}
/* ลูกศรเล็กชี้เข้าหาวง อยู่ขอบบนของตัวหมุน */
.wheel-pointer {
  position: absolute;
  top: -13px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 13px solid #fff;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.6));
}
.wheel-pct {
  position: relative;
  z-index: 2;
  font-size: 1.5rem;
  font-weight: 900;
  color: #fff;
}
/* เอา glow ตอน deals ชนะ/แพ้ ออกแล้ว */
.wheel-ring.is-win  .wheel-win,
.wheel-ring.is-lose .wheel-win { filter: none; }

/* ── spin reel rarity glow (คงไว้) ── */

/* ════════════════════════════════════════════════════════
   CREATE BATTLE PAGE
════════════════════════════════════════════════════════ */
.cb-page { max-width: 920px; margin: 0 auto; padding: 1.25rem 1rem 3.5rem; }

/* Top bar: back+title left, total pill centered */
.cb-topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-bottom: 1.5rem; }
.cb-topbar-left { grid-column: 1; }
.cb-total-pill { grid-column: 2; justify-self: center; }
.cb-back {
  background: none; border: none; color: var(--primary);
  font-size: 0.78rem; font-weight: 700; padding: 0;
  display: inline-flex; align-items: center; gap: 0.25rem; margin-bottom: 0.2rem;
  opacity: .9; transition: opacity .15s;
}
.cb-back:hover { opacity: 1; text-decoration: underline; }
.cb-title { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.01em; }

.cb-total-pill {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 999px; padding: 0.55rem 1.5rem;
  font-weight: 800; font-size: 1rem; min-width: 130px; justify-content: center;
}
.cb-coin {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: #181203; font-size: 0.72rem; font-weight: 800;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,.25);
}
.cb-coin.dark { background: #181203; color: var(--primary); box-shadow: none; }

/* ── Selected cases row ── */
.cb-cases { display: flex; gap: 0.85rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.cb-add-case, .cb-case-card {
  width: 184px; min-height: 210px;
  background: var(--card); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 0.4rem; padding: 0.85rem 0.85rem 0.95rem; position: relative;
}
.cb-add-case {
  color: var(--primary);
  border: 1.5px dashed color-mix(in srgb, var(--primary) 35%, transparent);
  transition: border-color .15s, background .15s, transform .1s;
  justify-content: center;   /* ไอคอน + ข้อความอยู่กึ่งกลางแนวตั้งของกล่อง */
  gap: 0.6rem;
}
.cb-add-case:hover {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--card) 88%, var(--primary) 12%);
  transform: translateY(-2px);
}
.cb-add-plus {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--primary) 14%, transparent);
  font-size: 1.6rem; font-weight: 700; line-height: 1;
}
.cb-add-case span:last-child { font-size: 0.9rem; font-weight: 800; }

.cb-case-card { border: 1px solid var(--border); }
.cb-case-card img { width: 136px; height: 136px; object-fit: contain; filter: drop-shadow(0 6px 12px rgba(0,0,0,.45)); margin-top: 0.2rem; }
.cb-case-name { font-size: 0.82rem; font-weight: 800; text-align: center; line-height: 1.2; margin-top: 0.15rem; }
.cb-case-price { font-size: 0.74rem; color: var(--primary); font-weight: 800; margin-top: -0.05rem; }
.cb-case-remove {
  position: absolute; top: 8px; right: 10px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--muted); border: none; color: var(--white);
  font-size: 0.85rem; line-height: 1; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, background .15s;
}
.cb-case-card:hover .cb-case-remove { opacity: .85; }
.cb-case-remove:hover { opacity: 1 !important; background: #ef4444; }

/* ── Section titles ── */
.cb-section-title { font-size: 1.05rem; font-weight: 800; margin-bottom: 0.85rem; }

/* ── Game modes ── */
.cb-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.85rem; margin-bottom: 1.4rem; }
.cb-mode {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.65rem;
  background: var(--card); border: 1px solid transparent; border-radius: var(--radius);
  padding: 1rem 1.1rem; text-align: left; min-height: 86px;
  transition: border-color .15s, background .15s;
}
.cb-mode:hover { border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.cb-mode.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--card) 92%, var(--accent) 8%);
}
.cb-mode.active .cb-mode-name { color: var(--accent); }
.cb-mode-name { font-size: 0.88rem; font-weight: 800; margin-bottom: 0.25rem; white-space: nowrap; }
.cb-mode-desc { font-size: 0.72rem; color: color-mix(in srgb, var(--white) 55%, transparent); font-weight: 600; line-height: 1.4; }
.cb-mode-icon { flex-shrink: 0; opacity: .25; margin-top: 0.1rem; }
.cb-mode.active .cb-mode-icon { opacity: .7; color: var(--primary); }

/* ── Additional options ── */
.cb-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.85rem; margin-bottom: 1rem; }
.cb-option {
  display: flex; align-items: center; gap: 0.85rem;
  background: var(--card); border: 1px solid transparent; border-radius: var(--radius);
  padding: 1rem 1.1rem; min-height: 86px;
}
.cb-option-text { flex: 1; min-width: 0; }
.cb-option-name { font-size: 0.88rem; font-weight: 800; margin-bottom: 0.2rem; }
.cb-option-desc { font-size: 0.72rem; color: color-mix(in srgb, var(--white) 55%, transparent); font-weight: 600; line-height: 1.4; }
.cb-option-icon { flex-shrink: 0; opacity: .25; }
.cb-option-funded { grid-column: 1; justify-content: space-between; }

/* Toggle switch */
.cb-switch {
  width: 46px; height: 26px; border-radius: 13px; border: none; flex-shrink: 0;
  background: var(--muted); position: relative;
  transition: background .2s;
}
.cb-switch .cb-knob {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4);
  transition: transform .2s cubic-bezier(.34,1.56,.64,1);
}
.cb-switch.on { background: var(--accent); }
.cb-switch.on .cb-knob { transform: translateX(20px); background: #fff; }

/* Counter (funded seats + case qty) */
.cb-counter { display: flex; align-items: center; gap: 0.55rem; }
.cb-case-card .cb-counter { margin-top: 0.35rem; }
.cb-counter-btn {
  width: 28px; height: 28px; border-radius: 50%; border: none;
  background: var(--muted); color: var(--white); font-size: 0.95rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.cb-counter-btn:hover { background: var(--accent); color: #fff; }
.cb-counter-value { min-width: 20px; text-align: center; font-weight: 800; font-size: 0.95rem; }
.cb-counter.small .cb-counter-btn { width: 24px; height: 24px; font-size: 0.82rem; }
.cb-counter.small .cb-counter-value { font-size: 0.85rem; }

/* ── Team layout selector (1v1, 2v2, ...) ── */
.cb-teams { display: flex; align-items: center; justify-content: center; gap: 0.65rem; flex-wrap: wrap; margin: 1.4rem 0 1.4rem; }
.cb-team-opt {
  display: flex; align-items: center; gap: 0.35rem;
  background: transparent; border: none; border-radius: 999px;
  padding: 0.6rem 1.05rem; color: var(--white);
  opacity: .4; transition: opacity .15s, background .2s, color .2s, transform .1s;
}
.cb-team-opt:hover { opacity: .75; }
.cb-team-opt.active {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 90%, white) 0%, var(--primary) 100%);
  color: #181203; opacity: 1;
}
.cb-person { display: block; width: 15px; height: 15px; }
.cb-vs { font-size: 0.72rem; font-weight: 800; margin: 0 0.05rem; opacity: .8; }

/* ── Create / preview button ── */
.cb-create-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  margin: 0 auto; min-width: 280px;
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 90%, white) 0%, var(--primary) 100%);
  border: none; border-radius: var(--radius);
  padding: 0.95rem 2rem; font-size: 0.98rem; font-weight: 800; color: #181203;
  box-shadow: 0 4px 18px color-mix(in srgb, var(--primary) 30%, transparent);
  transition: filter .15s, transform .1s, box-shadow .15s;
}
.cb-create-btn:hover { filter: brightness(1.07); box-shadow: 0 6px 22px color-mix(in srgb, var(--primary) 40%, transparent); }
.cb-create-btn:active { transform: scale(.98); }
.cb-create-btn:disabled { opacity: .45; cursor: not-allowed; filter: none; box-shadow: none; }

/* ── Case picker modal ── */
.cb-modal-overlay[hidden] { display: none; }
.cb-modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.cb-modal {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  width: 100%; max-width: 880px; max-height: 85vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.55);
}
.cb-modal-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); }
.cb-modal-head h3 { font-size: 1.05rem; font-weight: 800; }
.cb-modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--muted); border: none; color: var(--white);
  font-size: 1.1rem; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.cb-modal-close:hover { background: #ef4444; }
.cb-modal-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.65rem;
  padding: 1.1rem; overflow-y: auto;
}
.cb-modal-card {
  background: var(--card); border: 1px solid transparent; border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem; padding: 0.75rem 0.7rem 0.85rem;
  transition: border-color .15s, transform .1s, box-shadow .15s;
  cursor: pointer;
}
.cb-modal-card:hover { border-color: color-mix(in srgb, var(--accent) 55%, transparent); transform: translateY(-3px); box-shadow: 0 8px 20px rgba(0,0,0,.35); }
.cb-modal-card:active { transform: translateY(-1px) scale(.99); }
.cb-modal-card.selected { border-color: var(--accent); background: color-mix(in srgb, var(--card) 92%, var(--accent) 8%); }
.cb-modal-card img { width: 120px; height: 120px; object-fit: contain; filter: drop-shadow(0 5px 10px rgba(0,0,0,.4)); }
.cb-modal-foot { padding: 1rem 1.4rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; }
.cb-modal-done {
  background: var(--primary); border: none; border-radius: var(--radius);
  padding: 0.65rem 1.75rem; font-weight: 800; color: #181203;
  transition: filter .15s;
}
.cb-modal-done:hover { filter: brightness(1.08); }

/* ── Responsive ── */
@media (max-width: 1024px) {
  .cb-modes, .cb-options { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .cb-topbar { grid-template-columns: 1fr; gap: 0.75rem; }
  .cb-total-pill { grid-column: 1; justify-self: start; }
  .cb-modes, .cb-options { grid-template-columns: 1fr; }
  .cb-mode, .cb-option { min-height: 0; }
  .cb-add-case, .cb-case-card { width: calc(50% - 0.45rem); min-height: 210px; }
  .cb-create-btn { width: 100%; }
}

/*
   BATTLE PLAY PAGE  - redesigned (blue-led, compact)
 */
.bplay-wrap {
  display: flex; flex-direction: column;
  position: relative;
  height: calc(100dvh - var(--nav-h, 61px));
  min-height: 560px;
  overflow: auto;
  background:
    radial-gradient(1000px 460px at 50% -10%, color-mix(in srgb, var(--accent) 14%, transparent) 0%, transparent 62%),
    var(--bg);
  color: var(--white);
}

/*  Top bar (chip header)  */
.bplay-topbar {
  display: grid; grid-template-columns: 1fr minmax(260px, auto) 1fr; align-items: start; gap: 1rem;
  padding: 0.55rem max(1rem, (100% - 1180px) / 2 + 1rem) 0.75rem; min-height: 86px; flex-shrink: 0;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
/* Pack reel — แถบ pack เรียงต่อกันตอนรอผู้เล่น */
.bplay-pack-reel {
  display: none;
  gap: 0.6rem;
  padding: 0.9rem max(1rem, (100% - 1280px) / 2 + 1rem);
  overflow-x: auto;
  flex-shrink: 0;
  background: color-mix(in srgb, var(--card) 70%, var(--bg));
  border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 3%, #000 97%, transparent);
}
.bplay-pack-reel.is-active { display: flex; }
.bplay-pack-reel::-webkit-scrollbar { display: none; }
.bplay-pack-card {
  flex: 0 0 auto;
  width: clamp(96px, 11vw, 140px);
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  padding: 0.5rem 0.4rem;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.1));
  border: 1px solid rgba(255,255,255,.05);
}
.bplay-pack-card img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: contain; border-radius: 8px;
}
.bplay-pack-card-price {
  font-size: 0.72rem; font-weight: 900; color: var(--white);
}

.bplay-back {
  display: inline-flex; align-items: center; gap: 0.35rem;
  background: color-mix(in srgb, var(--secondary) 65%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
  border-radius: 0.5rem; color: var(--muted-fg);
  font-size: 0.74rem; font-weight: 700; padding: 0.34rem 0.7rem;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: border-color .15s, color .15s, background .15s;
}
.bplay-back:hover { border-color: color-mix(in srgb, var(--accent) 65%, transparent); color: var(--white); background: var(--secondary); }

.bplay-meta { display: flex; flex-direction: column; align-items: center; gap: 0.45rem; min-width: 0; overflow: hidden; }
.bplay-packs { display: flex; align-items: center; justify-content: center; gap: 0.25rem; flex-shrink: 0; }
.bplay-pack-thumb {
  width: 36px; height: 36px; border-radius: 3px; object-fit: cover;
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent); flex-shrink: 0;
}
.bplay-meta-divider { color: color-mix(in srgb, var(--white) 14%, transparent); }
.bplay-item-info { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bplay-item-info-name {
  font-size: 0.72rem; font-weight: 800; color: var(--white);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 180px;
}
.bplay-item-info-val { font-size: 0.66rem; font-weight: 900; color: hsl(40,90%,64%); }

/* header chips */
.bplay-mode-badge {
  font-size: 0.58rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase;
  padding: 0.22rem 0.58rem; border-radius: 999px; flex-shrink: 0; border: 1px solid transparent;
}
.bplay-round-stack {
  display: flex; align-items: center; justify-content: center; gap: 0.35rem;
  font-size: 0.78rem; font-weight: 900; color: var(--white);
}
.bplay-pack-label,
.bplay-pack-price,
.bplay-meta-sep,
.bplay-item-info,
.bplay-mode-badge { display: none; }
.bplay-actions { display: flex; justify-content: flex-end; align-items: flex-start; gap: 1rem; }
.bplay-action {
  border: 0; background: transparent; color: var(--white);
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.2rem 0; font-size: 0.75rem; font-weight: 800; cursor: pointer;
}
.bplay-cancel-room {
  color: #fff;
  background: var(--accent);
  border-radius: 0.45rem;
  padding: 0.3rem 0.7rem;
}
.bplay-cancel-room:hover { background: color-mix(in srgb, var(--accent) 85%, #000); }
.bplay-cancel-room[hidden] { display: none; }
.bplay-back { grid-column: 1; grid-row: 1; justify-self: start; }
.bplay-meta { grid-column: 2; grid-row: 1 / span 2; }
.bplay-actions { grid-column: 3; grid-row: 1; justify-self: end; }
.bplay-mode-badge.normal  { background: color-mix(in srgb, var(--accent) 18%, transparent); color: hsl(40,95%,68%); border-color: color-mix(in srgb, var(--accent) 38%, transparent); }
.bplay-mode-badge.jackpot { background: rgba(245,158,11,.16); color: #fbbf24; border-color: rgba(245,158,11,.30); }
.bplay-mode-badge.shared  { background: rgba(232,115,14,.16); color: #f0a868; border-color: rgba(232,115,14,.34); }
.bplay-round-label {
  font-size: 0.68rem; font-weight: 800; color: var(--muted-fg); flex-shrink: 0;
  padding: 0.22rem 0.58rem; border-radius: 999px;
  background: color-mix(in srgb, var(--secondary) 65%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.bplay-topbar .bplay-round-label {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--white);
  font-size: 0.78rem;
}
.bplay-cost-label {
  font-size: 0.72rem; color: var(--muted-fg); white-space: nowrap; flex-shrink: 0; margin-left: auto;
  padding: 0.32rem 0.72rem; border-radius: 0.5rem;
  background: color-mix(in srgb, var(--secondary) 65%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
}
.bplay-cost-label strong { color: hsl(40,90%,64%); font-weight: 900; }

/*  Body: side strip + arena  */
.bplay-body {
  display: flex; flex: 1 1 auto; min-height: 0; overflow: auto; position: relative;
  padding: 0.75rem clamp(1rem, 4vw, 6rem) 1.5rem;
}
/* นับถอยหลังก่อนเริ่มสุ่ม (5 → 1 → GO!) */
.bplay-countdown {
  position: absolute; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  font-size: 6rem; font-weight: 900; color: #fff;
  text-shadow: 0 0 32px rgba(245,176,39,.85), 0 6px 24px rgba(0,0,0,.6);
  background: rgba(0,0,0,.42);
  pointer-events: none;
  animation: bplayCountPulse .45s cubic-bezier(.2,1,.3,1);
}
.bplay-countdown.go { color: var(--primary); font-size: 7rem; }
@keyframes bplayCountPulse { from { transform: scale(1.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.bplay-mode-strip { display: none; }
.bplay-side-nav { display: none; }

/* Loading overlay ตอนโหลดห้อง (reload / เปิดลิงก์ตรง) */
.bplay-loading {
  position: absolute; inset: 0; z-index: 45;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1rem;
  background: var(--bg); color: var(--muted-fg); font-size: 0.9rem; font-weight: 800;
}
.bplay-spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--primary) 22%, transparent);
  border-top-color: var(--primary);
  animation: bplay-spin 0.7s linear infinite;
}
@keyframes bplay-spin { to { transform: rotate(360deg); } }
.bplay-mode-strip-label {
  writing-mode: vertical-rl; text-orientation: mixed;
  font-size: 0.56rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase;
  color: hsl(40,90%,62%);
}
.bplay-mode-strip-label.blue { color: hsl(28,85%,62%); }
.bplay-mode-strip-label.cyan { color: hsl(40,90%,62%); }

/*  Arena  */
.bplay-arena {
  flex: 1 1 auto; min-width: 0; min-height: 0;
  display: grid;
  grid-template-columns: repeat(var(--bplay-slots, 2), minmax(200px, 300px));
  justify-content: center; align-items: start; gap: 0.55rem;
  overflow: visible; position: relative;
  width: min(950px, 100%);
  margin: 0 auto;
  padding: 0;
}

/* VS divider between columns */
.bplay-divider {
  width: 1.5rem; flex-shrink: 0; align-self: center;
  display: flex; align-items: center; justify-content: center;
  position: relative; z-index: 4;
}
.bplay-divider-x {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 92%, white), var(--accent));
  border: 3px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.68rem; font-weight: 900; color: #fff;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 45%, transparent);
}

/*  Player column (framed card)  */
.bplay-col {
  min-width: 0;
  height: auto;
  display: flex; flex-direction: column; gap: 0.55rem; position: relative; overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.bplay-col::before { content: none; }

/* Items scroll area — 2 round ต่อแถว */
.bplay-col-items {
  flex: 1; overflow: visible; display: grid; grid-template-columns: repeat(2, 1fr);
  align-items: stretch; gap: 0.45rem; padding: 0; scrollbar-width: none;
}
.bplay-col-items::-webkit-scrollbar { display: none; }

.bplay-round-cell {
  min-height: clamp(118px, 17dvh, 180px);
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  background: color-mix(in srgb, var(--card) 82%, var(--bg));
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 900;
}
.bplay-round-cell.has-result {
  align-items: stretch;
  justify-content: stretch;
  padding: 0;
}
.bplay-round-item {
  width: 100%;
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  gap: 0.28rem;
  padding: 0.75rem 0.45rem 0.65rem;
  position: relative;
}
.bplay-round-item-pct {
  position: absolute; top: 0.55rem; left: 0.55rem;
  font-size: 0.58rem; font-weight: 800; color: color-mix(in srgb, var(--accent) 70%, var(--muted-fg));
}
.bplay-round-item-img {
  width: clamp(42px, 5vw, 72px);
  height: clamp(42px, 5vw, 72px);
  object-fit: contain;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,.5));
}
.bplay-round-item-name {
  width: 100%;
  color: var(--muted-fg);
  font-size: 0.62rem;
  font-weight: 700;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bplay-round-item-val {
  color: var(--white);
  font-size: 0.72rem;
  font-weight: 900;
}

/* Empty / waiting slot */
.bplay-empty-slot {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0.6rem; padding: 1.4rem 1rem; text-align: center;
}
.bplay-empty-icon {
  width: 48px; height: 48px; border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 1px dashed color-mix(in srgb, var(--accent) 40%, transparent);
  color: hsl(40,90%,62%);
  display: flex; align-items: center; justify-content: center;
  animation: bplay-pulse 1.8s ease-in-out infinite;
}
.bplay-empty-icon svg { width: 22px; height: 22px; }
@keyframes bplay-pulse { 0%,100%{ transform: scale(1); opacity:.85 } 50%{ transform: scale(1.06); opacity:1 } }
.bplay-waiting-label { font-size: 0.74rem; font-weight: 800; color: var(--muted-fg); letter-spacing: .02em; }

/*  Item card (drawn)  */
.bplay-item {
  width: 100%; max-width: 132px;
  display: flex; flex-direction: column; align-items: center;
  padding: 0.45rem 0.4rem 0.38rem; border-radius: 0.55rem;
  background: color-mix(in srgb, var(--secondary) 70%, transparent);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  animation: bplay-drop .38s cubic-bezier(.22,1,.36,1) both;
}
.bplay-item.rarity-blue   { border-color: rgba(56,189,248,.45); background: rgba(56,189,248,.07); }
.bplay-item.rarity-purple { border-color: rgba(167,139,250,.42); background: rgba(167,139,250,.07); }
.bplay-item.rarity-gold   { border-color: rgba(245,158,11,.45); background: rgba(245,158,11,.08); }
.bplay-item.rarity-red    { border-color: rgba(239,68,68,.42); background: rgba(239,68,68,.06); }
.bplay-item-pct { font-size: 0.56rem; color: var(--muted-fg); font-weight: 700; align-self: flex-start; margin-bottom: 0.15rem; }
.bplay-item-img { width: 56px; height: 56px; object-fit: contain; filter: drop-shadow(0 4px 10px rgba(0,0,0,.55)); }
.bplay-item-name { font-size: 0.6rem; font-weight: 700; color: var(--muted-fg); text-align: center; margin-top: 0.25rem; line-height: 1.2; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bplay-item-val { font-size: 0.68rem; font-weight: 900; color: var(--white); margin-top: 0.08rem; }
@keyframes bplay-drop { from { opacity: 0; transform: translateY(-14px) scale(.93); } to { opacity: 1; transform: translateY(0) scale(1); } }

/*  Player footer (in column)  */
.bplay-player {
  min-height: 132px;   /* สูงเท่ากันทุกแบบ (มี % chance / ปุ่ม Call Bots / Join) */
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.08rem;
  padding: 0.5rem 0.55rem; flex-shrink: 0;
  border: 0;
  background: color-mix(in srgb, var(--card) 82%, var(--bg));
  border-radius: 6px;
  transition: background .3s;
}
.bplay-player.is-winner { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.bplay-player-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--secondary); border: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; font-weight: 900; color: var(--white);
  overflow: hidden; flex-shrink: 0; transition: border-color .3s, box-shadow .3s;
}
.bplay-player-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bplay-player-name { font-size: 0.68rem; font-weight: 900; color: var(--white); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* % โอกาส (สัดส่วนมูลค่า) ใต้ผู้เล่น — สีต่างกันต่อผู้เล่น */
.bplay-player-chance { margin-top: 4px; padding: 2px 11px; border-radius: 5px; font-size: 0.76rem; font-weight: 800; color: #fff; line-height: 1.5; }
.bplay-player-chance[data-slot="0"] { background: #ef4444; }
.bplay-player-chance[data-slot="1"] { background: #f97316; }
.bplay-player-chance[data-slot="2"] { background: #eab308; }
.bplay-player-chance[data-slot="3"] { background: #db2777; }
.bplay-player-chance[data-slot="4"] { background: #ec4899; }
.bplay-player-chance[data-slot="5"] { background: #f59e0b; }
.bplay-player-score {
  font-size: 0.68rem; font-weight: 900; padding: 0; border-radius: 0;
  background: transparent; color: var(--white);
  min-width: 56px; text-align: center; transition: background .35s, color .35s, transform .2s;
}
.bplay-player-score.winning {
  background: var(--accent); color: #fff; transform: scale(1.08);
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 45%, transparent);
}

/* Join button inside empty column */
.bplay-join-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  margin: 0.45rem 0.6rem 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, white) 0%, var(--accent) 100%);
  border: none; border-radius: 0.55rem; padding: 0.55rem 0.95rem;
  font-size: 0.76rem; font-weight: 900; color: #fff; cursor: pointer;
  box-shadow: 0 5px 14px color-mix(in srgb, var(--accent) 32%, transparent);
  transition: filter .15s, transform .1s;
}
.bplay-join-btn:hover { filter: brightness(1.08); }
.bplay-join-btn:active { transform: scale(.97); }
.bplay-join-btn:disabled { opacity: .45; cursor: not-allowed; filter: none; box-shadow: none; }
.bplay-callbots-btn {
  margin-top: 0.45rem; padding: 0.5rem 1.1rem; border: 1px solid var(--border);
  border-radius: 0.5rem; background: var(--secondary); color: var(--white);
  font-size: 0.78rem; font-weight: 700; cursor: pointer; transition: background .15s, transform .1s;
}
.bplay-callbots-btn:hover { background: var(--muted); }
.bplay-callbots-btn:active { transform: scale(.97); }

/* Winner column glow (blue) */
.winner-glow .bplay-player-avatar,
.bplay-player.is-winner .bplay-player-avatar {
  border-color: var(--accent) !important;
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 55%, transparent) !important;
}

/*  Winner overlay  */
.bplay-winner-overlay[hidden] { display: none; }
.bplay-winner-overlay {
  position: absolute; inset: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  display: flex; align-items: center; justify-content: center; padding: 1.5rem;
}
.bplay-winner-screen { text-align: center; animation: bplay-pop .5s cubic-bezier(.34,1.56,.64,1) both; max-width: 100%; }
@keyframes bplay-pop { from { opacity: 0; transform: scale(.85); } to { opacity: 1; transform: scale(1); } }
.bplay-winner-title { font-size: 1.05rem; font-weight: 800; color: var(--white); margin-bottom: 1.5rem; letter-spacing: .02em; }
.bplay-winners-grid { display: flex; gap: 2.2rem; justify-content: center; flex-wrap: wrap; margin-bottom: 1.7rem; }
.bplay-winner-card { background: none; border: none; box-shadow: none; padding: 0; min-width: 0; text-align: center; position: relative; }
.bplay-winner-crown { font-size: 2rem; margin-bottom: -0.7rem; position: relative; z-index: 2; line-height: 1; filter: drop-shadow(0 3px 6px rgba(0,0,0,.45)); }
.bplay-winner-avatar { width: 90px; height: 90px; border-radius: 50%; overflow: hidden; margin: 0 auto 0.65rem; background: var(--secondary); display: flex; align-items: center; justify-content: center; font-size: 1.9rem; font-weight: 900; color: #fff; border: 3px solid color-mix(in srgb, var(--accent) 55%, transparent); }
.bplay-winner-avatar img { width: 100%; height: 100%; object-fit: cover; }
.bplay-winner-name { font-size: 1.02rem; font-weight: 800; color: var(--white); margin-bottom: 0.2rem; }
.bplay-winner-value { font-size: 0.95rem; font-weight: 900; color: hsl(40,90%,64%); }
.bplay-winner-actions { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; }
.bplay-recreate-btn { background: #22c55e; border: none; border-radius: 0.55rem; padding: 0.78rem 2rem; font-size: 0.88rem; font-weight: 800; color: #fff; cursor: pointer; transition: filter .15s, transform .1s; }
.bplay-recreate-btn:hover { filter: brightness(1.08); }
.bplay-recreate-btn:active { transform: scale(.97); }
.bplay-newbattle-btn { background: var(--secondary); border: 1px solid var(--border); border-radius: 0.55rem; padding: 0.6rem 1.6rem; font-size: 0.82rem; font-weight: 700; color: var(--white); cursor: pointer; transition: background .15s; }
.bplay-newbattle-btn:hover { background: var(--muted); }

/*  Items footer (pack summary)  */
.bplay-items-footer {
  display: flex; gap: 0.4rem; padding: 0.5rem 0.9rem; overflow-x: auto; flex-shrink: 0;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--border) 55%, transparent);
  scrollbar-width: none;
}
.bplay-items-footer:empty { display: none; }
.bplay-items-footer::-webkit-scrollbar { display: none; }

/*  Items footer — full grid of possible items (like the reference)  */
.bplay-items-footer {
  display: flex;
  justify-content: flex-start;
  gap: clamp(0.8rem, 1.45vw, 1.4rem);
  padding: 3.3rem clamp(1rem, 4vw, 6rem) 3.9rem;
  overflow-x: auto;
  overflow-y: hidden;
  max-height: none;
  min-height: 0;
  flex-shrink: 0;
  background:
    radial-gradient(900px 260px at 50% 45%, rgba(255,255,255,.035), transparent 70%),
    color-mix(in srgb, var(--bg) 94%, black);
  border-top: 0;
  border-bottom: 1px solid color-mix(in srgb, var(--border) 30%, transparent);
  scrollbar-width: none;
}
.bplay-items-footer:empty { display: none; }
.bplay-footer-item {
  position: relative;
  flex: 0 0 clamp(82px, 6.4vw, 122px);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; gap: 0.5rem;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  min-height: 0;
  transition: border-color .15s, transform .1s;
}
.bplay-footer-item:hover { transform: translateY(-2px); }
.bplay-footer-item .bplay-item-pct {
  position: absolute; top: 0.45rem; left: 0.55rem;
  font-size: 0.6rem; font-weight: 700; color: var(--muted-fg);
}
.bplay-footer-item .bplay-item-img {
  width: 100%; height: clamp(124px, 9.6vw, 184px);
  object-fit: cover; border-radius: 5px;
  filter: drop-shadow(0 7px 12px rgba(0,0,0,.45));
}
.bplay-item-info-name,
.bplay-footer-item .bplay-item-info-name {
  position: absolute; top: 1rem; left: 0.4rem; right: 0.4rem;
  font-size: clamp(0.58rem, 0.75vw, 0.9rem); font-weight: 900; color: var(--white);
  text-align: center; line-height: 1.08; max-width: none;
  overflow: hidden; text-overflow: ellipsis; white-space: normal;
  text-shadow: 0 2px 7px rgba(0,0,0,.75);
}
.bplay-footer-item .bplay-item-info-val { font-size: 0.72rem; font-weight: 900; color: var(--white); }

/* Total Cost chip (right side of top bar) */
.bplay-total-cost {
  grid-column: 3; grid-row: 2; justify-self: end;
  font-size: 0.78rem; color: var(--white); white-space: nowrap; flex-shrink: 0; margin-left: auto;
  padding: 0; border-radius: 0;
  background: transparent;
  border: 0;
}
.bplay-total-cost strong { color: hsl(40,90%,64%); font-weight: 900; }

@media (max-width: 900px) {
  .bplay-wrap { min-height: 520px; }
  .bplay-topbar { grid-template-columns: 1fr; justify-items: center; }
  .bplay-back { justify-self: start; }
  .bplay-actions { justify-self: center; }
  .bplay-arena { grid-template-columns: repeat(var(--bplay-slots, 2), minmax(96px, 1fr)); justify-content: center; overflow-x: auto; width: 100%; }
  .bplay-items-footer { padding-block: 2rem 2.3rem; }
}

@media (max-width: 560px) {
  .bplay-wrap { height: calc(100dvh - var(--mobile-nav-h, 56px)); min-height: 500px; }
  .bplay-topbar { padding: 0.45rem 0.65rem; gap: 0.45rem; }
  .bplay-meta { justify-content: flex-start; }
  .bplay-items-footer { padding-inline: 0.75rem; }
  .bplay-footer-item { flex-basis: 88px; }
}

/*  Battle vertical reel (pack-style spin inside each column)  */
.bplay-spin-window {
  width: 100%;
  height: 276px;            /* 3 cells (3 * 92) */
  margin-bottom: 10px;
  border-radius: 12px;
  overflow: hidden;
  background: transparent;      /* เอาพื้นหลังกล่อง reel ออก */
  border: 0;
  display: flex;
  position: relative;
}
.bplay-spin-window:empty { display: none; }   /* ก่อนหมุน: ซ่อน */
/* ลูกศรชี้แถวกลางที่ด้านข้าง — ซ้าย (►) ::before, ขวา (◄) ::after */
.bplay-spin-window::before,
.bplay-spin-window::after {
  content: ""; position: absolute; top: 50%; transform: translateY(-50%);
  width: 0; height: 0; z-index: 5;
  border-top: 8px solid transparent; border-bottom: 8px solid transparent;
}
.bplay-spin-window::before { left: 0;  border-left: 11px solid var(--primary); }
.bplay-spin-window::after  { right: 0; border-right: 11px solid var(--primary); }
.bplay-reel-window {
  position: relative;
  width: 100%;
  height: 276px;            /* 3 cells tall (3 * 92) */
  overflow: hidden;
  margin: auto 0;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
          mask-image: linear-gradient(180deg, transparent, #000 18%, #000 82%, transparent);
}
.bplay-reel-strip {
  display: flex; flex-direction: column; align-items: center;
  will-change: transform;
  transform: translateZ(0);
}
.bplay-reel-cell {
  height: 92px; flex: 0 0 92px;
  width: 100%; max-width: 130px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; opacity: .55;
  contain: layout paint;
}
.bplay-reel-cell .bplay-item-img { width: 46px; height: 46px; object-fit: contain; filter: none; transition: filter .25s; }
.bplay-reel-cell .bplay-item-name { font-size: 0.58rem; color: var(--muted-fg); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bplay-reel-cell .bplay-item-val { font-size: 0.66rem; font-weight: 900; color: var(--primary); }
.bplay-reel-cell.bplay-reel-won {
  opacity: 1;
  animation: bplayWonPop .45s cubic-bezier(.22,1,.36,1) both;
}
.bplay-reel-cell.bplay-reel-won .bplay-item-img {
  filter: drop-shadow(0 0 8px color-mix(in srgb, var(--primary) 75%, transparent));
}
.bplay-reel-cell.bplay-reel-won .bplay-item-val { color: var(--white); }
@keyframes bplayWonPop {
  0%   { transform: scale(1);    }
  55%  { transform: scale(1.16); }
  100% { transform: scale(1.08); }
}

/* ── Support chat widget ─────────────────────────────────────────────────── */
.support-widget { position: fixed; right: 20px; bottom: 20px; z-index: 1200; }
.support-toggle { position: relative; width: 56px; height: 56px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.45); transition: transform .15s; }
.support-toggle:hover { transform: translateY(-2px) scale(1.04); }
.support-ic-close { display: none; }
.support-widget.open .support-ic-open  { display: none; }
.support-widget.open .support-ic-close { display: block; }
.support-badge { position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 0.7rem; font-weight: 900; display: grid; place-items: center; border: 2px solid var(--bg); }
.support-badge[hidden] { display: none; }   /* กัน display:grid ทับ attribute hidden */
.support-panel { position: absolute; right: 0; bottom: 70px; width: 340px; max-width: calc(100vw - 32px); height: 460px; max-height: calc(100vh - 120px);
  background: var(--card); border: 1px solid color-mix(in srgb, var(--border) 60%, transparent); border-radius: 14px; overflow: hidden;
  display: flex; flex-direction: column; box-shadow: 0 16px 48px rgba(0,0,0,.5); animation: modal-in .2s ease; }
.support-panel[hidden] { display: none; }   /* สำคัญ: กัน display:flex ทับ hidden → toggle ปิดได้จริง */

/* Balance count up/down — เด้งเบาๆ ตอนเปลี่ยน ไม่เปลี่ยนสี (กันดูจาง) */
#navDepositBtn.balance-up   { animation: balPulse .4s ease; }
#navDepositBtn.balance-down { animation: balPulse .4s ease; }
@keyframes balPulse { 0%{ transform: scale(1);} 40%{ transform: scale(1.06);} 100%{ transform: scale(1);} }
.support-header { display: flex; align-items: center; justify-content: space-between; padding: 0.85rem 1rem; background: var(--accent); color: #fff; }
.support-header strong { font-size: 0.95rem; }
.support-sub { display: block; font-size: 0.7rem; opacity: .85; }
.support-close { background: none; border: 0; color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; }
.support-messages { flex: 1; overflow-y: auto; padding: 0.85rem; display: flex; flex-direction: column; gap: 0.5rem; }
.support-empty { color: var(--muted-fg); font-size: 0.82rem; text-align: center; margin: auto; }
.support-msg { max-width: 80%; padding: 0.5rem 0.7rem; border-radius: 12px; font-size: 0.85rem; line-height: 1.4; word-break: break-word; }
.support-msg.from-user  { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 4px; }
.support-msg.from-admin { align-self: flex-start; background: var(--secondary); color: var(--white); border-bottom-left-radius: 4px; }
.support-msg-img { display: block; max-width: 100%; border-radius: 8px; margin-bottom: 0.25rem; cursor: pointer; }
.support-msg-time { font-size: 0.62rem; opacity: .65; margin-top: 0.2rem; text-align: right; }
.support-preview { position: relative; padding: 0.5rem 0.85rem 0; }
.support-preview img { max-height: 70px; border-radius: 8px; }
.support-preview button { position: absolute; top: 2px; left: 64px; background: rgba(0,0,0,.7); color: #fff; border: 0; border-radius: 50%; width: 20px; height: 20px; cursor: pointer; }
.support-input-row { display: flex; align-items: center; gap: 0.35rem; padding: 0.6rem; border-top: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.support-text { flex: 1; min-width: 0; height: 38px; padding: 0 0.75rem; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  background: var(--secondary); color: var(--white); font-size: 0.85rem; outline: none; }
.support-icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--secondary); color: var(--white); display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.support-icon-btn.support-send { background: var(--accent); color: #fff; }
.support-icon-btn:hover { filter: brightness(1.1); }
@media (max-width: 480px) { .support-panel { width: calc(100vw - 24px); height: calc(100vh - 110px); } }
