@font-face { font-family: "Titillium Web"; font-weight: 400; src: url("fonts/TitilliumWeb-Regular.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Titillium Web"; font-weight: 600; src: url("fonts/TitilliumWeb-SemiBold.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Titillium Web"; font-weight: 700; src: url("fonts/TitilliumWeb-Bold.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Titillium Web"; font-weight: 900; src: url("fonts/TitilliumWeb-Black.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Gothic A1"; font-weight: 400 500; src: url("fonts/GothicA1-Medium.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Gothic A1"; font-weight: 600 700; src: url("fonts/GothicA1-Bold.woff") format("woff"); font-display: swap; }
@font-face { font-family: "Gothic A1"; font-weight: 800 900; src: url("fonts/GothicA1-ExtraBold.woff") format("woff"); font-display: swap; }

:root {
  --bg: rgba(255, 255, 255, .9);
  --line: #e3e7ee;
  --text: #1d2433;
  --ink: #1d3c8a;
  --scene-ink: #2d2a4a; /* 장면(파스텔 하늘·지형) 위에 바로 놓이는 글자: 그림자 없이도 읽히는 짙은 남보라 */
  --muted: #8c95a6;
  --navy: linear-gradient(180deg, #2f7bff, #1550d8);
  --red: #e8231b;
  --radius: 5px;
  --font: "Titillium Web", "Gothic A1", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  /* 하늘: 파스텔 (위는 옅은 하늘색, 지평선 쪽은 라벤더·살구빛). 화면에서 가장 조용한 층. planet.js SKY 와 맞춘다 */
  background: linear-gradient(180deg, #a9c6ee 0%, #c9dbf4 38%, #e9e6f6 70%, #f8ece9 100%) fixed #e9e6f6;
  font-family: var(--font);
  font-weight: 700;
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

/* 처음 불러오는 화면 */
#loading {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: linear-gradient(180deg, #a9c6ee 0%, #c9dbf4 38%, #e9e6f6 70%, #f8ece9 100%);
  transition: opacity .6s ease;
}
#loading.out { opacity: 0; pointer-events: none; }
#loading .box { width: min(320px, 80vw); text-align: center; color: var(--scene-ink); }
#loading .globe { font-size: 56px; line-height: 1; animation: spin-globe 2.4s ease-in-out infinite; }
@keyframes spin-globe { 50% { transform: translateY(-6px) rotate(-8deg); } }
#loading .name { margin: 10px 0 18px; font-size: 26px; font-weight: 900; letter-spacing: -.5px; }
#loading .bar { height: 10px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, .35); box-shadow: inset 0 1px 2px rgba(10, 40, 100, .2); }
#loading .bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #ffe14a, #ffc800); box-shadow: 0 0 8px rgba(255, 200, 0, .6); }
#loading .msg { margin-top: 10px; min-height: 1.3em; font-size: 13px; font-weight: 600; opacity: .9; }
#loading.warn .msg { color: #fff; background: rgba(232, 35, 27, .75); border-radius: 4px; padding: 3px 8px; display: inline-block; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; transition: filter .6s; }
body:has(#start:not([hidden])) #game { cursor: grab; touch-action: none; } /* 첫 화면(로비): 끌어서 둘러보기 */
body:has(#start:not([hidden])) #game.dragging { cursor: grabbing; }
#game.demo-in { animation: demo-in .9s ease-out; } /* 로비 데모를 처음부터 다시 틀 때 (main.js) */
@keyframes demo-in { from { opacity: .15; } }
#game.gray { filter: grayscale(.85) brightness(.92); transition: filter .8s .35s; } /* 내가 탈락한 동안 (터지는 색을 잠깐 보여 준 뒤 바랜다) */

/* 탈락 자리·레벨업 때 떠오르는 글자 (fx/texts.js). 파스텔 스티커: 파스텔로 채우고 짙은 남보라 외곽선 (fx/palette.js 와 같은 색).
   파스텔 하늘·지형 위에서 파스텔 글자가 읽히도록 대비는 색이 아니라 외곽선으로 준다. paint-order: 외곽선을 글자 뒤에 그려 글자가 가늘어지지 않게 */
:root {
  --fx-ink: #463a6e;
  --fx-cream: #fff8ec; --fx-butter: #ffe09a; --fx-peach: #ffc4a8; --fx-coral: #ffaaa0;
  --fx-pink: #ffb3d9; --fx-lilac: #d8c6ff; --fx-mint: #b8efd4; --fx-apricot: #ffcf94;
}
.fx-text {
  position: absolute; left: 0; top: 0; white-space: nowrap; pointer-events: none;
  font-size: 22px; font-weight: 900; color: var(--fx-peach);
  -webkit-text-stroke: 4px var(--fx-ink); paint-order: stroke fill; stroke-linejoin: round;
}
/* "A killed B": 이름은 그 플레이어 색, 나와 관련되면 크게. 남의 처치는 작고 조용하게 (외곽선 없이 잉크색) */
.fx-text.kill { font-size: 14px; font-weight: 800; color: var(--scene-ink); -webkit-text-stroke: 0; }
.fx-text.kill.me { font-size: 19px; color: var(--fx-coral); -webkit-text-stroke: 4px var(--fx-ink); }
.fx-text .nm { color: color-mix(in srgb, var(--c) 78%, #1a1630); }
.fx-text.kill.me .nm { color: color-mix(in srgb, var(--c) 60%, var(--fx-cream)); }
/* 연속 처치: 내 머리 위에서 크게 튀어나왔다가 탄력 있게 줄어든다 (이어 잡을수록 크고 피치 → 코랄 → 핑크 → 라일락) */
.fx-text.combo { font-size: 26px; font-weight: 900; letter-spacing: .5px; color: var(--fx-peach); -webkit-text-stroke-width: 5px; animation: combo-pop .5s cubic-bezier(.2, 1.7, .4, 1) both; }
.fx-text.combo.c2 { font-size: 30px; color: var(--fx-coral); }
.fx-text.combo.c3 { font-size: 34px; color: var(--fx-pink); }
.fx-text.combo.c4 { font-size: 38px; color: var(--fx-lilac); }
@keyframes combo-pop { 0% { scale: 2.4; } 55% { scale: .88; } 100% { scale: 1; } }
#hud { position: fixed; inset: 0; pointer-events: none; }

/* 이름표 */
#labels { position: absolute; inset: 0; overflow: hidden; }
.label {
  position: absolute; left: 0; top: 0;
  padding: 1px 4px;
  font-size: 13px; font-weight: 800; color: var(--scene-ink); white-space: nowrap;
  /* 배경·그림자 없이 글자만: 파스텔 지형 위에서 읽히는 짙은 잉크색 */
  will-change: transform;
}
.label.me { font-size: 14px; }
.label { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.label .top {
  /* 윗줄: 계급장·레벨, 처치 수, 점유율을 크림색 알약 하나에 담는다 (항목마다 다른 색 바탕을 두지 않아 깔끔하게). 글자는 짙은 잉크색 */
  position: relative; display: flex; align-items: center; gap: 1px; margin-bottom: 2px; padding: 1px 2px; border-radius: 999px;
  font-size: 12px; font-weight: 800; color: var(--scene-ink); font-variant-numeric: tabular-nums;
  background: rgba(255, 250, 242, .9); box-shadow: 0 1px 2px rgba(45, 42, 74, .2), inset 0 0 0 1px rgba(45, 42, 74, .08);
}
.label.me .top { font-size: 13px; }
.label .top > span { padding: 0 4px; border-radius: 999px; }
/* 항목 사이 가는 세로선 */
.label .top > span + span { background-image: linear-gradient(rgba(45, 42, 74, .16), rgba(45, 42, 74, .16)); background-size: 1px 60%; background-position: left center; background-repeat: no-repeat; }
.label .who { display: flex; align-items: center; gap: 4px; } /* 이름 (계급장·레벨은 윗줄 .top 에 처치 수·점유율과 함께) */
/* 처치 수: 칼 모양만 코랄빛 */
.label .kl::first-letter { color: #e8590c; }
/* 실시간 점유율: 모든 캐릭터가 같은 잉크색 (늘면 초록, 줄면 빨강으로만 바뀐다) */
.label .pc { color: var(--scene-ink); }
.label .pc:empty { display: none; }
/* 점유율이 늘면 ▲ + 빨간 글자로 톡, 많이 늘면(1% 넘게) 더 크게, 줄면 ▼ + 파란 글자로 좌우로 흔들림 (players.js labelArea).
   바탕은 바꾸지 않고 글자 색만. 화살표와 글자 색은 클래스가 붙어 있는 동안(약 1.2초)만 */
.label .pc.up { color: #e03131; }
.label .pc.down { color: #1c7ed6; }
/* 화살표 자리는 늘 비워 둔다 (나타났다 사라질 때 윗줄 폭이 늘었다 줄었다 하지 않게) */
.label .pc::before { content: "▲"; display: inline-block; width: 1em; margin-right: 2px; font-size: .8em; text-align: center; visibility: hidden; }
.label .pc.up::before, .label .pc.down::before { visibility: visible; animation: pc-arrow .35s ease-out; }
.label .pc.down::before { content: "▼"; }
@keyframes pc-arrow { from { opacity: 0; transform: translateY(var(--from, 4px)); } }
.label .pc.down::before { --from: -4px; }
.label .pc.up { animation: pc-up .55s cubic-bezier(.2, 1.6, .4, 1); }
.label .pc.up.big { animation: pc-up-big .9s cubic-bezier(.2, 1.6, .4, 1); }
.label .pc.down { animation: pc-down .5s ease-out; }
@keyframes pc-up {
  0% { transform: scale(1); }
  30% { transform: scale(1.35); }
  100% { transform: scale(1); }
}
@keyframes pc-up-big {
  0% { transform: scale(1); }
  25% { transform: scale(1.8); }
  100% { transform: scale(1); }
}
@keyframes pc-down {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-3px); }
  35% { transform: translateX(3px); }
  55% { transform: translateX(-2px); }
  75% { transform: translateX(1px); }
}
/* 계급·레벨: 윗줄 크림색 알약 안에 계급장 + 숫자. 바탕 없이 계급장 색(--ico)으로만 계급 단계를 보인다 */
.label .lv { display: inline-flex; align-items: center; gap: 2px; padding-left: 2px; letter-spacing: .2px; --ico: #8e94aa; }
.label .lv[data-tone="silver"] { --ico: #7f9bc4; }
.label .lv[data-tone="bronze"] { --ico: #c8742a; }
.label .lv[data-tone="gold"] { --ico: #e0a800; }
.label .lv[data-tone="deep"] { --ico: #ec8a00; }
.label .lv[data-tone="general"] { --ico: #e8231b; }
.label .lv .rank-ico { height: 1.35em; }
.label .lv b { font-weight: inherit; }
/* 계급 단계별 색 (rank.js tone, paintRank): 계급장 색(--ico)과 알약 바탕. 순위표·레전드 창·탈락 창이 같이 쓴다 (gray 는 각자 기본색, 이름표는 위에 따로) */
:is(#board li .ri, .lg-rows .ri, #dead-why .killer .lv)[data-tone="silver"] { --ico: #f4f8ff; color: #fff; background: rgba(70, 85, 110, .72); }
:is(#board li .ri, .lg-rows .ri, #dead-why .killer .lv)[data-tone="bronze"] { --ico: #ffb36b; color: #ffe2c4; background: rgba(95, 48, 18, .82); }
:is(#board li .ri, .lg-rows .ri, #dead-why .killer .lv)[data-tone="gold"] { --ico: #9a6400; color: #3a2600; background: #ffe27a; }
:is(#board li .ri, .lg-rows .ri, #dead-why .killer .lv)[data-tone="deep"] { --ico: #6b3f00; color: #3a2600; background: #ffc800; }
:is(#board li .ri, .lg-rows .ri, #dead-why .killer .lv)[data-tone="general"] { --ico: #ffe14a; color: #fff; background: linear-gradient(90deg, #c8101c, #e8231b); }
.rank-ico { height: 1em; fill: var(--ico, currentColor); flex: none; display: block; }
.rank-ico .core { fill: rgba(0, 0, 0, .35); }
/* 레벨업: 레벨 표시가 크게 튀었다가 돌아온다 */
.label.lvup .lv { animation: lv-pop .9s cubic-bezier(.2, 1.6, .4, 1); }
.label.promo .lv { animation: lv-promo 1.6s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes lv-promo {
  0% { transform: scale(1); }
  20% { transform: scale(2.4); box-shadow: 0 0 18px #ffd23f, 0 0 4px #fff; }
  60% { transform: scale(1.4); box-shadow: 0 0 12px #ffd23f; }
  100% { transform: scale(1); }
}
@keyframes lv-pop {
  0% { transform: scale(1); }
  25% { transform: scale(1.9); box-shadow: 0 0 14px #ffd23f; }
  100% { transform: scale(1); }
}
/* 레벨업·진급 때 윗줄 알약 오른쪽에 잠깐 뜨는 "Spd +N%" (players.js setLevel). absolute 라 이름표 폭·가운데 정렬은 그대로.
   레벨업은 민트 칩, 진급은 계급 색 칩으로 더 크고 오래 (시간은 players.js LV_SHOW·PROMO_SHOW 와 같게) */
.label .spd {
  position: absolute; left: 100%; top: 50%; margin-left: 4px; padding: 1px 6px; border-radius: 999px;
  font-style: normal; font-size: 11px; font-weight: 800; white-space: nowrap; pointer-events: none;
  color: #17543a; background: #b8efd4; box-shadow: 0 1px 2px rgba(45, 42, 74, .25);
  opacity: 0; transform: translateY(-50%); transform-origin: left center;
  --tc: #8e94aa;
}
.label .spd:empty { display: none; }
.label .spd[data-tone="silver"] { --tc: #7f9bc4; }
.label .spd[data-tone="bronze"] { --tc: #c8742a; }
.label .spd[data-tone="gold"] { --tc: #e0a800; }
.label .spd[data-tone="deep"] { --tc: #ec8a00; }
.label .spd[data-tone="general"] { --tc: #e8231b; }
.label.lvup .spd { animation: spd-show 1.6s cubic-bezier(.2, 1.6, .4, 1) both; }
.label.promo .spd { font-size: 13px; color: #fff; background: var(--tc); box-shadow: 0 0 10px #ffd23f, 0 1px 2px rgba(45, 42, 74, .3); animation: spd-show 2.6s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes spd-show {
  0% { opacity: 0; transform: translate(-6px, -50%) scale(.6); }
  15% { opacity: 1; transform: translate(0, -50%) scale(1.15); }
  25% { transform: translate(0, -50%) scale(1); }
  80% { opacity: 1; transform: translate(0, -50%) scale(1); }
  100% { opacity: 0; transform: translate(0, -60%) scale(1); }
}

/* 오른쪽 위: 순위 (작고 반투명한 검정, 시스템 기본 폰트) */
#board {
  /* 폭은 내용에 맞춰 줄었다 늘었다 한다 (오른쪽 끝은 고정). 가장 넓어도 닉네임 16칸(영문 16자·한글 8자) + Lv100 계급장이 1위 줄에 들어가는 320px */
  position: absolute; right: 12px; top: 12px; width: max-content; min-width: 200px; max-width: 320px;
  border-radius: var(--radius); overflow: hidden;
  color: var(--scene-ink);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  font-size: 11px; font-weight: 500;
}
#board .head { display: flex; justify-content: flex-end; align-items: baseline; gap: 6px; white-space: nowrap; padding: 4px 9px; color: var(--scene-ink); font-weight: 700; }
#board .head small { opacity: .75; font-weight: 400; font-size: 9.5px; overflow: hidden; text-overflow: ellipsis; }
#board ol { margin: 0; padding: 3px 0; list-style: none; counter-reset: r; }
/* 계단식: 1위는 왼쪽 위에서 크게, 등수가 내려갈수록 오른쪽으로 물러나며 작아진다 (--i: 0부터, hud.js) */
#board li { --step: 3px; display: flex; align-items: center; gap: 3px; padding: 1px 9px; margin-left: calc(var(--i, 0) * var(--step)); counter-increment: r; border-radius: 4px; }
#board li::before { content: counter(r); width: 14px; flex: none; color: rgba(45, 42, 74, .5); text-align: right; font-variant-numeric: tabular-nums; }
#board li:nth-child(1) { --rk: #c99400; font-size: 13px; font-weight: 800; padding: 3px 9px; background: linear-gradient(90deg, rgba(255, 200, 40, .32), rgba(255, 200, 40, 0) 85%); }
#board li:nth-child(2) { --rk: #7d8796; font-size: 12px; font-weight: 700; padding: 2px 9px; background: linear-gradient(90deg, rgba(220, 230, 240, .2), rgba(220, 230, 240, 0) 80%); }
#board li:nth-child(3) { --rk: #b8682e; font-size: 11.5px; font-weight: 700; padding: 2px 9px; background: linear-gradient(90deg, rgba(230, 150, 90, .2), rgba(230, 150, 90, 0) 75%); }
#board li:nth-child(-n+3)::before { color: var(--rk); font-weight: 800; width: 16px; }
#board li:nth-child(1) .sc { color: #a87400; }
#board li.extra { font-size: 11px; font-weight: 700; padding: 1px 9px; background: none; }
/* 계급장 + 레벨: 작은 알약 (색은 계급 단계, 이름표와 같은 톤) */
#board li .ri, .lg-rows .ri {
  flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 2px; padding: 0 4px; border-radius: 999px;
  min-width: 2.7em; font-size: .82em; font-weight: 800; line-height: 1.35; font-variant-numeric: tabular-nums;
  --ico: #d5dbe5; color: #fff; background: rgba(20, 30, 50, .55);
}
#board li .ri b, .lg-rows .ri b { font-weight: inherit; }
#board li .ri::before { content: none; } /* 계급장 + "Lv.n" (hud.js). 캐릭터 이름표는 폭을 아끼려고 계급장 + 숫자만 */
#board li .ri b, .lg-rows .ri b { order: 2; }
/* 이름은 플레이어 색으로 (색 사각형 대신). 밝은 하늘 위에서 노랑 같은 밝은 색도 읽히게 짙은 색을 조금 섞는다 */
#board li .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: color-mix(in srgb, var(--c, #888) 72%, #1a1630); }
#board li .kl { flex: none; min-width: 28px; white-space: nowrap; text-align: right; color: rgba(45, 42, 74, .55); font-variant-numeric: tabular-nums; } /* 처치 수 */
#board li .pc { flex: none; min-width: 34px; white-space: nowrap; text-align: right; color: rgba(45, 42, 74, .55); font-variant-numeric: tabular-nums; } /* 지금 점유율 */
#board li .sc { flex: none; min-width: 40px; margin-left: 4px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; } /* 이번 판 점수 (순위 기준) */
#board li.me { background-color: rgba(255, 255, 255, .4); font-weight: 700; }
/* 순위표 아래 레전드: 역대 최고 점수 3위 (hud.js MiniLegend) */
/* 순위표 폭과 상관없이 내용(이름 + 기록)에 맞는 폭으로, 오른쪽에 붙여 둔다. 좁은 화면에서는 순위표 폭까지만 (긴 이름은 …) */
#bd-legend { width: max-content; max-width: 100%; margin: 2px 0 0 auto; padding: 3px 0 4px; border-top: 1px solid rgba(45, 42, 74, .15); border-radius: 0 0 4px 4px; pointer-events: auto; cursor: pointer; transition: background .15s; }
#bd-legend:hover { background: rgba(255, 255, 255, .3); } /* 누르면 레전드 창 */
#bd-legend .lg-head { text-align: right; white-space: nowrap; padding: 1px 9px 2px; color: #b07800; font-weight: 800; font-size: 10.5px; letter-spacing: 0; }
#bd-legend .lg-head .what { margin-left: 4px; font-size: 9px; font-weight: 700; color: rgba(45, 42, 74, .6); text-transform: uppercase; letter-spacing: .1px; } /* 한 줄: Legend · Top Score */
#bd-legend ol { padding: 0 9px; }
#board #bd-legend li { all: unset; display: flex; align-items: center; gap: 3px; padding: 0.5px 0; font-size: 10.5px; }
#board #bd-legend li::before { content: none; }
#board #bd-legend li .md { flex: none; font-size: 10px; }
#bd-legend li .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#bd-legend li .val { flex: none; margin-left: 8px; font-variant-numeric: tabular-nums; color: #a87400; font-weight: 700; }
#bd-legend li.me .nm { font-weight: 800; }
#bd-legend li.live .val::after { content: "●"; margin-left: 2px; color: #ff4d4d; font-size: 7px; vertical-align: middle; animation: lg-blink 1.2s infinite; }
#bd-legend li.empty { color: rgba(45, 42, 74, .4); }
@keyframes lg-blink { 50% { opacity: .2; } }
#board li.extra { margin-top: 3px; border-top: 1px dashed rgba(255, 255, 255, .35); padding-top: 2px; } /* 10위 밖 내 순위 */

body:has(#start:not([hidden])) #board { display: none; } /* 로비 배경은 녹화 데모라 순위표(실시간 정보)를 보이지 않는다 */

/* 왼쪽 위: 이번 판 점수 (휴대폰에서 전체 화면 버튼이 보이면 그 오른쪽). 배경 없이 글자만: 이름표처럼 장면 위 짙은 잉크색 */
#score {
  position: absolute; left: max(12px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top));
  display: flex; align-items: baseline; gap: 7px; padding: 4px 2px 5px; pointer-events: none;
}
body:has(#btn-fs:not([hidden])) #score { left: calc(max(12px, env(safe-area-inset-left)) + 48px); }
#score small { color: color-mix(in srgb, var(--scene-ink) 65%, transparent); font-size: 11px; font-weight: 800; letter-spacing: .6px; text-transform: uppercase; }
#score b { min-width: 2ch; color: var(--scene-ink); font-size: 20px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }

/* 아래 가운데: 부스터 게이지 */
#boost {
  position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%);
  width: min(320px, calc(100% - 300px)); min-width: 180px;
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 10px;
  padding: 7px 12px 6px; border-radius: 6px;
  background: var(--bg); box-shadow: 0 0 0 1px rgba(10, 20, 40, .08);
  font-size: 12px;
}
#boost .bar {
  grid-column: 1 / -1; height: 12px; border-radius: 3px; overflow: hidden;
  background: #e6ebf2; box-shadow: inset 0 0 0 1px rgba(20, 30, 50, .08);
}
#boost .bar i {
  display: block; height: 100%; width: 0;
  border-radius: 3px; background: linear-gradient(90deg, #8fa3c4, #a8b8d4);
  transition: width .1s linear;
}
#boost.ready .bar i { background: linear-gradient(90deg, #ffb000, #ffe14a); }
#boost.on .bar i { background: linear-gradient(90deg, #e8231b, #ffc800); box-shadow: 0 0 10px #ff7a00; }
#boost .name { color: var(--ink); }
#boost .hint { justify-self: end; color: var(--muted); font-weight: 600; }
#boost.home .hint::before { content: "⚡ "; color: #f0a500; }
#boost.on .name::after { content: " ON!"; color: #e85d04; }

#help {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); white-space: nowrap;
  padding: 2px 10px; border-radius: 10px; font-size: 11px; color: #fff; background: rgba(10, 16, 34, .35);
}
/* ?fps: 성능 확인용 */
#fps { position: fixed; left: 8px; top: 92px; z-index: 50; padding: 2px 7px; white-space: pre; border-radius: 4px; font: 11px/1.4 ui-monospace, monospace; color: #fff; background: rgba(0, 0, 0, .6); pointer-events: none; }
#ping {
  /* 오른쪽 아래 맨 구석. 미니맵은 그 위 (minimap.js BOTTOM) */
  position: absolute; right: 14px; bottom: 14px; padding: 1px 8px; border-radius: 9px;
  font-size: 11px; color: #fff; background: rgba(10, 16, 34, .35); pointer-events: none;
}
#ping::before { content: '●'; margin-right: 4px; font-size: 9px; }
#ping.good::before { color: #5ee36a; }
#ping.ok::before { color: #ffd23f; }
#ping.bad::before { color: #ff5a4f; }
#offline {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 4px; color: #fff; background: var(--red);
}


/* 처음 화면: 관전 위에 제목과 닉네임 입력·시작 버튼 */
#start { position: fixed; inset: 0; pointer-events: none; }
/* 제목: 왼쪽 위에 한 줄, 짙은 잉크색 (그림자 없음) */
#start h1 {
  position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(10px, env(safe-area-inset-top));
  margin: 0; white-space: nowrap; line-height: 1.1;
  font-size: clamp(22px, 3.2vw, 36px); font-weight: 900; letter-spacing: -.5px; color: var(--scene-ink);
}
#start h1 b { display: inline; color: #f0780a; } /* GlobeGrab: 뒤 "Grab" 만 주황 */
#start .cta {
  position: absolute; left: 50%; bottom: max(28px, 5vh, env(safe-area-inset-bottom)); transform: translateX(-50%); margin: 0;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  width: min(320px, calc(100vw - 32px));
}
/* 가운데: 고른 룸의 레전드 (hud.js RoomLegend). 옛 오락실 게임의 HIGH SCORES 표처럼 바탕 없이 큰 글자만.
   파스텔 하늘·행성 위에서 읽히게 밝은 글자에 짙은 외곽선 (떠오르는 글자 .fx-text 와 같은 방식). 줄마다 색이 다르다.
   칸: 순위 · 점수 · 이름 · (그 판의 점유율·처치). 표처럼 세로 줄을 맞추려고 ol 이 격자, li 는 display: contents */
#room-legend {
  position: absolute; left: 50%; top: max(60px, 8vh); transform: translateX(-50%);
  width: min(560px, calc(100vw - 24px)); text-align: center;
  font-family: "Titillium Web", "Gothic A1", sans-serif; font-weight: 900; color: #fff;
  -webkit-text-stroke: 5px var(--fx-ink); paint-order: stroke fill;
}
#room-legend h2 { margin: 0 0 6px; font-size: 34px; font-weight: 900; line-height: 1.1; letter-spacing: 2px; color: var(--fx-butter); }
#room-legend h2 .blink { display: block; animation: hs-blink 1.1s steps(1) infinite; }
#room-legend h2 .room { display: block; font-size: 17px; letter-spacing: 1px; color: var(--fx-mint); -webkit-text-stroke-width: 4px; }
@keyframes hs-blink { 50% { color: var(--fx-coral); } }
#room-legend ol {
  display: grid; grid-template-columns: max-content max-content minmax(0, max-content) max-content; column-gap: 22px; row-gap: 2px;
  width: max-content; max-width: 100%; margin: 0 auto; padding: 0; list-style: none; font-size: 24px; line-height: 1.22; font-variant-numeric: tabular-nums;
}
#room-legend li { display: contents; }
#room-legend li > span { white-space: nowrap; }
#room-legend .rk { text-align: right; }
#room-legend .sc { text-align: right; }
#room-legend .nm { text-align: left; overflow: hidden; text-overflow: ellipsis; padding: 0 3px; } /* padding: 외곽선이 잘리지 않게 */
#room-legend .ex { text-align: left; align-self: center; font-size: .6em; font-weight: 700; -webkit-text-stroke-width: 3px; color: var(--fx-cream); }
#room-legend .r1 { color: var(--fx-butter); font-size: 1.12em; }
#room-legend .r2 { color: #e9eef6; }
#room-legend .r3 { color: var(--fx-apricot); }
#room-legend .r4, #room-legend .r8 { color: var(--fx-mint); }
#room-legend .r5, #room-legend .r9 { color: var(--fx-pink); }
#room-legend .r6, #room-legend .r10 { color: var(--fx-lilac); }
#room-legend .r7 { color: var(--fx-peach); }
#room-legend li.empty { color: rgba(255, 255, 255, .75); }
#room-legend li.empty > span { -webkit-text-stroke-color: rgba(70, 58, 110, .45); letter-spacing: 1px; }
/* 휴대폰: 왼쪽 위 전체 화면 버튼 아래로 내리고 글자를 줄인다. 낮은 화면(가로로 든 휴대폰)에서는 룸 목록·닉네임 칸 자리가 모자라 숨긴다 */
body:has(#btn-fs:not([hidden])) #room-legend { top: calc(max(10px, env(safe-area-inset-top)) + 82px); }
@media (max-width: 640px) {
  #room-legend { -webkit-text-stroke-width: 4px; }
  #room-legend h2 { font-size: 28px; }
  #room-legend h2 .room { font-size: 14px; -webkit-text-stroke-width: 3px; }
  #room-legend ol { font-size: 19px; column-gap: 11px; row-gap: 1px; }
  #room-legend .ex { -webkit-text-stroke-width: 2.5px; }
}
@media (max-height: 620px) { #room-legend { display: none; } }
/* 로비에서는 데모 캐릭터의 이름표·떠오르는 글자를 숨긴다 (HIGH SCORES 글자와 겹쳐 읽기 어렵다) */
body:has(#room-legend:not([hidden])):has(#start:not([hidden])) #labels { display: none; }
#start .lbl { margin-bottom: 6px; color: var(--scene-ink); font-size: 13px; font-weight: 700; }
/* 닉네임 칸과 시작 버튼을 한 덩어리로 */
/* 전체 화면 버튼 (휴대폰, 모든 화면): 동그란 반투명 버튼에 아이콘 (전체 화면이면 줄이기 아이콘으로).
   첫 화면에서는 왼쪽 위 제목 아래, 게임 중에는 제목이 없으니 왼쪽 위 구석. 창(탈락·레전드) 위에도 보이고 눌린다 */
#btn-fs {
  position: fixed; z-index: 30; left: max(12px, env(safe-area-inset-left)); top: calc(max(10px, env(safe-area-inset-top)) + 36px);
  display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 1px solid rgba(45, 42, 74, .14); border-radius: 50%;
  background: rgba(255, 255, 255, .6); color: var(--scene-ink); cursor: pointer; pointer-events: auto; -webkit-tap-highlight-color: transparent;
}
body:has(#start[hidden]) #btn-fs { top: max(10px, env(safe-area-inset-top)); }
#btn-fs:active { background: rgba(255, 255, 255, .9); transform: scale(.94); }
#btn-fs svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
#btn-fs .to-exit, #btn-fs.on .to-full { display: none; }
#btn-fs.on .to-exit { display: block; }
#start .join {
  pointer-events: auto; display: flex; gap: 4px; width: 100%; padding: 4px; border-radius: 10px;
  background: rgba(255, 255, 255, .6); box-shadow: 0 4px 16px rgba(10, 40, 100, .2);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
#start .join:focus-within { box-shadow: 0 0 0 2px #2f7bff, 0 4px 16px rgba(10, 40, 100, .2); }
#in-name {
  flex: 1; min-width: 0; padding: 0 10px; border: 0; outline: none; background: none;
  font: inherit; font-size: 15px; font-weight: 700; color: var(--text);
}
#in-name::placeholder { color: #5f6f8a; font-weight: 600; }
#btn-start {
  flex: none; cursor: pointer; padding: 8px 18px; border: 0; border-radius: 7px;
  font: inherit; font-size: 15px; font-weight: 800; color: #fff; background: #1f7aff;
  transition: background .15s;
}
#btn-start:hover { background: #1463e0; }
#btn-start:disabled { opacity: .7; cursor: default; }
/* 로비: 서버(이름·지역·핑) 머리줄 아래 룸 줄 (이름 · 상태 · 인원 막대 · 인원). 고른 룸은 파란 테두리 */
#start .rooms {
  pointer-events: auto; width: 100%; max-height: 34vh; overflow-y: auto; margin-bottom: 10px; padding: 4px;
  border-radius: 10px; text-align: left; background: rgba(255, 255, 255, .6); box-shadow: 0 4px 16px rgba(10, 40, 100, .2);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.rooms .srv { display: flex; align-items: baseline; gap: 6px; padding: 3px 8px 2px; font-size: 12px; color: var(--scene-ink); }
.rooms .srv b { font-weight: 800; }
.rooms .srv small { color: #5f6f8a; font-weight: 700; }
.rooms .png { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.rooms .png::before { content: '●'; margin-right: 4px; font-size: 9px; color: #b9c0cc; }
.rooms .png.good::before { color: #2fbf4a; }
.rooms .png.ok::before { color: #e8b400; }
.rooms .png.bad::before, .rooms .png.off::before { color: #ff5a4f; }
.rooms .room {
  display: grid; grid-template-columns: minmax(0, 1fr) auto 64px 42px; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 2px solid transparent; border-radius: 7px; background: none; cursor: pointer;
  font: inherit; font-size: 14px; color: var(--text); text-align: left; -webkit-tap-highlight-color: transparent;
}
.rooms .room:hover:not(:disabled) { background: rgba(255, 255, 255, .55); }
.rooms .room.sel { border-color: #1f7aff; background: rgba(255, 255, 255, .8); }
.rooms .room:disabled { cursor: default; opacity: .55; }
.rooms .nm { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-weight: 700; }
.rooms .room em { font-style: normal; font-size: 11px; font-weight: 800; color: #5f6f8a; }
.rooms .room.busy em { color: #c88a00; }
.rooms .room.full em, .rooms .room.offline em { color: var(--red); }
.rooms .bar { height: 6px; border-radius: 3px; background: rgba(45, 42, 74, .14); overflow: hidden; }
.rooms .bar i { display: block; height: 100%; border-radius: 3px; background: #2fbf4a; }
.rooms .busy .bar i { background: #e8b400; }
.rooms .full .bar i { background: var(--red); }
.rooms .cnt { font-size: 12px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; color: #3c4660; }
#start-err { min-height: 1.2em; margin: 6px 0 0; color: #fff; font-size: 12px; }
#start-err:empty { visibility: hidden; }
#start-err:not(:empty) { padding: 2px 8px; border-radius: 4px; background: rgba(232, 35, 27, .85); }

/* 입장·탈락 창 */
.panel-wrap { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(30, 60, 100, .18); }
.panel {
  width: min(340px, 100%); max-height: 100%; overflow: auto;
  padding: 16px 16px; border-radius: 8px; background: #fff; /* 창 안쪽 여백 (탈락 창 제목 띠의 -16px 와 맞춘다) */
  box-shadow: 0 0 0 1px rgba(10, 20, 40, .08);
  position: relative;
}
.panel h2.title { margin: 0 0 16px; font-size: 22px; color: var(--ink); text-align: center; }
.panel button.close {
  position: absolute; top: 6px; right: 6px; width: 34px; height: 34px; margin: 0; padding: 0;
  border-radius: 50%; background: none; color: var(--muted); font-size: 26px; line-height: 1;
}
.panel button.close:hover { background: #f0f2f6; color: var(--ink); }
.panel h2 { margin: 0 0 4px; font-size: 28px; color: var(--red); }
.panel label { display: block; margin-bottom: 10px; font-size: 13px; color: var(--ink); text-align: center; }
.panel input { text-align: center; }
.panel input {
  display: block; width: 100%; margin-top: 4px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 4px; font: inherit; font-size: 16px;
}
.panel input:focus { outline: 2px solid #2f7bff; border-color: transparent; }
.panel button {
  width: 100%; margin-top: 6px; padding: 12px; border: 0; border-radius: 5px;
  font: inherit; font-size: 17px; color: #fff; background: var(--navy); cursor: pointer;
}
.panel button:disabled { opacity: .6; cursor: default; }
.panel button small { opacity: .7; font-weight: 600; }
.err { min-height: 1.2em; margin: 8px 0 0; color: var(--red); font-size: 13px; }
/* 탈락 창 제목: 빨간 띠 + 죽은 까닭 아이콘 (흔들리며 등장) */
.panel.dead { padding-top: 0; overflow: hidden auto; }
.dead-head {
  display: flex; align-items: center; gap: 12px; margin: 0 -16px 10px; padding: 12px 16px 11px;
  color: #fff; background: linear-gradient(135deg, #ff4b3e, #c8101c);}
.dead-head .ico { flex: none; font-size: 38px; line-height: 1; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .3)); animation: dead-ico .6s cubic-bezier(.3, 1.6, .5, 1) both; }
.dead-head small { display: block; font-size: 11px; font-weight: 700; letter-spacing: 1.5px; text-transform: uppercase; opacity: .85; }
.panel .dead-head h2 { margin: 0; font-size: 26px; line-height: 1.1; color: #fff; }
.panel.dead[data-how="self"] .dead-head { background: linear-gradient(135deg, #8a5cff, #5a2fc0); }
@keyframes dead-ico { from { transform: scale(.2) rotate(-30deg); opacity: 0; } 60% { transform: scale(1.2) rotate(8deg); opacity: 1; } to { transform: none; } }
/* 왜 죽었는지: 눈에 띄는 카드, 잡은 플레이어는 색 점 + 계급장 + 굵은 이름 */
#dead-why {
  margin: 0 0 10px; padding: 8px 10px; border-radius: 6px; border-left: 4px solid var(--red);
  background: #fff1f0; color: var(--text); font-size: 15px; line-height: 1.5; text-align: center;
}
.panel.dead[data-how="self"] #dead-why { border-left-color: #7a4cf0; background: #f4f0ff; }
#dead-why b { font-weight: 800; color: #111; }
#dead-why .killer { display: inline-flex; align-items: center; gap: 4px; padding: 1px 7px 1px 5px; border-radius: 5px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--c); vertical-align: middle; white-space: nowrap; }
#dead-why .killer i { width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
#dead-why .killer .lv { display: inline-flex; align-items: center; gap: 2px; padding: 0 4px; border-radius: 8px; font-size: 10px; font-weight: 700; color: #fff; background: #5b6372; --ico: #fff; }
#dead-why .killer .lv .rank-ico { height: 1em; fill: var(--ico); }
#dead-why .killer .lv b { color: inherit; font-weight: 700; }
.dead-stats { display: flex; gap: 8px; margin-bottom: 10px; }
.dead-stats div { flex: 1; padding: 8px; border-radius: 5px; background: #f3f5f9; text-align: center; }
.dead-stats small { display: block; color: var(--muted); font-size: 12px; }
.dead-stats b { font-size: 24px; color: var(--ink); }
/* 개인 최고 기록 / 새 기록 */
.dead-stats div { position: relative; }
.dead-stats .pb { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.dead-stats .new { display: none; }
.dead-stats .record { background: linear-gradient(180deg, #fff6d6, #ffe9a3); box-shadow: inset 0 0 0 1.5px #f2b705; }
.dead-stats .record .new {
  display: block; position: absolute; top: -8px; left: 50%; transform: translateX(-50%);
  padding: 1px 7px; border-radius: 999px; background: #f2a705; color: #fff;
  font-style: normal; font-size: 10px; font-weight: 800; letter-spacing: .5px; white-space: nowrap;
  animation: pop .5s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes pop { from { transform: translateX(-50%) scale(.3); opacity: 0; } }
#dead-legend { margin: 0 0 10px; padding: 7px 10px; border-radius: 5px; background: #1d2433; color: #ffd54a; font-size: 13px; font-weight: 700; text-align: center; }
.panel button.link { margin-top: 8px; padding: 6px; background: none; color: var(--ink); font-size: 14px; font-weight: 700; }
.panel button.link:hover { text-decoration: underline; }

/* 레전드 순위 창 */
#legend { z-index: 20; }
.panel.legend { width: min(400px, 100%); padding: 14px 12px 12px; }
.panel.legend .title { margin-bottom: 10px; color: #b07800; }
.legend .sub { margin: 6px 0 4px; color: var(--muted); font-size: 12px; text-align: center; }
.lg-rows { margin: 0; padding: 0; list-style: none; }
.lg-rows li {
  display: flex; align-items: center; gap: 7px; padding: 5px 8px; border-radius: 5px;
  color: var(--text); font-size: 13px;
}
.lg-rows li + li { margin-top: 2px; }
.lg-rows li:nth-child(1) { font-size: 17px; font-weight: 800; padding: 9px 10px; background: linear-gradient(90deg, #ffe79a, #fff6d6 70%, #fff0); }
.lg-rows li:nth-child(2) { font-size: 15px; font-weight: 700; padding: 7px 9px; background: linear-gradient(90deg, #e5ebf2, #f5f7fa 70%, #fff0); }
.lg-rows li:nth-child(3) { font-size: 14px; font-weight: 700; padding: 6px 9px; background: linear-gradient(90deg, #f6d9bf, #fbeee3 70%, #fff0); }
.lg-rows li.me { box-shadow: inset 0 0 0 2px #2f7bff; }
.lg-rows li.slot { opacity: .45; }
.lg-rows li.slot .nm { color: var(--muted); font-weight: 400; }
.lg-rows li.slot .rk { filter: grayscale(1); }
.lg-rows .ri.ghost { visibility: hidden; }
.lg-rows .rk { flex: none; width: 24px; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.lg-rows li:nth-child(-n+3) .rk { font-size: 1.2em; }
.lg-rows .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lg-rows .nm b { font-weight: inherit; }
/* 이름 아래 작게: 그 판의 최대 점유율 · 처치 수 */
.lg-rows .nm .ex { display: block; overflow: hidden; text-overflow: ellipsis; color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.2; }
.lg-rows .when { flex: none; color: var(--muted); font-size: 11px; font-weight: 400; }
.lg-rows li.live .when { color: #fff; background: var(--red); padding: 0 5px; border-radius: 3px; font-weight: 800; font-size: 10px; animation: blink 1.2s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .55; } }
.lg-rows .val { flex: none; min-width: 64px; text-align: right; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; }
.lg-rows li:nth-child(1) .val { color: #b07800; }

/* 탈락 창 버튼: 다시 하기(넓게) + 그만하기 */
.dead-btns { display: flex; gap: 6px; }
.dead-btns #btn-again { flex: 1; }
.panel .dead-btns button.quit { width: auto; padding: 12px 16px; color: var(--ink); background: #eef1f6; }
.panel .dead-btns button.quit:hover { background: #e2e7ef; }
#dead-auto { margin: 8px 0 0; min-height: 1.2em; text-align: center; color: var(--muted); font-size: 12px; }

@media (max-width: 640px) {
  #start h1 { font-size: 20px; }
  #board { max-width: 262px; font-size: 10.5px; }
  #board li { --step: 2px; }
  #board li:nth-child(1) { font-size: 12px; }
  #board li:nth-child(2) { font-size: 11px; }
  #board li:nth-child(3) { font-size: 10.5px; }
  #board li:nth-child(n+6):not(.me) { display: none; }
  #board li :is(.kl, .pc) { display: none; } /* 좁은 화면: 이름 자리를 위해 점수만 (처치 수·점유율은 이름표에서) */
  #help { display: none; }
  #boost { bottom: 14px; width: calc(100% - 300px); }
  #score b { font-size: 17px; }
  body:has(#btn-fs:not([hidden])) #score { top: calc(max(10px, env(safe-area-inset-top)) + 6px); } /* 전체 화면 버튼(38px)과 가운데 높이 맞춤 */
  .dead-stats { gap: 6px; }
  .dead-stats div { padding: 8px 4px; }
  .dead-stats b { font-size: 20px; }
}


/* 그리기 오류 알림 (stage.js watchGLErrors) */
/* 불러오는 화면(z-index 100)보다도 위에. 아래쪽 안전 영역(홈 막대)을 피한다 */
#glerr {
  position: fixed; left: 8px; right: 8px; bottom: max(8px, env(safe-area-inset-bottom)); z-index: 1000;
  display: flex; align-items: flex-start; gap: 8px; max-height: 40vh; overflow: auto;
  padding: 8px 10px; border-radius: var(--radius); background: rgba(190, 20, 20, .92); color: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .3); pointer-events: auto;
}
#glerr[hidden] { display: none; }
#glerr pre { flex: 1; margin: 0; font: 600 12px/1.4 ui-monospace, monospace; white-space: pre-wrap; user-select: text; -webkit-user-select: text; }
#glerr button {
  flex: none; padding: 6px 12px; border: 0; border-radius: 6px; background: #fff; color: #b01414;
  font: 800 12px/1 system-ui, sans-serif; cursor: pointer;
}
