/* ============================================
   GameID Vault — Design Tokens
   Palette: deep indigo backdrop, gold "premium
   pass" accent, teal confirm accent.
   Signature element: perforated ticket-style
   product cards (a digital game ID = a pass).
============================================ */

:root {
  --bg-deep: #06070D;
  --bg-panel: #0E1220;
  --bg-panel-raised: #161B30;
  --line: #232A45;
  --gold: #2FB5FF;
  --gold-dim: #1978B8;
  --teal: #4CE0D2;
  --text-hi: #F2F6FF;
  --text-mid: #9FB0D9;
  --text-low: #5C6690;
  --danger: #FF5C7A;

  --font-display: 'Kanit', sans-serif;
  --font-body: 'Sarabun', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 14px;
  --shadow-card: 0 8px 28px rgba(0,0,0,0.5);
  --glow: 0 0 20px rgba(47,181,255,0.35);
}

* { box-sizing: border-box; }

#terminalBg {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  opacity: 0.55; mix-blend-mode: screen;
}
#terminalBg canvas { display: block; width: 100%; height: 100%; }
@media (max-width: 640px) {
  #terminalBg { opacity: 0.32; } /* เบาลงบนมือถือ กันกินแบตเตอรี่/ตัวหนังสือชนกัน */
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text-hi);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(circle at 10% -5%, rgba(47,181,255,0.14), transparent 40%),
    radial-gradient(circle at 95% 5%, rgba(76,224,210,0.10), transparent 35%),
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 1px, transparent 1px);
  background-size: auto, auto, 40px 40px, 40px 40px;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(20,16,43,0.9);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; gap: 20px;
  padding: 14px 20px; max-width: 1180px; margin: 0 auto; flex-wrap: wrap;
}
.brand {
  font-family: var(--font-display); font-weight: 600; font-size: 1.35rem;
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
}
.brand .logo-mark {
  width: 44px; height: 44px; border-radius: 0;
  background: transparent; box-shadow: none; overflow: visible;
  display: flex; align-items: center; justify-content: center;
  animation: logoWobble 4.2s ease-in-out infinite;
}
.brand .logo-mark img {
  width: 100%; height: 100%; object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(47,181,255,0.55));
  transition: transform 0.3s ease;
}
.brand:hover .logo-mark img { transform: scale(1.1) rotate(-5deg); }
@keyframes logoWobble {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-3px) rotate(-3deg); }
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-links a { position: relative; padding: 8px 12px; border-radius: 8px; font-size: 0.9rem; color: var(--text-mid); font-weight: 500; transition: color 0.15s ease; }
.nav-links a::after {
  content: ''; position: absolute; left: 12px; right: 12px; bottom: 5px; height: 1.5px;
  background: linear-gradient(90deg, var(--gold), var(--teal)); transform: scaleX(0); transform-origin: left;
  transition: transform 0.22s ease;
}
.nav-links a:hover { color: var(--gold); background: rgba(47,181,255,0.08); }
.nav-links a:hover::after { transform: scaleX(1); }
@media (max-width: 900px) { .nav-links { display: none; } }

.search-wrap { flex: 1; position: relative; max-width: 480px; min-width: 180px; }
.search-wrap input {
  width: 100%; padding: 10px 14px 10px 38px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-panel); color: var(--text-hi); font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.search-wrap input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(47,181,255,0.18); }
.search-wrap svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  color: var(--text-low); width: 16px; height: 16px;
}

.nav-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex-wrap: wrap; }
.btn {
  padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--text-hi); font-size: 0.9rem; font-weight: 500;
  transition: all 0.15s ease; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--gold); color: var(--gold); }
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dim));
  color: #04121E; border: none; font-weight: 700; position: relative; overflow: hidden;
}
.btn-gold::before {
  content: ''; position: absolute; top: 0; left: -60%; width: 40%; height: 100%;
  background: linear-gradient(115deg, transparent, rgba(255,255,255,0.55), transparent);
  transform: skewX(-20deg); transition: left 0.5s ease;
}
.btn-gold:hover::before { left: 130%; }
.btn-gold:hover { filter: brightness(1.08); color: #04121E; }
.btn-ghost { border-color: transparent; color: var(--text-mid); cursor: default; }
.btn-ghost:hover { color: var(--text-mid); border-color: transparent; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); color: var(--text-hi); }

