/* แคตตาล็อกการ์ด — mobile-first (Boss สั่ง 18 ส.ค. 2026 "ปรับให้เหมาะกับโทรศัพเป็นหลัก")
   เขียนจากจอเล็กขึ้นไป: ค่าเริ่มต้น = มือถือ · @media (min-width) ค่อยขยายให้จอใหญ่
   🔴 ช่องค้นหาต้อง font-size ≥16px ไม่งั้น iOS Safari ซูมหน้าเองตอนแตะ */

.cat-head { margin: 4px 0 10px; }
.cat-head h1 { font-size: 22px; margin: 0; letter-spacing: -.01em; }
.cat-sub { margin: 2px 0 0; color: var(--muted); font-size: 14px; }

/* แถบค้นหาเกาะบนสุดตอนเลื่อน — มือถือใช้นิ้วเดียวค้นซ้ำได้ไม่ต้องเลื่อนกลับ
   🔴 top ต้องเป็นความสูงหัวเว็บจริง (--header-h จาก base.html) ไม่ใช่ 0 — ไม่งั้นไปเกาะทับหัวเว็บ
   ที่ก็ sticky top:0 เหมือนกัน (เจอจริง 27 ส.ค. 2026 หน้านี้) */
.cat-searchbar {
  position: sticky; top: var(--header-h, 56px); z-index: 5;
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); padding: 8px 0 6px; margin: 0 0 8px;
}
.cat-searchbar input {
  flex: 1; min-width: 0;
  font-size: 16px; padding: 13px 14px;
  border: 2px solid var(--ink); border-radius: 12px; background: var(--card);
  box-shadow: 3px 3px 0 var(--ink);
}
.cat-searchbar input:focus { outline: 3px solid var(--gold); outline-offset: 1px; }
.cat-searchbar button {
  flex: 0 0 auto; width: 44px; height: 44px;      /* 44px = ขนาดปุ่มขั้นต่ำที่นิ้วกดไม่พลาด */
  border: 2px solid var(--ink); border-radius: 12px;
  background: var(--card); font-size: 16px; cursor: pointer;
}

