* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #2d3331;
  font-family: "PT Sans Caption", "Trebuchet MS", "Helvetica Neue", Arial, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; cursor: crosshair; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#score { position: absolute; left: 10px; top: 10px; width: 240px; }
#bar {
  position: relative; height: 24px; border-radius: 12px; background: rgba(0,0,0,.18); overflow: hidden;
}
#barfill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: #e8454f; border-radius: 12px; transition: width .2s; }
#pct {
  position: absolute; left: 10px; top: 0; line-height: 24px; color: #fff; font-weight: 800; font-size: 14px;
  text-shadow: 0 1px 0 rgba(0,0,0,.35);
}
#bestline { margin: 6px 0 0 2px; color: #7a8f80; font-weight: 800; font-size: 13px; letter-spacing: .5px; }
#killpill {
  display: inline-block; margin: 6px 0 0 0; padding: 2px 10px 2px 8px; border-radius: 12px;
  background: #2d3331; color: #fff; font-weight: 800; font-size: 13px;
}
#killpill .skull { font-size: 14px; }

#lb { position: absolute; right: 10px; top: 10px; list-style: none; margin: 0; padding: 0; text-align: right; }
#lb li {
  display: inline-block; margin: 0 0 4px; padding: 2px 10px; border-radius: 12px;
  color: #fff; font-weight: 800; font-size: 14px; white-space: nowrap;
  text-shadow: 0 1px 0 rgba(0,0,0,.3); box-shadow: 0 2px 0 rgba(0,0,0,.18);
}
#lb li.me { outline: 2px solid #fff; }

