/* KinAraiDee — สไตล์ของเครื่องมือ (header/footer/ธีมมาจาก saitamo-shell.css)
   ใช้ token --stm-* ของเครือทั้งหมด: ปุ่มหลักทอง/ตัวอักษร Navy · ชิปที่เลือก = --stm-link */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--stm-bg); color: var(--stm-text);
  font-family: var(--stm-font); font-size: 16px; line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -9999px; top: 8px; z-index: 100; background: var(--stm-primary); color: var(--stm-on-primary); padding: 8px 12px; border-radius: var(--stm-r-btn); }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--stm-focus); outline-offset: 2px; }

.wrap { max-width: var(--stm-max); margin: 0 auto; padding-block: var(--stm-s5) var(--stm-s7); padding-inline: var(--stm-s4); }

/* hero */
.hero { display: flex; align-items: center; gap: var(--stm-s4); margin-bottom: var(--stm-s5); }
.hero__mascot { flex: none; width: 84px; height: auto; }
.eyebrow { margin: 0; font-size: .85rem; font-weight: 600; color: var(--stm-gold-text); letter-spacing: .02em; }
.hero__title { margin: 2px 0 4px; font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.15; font-weight: 700; text-wrap: balance; }
.hero__title span { color: var(--stm-gold-text); }
.hero__sub { margin: 0; color: var(--stm-muted); max-width: 60ch; }

/* tabs */
.tabs { display: inline-flex; gap: 4px; padding: 4px; margin-bottom: var(--stm-s4); max-width: 100%;
  background: var(--stm-surface); border: 1px solid var(--stm-border); border-radius: var(--stm-r-pill); }
.tab { min-height: 44px; padding: 8px 18px; border: 0; border-radius: var(--stm-r-pill); background: transparent;
  color: var(--stm-muted); font: 600 .95rem var(--stm-font); cursor: pointer; transition: background .2s, color .2s; }
.tab:hover { color: var(--stm-text); }
.tab[aria-selected="true"] { background: var(--stm-link); color: var(--stm-on-link); }

/* layout */
.grid { display: grid; grid-template-columns: 1fr; gap: var(--stm-s5); align-items: start; }
@media (min-width: 900px) { .grid { grid-template-columns: 360px 1fr; } }
.card { background: var(--stm-surface); border: 1px solid var(--stm-border); border-radius: var(--stm-r-card); padding: var(--stm-s5); box-shadow: var(--stm-shadow); min-width: 0; }
.filters h2 { margin: 0 0 var(--stm-s2); font-size: .95rem; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: var(--stm-s2); margin-bottom: var(--stm-s4); }
.chip { min-height: 40px; padding: 6px 14px; border: 1px solid var(--stm-border); border-radius: var(--stm-r-pill);
  background: var(--stm-surface-2); color: var(--stm-text); font: 500 .92rem var(--stm-font); cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s; }
.chip:hover { border-color: var(--stm-link); }
.chip:active { transform: scale(.96); }
.chip[aria-pressed="true"] { background: var(--stm-link-soft); border-color: var(--stm-link); color: var(--stm-link-ink); font-weight: 600; }
.filters__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--stm-s3); flex-wrap: wrap;
  padding-top: var(--stm-s3); border-top: 1px solid var(--stm-border); }
.count { margin: 0; font-size: .9rem; color: var(--stm-muted); }
.count b { color: var(--stm-gold-text); font-variant-numeric: tabular-nums; }

/* stage */
.stage { display: flex; flex-direction: column; align-items: center; gap: var(--stm-s4); min-width: 0; }
.slot { position: relative; width: 100%; max-width: 100%; aspect-ratio: 4 / 3; overflow: hidden;
  border-radius: var(--stm-r-card); border: 1px solid var(--stm-border);
  background: radial-gradient(circle at 30% 20%, var(--stm-navy-2), var(--stm-navy)); }
.slot > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.slot > img.on { opacity: 1; }
.slot.spinning > img.on { filter: blur(2px) saturate(1.2); }
.ph { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--stm-s2);
  color: #fff; font: 400 clamp(1.4rem, 4vw, 2rem) var(--stm-font-display); letter-spacing: .02em; text-align: center; padding: var(--stm-s5); }
.ph img { border-radius: 50%; border: 3px solid var(--stm-gold); }
.label { position: absolute; left: 0; right: 0; bottom: 0; padding: 64px var(--stm-s5) var(--stm-s4);
  background: linear-gradient(transparent, rgba(10, 25, 47, .92)); color: #fff; }
.label h3 { margin: 0; font-size: clamp(1.5rem, 4.5vw, 2.2rem); line-height: 1.2; font-weight: 700; text-wrap: balance; }
.label .sub { margin: 2px 0 0; font-size: .95rem; color: #F1E2A8; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: var(--stm-s2); }
.tags span { font-size: .8rem; padding: 2px 10px; border-radius: var(--stm-r-tag); background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .22); }
.slot.win { animation: pop .45s cubic-bezier(.2, 1.6, .4, 1); box-shadow: 0 0 0 3px var(--stm-gold); }
@keyframes pop { from { transform: scale(.95); } to { transform: scale(1); } }

.msg { margin: 0; min-height: 1.6em; color: var(--stm-muted); font-weight: 600; text-align: center; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--stm-s3); }
.btn-primary, .btn-ghost { display: inline-flex; align-items: center; justify-content: center; gap: var(--stm-s2);
  border-radius: var(--stm-r-btn); font-family: var(--stm-font); cursor: pointer; text-decoration: none; transition: background .15s, transform .1s, border-color .15s; }
.btn-primary { min-height: 52px; padding: 10px 36px; border: 0; background: var(--stm-primary); color: var(--stm-on-primary); font-size: 1.15rem; font-weight: 700; }
.btn-primary:hover { background: var(--stm-primary-hover); }
.btn-primary:active { transform: translateY(2px); }
.btn-primary:disabled { opacity: .55; cursor: not-allowed; }
.btn-ghost { min-height: 44px; padding: 8px 16px; border: 1px solid var(--stm-border); background: var(--stm-surface); color: var(--stm-text); font-size: .95rem; font-weight: 500; }
.btn-ghost:hover { border-color: var(--stm-link); color: var(--stm-link); }
.btn-primary svg, .btn-ghost svg { width: 20px; height: 20px; flex: none; }
.hist { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--stm-s2); }
.hist span { font-size: .85rem; padding: 2px 10px; border-radius: var(--stm-r-pill); background: var(--stm-surface-2); border: 1px solid var(--stm-border); color: var(--stm-muted); }

.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 60; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 13px; border-radius: 2px; animation: fall 1.6s ease-in forwards; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
