/*
 * Coin Master Spin TH — design system
 * Generated with ui-ux-pro-max: style "Claymorphism" (soft 3D, chunky, rounded),
 * palette "Idle & Clicker Game" (reward gold + purple), font "Thai Modern" (Noto Sans Thai).
 * Plain CSS, no build step. Works on top of Bootstrap 4 (index.php) and Tabler (blog.php).
 */

:root {
  --cm-bg: #FFFBEB;
  --cm-fg: #0F172A;
  --cm-muted-fg: #475569;
  --cm-card: #FFFFFF;
  --cm-border: #F3E2C7;
  --cm-primary: #6D28D9;
  --cm-primary-dark: #4C1D95;
  --cm-on-primary: #FFFFFF;
  --cm-accent: #F59E0B;
  --cm-accent-dark: #B45309;
  --cm-on-accent: #0F172A;
  --cm-visited-bg: #E2E8F0;
  --cm-visited-fg: #475569;
  --cm-ring: #7C3AED;
  --cm-radius-sm: 12px;
  --cm-radius: 20px;
  --cm-radius-pill: 999px;
  --cm-shadow: 0 4px 0 rgba(180, 83, 9, .10), 0 10px 24px rgba(15, 23, 42, .06);
  --cm-shadow-press: 0 2px 0 rgba(180, 83, 9, .14);
  --cm-space-1: 4px;
  --cm-space-2: 8px;
  --cm-space-3: 12px;
  --cm-space-4: 16px;
  --cm-space-5: 24px;
  --cm-space-6: 32px;
  --cm-font: 'Noto Sans Thai', 'Sarabun', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --cm-ease: cubic-bezier(.2, .8, .2, 1);
  --cm-nav-h: 60px;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--cm-nav-h) + 8px); }

body.cm {
  margin: 0;
  padding-top: 0;
  background: var(--cm-bg);
  color: var(--cm-fg);
  font-family: var(--cm-font);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

.cm a { color: var(--cm-primary); }
.cm a:hover { color: var(--cm-primary-dark); }
.cm :focus-visible { outline: 3px solid var(--cm-ring); outline-offset: 2px; border-radius: 6px; }

.cm .adsbygoogle, .cm ins, .cm iframe { max-width: 100% !important; }

.cm-skip {
  position: absolute; left: 8px; top: -60px; z-index: 2000;
  background: var(--cm-accent); color: var(--cm-on-accent) !important;
  padding: 8px 16px; border-radius: var(--cm-radius-pill); font-weight: 700;
}
.cm-skip:focus { top: 8px; }

.cm-wrap { box-sizing: border-box; width: 100%; max-width: 960px; min-width: 0; margin: 0 auto; padding: 0 var(--cm-space-3); }
.cm .page { min-width: 0; }

/* ---------- Navbar ---------- */
.cm-nav {
  position: sticky; top: 0; z-index: 1030;
  background: linear-gradient(135deg, var(--cm-primary-dark), var(--cm-primary));
  color: var(--cm-on-primary);
  box-shadow: 0 2px 12px rgba(76, 29, 149, .25);
}
.cm-nav__inner {
  max-width: 960px; margin: 0 auto; min-height: var(--cm-nav-h);
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 0 var(--cm-space-3);
}
.cm .cm-brand {
  display: inline-flex; align-items: center; gap: var(--cm-space-2);
  color: #fff; font-weight: 700; font-size: 1.05rem; text-decoration: none; min-height: 44px;
}
.cm .cm-brand:hover { color: #FDE68A; text-decoration: none; }
.cm-brand img { width: 36px; height: 36px; border-radius: 10px; background: #fff; }

.cm-nav__toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: var(--cm-radius-sm);
  background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer;
  transition: background-color .2s var(--cm-ease);
}
.cm-nav__toggle:hover { background: rgba(255, 255, 255, .24); }
.cm-nav__toggle svg { width: 24px; height: 24px; }

.cm-nav__menu {
  list-style: none; margin: 0; padding: 0 0 var(--cm-space-3);
  width: 100%; display: none; flex-direction: column; gap: var(--cm-space-1);
}
.cm-nav.is-open .cm-nav__menu { display: flex; }
.cm .cm-nav__menu a {
  display: flex; align-items: center; gap: var(--cm-space-2);
  min-height: 44px; padding: var(--cm-space-2) var(--cm-space-3);
  color: #fff; text-decoration: none; border-radius: var(--cm-radius-sm);
  transition: background-color .2s var(--cm-ease);
}
.cm .cm-nav__menu a:hover, .cm .cm-nav__menu a[aria-current="page"] { background: rgba(255, 255, 255, .16); color: #fff; }
.cm-nav__menu svg { width: 20px; height: 20px; flex: none; }

@media (min-width: 992px) {
  .cm-nav__toggle { display: none; }
  .cm-nav__menu { display: flex; flex-direction: row; flex-wrap: wrap; justify-content: flex-end; width: auto; padding: 6px 0; }
  .cm .cm-nav__menu a { font-size: .9rem; white-space: nowrap; min-height: 40px; padding: 6px 10px; }
}

/* ---------- Hero ---------- */
.cm-hero {
  margin: var(--cm-space-4) 0;
  padding: var(--cm-space-5) var(--cm-space-4);
  text-align: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(253, 230, 138, .55), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(196, 181, 253, .45), transparent 50%),
    var(--cm-card);
  border: 3px solid var(--cm-border);
  border-radius: var(--cm-radius);
  box-shadow: var(--cm-shadow);
}
.cm-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--cm-radius-pill);
  background: #FEF3C7; color: #92400E; font-size: .85rem; font-weight: 600;
}
.cm-badge svg { width: 16px; height: 16px; }
.cm .cm-hero__title {
  margin: var(--cm-space-3) 0 var(--cm-space-2);
  font-size: clamp(1.4rem, 5vw, 2rem); font-weight: 700; line-height: 1.3;
  color: var(--cm-fg); text-wrap: balance;
}
.cm .cm-hero__title a { color: var(--cm-primary); text-decoration: none; }
.cm-hero__sub { margin: 0 auto var(--cm-space-4); max-width: 36em; color: var(--cm-muted-fg); font-size: .95rem; }
.cm-hero__actions { display: grid; gap: var(--cm-space-2); grid-template-columns: 1fr; max-width: 560px; margin: 0 auto; }
@media (min-width: 576px) { .cm-hero__actions { grid-template-columns: 1fr 1fr; } }