/* ---------- Hero ---------- */
.hero { padding: 56px 0 28px; text-align: center; }
.hero-eyebrow {
  font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--teal); margin-bottom: 14px;
}
.hero h1 {
  font-family: var(--font-display); font-size: clamp(2rem, 5vw, 3.1rem);
  font-weight: 600; line-height: 1.15; margin: 0 0 14px;
}
.hero p { color: var(--text-mid); max-width: 560px; margin: 0 auto; font-size: 1.05rem; }

/* ---------- Category tabs ---------- */
.tabs { display: flex; gap: 10px; overflow-x: auto; padding: 24px 0 8px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0; padding: 9px 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-panel); color: var(--text-mid); font-size: 0.9rem; font-weight: 500;
  white-space: nowrap; transition: all 0.15s ease;
}
.tab.active, .tab:hover { background: var(--gold); color: #04121E; border-color: var(--gold); font-weight: 700; }

/* ---------- Product grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 20px; padding: 20px 0 60px; }

.ticket {
  position: relative; background: var(--bg-panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card);
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease; display: flex; flex-direction: column;
}
.ticket:hover { transform: translateY(-4px); border-color: var(--gold-dim); box-shadow: var(--shadow-card), var(--glow); }

/* ---------- Hero banner (signature element) ---------- */
.hero-banner {
  position: relative;
  margin: 24px 0 8px;
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 20% 30%, rgba(47,181,255,0.25), transparent 55%),
    radial-gradient(circle at 80% 70%, rgba(76,224,210,0.18), transparent 55%),
    linear-gradient(135deg, #0A0F1E, #050810);
  padding: 64px 32px;
  text-align: center;
}
.hero-banner::before, .hero-banner::after {
  content: '';
  position: absolute; top: 0; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(47,181,255,0.5), transparent);
}
.hero-banner::before { left: 12%; }
.hero-banner::after { right: 12%; }
.hero-wordmark {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.6rem, 8vw, 4.6rem);
  letter-spacing: 0.02em;
  margin: 0;
  color: var(--text-hi);
  text-shadow: 0 0 12px rgba(47,181,255,0.6), 0 0 40px rgba(47,181,255,0.35);
}
.hero-wordmark span { color: var(--gold); }
.hero-banner .hero-sub {
  font-family: var(--font-mono); font-size: 0.8rem; letter-spacing: 0.22em;
  text-transform: uppercase; color: var(--teal); margin-top: 14px;
}
.hero-corner {
  position: absolute; font-family: var(--font-mono); color: var(--gold-dim); font-size: 1.1rem; opacity: 0.6;
}
.hero-corner.tl { top: 18px; left: 22px; }
.hero-corner.tr { top: 18px; right: 22px; transform: scaleX(-1); }
.hero-corner.bl { bottom: 18px; left: 22px; transform: scaleY(-1); }
.hero-corner.br { bottom: 18px; right: 22px; transform: scale(-1); }

/* Category preview banners */
.cat-banners { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 28px 0; }
.cat-banner {
  position: relative; border-radius: var(--radius); border: 1px solid var(--line);
  padding: 28px 20px; overflow: hidden; min-height: 110px; display: flex; align-items: center; gap: 14px;
  background: linear-gradient(135deg, var(--bg-panel-raised), var(--bg-panel));
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.2s ease;
}
.cat-banner:hover { border-color: var(--gold-dim); box-shadow: var(--glow); transform: translateY(-3px); }
.cat-banner .cat-icon {
  width: 46px; height: 46px; border-radius: 12px; flex-shrink: 0; overflow: hidden;
  background: linear-gradient(135deg, var(--gold), var(--teal));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 700; color: #04121E; font-size: 1.2rem;
  box-shadow: 0 0 18px rgba(47,181,255,0.4);
  transition: transform 0.3s ease;
}
.cat-banner:hover .cat-icon { transform: rotate(-6deg) scale(1.08); }
.cat-banner .cat-icon img { width: 100%; height: 100%; object-fit: cover; }
.cat-banner .cat-name { font-family: var(--font-display); font-weight: 600; font-size: 1.15rem; }
.cat-banner .cat-count { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-low); margin-top: 2px; }