#minimap {
  position: absolute; right: 14px; bottom: 14px; width: 150px; height: 150px; border-radius: 50%;
  background: rgba(0,0,0,.08); border: 2px solid rgba(0,0,0,.25); image-rendering: pixelated;
}
#toast {
  position: absolute; left: 50%; top: 18%; transform: translateX(-50%);
  color: #2d3331; font-weight: 800; font-size: 24px; opacity: 0; transition: opacity .25s;
}
#toast.show { opacity: 1; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; display: flex; align-items: flex-start; justify-content: center;
  background: rgba(20,28,40,.78); z-index: 10; padding-top: 8vh;
}
.center { text-align: center; width: min(92vw, 420px); }
.logo { margin: 0; font-size: 64px; font-weight: 900; color: #f4d03f; letter-spacing: -1px; line-height: 1;
  text-shadow: 0 4px 0 #7d6a12, 0 6px 10px rgba(0,0,0,.4); }
.logo span { color: #58c14b; text-shadow: 0 4px 0 #2d6b26, 0 6px 10px rgba(0,0,0,.4); }
.logo.small { font-size: 44px; margin-bottom: 14px; }
.hint { margin: 10px 0 12px; color: #8b9aa3; font-size: 14px; font-weight: 700; }
.row { display: flex; gap: 8px; }
#name {
  flex: 1; min-width: 0; font: inherit; font-size: 20px; font-weight: 700;
  padding: 8px 12px; border: 2px solid #c9c27a; border-radius: 4px; outline: none; color: #333;
  background: #fbf8dc;
}
.btn {
  font: inherit; font-size: 22px; font-weight: 900; color: #6b5a00; letter-spacing: 1px;
  background: linear-gradient(#fff07a, #f2d03a); border: 0; border-radius: 6px; padding: 8px 22px; cursor: pointer;
  box-shadow: 0 4px 0 #b89a12;
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #b89a12; }
.btn.wide { width: 100%; padding: 10px; }
#skins { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0 10px; }
.skin {
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer; border: 3px solid transparent;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.22); transition: transform .1s;
}
.skin:hover { transform: scale(1.1); }
.skin.sel { border-color: #fff; transform: scale(1.12); }
.best { color: #c9d1d6; font-size: 13px; margin: 6px 0 0; font-weight: 800; letter-spacing: .5px; }
#reason { margin: 12px 0 6px; color: #ff7b7b; font-weight: 800; font-size: 15px; }
.stats { color: #c9d1d6; font-size: 13px; font-weight: 800; letter-spacing: .5px; line-height: 1.6; }
.stats b { color: #fff; }
.link { background: none; border: 0; color: #8b9aa3; font: inherit; font-weight: 700; font-size: 13px;
  margin-top: 16px; cursor: pointer; text-decoration: underline; }

@media (max-width: 600px) {
  #score { width: 170px; }
  #lb li { font-size: 12px; }
  #minimap { width: 90px; height: 90px; }
  .logo { font-size: 48px; }
}

/* multiplayer */
.row { flex-wrap: wrap; }
.btn.online { background: linear-gradient(#8fe07a, #4fb63f); color: #1f4d16; box-shadow: 0 4px 0 #2d6b26; }
.btn.online:active { box-shadow: 0 1px 0 #2d6b26; }
.status { min-height: 18px; margin: 8px 0 0; color: #c9d1d6; font-size: 13px; font-weight: 700; }
.status.error { color: #ff7b7b; }
#mode {
  display: inline-block; margin-top: 6px; padding: 2px 10px; border-radius: 12px;
  background: rgba(0,0,0,.35); color: #fff; font-size: 11px; font-weight: 800; letter-spacing: 1px;
}

/* rooms: 방 만들기 · 방 목록 · 비밀번호 · 초대 */
.online-row { margin-top: 8px; }
.online-row .btn { flex: 1; font-size: 15px; padding: 8px 6px; }
.btn.online.alt { background: linear-gradient(#bfe9b3, #8fd07f); }
.panel h2 { margin: 0 0 14px; color: #f4d03f; font-size: 30px; font-weight: 900; letter-spacing: 1px; text-shadow: 0 3px 0 #7d6a12; }
.panel .sub { margin: -6px 0 10px; color: #c9d1d6; font-weight: 800; }
.field {
  display: block; width: 100%; margin: 0 0 10px; font: inherit; font-size: 18px; font-weight: 700;
  padding: 8px 12px; border: 2px solid #c9c27a; border-radius: 4px; outline: none; color: #333; background: #fbf8dc;
}
.field.code { flex: 1; min-width: 0; margin: 0; text-transform: uppercase; letter-spacing: 6px; text-align: center; }
.check { display: block; margin: 0 0 10px; color: #c9d1d6; font-weight: 800; font-size: 15px; cursor: pointer; text-align: left; }
#room-list { list-style: none; margin: 12px 0 0; padding: 0; max-height: 46vh; overflow-y: auto; text-align: left; }
#room-list li {
  display: flex; gap: 10px; align-items: center; margin: 0 0 6px; padding: 8px 12px; border-radius: 6px;
  background: rgba(255,255,255,.08); color: #fff; font-weight: 800; font-size: 14px; cursor: pointer;
}
#room-list li:hover { background: rgba(255,255,255,.16); }
#room-list li.full { opacity: .45; cursor: default; }
#room-list li.empty { justify-content: center; color: #8b9aa3; cursor: default; background: none; }
#room-list .rn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#room-list .rh { color: #8b9aa3; max-width: 30%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 로비: 코드·초대 링크(클릭 복사) · 플레이어 목록 · 방장 START */
.invite-box { display: flex; gap: 8px; margin: 0 0 12px; }
.inv {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 10px;
  font: inherit; color: #fff; background: rgba(255,255,255,.08); border: 2px dashed rgba(255,255,255,.25); border-radius: 6px; cursor: pointer;
}
.inv:hover { background: rgba(255,255,255,.16); }
#lobby-code { flex: 0 0 34%; }
.inv .lbl { color: #8b9aa3; font-size: 11px; font-weight: 800; letter-spacing: 1px; }
.inv b { font-size: 26px; font-weight: 900; letter-spacing: 4px; color: #f4d03f; }
.inv b.url { max-width: 100%; font-size: 12px; letter-spacing: 0; color: #8fe07a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: 31px; }
.inv .hint2 { color: #8b9aa3; font-size: 11px; font-weight: 700; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { margin: 0 0 6px; color: #8b9aa3; font-size: 12px; font-weight: 800; letter-spacing: 1px; text-align: left; }
#lobby-players { list-style: none; margin: 0 0 12px; padding: 0; max-height: 40vh; overflow-y: auto; text-align: left; }
#lobby-players li {
  display: flex; gap: 10px; align-items: center; margin: 0 0 6px; padding: 7px 12px; border-radius: 6px;
  background: rgba(255,255,255,.08); color: #fff; font-weight: 800; font-size: 15px;
}
#lobby-players li.me { outline: 2px solid rgba(255,255,255,.5); }
#lobby-players .chip { width: 18px; height: 18px; border-radius: 5px; flex: none; box-shadow: inset 0 -3px 0 rgba(0,0,0,.22); }
#lobby-players .pn { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#lobby-players .you { padding: 1px 6px; border-radius: 8px; background: #58c14b; color: #1f4d16; font-size: 11px; }
.wait { margin: 4px 0 0; color: #f4d03f; font-weight: 800; font-size: 15px; }

/* 진단 오버레이: 터치·클릭을 막지 않는다 */
#debug { position: fixed; left: 6px; bottom: 6px; margin: 0; padding: 4px 6px; z-index: 50; pointer-events: none;
  font: 10px/1.35 ui-monospace, Menlo, Consolas, monospace; color: #cfe; background: rgba(0, 0, 0, 0.55); border-radius: 4px; white-space: pre; }
#debug.hidden { display: none; }