/* ---------- Buttons ---------- */
.cm .cm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--cm-space-2);
  min-height: 48px; padding: 10px 18px;
  border: 0; border-radius: var(--cm-radius-pill);
  font-family: var(--cm-font); font-weight: 700; font-size: 1rem; line-height: 1.2;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  box-shadow: var(--cm-shadow-press);
  transition: transform .15s var(--cm-ease), box-shadow .15s var(--cm-ease), background-color .2s var(--cm-ease), filter .2s var(--cm-ease);
}
.cm .cm-btn:hover { text-decoration: none; filter: brightness(1.05); }
.cm .cm-btn:active { transform: translateY(2px); box-shadow: none; }
.cm .cm-btn svg { width: 20px; height: 20px; flex: none; }

.cm .cm-btn--line { background: #06C755; color: #fff; }
.cm .cm-btn--line:hover { color: #fff; }
.cm .cm-btn--fb { background: #1877F2; color: #fff; }
.cm .cm-btn--fb:hover { color: #fff; }

/* "รับสปิน" — gold reward CTA; visited links turn grey so users know what they already claimed */
.cm .cm-btn--spin { background: var(--cm-accent); color: var(--cm-on-accent); min-width: 104px; }
.cm .cm-btn--spin:hover { background: #FBBF24; color: var(--cm-on-accent); }
.cm .cm-btn--spin:visited { background: var(--cm-visited-bg); color: var(--cm-visited-fg); }
.cm .cm-btn--soft { background: #EDE9FE; color: var(--cm-primary-dark); }
.cm .cm-btn--soft:hover { color: var(--cm-primary-dark); }

/* ---------- Spin list (table rendered as cards) ---------- */
.cm-section-title {
  display: flex; align-items: center; justify-content: space-between; gap: var(--cm-space-2);
  margin: var(--cm-space-5) 0 var(--cm-space-3);
}
.cm .cm-section-title h2 { margin: 0; font-size: 1.25rem; font-weight: 700; color: var(--cm-fg); }
.cm-count { color: var(--cm-muted-fg); font-size: .9rem; }

.cm .cm-spins { width: 100%; border-collapse: separate; border-spacing: 0; margin: 0; background: transparent; }
.cm .cm-spins thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.cm .cm-spins tbody { display: flex; flex-direction: column; gap: var(--cm-space-3); }
.cm .cm-spins tr {
  display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: var(--cm-space-3);
  padding: var(--cm-space-3);
  background: var(--cm-card);
  border: 2px solid var(--cm-border);
  border-radius: var(--cm-radius);
  box-shadow: var(--cm-shadow);
}
.cm .cm-spins td { display: block; padding: 0; border: 0; background: none !important; vertical-align: middle; min-width: 0; }
.cm .cm-spins td[colspan] { grid-column: 1 / -1; }
.cm .cm-spins tr:has(> td[colspan]) { padding: 0; background: transparent; border: 0; box-shadow: none; display: block; }
.cm .cm-spins td img { max-width: 100%; height: auto; }
.cm .cm-spins .spin-icon {
  width: 48px; height: 48px; padding: 4px; border-radius: 14px; background: #FEF3C7; object-fit: contain; display: block; margin: 0 auto;
}
.cm .cm-spins .btn { min-height: 48px; border-radius: var(--cm-radius-pill); font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.cm .cm-spins p { margin: 0; }
.cm .cm-spins .btn-danger { background: var(--cm-primary); border-color: var(--cm-primary); color: #fff; font-size: 1rem; padding: 8px 14px; }

.cm-spin__title { display: block; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.cm-spin__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; color: var(--cm-muted-fg); font-size: .85rem; }
.cm-new {
  display: inline-block; padding: 1px 8px; border-radius: var(--cm-radius-pill);
  background: #DCFCE7; color: #166534; font-size: .75rem; font-weight: 700;
}

@media (max-width: 400px) {
  .cm .cm-spins tr { grid-template-columns: 44px 1fr; }
  .cm .cm-spins tr > td:last-child:not([colspan]) { grid-column: 1 / -1; }
  .cm .cm-spins tr > td:last-child .cm-btn, .cm .cm-spins tr > td:last-child .btn { width: 100%; }
  .cm .cm-spins .spin-icon { width: 44px; height: 44px; }
}

/* ---------- Ads ---------- */
.cm-ad { margin: var(--cm-space-4) 0; text-align: center; }

/* ---------- Content / article ---------- */
.cm-card {
  background: var(--cm-card);
  border: 2px solid var(--cm-border);
  border-radius: var(--cm-radius);
  box-shadow: var(--cm-shadow);
  padding: var(--cm-space-5) var(--cm-space-4);
  margin: var(--cm-space-4) 0;
}
@media (min-width: 768px) { .cm-card { padding: var(--cm-space-6); } }

.cm-prose { font-size: 1rem; line-height: 1.75; color: #1E293B; overflow-wrap: anywhere; }
.cm .cm-prose h1, .cm .cm-prose h2, .cm .cm-prose h3 {
  font-family: var(--cm-font); color: var(--cm-primary-dark); font-weight: 700; line-height: 1.4;
  margin: var(--cm-space-5) 0 var(--cm-space-3);
}
.cm .cm-prose h1 { font-size: 1.3rem; }
.cm .cm-prose h2 { font-size: 1.2rem; }
.cm .cm-prose h3 { font-size: 1.1rem; }
.cm .cm-prose h1:first-child, .cm .cm-prose h2:first-child { margin-top: 0; }
.cm .cm-prose b { color: var(--cm-fg); }
.cm .cm-prose > br:first-child { display: none; }
.cm .cm-prose hr { border: 0; border-top: 2px dashed var(--cm-border); margin: var(--cm-space-5) 0; }
.cm .cm-prose img { max-width: 100%; height: auto; border-radius: var(--cm-radius-sm); }

.cm-keywords { margin-top: var(--cm-space-4); font-size: .85rem; color: var(--cm-muted-fg); text-align: center; line-height: 1.8; }

/* ---------- Blog list ---------- */
.cm-posts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--cm-space-3); }
@media (min-width: 768px) { .cm-posts { grid-template-columns: 1fr 1fr; } }
.cm .cm-post {
  display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: var(--cm-space-3);
  padding: var(--cm-space-3); min-height: 88px;
  background: var(--cm-card); border: 2px solid var(--cm-border); border-radius: var(--cm-radius);
  box-shadow: var(--cm-shadow); color: var(--cm-fg); text-decoration: none;
  transition: transform .15s var(--cm-ease), border-color .2s var(--cm-ease);
}
.cm .cm-post:hover { border-color: #FCD34D; color: var(--cm-fg); text-decoration: none; transform: translateY(-2px); }
.cm-post img { width: 64px; height: 64px; object-fit: cover; border-radius: 14px; background: #FEF3C7; }
.cm-post__title { font-weight: 600; line-height: 1.4; }
.cm-post__more { display: block; margin-top: 4px; color: var(--cm-primary); font-size: .85rem; font-weight: 600; }

.cm-breadcrumb { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: .9rem; color: var(--cm-muted-fg); margin: 0 0 var(--cm-space-3); }
.cm-breadcrumb a { font-weight: 600; }

/* ---------- Footer ---------- */
.cm-footer {
  margin-top: var(--cm-space-6);
  padding: var(--cm-space-5) 0 calc(var(--cm-space-5) + env(safe-area-inset-bottom));
  background: var(--cm-primary-dark); color: #EDE9FE; text-align: center; font-size: .9rem;
}
.cm .cm-footer a { color: #fff; font-weight: 600; }

/* ---------- Copy page (spin-link-only) ---------- */
.cm-copy-box {
  white-space: normal; font-size: .95rem; line-height: 1.7; background: #FFFDF5;
  border: 2px dashed var(--cm-border); border-radius: var(--cm-radius-sm); padding: var(--cm-space-4);
  overflow-wrap: anywhere;
}
.cm-toolbar { display: flex; flex-wrap: wrap; gap: var(--cm-space-2); align-items: center; justify-content: space-between; margin-bottom: var(--cm-space-3); }
.cm-toast { color: #166534; font-weight: 600; font-size: .9rem; min-height: 1.4em; }

@media (prefers-reduced-motion: reduce) {
  .cm *, .cm *::before, .cm *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