/* ---------- Hero floating particles ---------- */
.hero-particles { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.hero-particles .p {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: var(--teal); box-shadow: 0 0 8px 2px rgba(76,224,210,0.7);
  animation: floatUp linear infinite;
}
@keyframes floatUp {
  0% { transform: translateY(20px) translateX(0); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-220px) translateX(var(--drift, 20px)); opacity: 0; }
}
.p0 { left: 6%;  bottom: 0; animation-duration: 7s;  animation-delay: 0s;   --drift: 10px; }
.p1 { left: 16%; bottom: 0; animation-duration: 9s;  animation-delay: 1.2s; --drift: -14px; background: var(--gold); box-shadow: 0 0 8px 2px rgba(47,181,255,0.7); }
.p2 { left: 28%; bottom: 0; animation-duration: 6s;  animation-delay: 2.4s; --drift: 18px; }
.p3 { left: 42%; bottom: 0; animation-duration: 8s;  animation-delay: 0.6s; --drift: -8px; background: var(--gold); box-shadow: 0 0 8px 2px rgba(47,181,255,0.7); }
.p4 { left: 58%; bottom: 0; animation-duration: 7.5s;animation-delay: 3s;   --drift: 12px; }
.p5 { left: 74%; bottom: 0; animation-duration: 9.5s;animation-delay: 1.8s; --drift: -16px; background: var(--gold); box-shadow: 0 0 8px 2px rgba(47,181,255,0.7); }
.p6 { left: 88%; bottom: 0; animation-duration: 6.5s;animation-delay: 2.9s; --drift: 6px; }

/* ---------- Card 3D tilt + button ripple ---------- */
.grid { perspective: 1200px; }
.ticket { will-change: transform; }
.ticket.tilting { transition: none; }

.btn, .btn-gold, .ticket-buy-btn { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%; transform: scale(0);
  background: rgba(255,255,255,0.5); animation: rippleAnim 0.55s ease-out;
  pointer-events: none;
}
@keyframes rippleAnim { to { transform: scale(3); opacity: 0; } }

