/* 티노어택 화면. HUD 원칙(tukorea-destruction 과 같음): 플레이 중 늘 보이는 것은 카드 없이 그림자 얹은 글자와 얇은 선,
   열어서 보는 것(로비·메뉴·점수판·결과)만 유리 패널. 티노 남색·파랑 + 오렌지 팀색.
   기기별: PC(마우스) · 터치 태블릿(.touch, 761px~) · 휴대폰(≤760px 또는 낮은 화면) */
:root {
  color-scheme: dark;
  --navy: #162b49;
  --blue: #0d57a7;
  --blue-2: #3c63ae;
  --orange: #ef7a2a;
  --orange-2: #f6a35e;
  --sky: #9db6e3;
  --egg: #e3ecf9;
  --panel: rgba(12, 21, 38, 0.76);
  --panel-2: rgba(255, 255, 255, 0.07);
  --hud: rgba(10, 18, 32, 0.42);
  --line: rgba(157, 182, 227, 0.22);
  --text: #eef3fb;
  --muted: #a9b8cf;
  --hot: #ff8a3d;
  --hot-2: #ffd27a;
  --ok: #7fd1a6;
  --bad: #ff5d5d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.9), 0 0 10px rgba(0, 0, 0, 0.55);
  --display: "Jua", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --body: "Noto Sans KR", "Apple SD Gothic Neo", system-ui, sans-serif;
  --sat: max(12px, env(safe-area-inset-top, 0px));
  --sar: max(12px, env(safe-area-inset-right, 0px));
  --sab: max(14px, env(safe-area-inset-bottom, 0px));
  --sal: max(12px, env(safe-area-inset-left, 0px));
}
* { box-sizing: border-box; }
/* iPadOS Safari 는 user-scalable=no 를 무시하므로 touch-action 으로 핀치·더블탭 확대를 막는다 */
html, body { margin: 0; height: 100%; overflow: hidden; background: #0a1220; color: var(--text); font-family: var(--body);
  touch-action: none; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
canvas#view { position: fixed; inset: 0; display: block; width: 100vw; height: 100vh; touch-action: none; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--hot-2); outline-offset: 2px; }
[hidden] { display: none !important; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3); }
.hud { text-shadow: var(--shadow); }
.num { font-variant-numeric: tabular-nums; }
.kbd { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 5px; background: var(--panel-2);
  border: 1px solid var(--line); text-align: center; font-size: 11px; line-height: 17px; margin-right: 4px; font-weight: 500; }
#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 6; }
#boot { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px; background: radial-gradient(circle at 50% 40%, #1d3a63, #0a1220);
  font-family: var(--display); font-size: 20px; z-index: 50; transition: opacity 0.4s; }
#boot .egg { width: 54px; height: 70px; animation: wob 1.2s ease-in-out infinite; }
#boot.gone { opacity: 0; pointer-events: none; }
@keyframes wob { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) translateY(-4px); } }

/* ---------- 공통 버튼·입력 ---------- */
.btn { appearance: none; border: 1px solid var(--line); background: var(--panel-2); border-radius: 12px; padding: 10px 16px; cursor: pointer;
  font-weight: 700; font-size: 14px; transition: transform 0.08s, background 0.15s; touch-action: manipulation; }
