body {
    background-color: #0f0f0f;
    color: #fff;
    font-family: 'Segoe UI', sans-serif;
    padding: 20px;
    /* Default full-screen background */
    background-image: url('BG/BG.webp');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}
h1 {
    text-align: center;
    color: #2600ff;
    border:2px solid #ff0000; /* ขอบแดง */
    box-shadow:0 0 18px 2px #ff0000cc;
    transition:height 0.2s;
    backdrop-filter: blur(2px);
}
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); /* ให้ได้หลายคอลัมน์แบบในภาพ */
    gap: 16px;
    margin-top: 32px;
    padding: 10px;
    border:5px solid #ff0000; /* ขอบแดง */
    border-radius: 18px;
    box-shadow:0 0 18px 2px #eeff00;  
    background: rgba(0,0,0,0.25);
}
  
  
iframe {
    width: 100%;
    height: 450px;
    border: 2px solid #ff0000;
    border-radius: 20px;
}
.fade {
  opacity: 0.3;
  transition: opacity 0.5s;
}
  
.title {
    margin-top: 8px;
    text-align: center;
    font-size: 14px;
    color: #bbb;
}
.grid-container > div, .preview-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.04);
    border:2px solid #00ff55; /* ขอบเขียว */
    border-radius: 18px;
    box-shadow: 0 0 0 1px rgba(0,255,85,0.2), 0 0 14px rgba(0,255,85,0.25);
    padding: 8px 3px 8px 3px; 
    transition: box-shadow 0.2s, transform 0.2s;
    /* Performance: isolate layout/paint and skip offscreen */
    content-visibility: auto;
    contain: content;
    contain-intrinsic-size: 230px 260px; /* rough placeholder size to prevent CLS */
}
.preview-box:hover {
    box-shadow: 0 0 0 1px rgba(0,255,85,0.35), 0 0 22px rgba(0,255,85,0.35);
    transform: scale(1.02);
}
.preview-img {
    width: 100%;
    max-width: 100%;
    height: auto;              /* ปล่อยให้สูงตามเนื้อภาพ */
    object-fit: contain;       /* แสดงเต็มความกว้าง ไม่ตัดหัวตัดท้าย */
    border-radius: 14px;
    border: 2px solid #00a8ff; /* ขอบฟ้า */
    margin-bottom: 3px;
    background: #222;
    box-shadow: 0 2px 10px #0002;
    will-change: transform;
    display: block;
}
/* ลบช่องว่างบรรทัดและให้ลิงก์ครอบรูปขยายเต็มความกว้าง */
.vscroll a { display:block; width:100%; line-height:0; }
.vscroll img { display:block; width:100%; height:auto; }
@media (max-width: 600px) {
    .grid-container {
        grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2 คอลัมน์เท่ากัน เต็มความกว้าง */
        gap: 10px;
        margin-top: 16px;
        padding: 8px;
    }
    .preview-box {
        padding: 6px 2px 6px 2px;
        /* ปิด contain บนมือถือเพื่อหลีกเลี่ยงการคำนวณขนาดผิด ทำให้ดูเล็กเกิน */
        content-visibility: visible;
        contain: initial;
        contain-intrinsic-size: auto;
    }
    /* ปรับความสูงช่องเลื่อนให้เหมาะกับจอมือถือ */
    .vscroll { max-height: 240px; }
}

