* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d2230; color: #eef1f7;
  font-family: 'Pretendard', 'Malgun Gothic', 'Apple SD Gothic Neo', sans-serif; user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; border-radius: 12px;
  min-height: 44px; padding: 0 18px; background: #3a4258; font-weight: 700; }
button:hover { filter: brightness(1.12); }
button:disabled { opacity: .4; cursor: not-allowed; filter: none; }
button.primary { background: #ffcc4d; color: #1d2230; }
button.danger { background: #e5383b; color: #fff; }
input { font: inherit; color: #1d2230; border: 0; border-radius: 10px; padding: 10px 12px; min-height: 44px; background: #eef1f7; }
input:focus { outline: 3px solid #ffcc4d; }

#app { position: fixed; inset: 0; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #0d0f15; }
#hud { position: absolute; inset: 0; pointer-events: none; }
#hud .on-touch, #hud button, #hud .menu { pointer-events: auto; }
#layer { position: absolute; inset: 0; pointer-events: none; }
#layer > * { pointer-events: auto; }
#screen { position: absolute; inset: 0; overflow: auto; }
#screen:empty { display: none; }

/* 연결 상태 */
#net { position: absolute; top: 12px; right: 14px; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; background: rgba(20,24,34,.8); font-size: 13px; z-index: 50; pointer-events: none; }
#net i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: #888; }
#net.ok i { background: #2fb45a; } #net.retry i { background: #f7d02c; } #net.down i { background: #e5383b; }

.toast { position: fixed; left: 50%; bottom: 40px; transform: translate(-50%, 20px); opacity: 0;
  background: #2b3245; padding: 12px 20px; border-radius: 12px; transition: .25s; z-index: 100; pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); max-width: 90vw; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* 첫 화면 · 대기실 */
.page { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(ellipse at top, #2b3245, #161a24 70%); }
.card { background: #2b3245; border-radius: 20px; padding: 28px; width: min(520px, 100%); box-shadow: 0 16px 40px rgba(0,0,0,.35); }
.title { font-size: 34px; font-weight: 900; margin: 0 0 4px; letter-spacing: -1px; }
.title b { color: #e5383b; }
.sub { color: #aab3c7; margin: 0 0 22px; }
.row { display: flex; gap: 10px; align-items: center; margin: 10px 0; }
.row > input { flex: 1; min-width: 0; }
.label { font-size: 13px; color: #aab3c7; margin: 18px 0 6px; }
.err { color: #ff8c8c; min-height: 22px; font-size: 14px; margin-top: 6px; }
.code { font-size: 46px; font-weight: 900; letter-spacing: 10px; color: #ffcc4d; }
.who { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.who li { display: flex; align-items: center; gap: 8px; background: #232939; border-radius: 10px; padding: 4px 10px; min-height: 44px; }
.who li.me { outline: 2px solid #ffcc4d; }
.who .star { color: #ffcc4d; margin-left: auto; }
.colors { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.colors button { min-height: 36px; padding: 0; border-radius: 8px; border: 3px solid transparent; }
.colors button.sel { border-color: #fff; }
.seg { display: flex; gap: 6px; }
.seg button.sel { background: #ffcc4d; color: #1d2230; }
.hint { color: #aab3c7; font-size: 14px; margin-top: 8px; min-height: 20px; }
canvas.bean { flex: none; }

/* HUD */
.hud-top { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); width: min(460px, 60vw); text-align: center; }
.bar { height: 16px; border-radius: 8px; background: rgba(0,0,0,.55); border: 2px solid #11141c; overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(#5be07a, #2fb45a); width: 0; transition: width .3s; }
.bar-label { font-size: 12px; color: #cfd6e6; margin-bottom: 4px; text-shadow: 0 1px 2px #000; }
.hud-left { position: absolute; top: 12px; left: 12px; width: 250px; background: rgba(20,24,34,.78); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.hud-left .role { font-weight: 800; margin-bottom: 6px; }
.hud-left .role.imp { color: #ff6b6b; } .hud-left .role.crew { color: #7fd3ff; }
.hud-left .fake { color: #ff8c8c; font-size: 12px; margin-bottom: 6px; }
.hud-left ul { list-style: none; padding: 0; margin: 0; }
.hud-left li { padding: 2px 0; } .hud-left li.done { color: #5be07a; text-decoration: line-through; }
.hud-btns { position: absolute; right: 16px; bottom: 16px; display: flex; gap: 10px; align-items: flex-end; }
.act { position: relative; padding: 0; white-space: nowrap; width: 92px; height: 92px; border-radius: 18px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 15px; background: #3a4258; border: 3px solid #11141c; }
.act small { font-size: 11px; opacity: .8; font-weight: 600; }
.act.use { background: #2f7de1; } .act.kill { background: #c1272d; } .act.report { background: #d46a12; } .act.sab { background: #6d3fc0; }
.act .cd { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 30px; font-weight: 900;
  background: rgba(0,0,0,.45); border-radius: 15px; }
.menu { position: absolute; right: 16px; bottom: 120px; background: #2b3245; border-radius: 14px; padding: 10px; display: flex; flex-direction: column; gap: 8px; width: 270px; }
.menu .t { font-size: 13px; color: #aab3c7; }
.banner { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; }
.banner h1 { font-size: clamp(34px, 6vw, 60px); white-space: nowrap; margin: 0; font-weight: 900; text-shadow: 0 4px 0 #000; }
.banner p { font-size: 20px; margin: 8px 0 0; text-shadow: 0 2px 0 #000; }
.alert { position: absolute; top: 56px; left: 50%; transform: translateX(-50%); padding: 10px 18px; border-radius: 12px; font-weight: 800; text-align: center; }
.alert.lights { background: #f7d02c; color: #1d2230; }
.alert.reactor { background: #c1272d; color: #fff; animation: pulse 1s infinite; }
.alert.vent { background: #3a4258; top: auto; bottom: 130px; }
@keyframes pulse { 50% { filter: brightness(1.35); } }
.redge { position: absolute; inset: 0; box-shadow: inset 0 0 120px rgba(229,56,59,.55); animation: pulse 1s infinite; pointer-events: none; }
.wait { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); font-size: 20px; color: #cfd6e6; }

/* 미니게임 창 */
.task-back { position: absolute; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 20; }
.task-win { width: 480px; max-width: 94vw; background: #e9ecf2; color: #1d2230; border-radius: 16px; padding: 14px; position: relative; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.task-win h3 { margin: 0 0 10px; font-size: 18px; }
.task-win .x { position: absolute; right: 10px; top: 8px; min-height: 36px; width: 36px; padding: 0; background: #c9ced9; }
.task-win .stage { position: relative; width: 452px; max-width: 100%; height: 300px; background: #fff; border-radius: 10px; overflow: hidden; }
.task-win .msg { min-height: 24px; margin-top: 8px; font-weight: 700; text-align: center; }
.task-win .ok { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 44px; font-weight: 900; color: #2fb45a; background: rgba(255,255,255,.85); }

/* 회의 */
.meet { position: absolute; inset: 0; background: rgba(12,14,20,.92); display: flex; flex-direction: column; padding: 18px; gap: 12px; z-index: 30; }
.meet-head { padding-right: 190px; display: flex; justify-content: space-between; align-items: center; font-size: 20px; font-weight: 800; }
.meet-head .time { color: #ffcc4d; font-variant-numeric: tabular-nums; }
.meet-body { flex: 1; display: flex; gap: 14px; min-height: 0; }
.cards { flex: 1.2; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-content: start; overflow: auto; }
.pcard { background: #e9ecf2; color: #1d2230; border-radius: 12px; padding: 6px 10px; display: flex; align-items: center; gap: 8px; min-height: 58px; position: relative; cursor: default; }
.pcard.can { cursor: pointer; } .pcard.can:hover { outline: 3px solid #ffcc4d; }
.pcard.dead { background: #8a909c; opacity: .7; }
.pcard .nm { font-weight: 800; }
.pcard .tag { margin-left: auto; font-size: 12px; font-weight: 800; color: #2f7de1; }
.pcard .voters { position: absolute; left: 60px; bottom: 4px; display: flex; gap: 3px; }
.pcard .voters i, .skipvoters i { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 1px solid #000; }
.pcard .confirm { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; }
.pcard .confirm button { min-height: 34px; padding: 0 10px; }
.chat { flex: 1; display: flex; flex-direction: column; background: #e9ecf2; color: #1d2230; border-radius: 12px; min-width: 0; }
.chat .log { flex: 1; overflow: auto; padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.chat .line { display: flex; gap: 6px; align-items: flex-start; }
.chat .line b { white-space: nowrap; }
.chat .line.ghost { opacity: .6; font-style: italic; }
.chat .send { display: flex; gap: 6px; padding: 8px; border-top: 1px solid #c9ced9; }
.chat .send input { flex: 1; background: #fff; }
.chat .note { font-size: 12px; color: #6b7285; padding: 0 10px; }
.meet-foot { display: flex; gap: 10px; align-items: center; }
.skipvoters { display: flex; gap: 3px; }
.splash { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; flex-direction: column; background: rgba(0,0,0,.85); z-index: 40; text-align: center; }
.splash h1 { font-size: 56px; margin: 0; color: #ff6b6b; }
.splash p { font-size: 22px; }
.eject { position: absolute; inset: 0; background: #05060a; z-index: 45; overflow: hidden; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.eject canvas { position: absolute; left: 0; top: 0; }
.eject h2 { position: relative; font-size: 34px; margin: 0; text-align: center; }
.eject p { position: relative; font-size: 18px; color: #aab3c7; }
.result { position: absolute; inset: 0; background: rgba(5,6,10,.94); z-index: 50; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 12px; text-align: center; }
.result h1 { font-size: 64px; margin: 0; }
.result h1.crew { color: #7fd3ff; } .result h1.imp { color: #ff4d4d; }
.result .imps { display: flex; gap: 18px; }
.result .imps div { display: flex; flex-direction: column; align-items: center; }

/* 캐릭터 고르기 (회사분들 8명 + 신입 2명) */
.chars { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.chars button { min-height: 0; padding: 4px 2px 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: #232939; border: 3px solid transparent; border-radius: 12px; font-size: 11px; font-weight: 700; line-height: 1.2; }
.chars button.sel { background: #3a4258; }
.chars button span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.card { width: min(560px, 100%); }