.ticket-media {
  position: relative; aspect-ratio: 4/3;
  background: linear-gradient(135deg, var(--bg-panel-raised), var(--bg-panel));
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display); font-size: 1.1rem; color: var(--text-low); overflow: hidden;
}
.ticket-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.35s ease; }
.ticket:hover .ticket-media img { transform: scale(1.06); }
.ticket-media-empty { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
/* eFootball stock: cover image ratio 390x550 (portrait) */
.ticket[data-game="efootball"] .ticket-media { aspect-ratio: 390 / 550; }

/* Shine sweep across the card image on hover */
.ticket-shine {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(115deg, transparent 40%, rgba(255,255,255,0.35) 50%, transparent 60%);
  transform: translateX(-120%); transition: transform 0.7s ease;
}
.ticket:hover .ticket-shine { transform: translateX(120%); }

.ticket-flags-tl, .ticket-flags-tr {
  position: absolute; top: 10px; z-index: 2; display: flex; flex-direction: column; gap: 6px;
}
.ticket-flags-tl { left: 10px; align-items: flex-start; }
.ticket-flags-tr { right: 10px; align-items: flex-end; }

.ticket-badge {
  background: rgba(20,16,43,0.85);
  border: 1px solid var(--line); color: var(--teal); font-family: var(--font-mono);
  font-size: 0.7rem; padding: 3px 9px; border-radius: 999px; letter-spacing: 0.04em;
}
.ticket-status {
  font-family: var(--font-mono); font-size: 0.68rem;
  padding: 3px 9px; border-radius: 999px; background: rgba(45,212,191,0.15); color: var(--teal);
  border: 1px solid rgba(45,212,191,0.4);
}
.ticket-status.sold { background: rgba(240,87,107,0.15); color: var(--danger); border-color: rgba(240,87,107,0.4); }

.ticket-ribbon {
  position: absolute; bottom: 10px; left: 10px; z-index: 2;
  background: rgba(47,181,255,0.9); color: #04121E;
  font-size: 0.68rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  font-family: var(--font-mono);
}

.ticket-flag {
  font-size: 0.68rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  font-family: var(--font-mono); letter-spacing: 0.02em; white-space: nowrap;
}
.flag-hot {
  background: linear-gradient(135deg,#ff5c39,#ff2f6b); color: #fff;
  box-shadow: 0 0 12px rgba(255,60,80,0.55); animation: flagPulse 1.7s ease-in-out infinite;
}
.flag-premium {
  background: linear-gradient(120deg,#a855f7,#f5c451,#a855f7); background-size: 220% 100%;
  color: #1a0e2e; box-shadow: 0 0 12px rgba(168,85,247,0.5); animation: flagShimmerBg 2.6s ease infinite;
}
.flag-sale {
  background: linear-gradient(135deg,#22c55e,#0ea5a0); color: #04241c;
  box-shadow: 0 0 12px rgba(34,197,94,0.45);
}
@keyframes flagPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
@keyframes flagShimmerBg { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }

.ticket-highlights { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 3px; }
.ticket-highlights li {
  font-size: 0.78rem; color: var(--text-mid); line-height: 1.4;
  padding-left: 14px; position: relative;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ticket-highlights li::before { content: '・'; position: absolute; left: 0; color: var(--teal); }

.ticket-footer { margin-top: auto; }
.ticket-stock-row {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-low);
  padding-top: 8px; border-top: 1px dashed var(--line); margin-top: 4px;
}
.ticket-stock-row .sold-count { color: var(--teal); }

.ticket-buy-btn {
  margin-top: 10px; width: 100%; padding: 9px; border-radius: 8px; text-align: center;
  background: linear-gradient(135deg, var(--gold), var(--gold-dim)); color: #04121E;
  font-weight: 700; font-size: 0.88rem; border: none;
}
.ticket-buy-btn:hover { filter: brightness(1.06); }
.ticket-buy-btn.disabled { background: var(--bg-panel-raised); color: var(--text-low); }

.perforation { position: relative; height: 0; border-top: 2px dashed var(--line); margin: 0 14px; }
.perforation::before, .perforation::after {
  content: ''; position: absolute; top: -8px; width: 16px; height: 16px;
  background: var(--bg-deep); border-radius: 50%;
}
.perforation::before { left: -22px; }
.perforation::after { right: -22px; }

.ticket-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.ticket-title { font-weight: 600; font-size: 1rem; line-height: 1.3; }
.ticket-meta { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-low); }

.ticket-price-panel {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(47,181,255,0.1), rgba(76,224,210,0.05));
  border: 1px solid rgba(47,181,255,0.25); border-radius: 10px; padding: 8px 12px;
}
.amount-orig { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-low); text-decoration: line-through; }
.ticket-price-panel .amount {
  font-family: var(--font-mono); font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em;
  background: linear-gradient(100deg, var(--gold) 30%, #fff 50%, var(--gold) 70%);
  background-size: 220% auto; background-clip: text; -webkit-background-clip: text; color: transparent;
  animation: priceShine 3.5s linear infinite;
  filter: drop-shadow(0 0 10px rgba(47,181,255,0.35));
}
.ticket-price-panel .amount small {
  font-size: 0.62rem; color: var(--text-low); font-weight: 500; -webkit-text-fill-color: var(--text-low); margin-left: 2px;
}
@keyframes priceShine { 0% { background-position: 0% center; } 100% { background-position: 220% center; } }

.ticket-trust {
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-size: 0.68rem; color: var(--text-low); font-family: var(--font-mono);
}
.ticket-trust span { display: flex; align-items: center; gap: 3px; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-low); grid-column: 1 / -1; }
.empty-state h3 { font-family: var(--font-display); color: var(--text-hi); margin-bottom: 8px; }

/* ---------- Product detail ---------- */
.detail-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; padding: 20px 0 80px; }
@media (max-width: 860px) { .detail-wrap { grid-template-columns: 1fr; gap: 24px; } }
.detail-media {
  aspect-ratio: 4/3; background: linear-gradient(135deg, var(--bg-panel-raised), var(--bg-panel));
  border-radius: var(--radius); border: 1px solid var(--line); display: flex; align-items: center;
  justify-content: center; overflow: hidden; font-family: var(--font-display); font-size: 1.4rem; color: var(--text-low);
}
.detail-media img { width: 100%; height: 100%; object-fit: contain; transition: opacity 0.15s ease, transform 0.15s ease; }
.detail-media img.swap { opacity: 0; transform: scale(0.98); }
/* eFootball stock: main image ratio 390x550 (portrait) */
.detail-wrap[data-game="efootball"] .detail-media { aspect-ratio: 390 / 550; max-width: 390px; margin: 0 auto; }
.detail-gallery { display: flex; gap: 10px; margin-top: 10px; overflow-x: auto; }
.detail-gallery img {
  width: 72px; height: 72px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--line); cursor: pointer; flex-shrink: 0; transition: border-color 0.15s ease, transform 0.15s ease;
}
.detail-gallery img:hover { transform: translateY(-2px); }
.detail-gallery img.active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(47,181,255,0.25); }
.highlight-list { list-style: none; margin: 14px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.highlight-list li { font-size: 0.92rem; color: var(--text-mid); padding-left: 20px; position: relative; line-height: 1.5; }
.highlight-list li::before { content: '✓'; position: absolute; left: 0; color: var(--teal); font-weight: 700; }
.detail-flags { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.popular-tag {
  display: inline-flex; align-items: center; gap: 4px; background: rgba(47,181,255,0.15);
  color: var(--gold); border: 1px solid rgba(47,181,255,0.4); font-size: 0.75rem;
  padding: 3px 10px; border-radius: 999px; font-family: var(--font-mono);
}
.breadcrumb { font-size: 0.85rem; color: var(--text-low); padding: 18px 0 0; }
.breadcrumb a:hover { color: var(--gold); }
.detail-title { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; margin: 4px 0 10px; }
.detail-price-row { display: flex; align-items: baseline; gap: 12px; margin: 6px 0 20px; flex-wrap: wrap; }
.detail-price-orig { font-family: var(--font-mono); font-size: 1.1rem; color: var(--text-low); text-decoration: line-through; }
.detail-price {
  font-family: var(--font-mono); font-size: 2.4rem; font-weight: 800; letter-spacing: -0.01em;
  background: linear-gradient(100deg, var(--gold) 30%, #fff 50%, var(--gold) 70%);
  background-size: 220% auto; background-clip: text; -webkit-background-clip: text; color: transparent;
  animation: priceShine 3.5s linear infinite, priceIn 0.5s cubic-bezier(.2,.8,.3,1.2) both;
  filter: drop-shadow(0 0 16px rgba(47,181,255,0.4));
}
@keyframes priceIn { from { opacity: 0; transform: translateY(6px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }
.spec-table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 0.92rem; }
.spec-table tr { border-bottom: 1px solid var(--line); }
.spec-table td { padding: 10px 4px; }
.spec-table td:first-child { color: var(--text-low); width: 40%; }
.spec-table td:last-child { font-family: var(--font-mono); }
.detail-desc { color: var(--text-mid); line-height: 1.7; margin: 16px 0; white-space: pre-wrap; }

/* ---------- Forms ---------- */
.auth-wrap { max-width: 420px; margin: 60px auto; padding: 32px; background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius); }
.auth-wrap h2 { font-family: var(--font-display); margin-top: 0; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; color: var(--text-mid); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg-deep); color: var(--text-hi); font-family: inherit; font-size: 0.95rem;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--gold); outline-offset: 1px; }
.form-msg { font-size: 0.85rem; padding: 10px 12px; border-radius: 8px; margin-bottom: 14px; display: none; }
.form-msg.error { display: block; background: rgba(240,87,107,0.12); color: var(--danger); border: 1px solid rgba(240,87,107,0.35); }
.form-msg.ok { display: block; background: rgba(45,212,191,0.12); color: var(--teal); border: 1px solid rgba(45,212,191,0.35); }
.full-btn { width: 100%; padding: 12px; font-size: 1rem; justify-content: center; }
.switch-line { text-align: center; margin-top: 16px; font-size: 0.9rem; color: var(--text-low); }

/* ---------- Admin ---------- */
.admin-layout { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 65px); gap: 0; }
@media (max-width: 780px) { .admin-layout { grid-template-columns: 1fr; } }

