/* ================= WEREWOLF (Activity) · ธีมเติมเกมออนไลน์ ================= */
#ww { overflow: hidden; }
#ww .topbar { z-index: 6; }

/* ===== ท้องฟ้าตามช่วงเวลา ===== */
.ww-sky { position: absolute; inset: 0; z-index: 0; transition: background 2s ease; background: linear-gradient(180deg, #0b1020, #13254a 55%, #0a1328); overflow: hidden; }
body.ww-night .ww-sky, body.ww-roles .ww-sky, body.ww-hunter .ww-sky { background: linear-gradient(180deg, #02040c, #0b1433 50%, #120d2e); }
body.ww-morning .ww-sky, body.ww-day .ww-sky { background: linear-gradient(180deg, #f59e0b 0%, #f97316 22%, #7c3aed 60%, #1e1b4b 100%); }
body.ww-day .ww-sky { background: linear-gradient(180deg, #38bdf8 0%, #2b7fff 35%, #1e3a8a 75%, #0f172a 100%); }
body.ww-vote .ww-sky, body.ww-result .ww-sky { background: linear-gradient(180deg, #450a0a, #7f1d1d 40%, #1c0510 100%); }
body.ww-ended .ww-sky { background: linear-gradient(180deg, #0b1020, #13254a 60%, #0f172a); }
.ww-stars { position: absolute; inset: 0; background-image: radial-gradient(1.5px 1.5px at 20px 30px, #fff, transparent), radial-gradient(1px 1px at 120px 80px, #c7d2fe, transparent), radial-gradient(1.5px 1.5px at 220px 160px, #fff, transparent), radial-gradient(1px 1px at 320px 50px, #e0e7ff, transparent), radial-gradient(1.2px 1.2px at 380px 210px, #fff, transparent); background-size: 400px 260px; opacity: 0; transition: opacity 2s; animation: twinkle 4s ease-in-out infinite alternate; }
body.ww-night .ww-stars, body.ww-roles .ww-stars, body.ww-hunter .ww-stars, body.ww-lobby .ww-stars, body.ww-ended .ww-stars { opacity: 0.9; }
@keyframes twinkle { to { filter: brightness(1.6); } }
.ww-moon { position: absolute; top: 9%; right: 10%; width: clamp(60px, 14vw, 110px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fffbe8, #fde68a 55%, #eab308); box-shadow: 0 0 60px 20px rgba(253, 230, 138, 0.35), inset -14px -10px 0 rgba(0, 0, 0, 0.12); opacity: 0; transform: translateY(40px); transition: opacity 2s, transform 2s; }
body.ww-night .ww-moon, body.ww-roles .ww-moon, body.ww-hunter .ww-moon, body.ww-lobby .ww-moon { opacity: 1; transform: none; }
.ww-sun { position: absolute; top: 10%; left: 12%; width: clamp(60px, 13vw, 100px); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, #fff7d6, #fde047 50%, #f59e0b); box-shadow: 0 0 80px 30px rgba(253, 224, 71, 0.45); opacity: 0; transform: translateY(80px); transition: opacity 2s, transform 2.4s cubic-bezier(0.2, 0.8, 0.2, 1); }
body.ww-morning .ww-sun, body.ww-day .ww-sun { opacity: 1; transform: none; }
.ww-fog { position: absolute; left: -20%; right: -20%; height: 30%; bottom: 0; background: radial-gradient(ellipse at 50% 100%, rgba(148, 163, 184, 0.22), transparent 70%); animation: fog 18s linear infinite alternate; opacity: 0; transition: opacity 2s; }
.ww-fog.f2 { bottom: 12%; animation-duration: 26s; animation-direction: alternate-reverse; }
body.ww-night .ww-fog, body.ww-roles .ww-fog { opacity: 1; }
@keyframes fog { to { transform: translateX(12%); } }

/* ===== แถบเฟส + ตัวนับเวลา ===== */
.ww-phase { position: relative; z-index: 4; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 10px 12px 0; }
.ww-phase-title { font-family: 'Kanit'; font-weight: 700; font-size: clamp(20px, 5.5vw, 30px); text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); }
.ww-timer { --p: 1; position: relative; width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; font-family: 'Kanit'; font-size: 16px; background: conic-gradient(var(--tc, #60a5fa) calc(var(--p) * 360deg), rgba(255, 255, 255, 0.12) 0); }
.ww-timer::before { content: ""; position: absolute; inset: 5px; border-radius: 50%; background: rgba(11, 16, 32, 0.92); }
.ww-timer span { position: relative; }
.ww-timer.warn { --tc: #ef4444; animation: pulse 0.6s infinite; }
.ww-timer:empty, .ww-timer.off { display: none; }

/* ===== วงผู้เล่นรอบกองไฟ ===== */
.ww-stage { position: relative; z-index: 3; flex: 1; min-height: 0; }
.ww-circle { position: absolute; inset: 0; }
.ww-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.ww-lines line { stroke: #f87171; stroke-width: 3; stroke-dasharray: 8 6; animation: dash 0.8s linear infinite; filter: drop-shadow(0 0 4px #ef4444); }
@keyframes dash { to { stroke-dashoffset: -28; } }
.ww-fire { position: absolute; left: 50%; top: 50%; width: clamp(54px, 13vw, 84px); height: clamp(64px, 15vw, 100px); transform: translate(-50%, -40%); pointer-events: none; z-index: 1; }
.ww-fire i { position: absolute; bottom: 14%; left: 50%; width: 60%; height: 80%; border-radius: 50% 50% 20% 20% / 60% 60% 40% 40%; transform: translateX(-50%); background: radial-gradient(circle at 50% 80%, #fff7d6, #fbbf24 35%, #f97316 60%, rgba(239, 68, 68, 0) 75%); filter: blur(1px); animation: flame 0.9s ease-in-out infinite alternate; }
.ww-fire i:nth-child(2) { width: 40%; height: 60%; left: 38%; animation-duration: 0.7s; opacity: 0.85; }
.ww-fire i:nth-child(3) { width: 40%; height: 55%; left: 62%; animation-duration: 1.1s; opacity: 0.8; }
.ww-fire b { position: absolute; bottom: 0; left: 50%; width: 110%; height: 22%; transform: translateX(-50%); border-radius: 40%; background: repeating-linear-gradient(20deg, #78350f 0 8px, #451a03 8px 14px); box-shadow: 0 0 40px 18px rgba(249, 115, 22, 0.35); }
@keyframes flame { to { transform: translateX(-50%) scaleY(1.12) scaleX(0.92); filter: blur(1.5px) brightness(1.15); } }
body.ww-day .ww-fire, body.ww-vote .ww-fire { opacity: 0.55; }

.tok { position: absolute; width: var(--ts, 74px); transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; gap: 3px; transition: left 0.6s, top 0.6s, filter 0.6s, opacity 0.6s; cursor: default; z-index: 3; }
.tok .ava { position: relative; width: calc(var(--ts, 74px) * 0.78); aspect-ratio: 1; border-radius: 50%; padding: 3px; background: linear-gradient(135deg, #2b7fff, #60a5fa); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); transition: transform 0.2s, box-shadow 0.3s, background 0.3s; }
.tok .ava img, .tok .ava .ph { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: #13254a; font-weight: 700; font-size: 20px; }
.tok .nm { max-width: calc(var(--ts, 74px) + 14px); font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: rgba(5, 8, 15, 0.7); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tok .bd { position: absolute; font-size: 15px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.7)); }
.tok .bd.tl { top: -4px; left: -2px; } .tok .bd.tr { top: -4px; right: -2px; } .tok .bd.br { bottom: 20px; right: -4px; font-size: 20px; } .tok .bd.bl { bottom: 20px; left: -4px; }
.tok .crown { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 16px; }
.tok.me .ava { background: linear-gradient(135deg, #facc15, #f59e0b); }
.tok.mate .ava { background: linear-gradient(135deg, #ef4444, #991b1b); }
.tok.offline { opacity: 0.55; }
.tok.dead { filter: grayscale(1) brightness(0.55); }
.tok.dead .ava::after { content: "💀"; position: absolute; inset: 0; display: grid; place-items: center; font-size: 26px; background: rgba(0, 0, 0, 0.35); border-radius: 50%; }
.tok.tappable { cursor: pointer; }
.tok.tappable .ava { animation: tap-hint 1.6s ease-in-out infinite; }
.tok.tappable:hover .ava { transform: scale(1.08); }
@keyframes tap-hint { 50% { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.35), 0 6px 18px rgba(0, 0, 0, 0.5); } }
.tok.picked .ava { box-shadow: 0 0 0 4px var(--pc, #ef4444), 0 0 26px 6px var(--pc, #ef4444); transform: scale(1.08); }
.tok.picked::before { content: ""; position: absolute; top: calc(var(--ts, 74px) * 0.39); left: 50%; width: calc(var(--ts, 74px) * 1.05); aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%; border: 2px dashed var(--pc, #ef4444); animation: spin 6s linear infinite; pointer-events: none; }
.tok .cnt { position: absolute; top: -12px; white-space: nowrap; z-index: 2; left: 50%; transform: translateX(-50%); min-width: 24px; padding: 1px 7px; border-radius: 99px; font-family: 'Kanit'; font-size: 14px; background: #dc2626; box-shadow: 0 0 12px #ef4444; animation: pop 0.3s; }
.tok .voted { position: absolute; bottom: 22px; right: -2px; width: 20px; height: 20px; border-radius: 50%; background: #22c55e; display: grid; place-items: center; font-size: 12px; }
.tok.shake { animation: tok-shake 0.5s; }
@keyframes tok-shake { 20%, 60% { transform: translate(calc(-50% - 6px), -50%); } 40%, 80% { transform: translate(calc(-50% + 6px), -50%); } }
.claw { position: absolute; inset: -10%; pointer-events: none; z-index: 5; }
.claw i { position: absolute; top: 10%; height: 80%; width: 5px; border-radius: 4px; background: linear-gradient(#fecaca, #dc2626); box-shadow: 0 0 10px #ef4444; transform: rotate(25deg) scaleY(0); transform-origin: top; animation: claw 0.45s ease-out forwards; }
.claw i:nth-child(1) { left: 28%; } .claw i:nth-child(2) { left: 48%; animation-delay: 0.06s; } .claw i:nth-child(3) { left: 68%; animation-delay: 0.12s; }
@keyframes claw { 60% { transform: rotate(25deg) scaleY(1); opacity: 1; } 100% { transform: rotate(25deg) scaleY(1); opacity: 0; } }

/* ===== คำแนะนำ + แถบปุ่ม ===== */
.ww-hint { position: relative; z-index: 4; text-align: center; padding: 0 16px; min-height: 26px; font-weight: 600; text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8); }
.ww-hint b { color: #fde68a; }
.ww-bar { position: relative; z-index: 4; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; padding: 10px 12px calc(12px + env(safe-area-inset-bottom)); }
.ww-bar .btn { padding: 10px 16px; font-size: 15px; }
.ww-bar .btn .badge { min-width: 20px; padding: 0 6px; border-radius: 99px; background: #ef4444; font-size: 12px; }
.ww-panel { position: relative; z-index: 4; margin: 0 auto 6px; width: min(560px, calc(100% - 24px)); }
.ww-chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 6px 0; }
.ww-chips span { padding: 4px 10px; border-radius: 99px; font-size: 13px; background: rgba(13, 26, 54, 0.85); border: 1px solid rgba(96, 165, 250, 0.25); }
.ww-chips span.maybe { border-style: dashed; color: #cbd5e1; }

/* หลับตาตอนกลางคืน (บทไม่มีพลัง) */
.ww-sleep { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; pointer-events: none; background: radial-gradient(circle, rgba(2, 4, 12, 0.35), rgba(2, 4, 12, 0.8)); animation: fade 1s; }
.ww-sleep div { font-family: 'Kanit'; font-size: 22px; text-align: center; color: #c7d2fe; animation: float 3s ease-in-out infinite; }
.ww-sleep div b { display: block; font-size: 46px; letter-spacing: 6px; color: #a5b4fc; }

/* ===== การ์ดบท ===== */
.role-card { width: min(300px, 78vw); margin: 0 auto; aspect-ratio: 0.68; border-radius: 22px; position: relative; perspective: 1000px; }
.role-card .in { position: absolute; inset: 0; transform-style: preserve-3d; animation: role-flip 1.1s cubic-bezier(0.2, 0.9, 0.2, 1) both; }
.role-card .f, .role-card .b { position: absolute; inset: 0; border-radius: 22px; backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 18px; text-align: center; }
.role-card .b { background: radial-gradient(circle at 30% 20%, #60a5fa, #2b7fff 45%, #1a4f9c); border: 4px solid #fff; transform: rotateY(180deg); }
.role-card .b::after { content: "🐺"; font-size: 90px; filter: drop-shadow(0 0 20px #0b1020); }
.role-card .f { background: radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--rc) 45%, #0b1020), #0b1020 70%); border: 4px solid var(--rc); box-shadow: 0 0 50px -6px var(--rc); }
.role-card .em { font-size: clamp(70px, 22vw, 110px); line-height: 1; filter: drop-shadow(0 0 24px var(--rc)); animation: float 3s ease-in-out infinite; }
.role-card .rn { font-family: 'Kanit'; font-size: 34px; color: var(--rc); text-shadow: 0 0 20px var(--rc); }
.role-card .tm { font-size: 13px; padding: 3px 12px; border-radius: 99px; background: rgba(0, 0, 0, 0.45); border: 1px solid var(--rc); }
@keyframes role-flip { from { transform: rotateY(180deg) scale(0.6); } 60% { transform: rotateY(-12deg) scale(1.04); } to { transform: rotateY(0) scale(1); } }
.role-help { text-align: left; margin: 14px 0 4px; font-size: 14px; color: #e2e8f0; line-height: 1.6; }
.role-help b { color: #fde68a; }

/* เปิดเผยการตาย / ผลส่อง */
.reveal { text-align: center; }
.reveal .who { position: relative; width: 120px; height: 120px; margin: 4px auto 10px; }
.reveal .who .ava { width: 100%; height: 100%; border-radius: 50%; padding: 4px; background: var(--rc, #ef4444); box-shadow: 0 0 40px var(--rc, #ef4444); }
.reveal .who img, .reveal .who .ph { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: #13254a; font-size: 40px; }
.reveal .verdict { font-family: 'Kanit'; font-size: 30px; margin: 4px 0; }

/* ===== แชทลับ ===== */
.ww-chat { position: fixed; left: 0; right: 0; bottom: 0; z-index: 85; max-height: 62vh; display: flex; flex-direction: column; background: linear-gradient(180deg, #13254a, #0b1020); border-top: 2px solid rgba(96, 165, 250, 0.4); border-radius: 22px 22px 0 0; box-shadow: 0 -20px 50px rgba(0, 0, 0, 0.6); animation: sheet-up 0.3s cubic-bezier(0.2, 1, 0.3, 1); }
@keyframes sheet-up { from { transform: translateY(100%); } }
.ww-chat header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; font-family: 'Kanit'; }
.ww-chat header .x { margin-left: auto; }
.ww-chat .tabs { display: flex; gap: 6px; padding: 0 14px 8px; }
.ww-chat .tabs button { padding: 6px 12px; border-radius: 10px; background: rgba(255, 255, 255, 0.06); font-weight: 600; font-size: 13px; }
.ww-chat .tabs button.on { background: var(--grad); }
.ww-chat .msgs { flex: 1; overflow-y: auto; padding: 4px 14px; display: flex; flex-direction: column; gap: 6px; min-height: 120px; }
.ww-chat .m { max-width: 85%; padding: 7px 11px; border-radius: 14px; background: rgba(255, 255, 255, 0.08); font-size: 14px; word-break: break-word; }
.ww-chat .m b { display: block; font-size: 11px; color: #93c5fd; }
.ww-chat .m.mine { align-self: flex-end; background: rgba(43, 127, 255, 0.35); }
.ww-chat .empty { color: var(--muted); text-align: center; padding: 20px; font-size: 14px; }
.ww-chat form { display: flex; gap: 8px; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); }
.ww-chat input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 14px; border: 1px solid rgba(96, 165, 250, 0.3); background: rgba(5, 8, 15, 0.7); color: #fff; font: inherit; }

/* ===== หน้าเลือกเกม ===== */
#picker .body { flex: 1; overflow: auto; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 18px 16px; }
#picker h1 { margin: 0; font-size: clamp(26px, 7vw, 38px); text-align: center; }
.game-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; width: min(620px, 100%); }
.game-card { position: relative; overflow: hidden; border-radius: 22px; padding: 22px 18px; text-align: left; min-height: 170px; border: 1px solid rgba(96, 165, 250, 0.3); transition: transform 0.18s, box-shadow 0.2s; display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; }
.game-card:hover { transform: translateY(-4px); box-shadow: 0 18px 40px -12px rgba(43, 127, 255, 0.7); }
.game-card .gi { position: absolute; top: 10px; right: 14px; font-size: 64px; filter: drop-shadow(0 0 16px rgba(255, 255, 255, 0.35)); animation: float 3s ease-in-out infinite; }
.game-card h2 { margin: 0; font-size: 28px; }
.game-card p { margin: 0; color: #cbd5e1; font-size: 14px; }
.game-card.uno { background: radial-gradient(circle at 80% 10%, rgba(239, 68, 68, 0.5), transparent 50%), linear-gradient(160deg, #13254a, #0b1020); }
.game-card.ww { background: radial-gradient(circle at 80% 10%, rgba(139, 92, 246, 0.55), transparent 50%), linear-gradient(160deg, #1e1b4b, #0b1020); }

/* ===== ตั้งค่าเอฟเฟกต์ส่วนตัว ===== */
.fx-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.fx-presets button { padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.06); border: 1px solid rgba(96, 165, 250, 0.25); font-weight: 700; }
.fx-presets button small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

/* ปิดพื้นหลังเคลื่อนไหวตามตั้งค่าของผู้เล่น */
body.fx-lite .ww-fog, body.fx-lite .ww-stars { animation: none !important; }
body.fx-lite .felt::before, body.fx-lite .topbar::after, body.fx-lite #drawPile .stack { animation: none !important; }
.game-card .link { align-self: flex-start; margin-top: 8px; font-size: 13px; padding: 4px 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.1); }
.game-card .link:hover { background: rgba(255, 255, 255, 0.2); }
#picker .hero-logo { width: min(220px, 60vw); }
#picker .hint { color: var(--muted); text-align: center; font-size: 13px; margin: 0; }
.fx-presets button.on { background: var(--grad); border-color: transparent; }
.ww-panel .settings { margin: 0; padding: 10px 14px; }
.fx-presets button.on small { color: rgba(255, 255, 255, 0.85); }
/* artwork บท (วาดเอง) */
.role-card .em .role-art { width: clamp(96px, 30vw, 150px); height: auto; filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.55)) drop-shadow(0 0 22px var(--rc)); }
.tok .bd .em, .ww-chips .em { width: 1.3em; height: 1.3em; vertical-align: -0.35em; }
.tok .bd.br { bottom: 16px; right: -10px; }
.tok .bd.br .em { width: 28px; height: 28px; filter: drop-shadow(0 2px 3px #000); }
