/* ===== Werewolf Online — tema malam interaktif ===== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --bg1: #0b1026; --bg2: #1b2350;
  --card: rgba(255,255,255,.07); --card-border: rgba(255,255,255,.14);
  --text: #eef1ff; --muted: #a7aed6;
  --accent: #ffb347; --accent2: #7c5cff; --danger: #ff5c7a; --ok: #4ade80;
}
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  color: var(--text); min-height: 100vh; overflow-x: hidden;
  background: linear-gradient(180deg, var(--bg1), var(--bg2));
  transition: background 1.2s ease;
}
body.phase-day { --bg1: #2b1a3e; --bg2: #8a4b6e; background: linear-gradient(180deg, #3a2358, #b85c70 130%); }
body.phase-voting { --bg1: #170b2e; --bg2: #3d1a63; }
body.phase-over { --bg1: #0e2a1a; --bg2: #14532d; }
body.phase-lobby { --bg1: #0b1026; --bg2: #27356e; }

/* bintang berkelip + bulan */
.stars {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(2px 2px at 20px 30px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 130px 90px, #cdd6ff 50%, transparent 51%),
    radial-gradient(2px 2px at 250px 50px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 320px 140px, #ffe9b0 50%, transparent 51%),
    radial-gradient(2px 2px at 70px 180px, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 200px 220px, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 340px 260px, #cdd6ff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 160px 320px, #fff 50%, transparent 51%);
  background-size: 380px 380px;
  animation: twinkle 3.2s ease-in-out infinite alternate;
  opacity: .9;
}
body.phase-day .stars { opacity: .15; }
@keyframes twinkle { from { opacity: .45; } to { opacity: .95; } }
.moon {
  position: fixed; top: 22px; right: 22px; width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fffbe8, #f5d97e 60%, #e8b93c);
  box-shadow: 0 0 44px 10px rgba(245,217,126,.45);
  z-index: 0; pointer-events: none; animation: moonPulse 5s ease-in-out infinite;
}
body.phase-day .moon {
  background: radial-gradient(circle at 35% 35%, #fff7d6, #ffd93c 60%, #ff9d2e);
  box-shadow: 0 0 60px 18px rgba(255,180,60,.55);
}
@keyframes moonPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }

header#topbar {
  position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: rgba(8,10,28,.75); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--card-border);
}
.brand { font-weight: 800; letter-spacing: .3px; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.chip { background: var(--accent2); padding: 4px 10px; border-radius: 999px; font-weight: 700; font-size: .85rem; }

main { position: relative; z-index: 1; max-width: 560px; margin: 0 auto; padding: 18px 14px 60px; }
.hidden { display: none !important; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.hero { text-align: center; padding: 26px 0 8px; animation: fadeUp .7s ease both; }
.hero-wolf { font-size: 84px; animation: bob 3s ease-in-out infinite; filter: drop-shadow(0 10px 24px rgba(0,0,0,.5)); }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.hero h1 { margin: 4px 0; font-size: 2.1rem; letter-spacing: 2px; }
.hero h1 span { color: var(--accent); }
.tagline { color: var(--muted); max-width: 420px; margin: 6px auto 0; line-height: 1.5; }

.card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: 18px;
  padding: 16px; margin: 14px 0; backdrop-filter: blur(6px);
  animation: fadeUp .5s ease both;
}
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card h3 { margin: 2px 0 10px; }
.lbl { display: block; font-size: .85rem; color: var(--muted); margin: 8px 0 6px; }
input[type="text"], select {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid var(--card-border);
  background: rgba(0,0,0,.35); color: var(--text); font-size: 1.05rem; outline: none;
}
input[type="text"]:focus, select:focus { border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(124,92,255,.25); }
.code-input { text-transform: uppercase; letter-spacing: 4px; font-weight: 800; text-align: center; font-size: 1.3rem; }

.btn {
  display: inline-block; border: none; cursor: pointer; border-radius: 12px;
  padding: 11px 16px; font-size: 1rem; font-weight: 700; color: var(--text);
  background: rgba(255,255,255,.12); transition: transform .12s ease, filter .2s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent2), #b45cff); box-shadow: 0 8px 22px rgba(124,92,255,.35); }
.btn.big { width: 100%; margin-top: 12px; padding: 15px; font-size: 1.08rem; }
.btn.small { padding: 7px 12px; font-size: .85rem; }
.btn.ghost { background: rgba(255,255,255,.08); }
.btn.danger { background: rgba(255,92,122,.22); color: #ffb3c0; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .82rem; margin: 18px 0 4px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--card-border); }

.howto ol { margin: 6px 0 2px 18px; padding: 0; line-height: 1.55; color: var(--muted); }
.howto summary, details.card summary { cursor: pointer; font-weight: 700; }

.room-code {
  font-size: 3rem; font-weight: 900; letter-spacing: 10px; margin: 6px 0 10px;
  color: var(--accent); text-shadow: 0 4px 22px rgba(255,179,71,.35);
}
.player-list { list-style: none; margin: 0; padding: 0; }
.player-list li {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px;
  background: rgba(0,0,0,.22); margin-bottom: 7px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); flex: none; }
.dot.off { background: #666; box-shadow: none; }
.badge { font-size: .72rem; background: var(--accent2); border-radius: 999px; padding: 2px 8px; font-weight: 700; }
.badge.dead { background: var(--danger); }
.player-list .role { margin-left: auto; font-weight: 700; }

.switch-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px dashed rgba(255,255,255,.08); }
.switch-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent2); }
.switch-row select { width: auto; }

