* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1b1b1b; font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; color: #fff; user-select: none; }
#app canvas { display: block; }
.hidden { display: none !important; }
kbd { background: #fff3bf; color: #5c3c00; border-radius: 4px; padding: 0 6px; font-weight: 700; border-bottom: 2px solid #e8b100; }

/* ---------- Màn vào nhà */
.overlay { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, rgba(255, 236, 153, 0.35), rgba(0, 0, 0, 0.55)); z-index: 20; }
.card { width: min(520px, 92vw); background: #fff9db; color: #3b2f05; border-radius: 22px; padding: 28px 30px 22px; box-shadow: 0 12px 0 #e8a33d, 0 20px 50px rgba(0, 0, 0, 0.4); text-align: center; }
.logo { font-size: 52px; line-height: 1; }
.card h1 { margin: 6px 0 4px; font-size: 40px; color: #e03131; letter-spacing: 1px; text-shadow: 3px 3px 0 #ffd43b; }
.tag { margin: 0 0 18px; font-size: 15px; line-height: 1.45; color: #5c4a14; }
.row { display: flex; gap: 10px; }
#nameInput { flex: 1; font-size: 18px; padding: 12px 14px; border-radius: 12px; border: 3px solid #e8a33d; outline: none; background: #fff; color: #333; }
#nameInput:focus { border-color: #e03131; }
button { font: inherit; font-weight: 800; cursor: pointer; border: none; border-radius: 12px; padding: 12px 20px; background: #e03131; color: #fff; box-shadow: 0 4px 0 #a61e1e; transition: transform .08s; }
button:hover:not(:disabled) { transform: translateY(-1px); }
button:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #a61e1e; }
button:disabled { background: #adb5bd; box-shadow: 0 4px 0 #868e96; cursor: not-allowed; }
.err { color: #c92a2a; min-height: 18px; margin: 8px 0 0; font-weight: 600; font-size: 14px; }
.howto { text-align: left; font-size: 14px; line-height: 1.5; display: grid; gap: 8px; margin-top: 12px; padding-top: 14px; border-top: 2px dashed #f0c36d; }

/* ---------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#topbar { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); text-align: center; }
#phase { font-weight: 700; font-size: 16px; background: rgba(0, 0, 0, 0.45); padding: 6px 16px; border-radius: 999px; }
#timer { margin-top: 6px; font-size: 40px; font-weight: 900; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5); }
#timer.urgent { color: #ff6b6b; animation: pulse .5s infinite alternate; }
@keyframes pulse { to { transform: scale(1.12); } }
#role { position: absolute; top: 14px; left: 14px; font-weight: 800; font-size: 16px; padding: 8px 14px; border-radius: 12px; }
#role:empty { display: none; }
#role.mom { background: #e03131; }
#role.kid { background: #1971c2; }
#role.ghost { background: #495057; }
#patience { position: absolute; top: 112px; left: 50%; transform: translateX(-50%); width: 300px; text-align: center; font-size: 13px; font-weight: 700; text-shadow: 0 1px 2px #000; }
.bar { margin-top: 4px; height: 14px; background: rgba(0, 0, 0, 0.5); border-radius: 999px; overflow: hidden; border: 2px solid rgba(255, 255, 255, 0.7); }
#patienceFill { height: 100%; width: 100%; background: linear-gradient(90deg, #f783ac, #e64980); transition: width .3s; }
#patienceFill.low { background: linear-gradient(90deg, #ff8787, #c92a2a); animation: pulse .4s infinite alternate; }
#hiders { position: absolute; top: 14px; right: 14px; font-weight: 800; background: rgba(0, 0, 0, 0.45); padding: 8px 14px; border-radius: 12px; }

#crosshair { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4); }
#crosshair::after { content: ""; position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px; background: #fff; border-radius: 50%; }
#crosshair.kid { border-color: #ffd43b; border-style: dashed; }
#cdWrap { position: absolute; left: 50%; top: calc(50% + 22px); width: 46px; height: 4px; margin-left: -23px; }
#cooldown { height: 100%; background: #fff; border-radius: 2px; transform-origin: left; transform: scaleX(0); opacity: .8; }

#disguiseInfo { position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%); text-align: center; font-size: 17px; text-shadow: 0 2px 3px #000; line-height: 1.5; }
#disguiseInfo .hint { font-size: 15px; color: #ffec99; }
#help { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); font-size: 13px; background: rgba(0, 0, 0, 0.5); padding: 7px 14px; border-radius: 10px; max-width: 94vw; text-align: center; line-height: 1.6; }
#help b { color: #ffd43b; }

#toasts { position: absolute; top: 170px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.toast { background: rgba(0, 0, 0, 0.6); padding: 8px 16px; border-radius: 10px; font-weight: 600; animation: pop .25s ease-out; transition: opacity .5s, transform .5s; text-align: center; }
.toast.big { font-size: 20px; font-weight: 900; background: rgba(224, 49, 49, 0.85); }
.toast.bad { background: rgba(73, 80, 87, 0.9); }
.toast.out { opacity: 0; transform: translateY(-10px); }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }

#blind { position: absolute; inset: 0; background: radial-gradient(circle, #1a1530, #05040a); display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
#blind h2 { font-size: 40px; margin: 10px 0; color: #ffd8a8; }
#blind p { font-size: 22px; margin: 4px; }
#blind .sub { font-size: 15px; color: #adb5bd; }
.zzz { font-size: 60px; font-weight: 900; color: #a5d8ff; animation: float 1.5s infinite alternate ease-in-out; }
@keyframes float { to { transform: translateY(-14px) rotate(-6deg); } }

.panel { background: rgba(255, 249, 219, 0.96); color: #3b2f05; border-radius: 18px; padding: 16px 20px; box-shadow: 0 8px 0 #e8a33d, 0 12px 30px rgba(0, 0, 0, 0.35); pointer-events: auto; }
.panel.side { position: absolute; top: 70px; left: 14px; width: 270px; }
.panel.center { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); min-width: 380px; text-align: center; }
.panel h3 { margin: 0 0 8px; color: #e03131; }
#playerList { list-style: none; padding: 0; margin: 0 0 10px; }
#playerList li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px dashed #f0c36d; font-weight: 600; }
#playerList .sc { margin-left: auto; color: #868e96; font-size: 13px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid rgba(0, 0, 0, 0.2); flex: none; margin-right: 6px; vertical-align: middle; }
#startBtn { width: 100%; font-size: 18px; }
#lobbyNote { font-size: 13px; margin: 8px 0 4px; color: #5c4a14; }
.lan { font-size: 12px; margin: 6px 0 0; color: #5c4a14; word-break: break-all; }
.lan b { color: #1971c2; user-select: text; }

.panel table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.panel th { font-size: 12px; text-transform: uppercase; color: #868e96; text-align: left; padding: 4px 8px; }
.panel td { padding: 6px 8px; border-top: 1px dashed #f0c36d; text-align: left; font-weight: 600; }
.panel tr.me td { background: #fff3bf; }
#result h2 { margin: 0; font-size: 36px; }
#result h2.win { color: #2f9e44; }
#result h2.lose { color: #e03131; }
.reason { margin: 6px 0 4px; font-size: 17px; }
.next { font-size: 13px; color: #868e96; margin: 10px 0 0; }

.opt { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 700; margin: 6px 0; }
.opt select { flex: 1; font: inherit; padding: 4px 6px; border-radius: 8px; border: 2px solid #e8a33d; background: #fff; color: #333; }
.opt select:disabled { background: #f1f3f5; color: #868e96; }
.opt.check { justify-content: flex-start; font-weight: 600; }
#mapDesc { font-size: 12px; margin: 2px 0 8px; color: #5c4a14; }
#eventBadge { position: absolute; top: 58px; right: 14px; font-weight: 800; font-size: 14px; background: rgba(25, 113, 194, 0.9); padding: 6px 14px; border-radius: 12px; }
#census { position: absolute; top: 96px; right: 14px; width: 270px; max-height: calc(100vh - 170px); overflow-y: auto; z-index: 5; pointer-events: none; }
.censusNote { font-size: 12px; margin: 0 0 6px; color: #5c4a14; }
#censusList { list-style: none; padding: 0; margin: 0; }
#censusList li { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px dashed #f0c36d; font-weight: 600; font-size: 14px; }
#censusList b { color: #e03131; }

#clickToPlay { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); background: rgba(0, 0, 0, 0.7); padding: 12px 20px; border-radius: 12px; font-weight: 700; pointer-events: auto; cursor: pointer; }