.iframe-label a {
    transition: all 0.2s;
    color: #222;
    text-decoration: none;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.836);
    padding: 4px 14px;
    border-radius: 10px;
    display: inline-block;
    box-shadow: 0 2px 8px #0002;
  }
  .iframe-label a:hover {
    color: #fff;
    background: #0078ff;
    transform: scale(1.12) rotate(-2deg);
    box-shadow: 0 4px 16px #0078ff44;
    text-shadow: 0 2px 8px rgba(1, 6, 78, 0.533);
}
.iframe-label a {
    background: linear-gradient(90deg,#ff4,#f0f,#0ff,#4f4,#ff4);
    background-size: 200% 200%;
    color: transparent;
    -webkit-background-clip: text;
    background-clip: text;
    animation: rainbow 2s linear infinite;
  }
  @keyframes rainbow {
    to { background-position: 200% 0; }
}

.glow-text {
  color: #fff;
  text-shadow:
    0 0 8px #00e6ff,
    0 0 16px #00e6ff,
    0 0 32px #00e6ff,
    0 2px 8px #003d60,
    0 0 2px #fff;
  font-weight: bold;
  letter-spacing: 0.5px;
  font-size: 1.1em;
  animation: glow-pulse 2s ease-in-out infinite alternate;
}
@keyframes glow-pulse {
  from {
    text-shadow:
      0 0 8px #00e6ff,
      0 0 16px #00e6ff,
      0 0 32px #00e6ff,
      0 2px 8px #003d60,
      0 0 2px #fff;
  }
  to {
    text-shadow:
      0 0 16px #00e6ff,
      0 0 32px #00e6ff,
      0 0 64px #00e6ff,
      0 2px 16px #003d60,
      0 0 4px #fff;
  }
}
#marquee-zone {
  position: relative;
  width: 330px; /* ปรับตามขนาดที่ต้องการ */
  height: 40px;
  overflow: visible;
  margin: 24px 0 0 16px;
}
#marquee-box {
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  background: rgba(0,0,0,0.7);
  border-radius: 12px;
  padding: 7px 10px;
  border: 2px solid #fff3;
  position: absolute;
  left: 0; top: 0;
  z-index: 2;
}
#marquee-content {
  display: inline-block;
  animation: marquee-move 4s linear infinite;
  font-size: 1.25rem;
  color: #fff;
  font-weight: bold;
}
@keyframes marquee-move {
  0% { transform: translateX(100%);}
  100% { transform: translateX(-100%);}
}
#after-click {
  position: absolute;
  left: 0; top: 0;
  background: #fffbe6;
  border-radius: 10px;
  padding: 6px 12px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 10px #0003;
  font-size: 1.05rem;
}
#after-click input {
  border: 1.5px solid #aaa;
  border-radius: 7px;
  padding: 3px 8px;
  font-size: 1rem;
}
.icon-cart-btn {
  background: #fffbe6;
  border: 2px solid #ffb700;
  border-radius: 50%;
  font-size: 1.7rem;
  width: 2.5em;           /* ความกว้างปุ่ม (เพิ่มเอง) */
  height: 2.5em;          /* ความสูงปุ่ม (เพิ่มเอง) */
  cursor: pointer;
  margin-left: 7px;
  box-shadow: 0 2px 8px #0002;
  transition: background 0.15s, transform 0.15s;
}
.icon-cart-btn:hover {
  background: #ffe066;
  transform: scale(1.10);
}
/* เพิ่มใน style.css */
@keyframes gridGlow {
  0% { box-shadow: 0 0 0 0 #ff980033; }
  50% { box-shadow: 0 0 16px 8px #ff980055; }
  100% { box-shadow: 0 0 0 0 #ff980033; }
}

.preview-box.animated {
  animation: gridGlow 1.2s infinite;
  /* animation-delay จะถูก set จาก JS */
  will-change: box-shadow, transform;
}

/* Iframe in modal - isolate for cheaper rendering */
.myIframe {
  contain: strict;
}
.vscroll {
  display:block;
  height:auto;               /* ให้ความสูงยืดหยุ่น */
  max-height:260px;          /* ความสูงของช่องภาพแบบในภาพตัวอย่าง */
  overflow-y:auto;
  overflow-x:hidden;
  padding:0;
  background:rgba(0,0,0,0.6);
  border-radius:10px;
  width:100%;
  box-sizing:border-box;
  -webkit-overflow-scrolling:touch;
}

/* ป้ายชื่อใต้รูป */
.title {
    margin-top: 6px;
    text-align: center;
    font-size: 13px;
    color: #39ff14;           /* เขียวเรืองแสง */
    font-weight: 600;
    text-shadow: 0 0 8px rgba(57,255,20,0.6);
}
.vscroll img{
  display:block;
  width:100% !important;
  max-width:none;
  height:auto;
  border-radius:0;
  margin:0;
}