.admin-side { border-right: 1px solid var(--line); padding: 24px 18px; display: flex; flex-direction: column; gap: 4px; }
.admin-side-title {
  font-family: var(--font-mono); font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-low); margin-bottom: 12px; padding: 0 4px;
}
.admin-nav { display: flex; flex-direction: column; gap: 4px; }
.admin-nav-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 11px 12px; border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--text-mid); font-size: 0.92rem; font-weight: 500; transition: all 0.15s ease;
}
.admin-nav-icon { font-size: 1.05rem; width: 20px; text-align: center; }
.admin-nav-btn:hover { background: rgba(47,181,255,0.08); color: var(--text-hi); }
.admin-nav-btn.active {
  background: linear-gradient(135deg, rgba(47,181,255,0.18), rgba(76,224,210,0.1));
  border-color: rgba(47,181,255,0.35); color: var(--gold); font-weight: 600;
}
.admin-nav-exit {
  margin-top: auto; padding: 11px 12px; border-radius: 10px; color: var(--text-low);
  font-size: 0.88rem; border-top: 1px solid var(--line); padding-top: 16px; margin-top: 16px;
}
.admin-nav-exit:hover { color: var(--text-hi); }

.admin-main { padding: 28px 24px; }
.admin-main-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 4px; }
.admin-main-header h2 { font-family: var(--font-display); margin: 0; display: flex; align-items: center; gap: 10px; }
.admin-count {
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--teal); background: rgba(76,224,210,0.12);
  border: 1px solid rgba(76,224,210,0.3); border-radius: 999px; padding: 2px 10px;
}
.admin-main h2 { font-family: var(--font-display); margin-top: 0; }