.phase-banner {
  text-align: center; font-size: 1.5rem; font-weight: 900; letter-spacing: 1px;
  padding: 14px; border-radius: 16px; margin-top: 6px;
  background: linear-gradient(135deg, rgba(124,92,255,.35), rgba(255,179,71,.22));
  border: 1px solid var(--card-border); animation: bannerIn .6s ease both;
}
@keyframes bannerIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.announce { border-left: 4px solid var(--accent); }
.announce-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 4px; }

.role-chip {
  text-align: center; font-weight: 800; padding: 10px; border-radius: 12px; margin: 12px 0;
  background: rgba(0,0,0,.35); border: 1px dashed var(--card-border);
}

/* kartu peran flip */
.flip-wrap { perspective: 900px; display: flex; justify-content: center; margin: 18px 0; }
.flip-card {
  width: 250px; height: 340px; position: relative; cursor: pointer;
  transform-style: preserve-3d; transition: transform .8s cubic-bezier(.2,.7,.3,1.2);
}
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 20px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 20px; text-align: center; border: 2px solid var(--card-border);
  background: linear-gradient(160deg, #232a5e, #12173a); font-weight: 700;
}
.flip-back { transform: rotateY(180deg); background: linear-gradient(160deg, #3b2a63, #1d1440); }
.flip-emoji { font-size: 64px; }
.role-big { font-size: 72px; }
.role-name { font-size: 1.5rem; font-weight: 900; }
.role-desc { color: var(--muted); font-size: .92rem; line-height: 1.5; font-weight: 500; }

/* panel aksi */
.action-card { border: 1px solid var(--accent2); box-shadow: 0 0 0 3px rgba(124,92,255,.15), 0 14px 34px rgba(0,0,0,.35); }
.target-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 10px; }
.target-btn {
  border: 1px solid var(--card-border); background: rgba(0,0,0,.3); color: var(--text);
  border-radius: 12px; padding: 13px 10px; font-size: 1rem; font-weight: 700; cursor: pointer;
  transition: transform .1s, background .2s, border-color .2s;
}
.target-btn:hover { background: rgba(124,92,255,.25); border-color: var(--accent2); }
.target-btn:active { transform: scale(.96); }
.target-btn.picked { background: var(--accent2); border-color: #fff; }
.target-btn:disabled { opacity: .4; }
.timerbar { height: 10px; border-radius: 99px; background: rgba(255,255,255,.12); overflow: hidden; margin: 10px 0 4px; }
.timerbar > div { height: 100%; background: linear-gradient(90deg, var(--accent), #ff7847); border-radius: 99px; transition: width .5s linear; }
.timer-text { font-size: .85rem; color: var(--muted); text-align: right; }
.waiting { text-align: center; padding: 10px 4px; }
.pulse { animation: pulse 1.6s ease-in-out infinite; display: inline-block; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.18); opacity: .75; } }
.result-box { border-radius: 12px; padding: 12px; margin-top: 10px; font-weight: 700; text-align: center; }
.result-wolf { background: rgba(255,92,122,.2); border: 1px solid var(--danger); }
.result-safe { background: rgba(74,222,128,.16); border: 1px solid var(--ok); }

/* daftar warga */
.players-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 9px; }
.tile {
  background: rgba(0,0,0,.28); border: 1px solid var(--card-border); border-radius: 14px;
  padding: 10px 6px; text-align: center; position: relative; transition: filter .4s, opacity .4s;
}
.tile .avatar { font-size: 30px; }
.tile .tname { font-weight: 700; font-size: .9rem; margin-top: 3px; word-break: break-word; }
.tile .tstatus { font-size: .72rem; color: var(--muted); }
.tile.dead { filter: grayscale(1); opacity: .55; }
.tile.dead::after { content: '💀'; position: absolute; top: 4px; right: 7px; font-size: 15px; }
.tile .cdot { position: absolute; top: 7px; left: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.tile .cdot.off { background: #666; }

.tally-row { display: flex; align-items: center; gap: 10px; margin: 7px 0; }
.tally-name { width: 110px; font-weight: 700; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tally-bar { flex: 1; height: 16px; background: rgba(255,255,255,.1); border-radius: 99px; overflow: hidden; }
.tally-bar > div { height: 100%; background: linear-gradient(90deg, var(--danger), #ff9d47); width: 0; transition: width .8s ease; }
.tally-count { font-weight: 800; width: 24px; text-align: right; }

.log-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
.log-list li { padding: 6px 4px; border-bottom: 1px dashed rgba(255,255,255,.07); color: var(--muted); font-size: .9rem; }

/* chat diskusi */
.chat-list { max-height: 250px; overflow-y: auto; display: flex; flex-direction: column; gap: 7px; padding: 4px 2px; }
.chat-msg { background: rgba(0,0,0,.28); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 7px 11px; max-width: 88%; align-self: flex-start; animation: fadeUp .3s ease both; }
.chat-msg.mine { align-self: flex-end; background: rgba(124,92,255,.28); border-color: rgba(124,92,255,.5); }
.chat-msg .cname { font-size: .72rem; font-weight: 800; color: var(--accent); display: block; margin-bottom: 1px; }
.chat-msg.mine .cname { color: #cdbfff; }
.chat-msg .ctext { font-size: .93rem; line-height: 1.4; word-break: break-word; }
.chat-row { display: flex; gap: 8px; margin-top: 10px; }
.chat-row input { flex: 1; }
.chat-row .btn { flex: none; }
.chat-empty { color: var(--muted); font-size: .88rem; text-align: center; padding: 8px 0; }

.over-emoji { font-size: 76px; animation: bob 2.4s ease-in-out infinite; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #1d1440; border: 1px solid var(--danger); color: #ffd7de; padding: 12px 18px;
  border-radius: 12px; z-index: 50; opacity: 0; pointer-events: none; transition: all .3s ease;
  max-width: 88vw; text-align: center; font-weight: 600;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti-piece { position: absolute; top: -40px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .9; } }

@media (max-width: 420px) {
  .room-code { font-size: 2.3rem; letter-spacing: 6px; }
  .hero h1 { font-size: 1.7rem; }
  .flip-card { width: 220px; height: 310px; }
}

/* ---------- overlay efek narator (animasi momen game) ---------- */
#fxOverlay { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; pointer-events: none; opacity: 0; }
#fxOverlay.show { animation: fxFade 2s ease forwards; }
#fxEmoji { font-size: 110px; line-height: 1; filter: drop-shadow(0 10px 24px rgba(0,0,0,.45)); }
#fxText { font-size: clamp(20px, 5vw, 30px); font-weight: 800; color: #fff; text-shadow: 0 2px 14px rgba(0,0,0,.65); letter-spacing: .3px; }
#fxOverlay.fx-night { background: radial-gradient(ellipse at center, rgba(10,16,48,.25), rgba(4,6,26,.78)); }
#fxOverlay.fx-night #fxEmoji { animation: fxMoon 2s ease; }
#fxOverlay.fx-attack { background: radial-gradient(ellipse at center, rgba(80,0,0,.25), rgba(30,0,0,.82)); }
#fxOverlay.fx-attack #fxEmoji { animation: fxLunge 2s ease; }
#fxOverlay.fx-calm { background: radial-gradient(ellipse at center, rgba(255,170,60,.12), rgba(60,30,0,.45)); }
#fxOverlay.fx-calm #fxEmoji, #fxOverlay.fx-vote #fxEmoji, #fxOverlay.fx-win #fxEmoji, #fxOverlay.fx-hunter #fxEmoji { animation: fxPop 2s ease; }
#fxOverlay.fx-vote { background: radial-gradient(ellipse at center, rgba(40,60,140,.15), rgba(6,10,40,.6)); }
#fxOverlay.fx-win { background: radial-gradient(ellipse at center, rgba(255,200,0,.15), rgba(50,35,0,.5)); }
#fxOverlay.fx-execution { background: radial-gradient(ellipse at center, rgba(60,60,60,.2), rgba(0,0,0,.75)); }
#fxOverlay.fx-execution #fxEmoji { animation: fxDrop 2s ease; }
#fxOverlay.fx-hunter { background: radial-gradient(ellipse at center, rgba(120,60,0,.2), rgba(20,10,0,.7)); }
#fxOverlay.fx-shot { background: radial-gradient(ellipse at center, rgba(255,120,0,.25), rgba(40,10,0,.7)); }
#fxOverlay.fx-shot #fxEmoji { animation: fxBoom 2s ease; }
@keyframes fxFade { 0% { opacity: 0; } 12% { opacity: 1; } 78% { opacity: 1; } 100% { opacity: 0; } }
@keyframes fxMoon { 0% { transform: translateY(-70px) scale(.6); opacity: 0; } 30% { transform: translateY(0) scale(1.05); opacity: 1; } 100% { transform: scale(1); } }
@keyframes fxLunge { 0% { transform: scale(.2) rotate(-14deg); opacity: 0; } 25% { transform: scale(1.5) rotate(4deg); opacity: 1; } 45% { transform: scale(1.25) rotate(0); } 100% { transform: scale(1.25); } }
@keyframes fxPop { 0% { transform: scale(.3); opacity: 0; } 30% { transform: scale(1.15); opacity: 1; } 100% { transform: scale(1); } }
@keyframes fxDrop { 0% { transform: translateY(-110px); opacity: 0; } 30% { transform: translateY(0); opacity: 1; } 45% { transform: translateY(-12px); } 60% { transform: translateY(0); } 100% { transform: translateY(0); } }
@keyframes fxBoom { 0% { transform: scale(.2); opacity: 0; } 20% { transform: scale(1.7); opacity: 1; } 45% { transform: scale(1.2); } 100% { transform: scale(1.2); } }
body.shake { animation: bodyShake .5s ease; }
@keyframes bodyShake { 0%,100% { transform: translateX(0); } 15% { transform: translateX(-9px); } 30% { transform: translateX(8px); } 45% { transform: translateX(-6px); } 60% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

/* ---------- animasi werewolf menerkam mangsa ---------- */
#fxOverlay.show.fx-pounce { animation: fxFade 2.4s ease forwards; background: radial-gradient(ellipse at center, rgba(120,0,0,.35), rgba(20,0,0,.88)); }
#fxOverlay.fx-pounce #fxEmoji { animation: fxLunge 2.4s ease; }
#fxOverlay.fx-pounce::before, #fxOverlay.fx-pounce::after { content: ''; position: absolute; width: 190px; height: 30px; border-radius: 10px; background: repeating-linear-gradient(90deg, rgba(255,70,45,.9) 0 12px, transparent 12px 38px); transform: rotate(-32deg); opacity: 0; pointer-events: none; }
#fxOverlay.fx-pounce::before { top: 24%; left: 10%; animation: fxSlash 2.4s ease .1s; }
#fxOverlay.fx-pounce::after { bottom: 22%; right: 8%; animation: fxSlash 2.4s ease .3s; }
@keyframes fxSlash { 0% { opacity: 0; transform: rotate(-32deg) translateX(-46px) scaleX(.4); } 22% { opacity: 1; } 55% { opacity: 1; transform: rotate(-32deg) translateX(0) scaleX(1); } 85% { opacity: 0; } 100% { opacity: 0; } }

/* ---------- Lapisan 3D (Three.js) ---------- */
.hero3d { width: 100%; height: 230px; display: block; border-radius: 14px; margin-top: 14px; background: radial-gradient(120% 100% at 50% 0%, #101a38 0%, #0a0f24 70%); }
#reveal3d { width: 100%; height: 225px; display: block; margin-bottom: 8px; }
#pounce3d { position: absolute; inset: 0; width: 100%; height: 100%; display: none; }
#fxOverlay.show3d #pounce3d { display: block; }
#fxOverlay.show3d #fxEmoji { display: none; }
#fxOverlay.show3d #fxText { position: relative; z-index: 2; text-shadow: 0 2px 16px #000, 0 0 30px rgba(255,60,40,.45); }