.cat-filters { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cat-chip {
  border: 2px solid var(--ink); border-radius: 999px; background: var(--card);
  padding: 8px 14px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.cat-chip.active { background: var(--accent); color: #fff; }
.cat-count { color: var(--muted); font-size: 13px; margin-left: auto; }

/* 2 คอลัมน์บนมือถือ → กว้างขึ้นค่อยเพิ่มเอง */
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 480px) { .cat-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; } }
@media (min-width: 760px) { .cat-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1000px) { .cat-grid { grid-template-columns: repeat(6, 1fr); } }

.ct {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 2px solid var(--ink); border-radius: 12px;
  overflow: hidden; box-shadow: 3px 3px 0 var(--ink);
}
.ct:active { transform: translate(1px, 1px); box-shadow: 2px 2px 0 var(--ink); }
.ct-img { position: relative; aspect-ratio: 5 / 7; background: var(--gold-soft); }
.ct-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ct-noimg { display: flex; align-items: center; justify-content: center; height: 100%; font-size: 34px; }
.ct-name { font-size: 13px; font-weight: 800; line-height: 1.25; padding: 7px 8px 0; }
.ct-meta { font-size: 12px; color: var(--muted); padding: 2px 8px 8px; }

.ct-price {
  position: absolute; left: 6px; bottom: 6px;
  background: var(--accent); color: #fff; font-weight: 900; font-size: 14px;
  padding: 3px 9px; border-radius: 999px; border: 2px solid var(--ink);
}
.ct-qty {
  position: absolute; right: 6px; top: 6px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 999px;
  font-size: 12px; font-weight: 800; padding: 2px 7px;
}

/* ปุ่ม + ใส่ตะกร้าบนรูปการ์ด (Boss สั่ง 25 ส.ค. 2026 — หน้าการ์ดทั้งเซ็ตเดิมกดสั่งไม่ได้เลย)
   44px = ขนาดต่ำสุดที่นิ้วกดไม่พลาด · มุมขวาล่าง ไม่ทับป้ายราคา (ซ้ายล่าง) และป้ายจำนวน (ขวาบน) */
.ct-add {
  position: absolute; right: 6px; bottom: 6px;
  width: 44px; height: 44px; border-radius: 999px;
  border: 2px solid var(--ink); background: var(--card); color: var(--ink);
  font-size: 24px; font-weight: 900; line-height: 1; cursor: pointer; padding: 0;
  box-shadow: 2px 2px 0 var(--ink); display: flex; align-items: center; justify-content: center;
}
.ct-add:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.ct.incart .ct-add { background: var(--accent); color: #fff; }
/* ตัวเลขบอกว่าใบนี้อยู่ในตะกร้ากี่ใบแล้ว — ลอยเหนือปุ่ม + */
.ct-incart {
  position: absolute; right: 2px; bottom: 42px;
  min-width: 22px; height: 22px; padding: 0 5px; border-radius: 999px;
  background: var(--solid); color: #fff; font-size: 12px; font-weight: 900;
  display: flex; align-items: center; justify-content: center; border: 2px solid var(--card);
}
.ct.incart { border-color: var(--accent); }

/* แผ่นรายละเอียด: แต่ละแบบพิมพ์เป็นแถวของตัวเอง (ลิงก์ + ปุ่มนับจำนวน) */
.sheet-row { display: flex; gap: 8px; align-items: stretch; margin-top: 8px; flex-wrap: wrap; }
.sheet-row .sheet-buy { flex: 1 1 190px; margin-top: 0; }
.sheet-row .stepper {
  flex: 0 0 132px; border: 2px solid var(--ink); border-radius: 12px;
  box-shadow: 3px 3px 0 var(--ink); overflow: hidden;
}
.sheet-cart {
  display: block; text-align: center; text-decoration: none; margin-top: 12px;
  border: 2px solid var(--solid); border-radius: 12px; padding: 13px 12px;
  background: var(--solid); color: #fff; font-weight: 900; font-size: 15px;
  box-shadow: 3px 3px 0 var(--accent);
}

/* ของที่ยังไม่มี — รูปเทา + คาดป้าย (Boss: "ทำเป็นรูปเทาๆ แล้วคาดที่รูปว่าหมด จะมาเร็วๆ นี้") */
.ct.out { opacity: .92; }
.ct.out .ct-img img { filter: grayscale(1) contrast(.85) brightness(1.05); }
.ct.out .ct-name, .ct.out .ct-meta { color: var(--muted); }
.ct-soon {
  position: absolute; left: 0; right: 0; top: 50%;
  transform: translateY(-50%) rotate(-8deg);
  background: rgba(28, 21, 18, .82); color: #fff;
  /* 12px ขั้นต่ำ — 11px เล็กเกินอ่านบนมือถือ (ตัวตรวจหน้าจอจับได้ 24 ส.ค. 2026
     โผล่เฉพาะรอบที่มีของหมดจริง เลยไม่เคยเจอมาก่อน) */
  font-size: 12px; font-weight: 800; text-align: center;
  padding: 5px 2px; letter-spacing: .02em;
  border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink);
}

/* ตัวกรอง (เซ็ต/โดเมน/เรียง) — บนมือถือให้เลื่อนแนวนอนแทนที่จะตกบรรทัดจนสูง */
.cat-filters select {
  border: 2px solid var(--ink); border-radius: 999px; background: var(--card);
  padding: 8px 12px; font-size: 14px; font-weight: 700; max-width: 42vw;
}

/* แผ่นรายละเอียดการ์ด — มือถือเลื่อนขึ้นจากล่าง · จอใหญ่ลอยกลางจอ */
.sheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; }
.sheet[hidden] { display: none; }
.sheet-bg { position: absolute; inset: 0; background: rgba(20, 14, 12, .55); }
.sheet-box {
  position: relative; width: 100%; max-height: 92vh; overflow-y: auto;
  background: var(--card); border-top: 3px solid var(--ink);
  border-radius: 18px 18px 0 0; padding: 18px 16px 28px;
  animation: sheet-up .18s ease-out;
}
@keyframes sheet-up { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet-box { animation: none; } }
@media (min-width: 720px) {
  .sheet { align-items: center; justify-content: center; }
  .sheet-box { max-width: 420px; border: 3px solid var(--ink); border-radius: 18px; }
}
.sheet-close {
  position: absolute; right: 12px; top: 12px; width: 40px; height: 40px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--card);
  font-size: 16px; cursor: pointer;
}
.sheet-img {
  display: block; width: 62%; max-width: 240px; margin: 4px auto 12px;
  border-radius: 10px; border: 2px solid var(--ink);
}
.sheet-box h2 { font-size: 19px; margin: 0; text-align: center; }
.sheet-code { text-align: center; color: var(--muted); font-size: 13px; margin: 2px 0 0; }
.sheet-stat { text-align: center; font-size: 13px; color: var(--muted); margin: 6px 0 10px; }
.sheet-effect {
  font-size: 13.5px; line-height: 1.5; background: var(--gold-soft);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px;
}
.sheet-buy, .sheet-ask {
  display: block; text-align: center; text-decoration: none;
  border: 2px solid var(--ink); border-radius: 12px; padding: 13px 12px; margin-top: 8px;
  font-weight: 800; font-size: 15px; box-shadow: 3px 3px 0 var(--ink);
}
.sheet-buy { background: var(--accent); color: #fff; }
.sheet-ask { background: #06c755; color: #fff; }
.sheet-out { text-align: center; color: var(--muted); font-size: 14px; margin: 6px 0 0; }

/* ══════ ตัวกรองแบบกะทัดรัด + ปุ่ม −/+ และปุ่มซื้อ (Boss สั่ง 18 ส.ค. 14:39 · ย่อลงอีก 15:02) ══════
   พับเก็บเป็นค่าตั้งต้น · แต่ละหมวดเป็นแถวเดียวเลื่อนแนวนอน ไม่ตกบรรทัดจนดันสินค้าตกจอ */
.filt {
  border: 2px solid var(--ink); border-radius: 12px; background: var(--card);
  padding: 0 10px; margin: 0 0 10px; box-shadow: 3px 3px 0 var(--ink);
}
.filt > summary {
  cursor: pointer; font-weight: 800; font-size: 13px; padding: 9px 2px; list-style: none;
  display: flex; align-items: center; gap: 6px;
}
.filt > summary::-webkit-details-marker { display: none; }
.filt > summary::before { content: "⚙️"; font-size: 12px; }
.filt[open] > summary::after { content: "▲"; margin-left: auto; font-size: 10px; }
.filt:not([open]) > summary::after { content: "▼"; margin-left: auto; font-size: 10px; }
.filt-n { font-weight: 600; font-size: 12px; color: var(--muted); }
.filt-rows { padding-bottom: 8px; }
/* หัวข้อเล็กเหนือแต่ละแถวตัวกรอง (Boss ลอกสไตล์จาก riftbound.gg 28 ส.ค. 2026 — ชุดการ์ด/สี/ต้นทุน/...) */
.filt-label {
  margin: 8px 0 2px; font-size: 10px; font-weight: 800; letter-spacing: .04em;
  color: var(--muted); text-transform: uppercase;
}
.filt-label:first-of-type { margin-top: 2px; }
.filt-row {
  display: flex; gap: 5px; padding: 4px 0;
  overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.filt-row::-webkit-scrollbar { display: none; }
.fchip {
  flex: 0 0 auto;
  border: 1.5px solid var(--ink); border-radius: 999px; background: var(--card);
  padding: 5px 10px; font-size: 12px; font-weight: 700; cursor: pointer; line-height: 1.5;
  min-width: 40px; text-align: center;
  /* 🔴 ชิปตัวเลขต้นทุน (แค่ "0","1"...) แคบกว่านิ้วกดพอดี — ui_audit.py เจอ 27 ส.ค. 2026 */
}
.fchip.active { background: var(--accent); color: #fff; }
.fchip.reset { border-style: dashed; font-weight: 600; color: var(--muted); }
#f-sort {
  flex: 0 0 auto;
  border: 1.5px solid var(--ink); border-radius: 999px; background: var(--card);
  padding: 5px 8px; font-size: 12px; font-weight: 700;
}
/* สีประจำโดเมน — แตะรู้ทันทีว่ากดสีอะไรอยู่ (ตอน active พื้นทึบ) */
.fchip.dom { border-width: 2px; }
.fchip.dom-fury { border-color: #d1451f; }   .fchip.dom-fury.active { background: #d1451f; }
.fchip.dom-calm { border-color: #2f8f5b; }   .fchip.dom-calm.active { background: #2f8f5b; }
.fchip.dom-mind { border-color: #2c6fbb; }   .fchip.dom-mind.active { background: #2c6fbb; }
.fchip.dom-body { border-color: #b5852a; }   .fchip.dom-body.active { background: #b5852a; }
.fchip.dom-chaos { border-color: #7a3fa8; }  .fchip.dom-chaos.active { background: #7a3fa8; }
.fchip.dom-order { border-color: #3a3a3a; }  .fchip.dom-order.active { background: #3a3a3a; }

/* การ์ดหน้าแรก: ลิงก์ส่วนบน + แถวซื้อด้านล่าง (กดปุ่มซื้อ/บวกลบแล้วต้องไม่เด้งเข้าหน้าสินค้า) */
/* overflow:hidden — ปุ่มซื้อสีดำมุมเหลี่ยมเคยโผล่พ้นมุมโค้งของการ์ด เห็นชัดบนมือถือ */
.shop-card { display: flex; flex-direction: column; overflow: hidden; }
.shop-card .card-link { display: flex; flex-direction: column; flex: 1; text-decoration: none; color: inherit; }
.shop-card .card-body { padding: 8px 9px 9px; gap: 4px; }
.shop-card .card-title { font-size: 13px; line-height: 1.3; }
/* จำนวนคงเหลืออยู่แถวเดียวกับราคา ไม่ทับรูปการ์ด */
.card-meta-row { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin-top: auto; }
.card-meta-row .card-price { margin: 0; font-size: 17px; }
.card-stock {
  font-size: 12px; font-weight: 700; color: var(--muted);   /* ต่ำกว่า 12px อ่านไม่ออกบนมือถือ */
  background: var(--gold-soft); border-radius: 999px; padding: 2px 7px; white-space: nowrap;
}

/* 🔴 แถวซื้อบนการ์ด — วัดจากเบราว์เซอร์จริง 19 ส.ค. 2026: บนจอ 320–390px การ์ด 2 คอลัมน์
   กว้างแค่ ~140px แต่แถวนี้ต้องใช้ ~158px → ปุ่ม −/+ ถูกบีบเหลือ 29–34px (นิ้วโป้งกดพลาด)
   แก้ด้วยการ **ขึ้นบรรทัดใหม่** เมื่อที่ไม่พอ: แถวจำนวนเต็มความกว้าง / ปุ่มซื้อเต็มความกว้าง */
.buyrow { display: flex; flex-wrap: wrap; gap: 0; border-top: 2px solid var(--ink); }
.stepper {
  display: flex; align-items: center; justify-content: space-between;
  flex: 1 1 132px; min-width: 0; background: var(--gold-soft);
}
.stepper button {
  flex: 0 0 44px; width: 44px; height: 44px;  /* ≥44px = มาตรฐานปุ่มที่นิ้วกดไม่พลาด */
  border: none; background: transparent; font-size: 20px; font-weight: 900;
  cursor: pointer; color: var(--ink); line-height: 1;
}
.stepper button:active:not(:disabled) { background: rgba(0, 0, 0, .08); }
.stepper button:disabled { opacity: .25; cursor: not-allowed; }   /* ครบจำนวนแล้ว + กดไม่ได้ */
.stepper .st-n { flex: 1 1 auto; font-weight: 900; font-size: 15px; min-width: 20px; text-align: center; }
.stepper.has { background: var(--accent); }
.stepper.has button, .stepper.has .st-n { color: #fff; }
.stepper.has button:disabled { color: rgba(255, 255, 255, .5); }

.btn-buy {
  flex: 1 0 auto; padding: 0 14px; height: 44px;
  border: none; border-left: 2px solid var(--solid);
  background: var(--solid); color: #fff; font-size: 14px; font-weight: 900; cursor: pointer;
}
/* พอปุ่มซื้อตกลงมาอยู่บรรทัดล่าง เส้นคั่นต้องเป็นเส้นบน ไม่ใช่เส้นซ้าย (ไม่งั้นเห็นขีดลอยๆ) */
.buyrow > .btn-buy:not(:first-child) { border-left: none; }
@media (max-width: 430px) {
  .buyrow > .btn-buy { flex: 1 0 100%; border-left: none; border-top: 2px solid var(--ink); }
}
.btn-buy:active { background: var(--accent); }

/* หน้าตะกร้า/ชำระเงิน — ต้องมีรูปเหมือนหน้าแรก (Boss ทัก 15:15 "หน้าตะกร้าไม่มีรูป รูปไม่ไป")
   การ์ดเป็นสี่เหลี่ยมผืนผ้า 5:7 ถ้า crop เป็นจัตุรัสจะโดนตัดหัว-ท้าย → ใช้ contain */
.cart-row .cart-art {
  width: 58px; height: 80px; object-fit: contain;
  background: var(--gold-soft); border: 1px solid var(--line); border-radius: 8px; padding: 2px;
}
.cart-stepper {
  display: inline-flex; align-items: center; margin-top: 6px;
  border: 1.5px solid var(--ink); border-radius: 999px; background: var(--gold-soft); overflow: hidden;
}
.cart-stepper button { width: 44px; height: 44px; font-size: 18px; }   /* หน้าตะกร้าก็ต้องกดง่ายเท่าหน้าแรก */
.cart-stepper .st-n { font-size: 14px; }

.co-list { display: grid; gap: 8px; margin: 0 0 14px; max-width: 480px; }
.co-item {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 10px; padding: 8px 10px;
}
.co-item img {
  width: 34px; height: 48px; object-fit: contain; border-radius: 5px; background: var(--gold-soft);
}
.co-noimg { width: 34px; text-align: center; font-size: 20px; }
.co-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 700; line-height: 1.3; }
.co-qty { font-size: 13px; color: var(--muted); font-weight: 800; }
.co-sum { font-size: 14px; font-weight: 900; color: var(--accent); white-space: nowrap; }

/* หน้า "ฝากขายกับเรา" — อ่านบนมือถือเป็นหลัก (การ์ดเรียงเดี่ยว จอใหญ่ค่อยแตกเป็น 2 คอลัมน์) */
.cs-grid { display: grid; gap: 12px; margin: 16px 0; }
.cs-box {
  background: var(--card); border: 2px solid var(--ink); border-radius: 12px;
  padding: 14px 16px; box-shadow: 3px 3px 0 var(--ink);
}
.cs-box h2 { font-size: 17px; margin: 0 0 6px; }
.cs-box p { margin: 6px 0; font-size: 14px; line-height: 1.55; }
.cs-box ul { margin: 6px 0 0 18px; padding: 0; font-size: 14px; line-height: 1.7; }
.cs-steps { margin: 10px 0 0 20px; padding: 0; font-size: 15px; line-height: 1.9; }
.cs-steps li { margin-bottom: 2px; }
@media (min-width: 760px) { .cs-grid { grid-template-columns: 1fr 1fr; } }

/* แถบสรุปตะกร้าลอยล่างจอ */
.buybar {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60;
  display: flex; align-items: center; gap: 10px;
  background: var(--accent); color: #fff; text-decoration: none;
  border: 2px solid var(--ink); border-radius: 14px; padding: 12px 16px;
  box-shadow: 4px 4px 0 var(--ink); font-weight: 800;
}
.buybar[hidden] { display: none; }
.buybar b { font-size: 18px; }
.buybar-go { margin-left: auto; font-size: 14px; }
body.has-buybar { padding-bottom: 74px; }
@media (min-width: 720px) { .buybar { left: auto; right: 24px; min-width: 320px; } }

#more-wrap { display: flex; justify-content: center; padding: 18px 0 4px; }
#more {
  border: 2px solid var(--ink); border-radius: 12px; background: var(--card);
  padding: 12px 22px; font-size: 15px; font-weight: 800; cursor: pointer;
  box-shadow: 3px 3px 0 var(--ink);
}
.cat-status { text-align: center; color: var(--muted); font-size: 14px; padding: 8px 0 24px; }

/* ══════════ หน้าเช็คเด็ค (/deck) — Boss สั่ง 19 ส.ค. 2026 ══════════
   ลูกค้าวางลิสต์จาก riftbound.gg → บอกว่ามี/ขาดกี่ใบ/รวมเงิน
   ออกแบบจากมือถือก่อน: แถวละใบ อ่านจบในบรรทัดเดียว ไม่ใช่ตารางเลื่อนซ้ายขวา */
.dk-form textarea {
  width: 100%; font-size: 16px; font-family: ui-monospace, "Cascadia Mono", monospace;
  border: 2px solid var(--ink); border-radius: 12px; padding: 12px; line-height: 1.5;
}
.dk-hint { font-size: 13px; color: var(--muted); margin: 6px 0 10px; }
.dk-sum {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--gold-soft); border: 2px solid var(--ink); border-radius: 12px;
  padding: 12px 16px; margin: 16px 0 6px; box-shadow: 3px 3px 0 var(--ink);
}
.dk-sum-n { font-size: 26px; font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; }
.dk-sum-l { font-size: 13px; font-weight: 700; color: var(--muted); }
.dk-sum-miss { font-size: 14px; font-weight: 800; color: var(--err); }

.dk-rows { display: grid; gap: 8px; }
.dk-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 2px solid var(--ink); border-radius: 12px; padding: 8px 10px;
}
.dk-row.dk-none { opacity: .72; }
.dk-img { flex: 0 0 auto; width: 40px; height: 56px; }
.dk-img img { width: 100%; height: 100%; object-fit: contain; border-radius: 5px; background: var(--gold-soft); }
.dk-row.dk-none .dk-img img { filter: grayscale(1); }
.dk-noimg { font-size: 22px; }
.dk-mid { flex: 1 1 auto; min-width: 0; }
.dk-name { font-weight: 800; font-size: 14px; line-height: 1.25; }
.dk-code { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.dk-qty { font-size: 13px; margin-top: 2px; }
.dk-qty .dk-short { color: var(--err); }
.dk-right { flex: 0 0 auto; text-align: right; }
.dk-tag { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px; border: 1.5px solid currentColor; }
.dk-tag-ok { color: var(--ok); }
.dk-tag-part { color: var(--warn); }
.dk-tag-out { color: var(--err); }
.dk-cost { font-weight: 900; font-size: 15px; font-variant-numeric: tabular-nums; margin-top: 3px; }
.dk-unit { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