.settings-card {
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin: 16px 0;
}
.settings-card-title { font-family: var(--font-display); font-weight: 600; margin-bottom: 12px; color: var(--text-hi); }

.table-wrap { overflow-x: auto; margin-top: 20px; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
table.data th { color: var(--text-low); font-weight: 500; font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; background: var(--bg-panel-raised); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: rgba(255,255,255,0.02); }
.admin-thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.admin-thumb-empty { background: var(--bg-panel-raised); }
.admin-flags { font-size: 0.85rem; }
.badge-status { padding: 3px 9px; border-radius: 999px; font-size: 0.72rem; font-family: var(--font-mono); }
.badge-status.available { background: rgba(45,212,191,0.15); color: var(--teal); }
.badge-status.sold { background: rgba(240,87,127,0.15); color: var(--danger); }
.row-actions { display: flex; gap: 8px; }
.row-actions button { background: none; border: none; color: var(--text-low); font-size: 0.85rem; }
.row-actions button:hover { color: var(--gold); }

/* Product modal sections */
.modal-section-title {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-display); font-weight: 700; font-size: 0.85rem; color: var(--gold);
  margin: 24px 0 8px; padding: 5px 12px; border-radius: 999px;
  background: rgba(47,181,255,0.1); border: 1px solid rgba(47,181,255,0.25);
}
.modal h3 ~ .modal-section-title:first-of-type,
.modal-section-title:first-child { margin-top: 6px; }
.modal-section-hint { font-size: 0.78rem; color: var(--text-low); margin: 0 0 10px; line-height: 1.5; }