.btn:hover { background: rgba(255, 255, 255, 0.13); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--blue); border-color: #2c74c4; color: #fff; }
.btn.primary:hover { background: #1767bd; }
.btn.ghost { background: transparent; }
.btn.big { font-family: var(--display); font-weight: 400; font-size: 18px; padding: 12px 22px; }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.seg { display: flex; background: var(--panel-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { appearance: none; border: 0; background: transparent; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 500; flex: 1; white-space: nowrap; }
.seg button.on { background: var(--blue); color: #fff; }
.seg button:disabled { cursor: default; }
.seg.wide { width: 100%; }
input[type=text], input:not([type]), select { font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none; -webkit-user-select: text; user-select: text; touch-action: manipulation; }
select { appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--sky) 50%), linear-gradient(-45deg, transparent 50%, var(--sky) 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
select option { background: #13223b; }
input:focus, select:focus { border-color: var(--sky); }
.overlay { position: fixed; inset: 0; display: grid; place-items: center; padding: var(--sat) var(--sar) var(--sab) var(--sal); z-index: 20; background: rgba(6, 12, 24, 0.45); }
.card { padding: 20px 22px; }
.card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 22px; }
.card h3 { margin: 14px 0 8px; font-size: 13px; color: var(--muted); font-weight: 700; }
.row { display: flex; gap: 10px; justify-content: flex-end; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.note { margin: 8px 0 0; font-size: 11.5px; color: var(--muted); }
.hint { font-size: 11.5px; color: var(--muted); }

/* ================= 로비 =================
   레퍼런스: Shell Shockers·Krunker 첫 화면(가운데 큰 캐릭터, 아래 큰 플레이 하나, 옆에 친구·모드),
   skribbl.io(이름 + 플레이 + 비공개 방). 한 화면에 한 가지 큰 행동만 눈에 띄게 둔다.
   #lobby 하나가 그리드이고, 화면마다 at-title / at-room / at-result 로 자리만 바꾼다. */
#lobby { position: fixed; inset: 0; overflow-y: auto; z-index: 10; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(min-content, 1fr) auto; grid-template-areas: "top" "me" "act";
  gap: 6px 32px; padding: calc(var(--sat) + 2px) var(--sar) var(--sab) var(--sal);
  background: linear-gradient(180deg, rgba(10, 18, 32, 0.6), rgba(10, 18, 32, 0.12) 30%, rgba(10, 18, 32, 0.2) 60%, rgba(10, 18, 32, 0.85)); }
#lobby.gone { display: none; }
#lobby.at-room { grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "top top" "me side";
  padding-left: max(var(--sal), calc(50vw - 540px)); padding-right: max(var(--sar), calc(50vw - 540px)); }
#lobby.at-result { grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "top" "side"; background: rgba(10, 18, 32, 0.7); }

.lb-top { grid-area: top; display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 44px; }
.brand { display: flex; align-items: center; gap: 8px; }
.brand .egg { width: 24px; height: 31px; }
.brand h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 26px; line-height: 1; text-shadow: var(--shadow); }

/* 내 티노 */
.mytino { grid-area: me; display: flex; flex-direction: column; align-items: center; gap: 10px; width: min(560px, 100%); justify-self: center; }
.preview-wrap { position: relative; flex: 1 1 auto; width: 100%; min-height: 180px; cursor: grab; touch-action: pan-y;
  background: radial-gradient(ellipse 34% 8% at 50% 88%, rgba(6, 12, 24, 0.45), transparent 70%), radial-gradient(ellipse 46% 44% at 50% 56%, rgba(157, 182, 227, 0.3), transparent 72%); }
.preview-wrap:active { cursor: grabbing; }
.preview-wrap canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.turn-hint { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); padding: 3px 10px; border-radius: 999px; background: rgba(10, 18, 32, 0.55);
  color: var(--muted); font-size: 12px; pointer-events: none; transition: opacity 0.4s; }
.preview-wrap.turned .turn-hint { opacity: 0; }
.nameplate { display: flex; align-items: center; gap: 4px; padding: 0 14px; border-radius: 999px; background: rgba(10, 18, 32, 0.6); border: 1px solid var(--line); cursor: text; }
.nameplate input { width: 9em; background: none; border: 0; padding: 8px 0; text-align: center; font-family: var(--display); font-size: 20px; color: var(--text); }
.nameplate:focus-within { border-color: var(--sky); }
.nameplate .pen { color: var(--muted); font-size: 14px; }
.nameplate:has(input[readonly]) { border-color: transparent; cursor: default; }
.nameplate:has(input[readonly]) .pen { display: none; }
.wpick { display: flex; gap: 4px; padding: 4px; border-radius: 14px; background: rgba(10, 18, 32, 0.6); border: 1px solid var(--line); }
.wchip { appearance: none; border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 700; color: var(--muted);
  touch-action: manipulation; white-space: nowrap; }
.wchip:hover { color: var(--text); }
.wchip.on { background: var(--egg); color: var(--navy); }
.wline { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--muted); text-shadow: var(--shadow); min-height: 32px; }
.wline b { color: var(--text); margin-right: 2px; }
.wline .btn { text-shadow: none; background: rgba(10, 18, 32, 0.6); }

