/* ================= A+ motion graphics (UNO · เติมเกมออนไลน์) ================= */
canvas#particles { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
.screen { z-index: 1; }

/* ไพ่บิน (WAAPI คุม transform) */
.fly { position: fixed; z-index: 60; pointer-events: none; transform-style: preserve-3d; will-change: transform; filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.55)); }

/* คลื่นกระแทกตอนไพ่ตก */
.shock { position: fixed; width: 20px; height: 20px; margin: -10px; border-radius: 50%; border: 4px solid var(--c); box-shadow: 0 0 24px var(--c), inset 0 0 18px var(--c); animation: shock 0.65s cubic-bezier(0.1, 0.8, 0.3, 1) forwards; z-index: 55; pointer-events: none; }
@keyframes shock { from { transform: scale(0.4); opacity: 1; } to { transform: scale(13); opacity: 0; border-width: 1px; } }

/* ฉากพิเศษเต็มจอ */
.cine { position: fixed; inset: 0; z-index: 72; pointer-events: none; display: grid; place-items: center; animation: cine-bg 1.45s ease forwards; }
@keyframes cine-bg { 0% { background: rgba(5, 8, 15, 0); } 12%, 75% { background: radial-gradient(circle at 50% 42%, color-mix(in srgb, var(--c) 30%, transparent), rgba(5, 8, 15, 0.82) 60%); } 100% { background: rgba(5, 8, 15, 0); } }
.cine-lines { position: absolute; inset: -50%; background: repeating-conic-gradient(from 0deg, color-mix(in srgb, var(--c) 55%, transparent) 0 1.2deg, transparent 1.2deg 9deg); -webkit-mask: radial-gradient(circle, transparent 18%, #000 45%); mask: radial-gradient(circle, transparent 18%, #000 45%); animation: cine-lines 1.45s linear forwards; }
@keyframes cine-lines { 0% { transform: rotate(0) scale(0.6); opacity: 0; } 15% { opacity: 0.9; } 80% { opacity: 0.6; } 100% { transform: rotate(40deg) scale(1.3); opacity: 0; } }
.cine-card { position: absolute; top: 42%; left: 50%; --cw: clamp(110px, 30vw, 170px); transform-style: preserve-3d; animation: cine-card 1.45s cubic-bezier(0.2, 1.1, 0.3, 1) forwards; }
.cine-card .card { box-shadow: 0 0 0 4px #fff, 0 0 60px 10px var(--c); }
@keyframes cine-card { 0% { transform: translate(-50%, -50%) perspective(800px) rotateY(180deg) scale(0.2) rotate(-30deg); opacity: 0; } 25% { transform: translate(-50%, -50%) perspective(800px) rotateY(0) scale(1.15) rotate(6deg); opacity: 1; } 75% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; } 100% { transform: translate(-50%, -120%) scale(0.6); opacity: 0; } }
.cine-title { position: absolute; top: 70%; left: 50%; font-family: 'Kanit'; font-weight: 700; font-size: clamp(48px, 15vw, 110px); color: #fff; white-space: nowrap; -webkit-text-stroke: 2px #0b1020; text-shadow: -4px 0 0 rgba(239, 68, 68, 0.85), 4px 0 0 rgba(59, 130, 246, 0.85), 0 0 40px var(--c); animation: cine-title 1.45s cubic-bezier(0.2, 1.5, 0.4, 1) forwards; }
@keyframes cine-title { 0%, 15% { transform: translate(-50%, -50%) scale(3); opacity: 0; filter: blur(0); } 30% { transform: translate(-50%, -50%) scale(0.92); opacity: 1; } 40% { transform: translate(-50%, -50%) scale(1.04); } 78% { transform: translate(-50%, -50%) scale(1); opacity: 1; filter: blur(0); } 100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; filter: blur(6px); } }
.cine-sub { position: absolute; top: calc(70% + clamp(44px, 10vw, 76px)); left: 50%; transform: translateX(-50%); font-weight: 700; font-size: 18px; padding: 6px 16px; border-radius: 99px; background: rgba(15, 23, 42, 0.85); border: 1px solid var(--c); white-space: nowrap; animation: fade 0.3s 0.35s backwards, cine-out 1.45s forwards; }
@keyframes cine-out { 80% { opacity: 1; } 100% { opacity: 0; } }

/* ฟ้าผ่า + แฟลชขาว */
.strike { position: fixed; top: 0; left: 50%; width: min(28vw, 160px); height: 46vh; transform: translateX(-50%); z-index: 74; pointer-events: none; filter: drop-shadow(0 0 18px #60a5fa) drop-shadow(0 0 40px #2b7fff); animation: strike 0.6s ease-out forwards; }
.strike svg { width: 100%; height: 100%; }
@keyframes strike { 0% { clip-path: inset(0 0 100% 0); opacity: 1; } 25% { clip-path: inset(0 0 0 0); opacity: 1; } 40% { opacity: 0.4; } 55% { opacity: 1; } 100% { opacity: 0; } }
.white-flash { position: fixed; inset: 0; background: #fff; z-index: 73; pointer-events: none; animation: wflash 0.45s ease-out forwards; }
@keyframes wflash { 0% { opacity: 0; } 15% { opacity: 0.75; } 100% { opacity: 0; } }

/* ตัวอักษร glitch (UNO! / จับได้!) */
.glitch { position: fixed; left: 50%; top: 40%; transform: translate(-50%, -50%); z-index: 72; pointer-events: none; text-align: center; animation: glitch-in 1.35s cubic-bezier(0.2, 1.5, 0.4, 1) forwards; }
.glitch span { position: relative; display: inline-block; font-family: 'Kanit'; font-weight: 700; font-size: clamp(64px, 20vw, 140px); color: #fff; -webkit-text-stroke: 3px #0b1020; text-shadow: 0 0 40px var(--c), 0 8px 0 rgba(0, 0, 0, 0.35); }
.glitch span::before, .glitch span::after { content: attr(data-t); position: absolute; inset: 0; -webkit-text-stroke: 0; }
.glitch span::before { color: #ef4444; animation: glitch-a 0.35s steps(2) 3; clip-path: inset(0 0 60% 0); transform: translate(-6px, 0); opacity: 0.8; }
.glitch span::after { color: #3b82f6; animation: glitch-b 0.35s steps(2) 3; clip-path: inset(55% 0 0 0); transform: translate(6px, 0); opacity: 0.8; }
.glitch small { display: block; margin-top: 4px; font-weight: 700; font-size: 18px; padding: 6px 14px; border-radius: 99px; background: rgba(15, 23, 42, 0.9); border: 1px solid var(--c); }
@keyframes glitch-in { 0% { transform: translate(-50%, -50%) scale(0.2) rotate(-10deg); opacity: 0; } 22% { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; } 32% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { transform: translate(-50%, -70%) scale(0.95); opacity: 0; } }
@keyframes glitch-a { 50% { transform: translate(5px, -2px); clip-path: inset(20% 0 40% 0); } }
@keyframes glitch-b { 50% { transform: translate(-5px, 2px); clip-path: inset(40% 0 20% 0); } }

/* วงกระเพื่อมบอกตา */
.ping { position: fixed; width: 60px; height: 60px; margin: -30px; border-radius: 50%; border: 3px solid var(--c); z-index: 56; pointer-events: none; animation: ping 0.9s ease-out forwards; }
@keyframes ping { from { transform: scale(0.6); opacity: 1; } to { transform: scale(2.6); opacity: 0; } }

/* ไพ่เข้ามือแบบพลิก 3 มิติ */
.hand { perspective: 900px; }
.hand .card { transform-style: preserve-3d; }
.hand .card.flip-in { animation: flip-in 0.55s cubic-bezier(0.2, 1.2, 0.4, 1) backwards; }
@keyframes flip-in { 0% { transform: translateY(-120px) rotateY(180deg) scale(0.6); opacity: 0; } 60% { transform: translateY(6px) rotateY(-10deg) scale(1.05); opacity: 1; } 100% { transform: none; } }
.hand.wave .card { animation: wave 0.6s ease both; }
@keyframes wave { 40% { transform: translateY(-22px); } }

/* ขอบจอแดงเมื่อเวลาใกล้หมด (ตาเรา) */
body.hurry::after { content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 70; box-shadow: inset 0 0 0 4px rgba(239, 68, 68, 0.7), inset 0 0 90px rgba(239, 68, 68, 0.55); animation: pulse 0.6s infinite; }

/* แบนเนอร์ตาเรา: สไลด์เข้า */
.turn-banner.mine { animation: banner-in 0.5s cubic-bezier(0.2, 1.4, 0.4, 1), pulse 1.2s 0.5s infinite; }
@keyframes banner-in { from { transform: translate(-50%, -30px) scale(0.6); opacity: 0; } }

/* ขอบไฟวิ่งรอบผู้เล่นที่ถึงตา */
@property --a { syntax: "<angle>"; inherits: false; initial-value: 0deg; }
.opp.turn::before { content: ""; position: absolute; inset: -2px; border-radius: 16px; padding: 2px; background: conic-gradient(from var(--a), transparent 0 70%, var(--cur) 85%, transparent 100%); -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0); -webkit-mask-composite: xor; mask-composite: exclude; animation: spin-a 1.6s linear infinite; }
@keyframes spin-a { to { --a: 360deg; } }

/* กองจั่ว: หายใจเรืองแสง */
#drawPile .stack { animation: breathe 3s ease-in-out infinite; }
@keyframes breathe { 50% { filter: drop-shadow(0 0 14px rgba(43, 127, 255, 0.55)); } }

/* ล็อบบี้: รอคนเปิดเกม */
.seat.waiting .av { opacity: 0.4; }
.seat.waiting .name::after { content: " · รอเปิดเกม"; color: var(--muted); }
.countdown { font-family: "Kanit"; font-size: 20px; color: var(--brand-light); }

/* จบเกม: มงกุฎหล่น + อันดับไหลเข้า */
.end-sheet .winner .crown { animation: crown-drop 0.8s 0.3s cubic-bezier(0.3, 1.6, 0.5, 1) backwards, float 2s 1.1s ease-in-out infinite; }
@keyframes crown-drop { from { transform: translate(-50%, -120px) rotate(-30deg); opacity: 0; } }
.rank > div { animation: slide-in 0.45s cubic-bezier(0.2, 1.2, 0.4, 1) backwards; }
.rank > div:nth-child(1) { animation-delay: 0.5s; }
.rank > div:nth-child(2) { animation-delay: 0.6s; }
.rank > div:nth-child(3) { animation-delay: 0.7s; }
.rank > div:nth-child(4) { animation-delay: 0.8s; }
.rank > div:nth-child(n+5) { animation-delay: 0.9s; }
@keyframes slide-in { from { transform: translateX(-40px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