.badge-check-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 6px; }
.badge-check { display: block; cursor: pointer; }
.badge-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.badge-check-pill {
  display: flex; align-items: center; justify-content: center; gap: 4px;
  padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-panel-raised);
  font-size: 0.82rem; font-weight: 600; color: var(--text-mid); transition: all 0.15s ease; text-align: center;
}
.badge-check input:checked + .badge-check-pill.pill-popular { background: rgba(47,181,255,0.18); border-color: var(--gold); color: var(--gold); }
.badge-check input:checked + .badge-check-pill.pill-hot { background: linear-gradient(135deg,#ff5c39,#ff2f6b); border-color: transparent; color: #fff; }
.badge-check input:checked + .badge-check-pill.pill-premium { background: linear-gradient(135deg,#a855f7,#f5c451); border-color: transparent; color: #1a0e2e; }
.badge-check input:checked + .badge-check-pill.pill-sale { background: linear-gradient(135deg,#22c55e,#0ea5a0); border-color: transparent; color: #04241c; }
.badge-check-pill:hover { border-color: var(--gold-dim); }


.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10,8,22,0.7); display: none;
  align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop.show { display: flex; }
.modal {
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px; max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto;
}
.modal h3 { font-family: var(--font-display); margin-top: 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

footer { border-top: 1px solid var(--line); padding: 28px 0; text-align: center; color: var(--text-low); font-size: 0.85rem; }

.hidden { display: none !important; }

#fatalError {
  background: rgba(255,92,122,0.12); border-bottom: 1px solid rgba(255,92,122,0.4);
  color: var(--danger); font-size: 0.85rem; padding: 10px 20px; text-align: center;
}

/* ---------- Splash / loading screen ---------- */
#splashScreen {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-deep);
  overflow: hidden;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#splashScreen.splash-hide { opacity: 0; visibility: hidden; pointer-events: none; }
.splash-glow {
  position: absolute; width: 60vmax; height: 60vmax; border-radius: 50%;
  background: radial-gradient(circle, rgba(47,181,255,0.22), rgba(76,224,210,0.08) 45%, transparent 70%);
  animation: splashGlowPulse 3.4s ease-in-out infinite;
}
@keyframes splashGlowPulse {
  0%, 100% { transform: scale(0.92); opacity: 0.75; }
  50% { transform: scale(1.06); opacity: 1; }
}
.splash-inner { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.splash-logo {
  width: 96px; height: 96px; object-fit: contain; border-radius: 0;
  filter: drop-shadow(0 0 24px rgba(47,181,255,0.55));
  animation: splashLogoIn 0.75s cubic-bezier(.2,.9,.25,1.2) both, splashLogoFloat 2.6s ease-in-out 0.75s infinite;
}
@keyframes splashLogoIn {
  0% { opacity: 0; transform: scale(0.4) rotate(-8deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
@keyframes splashLogoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
.splash-name {
  font-family: var(--font-display); font-weight: 700; font-size: 1.9rem; color: var(--text-hi);
  letter-spacing: 0.02em; opacity: 0; animation: splashTextIn 0.6s ease 0.3s both;
}
.splash-name span { color: var(--gold); }
.splash-tag {
  font-family: var(--font-mono); font-size: 0.72rem; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--teal); opacity: 0; animation: splashTextIn 0.6s ease 0.48s both;
}
@keyframes splashTextIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.splash-bar {
  width: 160px; height: 3px; border-radius: 999px; background: var(--line); overflow: hidden;
  opacity: 0; animation: splashTextIn 0.6s ease 0.6s both;
}
.splash-bar-fill {
  width: 40%; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), var(--teal));
  animation: splashBarSlide 1.1s ease-in-out infinite;
}
@keyframes splashBarSlide {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(360%); }
}

/* ---------- ลูกเล่น: animations ---------- */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.grid .ticket { animation: fadeInUp 0.45s ease both; }
.grid .ticket:nth-child(1) { animation-delay: 0.02s; }
.grid .ticket:nth-child(2) { animation-delay: 0.06s; }
.grid .ticket:nth-child(3) { animation-delay: 0.10s; }
.grid .ticket:nth-child(4) { animation-delay: 0.14s; }
.grid .ticket:nth-child(5) { animation-delay: 0.18s; }
.grid .ticket:nth-child(6) { animation-delay: 0.22s; }
.grid .ticket:nth-child(n+7) { animation-delay: 0.26s; }

@keyframes glowPulse {
  0%, 100% { text-shadow: 0 0 12px rgba(47,181,255,0.6), 0 0 40px rgba(47,181,255,0.35); }
  50% { text-shadow: 0 0 20px rgba(47,181,255,0.85), 0 0 60px rgba(76,224,210,0.45); }
}
.hero-wordmark { animation: glowPulse 3.2s ease-in-out infinite; }

.ticket-buy-btn, .btn-gold { transition: filter 0.15s ease, transform 0.15s ease; }
.ticket-buy-btn:hover, .btn-gold:hover { transform: translateY(-1px); }
.ticket-buy-btn:active, .btn-gold:active { transform: translateY(0) scale(0.98); }

.tab { transition: all 0.15s ease, transform 0.1s ease; }
.tab:active { transform: scale(0.96); }

/* Skeleton loading state */
.skeleton-card { border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; background: var(--bg-panel); }
.skeleton-card .sk-media { aspect-ratio: 4/3; background: linear-gradient(90deg, var(--bg-panel) 25%, var(--bg-panel-raised) 37%, var(--bg-panel) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
.skeleton-card .sk-line { height: 12px; margin: 12px 14px; border-radius: 4px; background: linear-gradient(90deg, var(--bg-panel) 25%, var(--bg-panel-raised) 37%, var(--bg-panel) 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

/* ---------- Page transition ---------- */
@keyframes pageFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.page-fade { animation: pageFadeIn 0.28s ease both; }
@keyframes pageZoomIn { from { opacity: 0; transform: scale(0.97) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.page-zoom { animation: pageZoomIn 0.32s cubic-bezier(.2,.8,.3,1) both; }

/* Click feedback when tapping into a stock card */
.ticket:active { transform: scale(0.98); }

/* ---------- Toast notifications ---------- */
#toastStack {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; max-width: min(360px, calc(100vw - 40px));
}
.toast {
  background: var(--bg-panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 16px; font-size: 0.88rem; box-shadow: var(--shadow-card);
  animation: toastIn 0.25s ease both;
  display: flex; align-items: center; gap: 8px;
}
.toast.ok { border-color: rgba(76,224,210,0.5); color: var(--teal); }
.toast.error { border-color: rgba(255,92,122,0.5); color: var(--danger); }
.toast.fadeout { animation: toastOut 0.25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ---------- Upload widgets ---------- */
.upload-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.upload-btn {
  padding: 10px 16px; border-radius: 10px; border: 1.5px dashed var(--line);
  background: var(--bg-deep); color: var(--text-mid); font-size: 0.82rem; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; width: 100%; justify-content: center;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.upload-btn:hover { border-color: var(--gold); color: var(--gold); background: rgba(47,181,255,0.06); transform: translateY(-1px); }
.upload-row input[type=file] { display: none; }
.upload-spinner {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line);
  border-top-color: var(--gold); animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.thumb-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.thumb-strip .thumb { position: relative; width: 56px; height: 56px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.thumb-strip .thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-strip .thumb button {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(6,7,13,0.8); color: var(--danger); border: none; font-size: 10px; line-height: 1; padding: 0;
}

/* ---------- Tablet (iPad-ish) ---------- */
@media (min-width: 641px) and (max-width: 1024px) {
  .grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
  .ticket-title { font-size: 0.94rem; }
  .ticket-price-panel .amount { font-size: 1.3rem; }
}

/* ---------- Mobile: 3 stock cards per row, compact card ---------- */
@media (max-width: 640px) {
  .hero-banner { padding: 36px 18px 20px; }
  .detail-price { font-size: 1.8rem; }
  .container { padding: 0 10px; }

  .grid { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 0 40px; }
  .ticket { border-radius: 12px; }
  .ticket-body { padding: 8px 8px 10px; gap: 6px; }
  .ticket-title {
    font-size: 0.72rem; line-height: 1.3; font-weight: 600;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .ticket-highlights { display: none; }
  .ticket-trust { display: none; } /* ซ่อนแถวความเชื่อมั่นบนจอเล็กมาก ให้เหลือแต่ราคา+ปุ่มชัดๆ */
  .ticket-badge, .ticket-status, .ticket-flag, .ticket-ribbon { font-size: 0.5rem; padding: 2px 6px; }
  .ticket-flags-tl, .ticket-flags-tr { top: 6px; gap: 3px; }
  .ticket-flags-tl { left: 6px; } .ticket-flags-tr { right: 6px; }
  .ticket-ribbon { bottom: 6px; left: 6px; }
  .perforation { margin: 0 8px; }
  .perforation::before, .perforation::after { width: 10px; height: 10px; top: -5px; }
  .perforation::before { left: -14px; } .perforation::after { right: -14px; }
  .ticket-price-panel { padding: 5px 7px; gap: 3px; border-radius: 7px; }
  .ticket-price-panel .amount { font-size: 0.92rem; }
  .ticket-price-panel .amount small { font-size: 0.56rem; }
  .amount-orig { font-size: 0.56rem; }
  .ticket-stock-row { font-size: 0.56rem; padding-top: 4px; margin-top: 4px; gap: 2px; }
  .ticket-stock-row span:first-child { display: none; } /* ซ่อน "คลัง N" บนจอเล็กมาก เหลือแค่ยอดขายให้ไม่รก */
  .ticket-buy-btn { margin-top: 6px; padding: 6px; font-size: 0.68rem; border-radius: 6px; }
  .ticket:hover { transform: none; } /* ปิด tilt/lift บนมือถือ กันสั่นตอนแตะ */
}
@media (max-width: 380px) {
  .grid { gap: 6px; }
  .ticket-body { padding: 6px 6px 8px; }
}