/* 첫 화면 행동: [친구와 하기] [플레이] [모드] */
.acts { grid-area: act; display: grid; justify-items: center; gap: 4px; padding: 6px 0 4px; }
.act-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; width: min(660px, 100%); }
.act-side { height: 56px; min-width: 132px; background: rgba(10, 18, 32, 0.66); font-size: 15px; }
.act-row > .act-side:first-child { justify-self: end; }
.act-side.mode { justify-self: start; display: grid; align-content: center; gap: 1px; line-height: 1.15; }
.act-side.mode small { font-size: 10.5px; color: var(--muted); font-weight: 500; }
.act-side.mode b { font-size: 14px; }
/* 화면에서 하나뿐인 주황 버튼 (플레이·시작) */
.btn.play, .btn.start { border: 0; color: #fff; font-family: var(--display); font-weight: 400; text-shadow: 0 1px 0 rgba(120, 50, 10, 0.5);
  background: linear-gradient(180deg, #ff9b50, var(--orange)); box-shadow: 0 5px 0 #b4511a, 0 10px 24px rgba(0, 0, 0, 0.35); transition: transform 0.08s, box-shadow 0.08s, filter 0.15s; }
.btn.play:hover, .btn.start:hover { background: linear-gradient(180deg, #ffa862, #f2843a); }
.btn.play:active, .btn.start:active { transform: translateY(4px); box-shadow: 0 1px 0 #b4511a, 0 4px 12px rgba(0, 0, 0, 0.3); }
.btn.play:disabled, .btn.start:disabled { opacity: 1; filter: saturate(0.4) brightness(0.8); transform: none; }
.btn.play { display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 32px; min-width: 240px; padding: 14px 40px; border-radius: 20px; }
.btn.play svg { width: 26px; height: 26px; fill: currentColor; }
.err { min-height: 18px; color: var(--bad); font-size: 13px; text-align: center; text-shadow: var(--shadow); }
.err:empty { min-height: 0; }
.conn { font-size: 11.5px; color: var(--muted); text-shadow: var(--shadow); }

/* 친구와 하기·꾸미기 판 */
.sheet-back { position: fixed; inset: 0; z-index: 15; display: grid; place-items: center; padding: var(--sat) var(--sar) var(--sab) var(--sal); background: rgba(6, 12, 24, 0.5); }
.sheet { display: grid; gap: 12px; align-content: start; }
.sheet-head { display: flex; align-items: center; gap: 8px; }
.sheet-head h2 { flex: 1; }
.sheet.friends { width: min(380px, 100%); }
.or { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 10px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.join { display: flex; gap: 8px; }
.join input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 6px; text-align: center; font-size: 22px; font-family: var(--display); }
.closet { position: fixed; z-index: 15; right: var(--sar); top: calc(var(--sat) + 52px); width: min(360px, 44vw); max-height: calc(100% - var(--sat) - var(--sab) - 64px); overflow-y: auto; touch-action: pan-y; }
#lobby.dressing .acts, #lobby.dressing #scrRoom { display: none; }
#lobby.at-room .closet { position: static; grid-area: side; align-self: center; width: 100%; max-height: 100%; }
.closet-rows { display: grid; gap: 8px; }
.crow { display: grid; grid-template-columns: 52px 34px minmax(0, 1fr) 34px; align-items: center; gap: 6px; font-size: 13px; }
.crow.skin { grid-template-columns: 52px minmax(0, 1fr); padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.crow .k { color: var(--muted); font-size: 12px; }
.crow button { appearance: none; border: 1px solid var(--line); background: var(--panel-2); height: 36px; border-radius: 10px; cursor: pointer; font-size: 18px; touch-action: manipulation; }
.crow button:hover { background: rgba(255, 255, 255, 0.13); }
.crow select { width: 100%; padding: 8px 26px 8px 10px; font-size: 13.5px; }

/* 방: 코드 → 팀 → 규칙 한 줄 → 시작 */
.side { grid-area: side; align-self: center; width: 100%; display: grid; gap: 14px; max-height: 100%; overflow-y: auto; touch-action: pan-y; }
.code-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.code-row .code { display: block; font-family: var(--display); font-weight: 400; font-size: 40px; letter-spacing: 6px; line-height: 1; color: var(--hot-2); }
.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.teams.ffa { grid-template-columns: 1fr; }
.tlist { border-radius: 12px; padding: 8px 10px; background: var(--panel-2); border-top: 3px solid var(--sky); min-height: 96px; }
.tlist.blue { border-top-color: var(--blue-2); }
.tlist.orange { border-top-color: var(--orange); }
.tlist h4 { display: flex; align-items: center; gap: 6px; margin: 0 0 6px; font-family: var(--display); font-weight: 400; font-size: 16px; }
.tlist h4 .n { font-family: var(--body); font-size: 12px; color: var(--muted); }
.tlist.blue h4 { color: #8fb6ff; }
.tlist.orange h4 { color: var(--orange-2); }
.tjoin { appearance: none; margin-left: auto; border: 1px solid var(--line); background: transparent; color: var(--text); border-radius: 8px; padding: 3px 8px;
  font: inherit; font-family: var(--body); font-size: 11.5px; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.tjoin:hover { background: rgba(255, 255, 255, 0.12); }
.prow { display: flex; align-items: center; gap: 6px; font-size: 13.5px; padding: 3px 0; }
.prow.me b { color: var(--hot-2); }
.prow.bot b { color: var(--muted); font-weight: 500; }
.rules { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.rules b { color: var(--text); }
.settings { display: grid; gap: 8px; padding: 10px; border-radius: 12px; background: var(--panel-2); }
.setline { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.btn.start { font-size: 24px; padding: 13px 22px; border-radius: 16px; }
/* 낮은 화면에서 판이 스크롤돼도 시작 버튼은 늘 보이게 */
.side .btn.start { position: sticky; bottom: 0; z-index: 1; }
.wait { font-size: 13px; color: var(--muted); text-align: center; }

/* 결과 */
.result-card { width: min(560px, 100%); justify-self: center; }
.res-head { text-align: center; font-family: var(--display); font-size: clamp(30px, 6vw, 44px); line-height: 1.1; }
.res-head small { display: block; font-family: var(--body); font-size: 13px; color: var(--muted); margin-top: 4px; }
.res-head.blue { color: #8fb6ff; } .res-head.orange { color: var(--orange-2); }
.mvp { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 14px; }
.mvp .crown { font-family: var(--display); color: var(--hot-2); font-size: 18px; }
.result-card .row { margin-top: 0; justify-content: center; }
.table-wrap { max-height: 46vh; overflow-y: auto; touch-action: pan-y; }
table.score { width: 100%; border-collapse: collapse; font-size: 13px; }
table.score th { text-align: right; font-size: 11px; color: var(--muted); font-weight: 500; padding: 4px 6px; }
table.score th:first-child, table.score td:first-child { text-align: left; }
table.score td { text-align: right; padding: 5px 6px; border-top: 1px solid rgba(255, 255, 255, 0.06); }
table.score tr.me td { color: var(--hot-2); font-weight: 700; }
table.score tr.bot td:first-child { color: var(--muted); }
table.score tr.blue td:first-child { border-left: 3px solid var(--blue-2); }
table.score tr.orange td:first-child { border-left: 3px solid var(--orange); }
table.score tr.dead td { opacity: 0.55; }
.badge { font-size: 9.5px; padding: 1px 5px; border-radius: 6px; background: rgba(255, 255, 255, 0.12); color: var(--muted); }
.badge.host { background: rgba(255, 210, 122, 0.2); color: var(--hot-2); }

/* ================= HUD ================= */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; font-family: var(--body); }
#hud > * { position: absolute; }
#topbar { top: var(--sat); left: 50%; transform: translateX(-50%); display: flex; align-items: stretch; gap: 0; border-radius: 14px; overflow: hidden;
  background: var(--hud); }
#topbar .side { display: flex; align-items: center; gap: 8px; padding: 4px 12px; min-width: 96px; font-family: var(--display); }
#topbar .side b { font-size: 26px; font-weight: 400; }
#topbar .side .nm { font-size: 12px; max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topbar .side.blue { background: linear-gradient(90deg, rgba(13, 87, 167, 0.85), rgba(13, 87, 167, 0.4)); justify-content: flex-start; }
#topbar .side.orange { background: linear-gradient(270deg, rgba(239, 122, 42, 0.85), rgba(239, 122, 42, 0.4)); justify-content: flex-end; }
#topbar.ffa .side.blue { background: linear-gradient(90deg, rgba(255, 210, 122, 0.35), transparent); }
#topbar.ffa .side.orange { background: linear-gradient(270deg, rgba(157, 182, 227, 0.35), transparent); }
#topbar .mid { display: grid; justify-items: center; padding: 3px 14px; }
#topbar .mid b { font-size: 20px; font-family: var(--display); font-weight: 400; line-height: 1.1; }
#topbar .mid span { font-size: 10px; color: var(--muted); white-space: nowrap; }
#topbar .mid b.low { color: var(--hot); }
#netinfo { top: var(--sat); left: var(--sal); font-size: 10.5px; color: var(--muted); opacity: 0.85; }
#feed { top: var(--sat); right: var(--sar); display: grid; justify-items: end; gap: 4px; width: min(360px, 44vw); }
.kf { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 10px; background: var(--hud); font-size: 12.5px;
  text-shadow: var(--shadow); animation: kfin 0.25s ease-out; white-space: nowrap; max-width: 100%; overflow: hidden; }
.kf.me { background: rgba(255, 210, 122, 0.25); border: 1px solid rgba(255, 210, 122, 0.45); }
.kf .b { color: #8fb6ff; font-weight: 700; } .kf .o { color: var(--orange-2); font-weight: 700; } .kf .n { color: var(--egg); font-weight: 700; }
.kf .v { color: var(--muted); font-size: 11.5px; }
.kf .hs { color: var(--hot-2); }
.kf.out { opacity: 0; transition: opacity 0.4s; }
@keyframes kfin { from { transform: translateX(20px); opacity: 0; } }

#cross { left: 50%; top: 50%; width: 0; height: 0; --g: 8px; }
#cross i { position: absolute; background: #fff; box-shadow: 0 0 2px rgba(0, 0, 0, 0.9); border-radius: 1px; transition: transform 0.05s linear; }
#cross .t, #cross .b { width: 2px; height: 8px; left: -1px; }
#cross .l, #cross .r { width: 8px; height: 2px; top: -1px; }
#cross .t { top: calc(-1 * var(--g) - 8px); } #cross .b { top: var(--g); }
#cross .l { left: calc(-1 * var(--g) - 8px); } #cross .r { left: var(--g); }
#cross .dot { position: absolute; width: 3px; height: 3px; left: -1.5px; top: -1.5px; background: #fff; border-radius: 50%; box-shadow: 0 0 2px #000; }
#cross.hide { display: none; }
#cross.enemy i, #cross.enemy .dot { background: #ff7b6b; }
#cross .ring { position: absolute; width: 44px; height: 44px; left: -22px; top: -22px; transform: rotate(-90deg); opacity: 0; }
#cross .ring circle { fill: none; stroke: var(--hot-2); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 119.4; stroke-dashoffset: var(--off, 119.4);
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8)); }
#cross.reloading .ring { opacity: 1; }
#hitmark { left: 50%; top: 50%; width: 0; height: 0; opacity: 0; }
#hitmark i { position: absolute; width: 11px; height: 2.5px; background: #fff; box-shadow: 0 0 3px rgba(0, 0, 0, 0.9); border-radius: 2px; }
#hitmark i:nth-child(1) { transform: translate(-16px, -12px) rotate(45deg); }
#hitmark i:nth-child(2) { transform: translate(5px, -12px) rotate(-45deg); }
#hitmark i:nth-child(3) { transform: translate(-16px, 9px) rotate(-45deg); }
#hitmark i:nth-child(4) { transform: translate(5px, 9px) rotate(45deg); }
#hitmark.head i { background: var(--hot-2); width: 14px; }
#hitmark.kill i { background: var(--bad); width: 15px; height: 3px; }
#hitmark.go { animation: hm 0.28s ease-out; }
@keyframes hm { 0% { opacity: 1; transform: scale(1.4); } 60% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(0.9); } }
#dmgdirs { inset: 0; }
.dd { position: absolute; left: 50%; top: 50%; width: 180px; height: 180px; margin: -90px; border-radius: 50%; pointer-events: none;
  background: conic-gradient(from -22deg, rgba(255, 60, 60, 0.85) 0deg, rgba(255, 60, 60, 0) 44deg, transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 72px, #000 74px, #000 88px, transparent 90px); mask: radial-gradient(circle, transparent 72px, #000 74px, #000 88px, transparent 90px);
  transition: opacity 0.9s ease-in; }
#lowhp { inset: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(200, 20, 30, 0.55) 100%); opacity: 0; transition: opacity 0.3s; }
#lowhp.beat { animation: beat 1s ease-in-out infinite; }
@keyframes beat { 50% { filter: brightness(1.4); } }

#vitals { left: var(--sal); bottom: var(--sab); width: 260px; }
.hprow { display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 8px; }
.hprow .lbl { font-size: 11px; color: var(--muted); font-weight: 700; }
.hprow b { font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1; min-width: 46px; }
.hpbar { position: relative; height: 10px; border-radius: 6px; background: rgba(10, 18, 32, 0.55); border: 1px solid rgba(255, 255, 255, 0.25); overflow: hidden; }
.hpbar i, .hpbar em { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; border-radius: 5px; }
.hpbar i { background: linear-gradient(90deg, #7fd1a6, #b9f0c9); z-index: 1; transition: width 0.12s; }
.hpbar em { background: rgba(255, 255, 255, 0.55); transition: width 0.6s 0.25s; }
.hpbar.mid i { background: linear-gradient(90deg, #f4c04f, #ffe39a); }
.hpbar.low i { background: linear-gradient(90deg, #ff5d5d, #ff9b8a); }
.chips { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.chip { position: relative; display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px 2px 4px; border-radius: 10px; background: var(--hud); font-size: 13px; overflow: hidden; }
.chip svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#grenChip svg ellipse { fill: #f7a6c4; stroke: var(--navy); stroke-width: 1.5; }
#grenChip svg .dot { fill: #fff; stroke: none; }
#grenChip.empty { opacity: 0.4; }
#dashChip { padding-right: 6px; }
#dashChip .cd { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); transform-origin: left; transform: scaleX(0); }
#dashChip.ready { box-shadow: inset 0 0 0 1.5px var(--ok); }
.chip.prot { padding: 2px 8px; color: var(--hot-2); font-weight: 700; font-size: 11.5px; }
#ammo { right: var(--sar); bottom: var(--sab); text-align: right; font-family: var(--display); }
#ammo #wpnName { font-size: 13px; color: var(--sky); }
#ammo b { font-size: 40px; font-weight: 400; line-height: 1; }
#ammo #ammoMax { font-size: 16px; color: var(--muted); margin-left: 4px; }
#ammo #ammoRes { display: block; font-size: 11px; color: var(--muted); font-family: var(--body); }
#ammo #ammoAlt { display: block; font-size: 11px; color: var(--sky); font-family: var(--body); opacity: 0.8; }
#ammo .swapping { opacity: 0.5; }
#ammo.empty b { color: var(--bad); }
#banner { left: 50%; top: 22%; transform: translateX(-50%); font-family: var(--display); font-size: 30px; text-align: center; opacity: 0; white-space: nowrap; }
#banner small { display: block; font-size: 14px; font-family: var(--body); color: var(--egg); }
#banner.go { animation: ban 2.4s ease-out; }
#banner.giant { color: var(--hot-2); font-size: 38px; }
#banner.streak { color: var(--hot); }
@keyframes ban { 0% { opacity: 0; transform: translateX(-50%) scale(1.6); } 12% { opacity: 1; transform: translateX(-50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; } }
#respawn { left: 50%; top: 58%; transform: translateX(-50%); display: grid; justify-items: center; text-shadow: var(--shadow); }
#respawn .who { font-size: 14px; }
#respawn .who b { color: var(--orange-2); }
#respawn b.num { font-family: var(--display); font-weight: 400; font-size: 64px; line-height: 1; }
#respawn span { font-size: 13px; color: var(--egg); }
#toast { left: 50%; top: calc(var(--sat) + 56px); transform: translateX(-50%); padding: 7px 14px; font-size: 13px; opacity: 0; transition: opacity 0.25s; white-space: nowrap; }
#toast.show { opacity: 1; }
#lockHint { left: 50%; top: 74%; transform: translateX(-50%); padding: 10px 18px; font-size: 14px; font-weight: 700; display: flex; gap: 10px; align-items: center; }
#board { left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(620px, calc(100vw - 24px)); max-height: 78vh; overflow-y: auto; padding: 14px 16px; }
#board h3 { margin: 0 0 8px; font-family: var(--display); font-weight: 400; font-size: 18px; display: flex; justify-content: space-between; }
#board h3 span { font-family: var(--body); font-size: 12px; color: var(--muted); }
#board .teamhd { font-family: var(--display); font-size: 14px; margin: 8px 0 2px; }
#board .teamhd.blue { color: #8fb6ff; } #board .teamhd.orange { color: var(--orange-2); }

/* 저격 줌: 돋보기 렌즈 (가운데 원만 뚫린 비네트 + 금테 + 손잡이) */
#scope { inset: 0; }
#scope .lens { position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 50%, transparent 0, transparent min(36vh, 36vw), #c99a5b min(36vh, 36vw), #e9c27a calc(min(36vh, 36vw) + 7px), #8a6136 calc(min(36vh, 36vw) + 14px), rgba(16, 24, 40, 0.94) calc(min(36vh, 36vw) + 15px)); }
#scope .lens::after { content: ""; position: absolute; left: 50%; top: 50%; width: calc(min(36vh, 36vw) * 2); height: calc(min(36vh, 36vw) * 2); transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, rgba(255, 255, 255, 0.22), transparent 26%), radial-gradient(circle, transparent 70%, rgba(20, 40, 70, 0.35)); }
#scope .handle { position: absolute; left: calc(50% + min(36vh, 36vw) * 0.66); top: calc(50% + min(36vh, 36vw) * 0.66); width: 34px; height: 46vh; border-radius: 17px;
  transform: rotate(-45deg); transform-origin: 50% 0; background: linear-gradient(90deg, #8a6136, #c99a5b 40%, #8a6136); border: 3px solid var(--navy); }
#scope .cross { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; }
#scope .cross::before, #scope .cross::after { content: ""; position: absolute; background: rgba(22, 43, 73, 0.85); }
#scope .cross::before { left: 19px; top: 0; width: 2px; height: 40px; }
#scope .cross::after { top: 19px; left: 0; height: 2px; width: 40px; }

/* ---------- 메뉴 ---------- */
.menu-card { width: min(440px, 100%); max-height: 92vh; overflow-y: auto; touch-action: pan-y; }
.setrow { display: grid; grid-template-columns: 96px 1fr 44px; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid rgba(255, 255, 255, 0.06); font-size: 13px; }
.setrow .seg { grid-column: 2 / -1; }
.setrow input[type=range] { width: 100%; accent-color: var(--blue); }
.setrow output { font-size: 12px; color: var(--muted); text-align: right; }
.keys { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; margin-top: 12px; font-size: 12px; color: var(--muted); }

/* ---------- 연결·회전 안내 ---------- */
#conn { position: fixed; left: 50%; top: calc(var(--sat) + 60px); transform: translateX(-50%); z-index: 40; display: grid; justify-items: center; gap: 2px;
  padding: 10px 18px; border-radius: 14px; background: rgba(120, 30, 30, 0.85); border: 1px solid rgba(255, 150, 150, 0.4); font-size: 13px; }
#conn span { font-size: 11.5px; color: #ffd9d9; }
#rotate { display: none; position: fixed; inset: 0; z-index: 30; background: rgba(10, 18, 32, 0.92); place-content: center; justify-items: center; gap: 8px; text-align: center; padding: 20px; }
#rotate b { font-family: var(--display); font-weight: 400; font-size: 24px; }
#rotate span { font-size: 13px; color: var(--muted); }
#rotate .phone { width: 46px; height: 76px; border: 3px solid var(--sky); border-radius: 10px; animation: turn 2s ease-in-out infinite; margin-bottom: 8px; }
@keyframes turn { 0%, 25% { transform: rotate(0); } 60%, 100% { transform: rotate(-90deg); } }

/* ================= 터치 조작 ================= */
#touch { display: none; }
.touch #touch { display: block; position: absolute; inset: 0; pointer-events: none; }
.touch .pc-only { display: none; }
html:not(.touch) .touch-only { display: none; }
#lookZone { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
/* 플로팅 조이스틱: 왼쪽 아래 영역 어디를 짚어도 그 자리에 스틱이 생김. 손을 떼면 기본 자리에 흐릿한 안내 고리 */
#stickZone { position: absolute; left: 0; bottom: 0; width: 42vw; height: 60vh; touch-action: none; pointer-events: auto; }
#stick { position: absolute; left: calc(var(--sal) + 14px); bottom: calc(var(--sab) + 18px); width: 132px; height: 132px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.05); border: 1.5px solid rgba(255, 255, 255, 0.22); pointer-events: none; transition: opacity 0.2s; opacity: 0.7; }
#stick.live { opacity: 1; background: rgba(255, 255, 255, 0.1); border-color: rgba(255, 255, 255, 0.45); transition: none; }
#stick i { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px; border-radius: 50%; background: rgba(227, 236, 249, 0.35); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); }
#stick.live i { background: rgba(227, 236, 249, 0.6); }
/* 오른쪽 엄지: 큰 발사(오른쪽 아래) 둘레에 점프·대시, 위에 작은 버튼 4개 */
.tpad { position: absolute; right: var(--sar); bottom: var(--sab); width: 236px; height: 236px; pointer-events: none; }
.tpad button, .ttop button, .fire2, #tcustom > button { appearance: none; position: absolute; width: 58px; height: 58px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, 0.3); background: var(--hud);
  font-size: 12px; font-weight: 700; touch-action: none; color: var(--text); display: grid; place-items: center; pointer-events: auto; -webkit-tap-highlight-color: transparent;
  text-shadow: var(--shadow); padding: 0; }
.tpad button.down, .ttop button.down, .fire2.down, #tcustom > button.down { background: rgba(255, 255, 255, 0.3); transform: scale(0.94); }
.tpad button.on, #tcustom > button.on { background: rgba(255, 210, 122, 0.4); border-color: var(--hot-2); }
.tpad button.sm { width: 46px; height: 46px; font-size: 11px; }
/* 작은 버튼은 보이는 크기보다 누르는 범위를 넓게 (휴대폰 가로에서 줄어도 44px 이상) */
.tpad button.sm::before { content: ''; position: absolute; inset: -6px; border-radius: 50%; }
.tpad .fire { right: 0; bottom: 0; width: 100px; height: 100px; }
.tpad .fire, #tcustom > .fire { border: 0; font-family: var(--display); font-size: 19px; font-weight: 400;
  background: radial-gradient(circle, rgba(255, 110, 60, 0.85) 57%, transparent 59%), conic-gradient(var(--hot-2) var(--p, 360deg), rgba(255, 255, 255, 0.18) 0);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45); }
.tpad .fire.down, #tcustom > .fire.down { background: radial-gradient(circle, rgba(255, 140, 90, 0.95) 57%, transparent 59%), conic-gradient(var(--hot-2) var(--p, 360deg), rgba(255, 255, 255, 0.18) 0); }
#tJump { right: 112px; bottom: 0; }
#tDash { right: 104px; bottom: 66px; }
#tAim { right: 62px; bottom: 112px; }
#tReload { right: 4px; bottom: 112px; }
#tGren { right: 120px; bottom: 136px; }
#tMelee { right: 170px; bottom: 96px; }
#tSwap { right: 176px; bottom: 154px; }
.fire2 { left: calc(var(--sal) + 6px); bottom: calc(var(--sab) + 190px); width: 54px; height: 54px; font-size: 11px; }
.fire2, #tcustom > .fire2 {
  background: radial-gradient(circle, rgba(255, 110, 60, 0.75) 60%, transparent 62%); border: 0; }
.ttop { position: absolute; top: calc(var(--sat) + 22px); left: var(--sal); display: flex; gap: 8px; }
.ttop button { position: static; width: 40px; height: 40px; }
.ttop svg, #tcustom svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; }
.touch #netinfo { top: calc(var(--sat) + 2px); left: calc(var(--sal) + 100px); }
.touch #vitals { left: 50%; transform: translateX(-50%); bottom: var(--sab); width: min(240px, 30vw); }
.touch #vitals .hprow b { font-size: 22px; min-width: 34px; }
.touch #ammo { right: calc(var(--sar) + 248px); bottom: var(--sab); }
.touch #ammo b { font-size: 30px; }
.touch #feed { top: calc(var(--sat) + 46px); }

/* ================= 기기별 레이아웃 ================= */
/* 터치 태블릿(아이패드): 버튼을 조금 크게 */
@media (min-width: 761px) and (min-height: 521px) {
  .touch #stick { width: 150px; height: 150px; }
  .touch #stick i { width: 64px; height: 64px; margin: -32px; }
  .touch .tpad { transform: scale(1.12); transform-origin: right bottom; }
  .touch #ammo { right: calc(var(--sar) + 276px); }
}
/* 휴대폰 (세로·가로 공통) */
@media (max-width: 760px), (max-height: 520px) {
  .card { padding: 16px 16px; }
  .code-row .code { font-size: 32px; }
  .act-row { grid-template-columns: 1fr 1fr; width: min(440px, 100%); gap: 10px; }
  .act-row .play { grid-column: 1 / -1; order: -1; }
  .act-row > .act-side, .act-row > .act-side.mode { justify-self: stretch; min-width: 0; height: 50px; }
  #topbar .side { min-width: 64px; padding: 2px 8px; }
  #topbar .side b { font-size: 20px; }
  #topbar .side .nm { display: none; }
  #topbar.ffa .side .nm { display: inline; font-size: 10px; max-width: 64px; }
  #topbar .mid b { font-size: 16px; }
  #feed { width: min(260px, 40vw); }
  .kf { font-size: 11px; padding: 3px 8px; }
  .kf .v { font-size: 10px; }
  #banner { font-size: 22px; } #banner.giant { font-size: 28px; }
  #respawn b.num { font-size: 48px; }
  #board { max-height: 84vh; padding: 10px 12px; }
  table.score { font-size: 12px; }
  .setrow { grid-template-columns: 82px 1fr 40px; padding: 7px 0; }
}
/* 휴대폰 가로 (낮은 화면): 버튼 조금 작게 */
@media (max-height: 520px) {
  .tpad { transform: scale(0.86); transform-origin: right bottom; }
  #stickZone { width: 40vw; height: 72vh; }
  #stick { width: 116px; height: 116px; }
  #stick i { width: 50px; height: 50px; margin: -25px; }
  .fire2 { bottom: calc(var(--sab) + 140px); }
  /* 체력은 조이스틱 오른쪽, 탄약은 그 옆: 가운데 두면 좁은 화면에서 탄약 숫자와 겹친다 */
  .touch #vitals { left: calc(var(--sal) + 148px); transform: none; width: min(190px, 26vw); }
  .touch #ammo { right: auto; left: calc(var(--sal) + 160px + min(190px, 26vw)); text-align: left; }
  .touch #ammo b { font-size: 24px; }
  .touch #vitals .chips { margin-top: 3px; }
  #scope .handle { width: 24px; }
  #respawn { top: 30%; }
  #respawn b.num { font-size: 40px; }
  /* 로비: 왼쪽 티노, 오른쪽 행동 */
  #lobby.at-title { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); grid-template-areas: "top top" "me act"; }
  #lobby.at-title .acts { align-content: center; }
  .mytino { gap: 6px; }
  .wline > span { display: none; }
  .preview-wrap { min-height: 120px; }
  .nameplate input { font-size: 17px; padding: 5px 0; }
  .wchip { padding: 6px 11px; font-size: 13px; }
  .btn.play { font-size: 26px; padding: 10px 28px; }
  .side { gap: 8px; padding: 12px 14px; }
  .lb-top { min-height: 36px; }
  .code-row .code { font-size: 26px; letter-spacing: 4px; }
  .code-row .btn { padding: 7px 12px; font-size: 13px; }
  .tlist { min-height: 0; padding: 6px 8px; }
  .tlist h4 { font-size: 14px; margin-bottom: 2px; }
  .prow { font-size: 12.5px; padding: 1px 0; }
  .btn.start { font-size: 20px; padding: 9px 18px; }
  .closet { top: var(--sat); max-height: calc(100% - var(--sat) - var(--sab)); }
}
/* 휴대폰 세로: 한 줄로 쌓고 스크롤 */
@media (orientation: portrait) and (max-width: 760px) {
  #lobby.at-room { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto auto; grid-template-areas: "top" "me" "side"; }
  #lobby.at-room .preview-wrap { flex: 0 0 200px; }
  #lobby.at-room .side { max-height: none; overflow: visible; }
  .closet { left: var(--sal); right: var(--sar); top: auto; bottom: var(--sab); width: auto; max-height: 56vh; }
  #lobby.at-room .closet { position: fixed; }
  #lobby.at-room.dressing #scrRoom { display: grid; }
}
/* 휴대폰 세로: 플레이 중엔 가로로 돌리라는 안내 */
@media (orientation: portrait) and (max-width: 760px) {
  .touch.playing #rotate { display: grid; }
}
@media (prefers-reduced-motion: reduce) {
  #boot .egg, #rotate .phone, #lowhp.beat { animation: none; }
}

/* ---------- 모바일 버튼 배치 (touch-layout.js) ---------- */
#tcustom { position: absolute; inset: 0; pointer-events: none; }
.touch #touch button { opacity: var(--touch-alpha, 1); }
.tl-editing #touch { z-index: 30; }
.tl-editing #touch button { opacity: 1; }
.tl-editing #tcustom > button { outline: 2px dashed rgba(255, 255, 255, 0.55); outline-offset: 3px; cursor: move; }
.tl-editing #tcustom > button.tl-hidden { opacity: 0.3; }
.tl-editing #tcustom > button.tl-sel { outline: 3px solid var(--hot-2); }
.tl-editing #lookZone, .tl-editing #stickZone { pointer-events: none; }
#tlBar { position: fixed; z-index: 40; left: 0; right: 0; margin: 0 auto; width: fit-content; top: calc(var(--sat) + 6px); max-width: calc(100vw - 16px);
  padding: 6px 8px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 12px; }
/* 편집 중엔 위쪽 점수판을 숨겨 도구막대와 겹치지 않게 */
.tl-editing #topbar, .tl-editing #feed { visibility: hidden; }
#tlBar .tl-sel-name { min-width: 64px; font-weight: 700; text-align: center; }
#tlBar .tl-grp { display: flex; gap: 2px; }
#tlBar .tlb { appearance: none; height: 32px; min-width: 32px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); font: inherit; font-weight: 700; touch-action: manipulation; }
#tlBar .tlb:disabled { opacity: 0.35; }
#tlBar .tlb.primary { background: var(--blue); border-color: #2c74c4; color: #fff; }
#tlBar .tl-alpha { display: flex; align-items: center; gap: 4px; }
#tlBar .tl-alpha input { width: 70px; }

/* ---------- PC 키 설정 (keybinds.js) ---------- */
#keysPanel .kb-list { display: grid; gap: 3px; margin-top: 4px; }
#keysPanel .kb-row { display: grid; grid-template-columns: 1fr 96px 96px; gap: 6px; align-items: center; font-size: 13px; }
#keysPanel .kb-slot { appearance: none; height: 30px; border-radius: 8px; border: 1px solid rgba(255, 255, 255, 0.18); background: rgba(255, 255, 255, 0.07);
  color: var(--text); font: inherit; font-size: 12px; cursor: pointer; }
#keysPanel .kb-slot:hover { background: rgba(255, 255, 255, 0.14); }
#keysPanel .kb-slot.wait { border-color: var(--hot-2); background: rgba(255, 210, 122, 0.22); }
#keysPanel .kb-hint { margin: 8px 0 0; font-size: 12px; }

/* ---------- 메뉴: 위에 계속하기, 바로 아래 큰 바로가기 버튼, 그 밑에 설정 ---------- */
.menu-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.menu-head h2 { margin: 0; flex: 1; }
.btn.sm { padding: 6px 12px; font-size: 13px; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; margin-bottom: 6px; }
.qbtn { appearance: none; display: flex; align-items: center; justify-content: center; gap: 8px; height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer; }
.qbtn b { font-size: 17px; font-weight: 400; opacity: 0.85; }
.qbtn:hover { background: rgba(255, 255, 255, 0.13); }
.qbtn#btnLeave { color: #ffb4a8; }

/* 경기 중 화면 위에 계속 떠 있는 판은 배경 흐림을 끔 (매 프레임 3D 화면을 다시 흐리게 해서 무거움) */
#toast, #board, #lockHint, #respawn, #tlBar, #hud .panel { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(14, 24, 42, 0.82); }
