/* ⛔ iOS 는 «16px 미만» 입력창에 포커스하면 화면을 «확대»하고 «되돌리지 않는다».
   user-scalable=no·maximum-scale 은 iOS 10 이후 무시된다 — 폰트로만 막힌다.
   ⇒ 채팅을 한 번 누르면 화면이 확대된 채 «고정»됐다 (2026-09-08 사용자 신고).
   ⚠️ 16px 아래로 내리지 마라. 작게 보이고 싶으면 «칸»을 줄여라. */
:root {
  --bg-0: #05060f;
  --bg-1: #0a0e1c;
  --bg-2: #111830;
  --panel: rgba(18, 24, 48, .82);
  --ink: #eaf0ff;
  --muted: #8b97c4;
  --cyan: #00e5ff;
  --magenta: #ff2e97;
  --yellow: #ffd400;
  --green: #33e06a;
  --purple: #b14dff;
  --line: rgba(120, 150, 255, .18);
  --glow-cyan: 0 0 14px rgba(0, 229, 255, .55);
  --glow-mag: 0 0 14px rgba(255, 46, 151, .55);
  --radius: 16px;
  --font-disp: 'Orbitron', 'Pretendard Variable', sans-serif;
  --font-pix: 'Press Start 2P', 'Orbitron', monospace;
  --font-body: 'Pretendard Variable', Pretendard, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background: radial-gradient(1200px 800px at 50% -10%, #1a2352 0%, var(--bg-1) 55%, var(--bg-0) 100%);
  overflow: hidden;
}

/* 배경: 네온 그리드 + 스캔라인 */
.grid-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .35;
  background-image:
    linear-gradient(rgba(80, 120, 255, .09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 120, 255, .09) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 85%);
  -webkit-mask-image: radial-gradient(circle at 50% 30%, #000 0%, transparent 85%);
}
.scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 998; opacity: .06;
  background: repeating-linear-gradient(0deg, #fff 0 1px, transparent 1px 3px);
}

.screen { position: fixed; inset: 0; display: none; overflow-y: auto; z-index: 1; }
.screen.active { display: block; }

/* ===== 버튼 ===== */
.btn {
  font-family: var(--font-disp); font-weight: 700; font-size: 16px; color: var(--ink);
  border: 2px solid rgba(140, 170, 255, .5); border-radius: 12px; padding: 12px 20px; cursor: pointer;
  background: rgba(30, 40, 78, .8); transition: transform .08s, box-shadow .12s, background .12s;
  user-select: none; white-space: nowrap; letter-spacing: .3px;
}
.btn:hover { box-shadow: var(--glow-cyan); border-color: var(--cyan); }
.btn:active { transform: translateY(2px); }
.btn.big { font-size: 20px; padding: 15px 26px; width: 100%; }
.btn.small { font-size: 13px; padding: 8px 14px; }
.btn-primary { background: linear-gradient(135deg, var(--magenta), #c8006f); border-color: var(--magenta); color: #fff; }
.btn-primary:hover { box-shadow: var(--glow-mag); }
.btn-accent { background: linear-gradient(135deg, var(--cyan), #0099cc); border-color: var(--cyan); color: #04121a; }
.btn-ghost { background: rgba(30, 40, 78, .6); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.5); box-shadow: none; }

/* ===== 카드 ===== */
.card {
  background: var(--panel); border: 2px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .5), inset 0 0 0 1px rgba(255, 255, 255, .03);
  padding: 22px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

/* ===== 홈 ===== */
.home-wrap { min-height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 22px; padding: 32px 20px; }
.title-block { text-align: center; }
.tetro-rain { font-size: 40px; letter-spacing: 6px; animation: floaty 2.4s ease-in-out infinite; }
@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }
.game-title {
  font-family: var(--font-disp); font-weight: 900; font-size: clamp(34px, 9vw, 68px); line-height: 1;
  margin-top: 10px; color: #fff; letter-spacing: 1px;
  text-shadow: 0 0 18px rgba(0, 229, 255, .6), 0 0 40px rgba(255, 46, 151, .35);
}
.game-title span { color: var(--cyan); text-shadow: 0 0 20px rgba(0, 229, 255, .8); }
.subtitle { margin-top: 14px; font-size: 16px; color: var(--ink); background: rgba(0, 229, 255, .08);
  display: inline-block; padding: 7px 16px; border-radius: 999px; border: 1px solid rgba(0, 229, 255, .3); }
.subtitle b { color: var(--cyan); }

.home-card { width: min(440px, 100%); display: flex; flex-direction: column; gap: 16px; }
.fld { display: flex; flex-direction: column; gap: 6px; font-family: var(--font-disp); font-size: 14px; color: var(--muted); letter-spacing: .5px; }
.fld input, .join-row input {
  font-family: var(--font-body); font-size: 18px; font-weight: 600;
  border: 2px solid var(--line); border-radius: 12px; padding: 13px 16px; background: rgba(6, 10, 24, .8); color: var(--ink);
  outline: none; width: 100%;
}
.fld input:focus, .join-row input:focus { border-color: var(--cyan); box-shadow: var(--glow-cyan); }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.divider::before, .divider::after { content:''; flex:1; height: 1px; background: var(--line); }
.join-row { display: flex; gap: 10px; }
.join-row input { text-align: center; letter-spacing: 8px; font-family: var(--font-disp); font-weight: 800; text-transform: uppercase; }
.err-msg { color: var(--magenta); font-weight: 700; min-height: 18px; font-size: 14px; text-align: center; }
.foot { color: var(--muted); font-size: 12px; text-align: center; }

.join-room-badge { font-family: var(--font-disp); font-weight: 700; font-size: 18px; text-align: center;
  background: rgba(0, 229, 255, .08); color: var(--ink); border: 1px solid rgba(0,229,255,.3);
  border-radius: 12px; padding: 12px; margin-bottom: 4px; }
.join-room-badge b { color: var(--cyan); letter-spacing: 4px; }
#btn-back-home { align-self: center; }

/* ===== 로비 ===== */
.lobby-wrap { max-width: 1000px; margin: 0 auto; padding: 18px 16px 40px; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 16px; }
.room-badge { display: flex; align-items: center; gap: 10px; background: rgba(6,10,24,.85); color: #fff;
  border: 2px solid var(--cyan); border-radius: 12px; padding: 8px 18px; box-shadow: var(--glow-cyan); }
.rb-label { font-size: 12px; color: var(--muted); }
.rb-code { font-family: var(--font-disp); font-size: 26px; font-weight: 800; letter-spacing: 5px; color: var(--cyan); }
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.member-count { font-family: var(--font-disp); background: rgba(30,40,78,.7); border: 1px solid var(--line);
  padding: 7px 12px; border-radius: 999px; font-size: 13px; }

.lobby-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 820px) { .lobby-grid { grid-template-columns: 1fr; } }

.panel-title { font-family: var(--font-disp); font-weight: 700; font-size: 17px; display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 14px; letter-spacing: .5px; }
.panel-title b { color: var(--cyan); }
.host-tag { font-size: 11px; background: var(--magenta); color: #fff; padding: 3px 10px; border-radius: 999px; display: none; }
body.is-host .host-tag { display: inline-block; }

.participant-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 46vh; overflow-y: auto; }
.p-chip { display: flex; align-items: center; gap: 8px; background: rgba(6,10,24,.7); border: 2px solid var(--line);
  border-radius: 999px; padding: 6px 10px 6px 10px; animation: pop .2s ease; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.p-chip .dot { width: 12px; height: 12px; border-radius: 3px; flex: none; box-shadow: 0 0 6px currentColor; }
.p-chip .p-emoji { font-size: 17px; }
.p-chip .p-name { font-weight: 700; font-size: 14px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-chip .x { border: none; background: none; cursor: pointer; font-size: 15px; color: var(--magenta); padding: 0 2px; font-weight: 800; }
.p-chip.me { border-color: var(--cyan); box-shadow: 0 0 0 1px rgba(0,229,255,.3); }
.p-chip.ready { background: rgba(51,224,106,.14); border-color: rgba(51,224,106,.5); }
.tag-host { font-size: 10px; background: var(--magenta); color: #fff; padding: 1px 6px; border-radius: 999px; }
.tag-me { font-size: 10px; background: var(--cyan); color: #04121a; padding: 1px 6px; border-radius: 999px; font-weight: 700; }
.ready-badge { font-size: 13px; }

/* 설정 */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.setting:last-of-type { border-bottom: none; }
.s-label { font-family: var(--font-disp); font-weight: 600; font-size: 14px; }
.seg { display: flex; background: rgba(6,10,24,.7); border: 2px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg-wrap { flex-wrap: wrap; }
.seg-btn { font-family: var(--font-disp); font-weight: 600; border: none; background: none; color: var(--ink);
  padding: 8px 13px; cursor: pointer; font-size: 13px; }
.seg-btn.active { background: var(--cyan); color: #04121a; }
.stepper { display: flex; align-items: center; gap: 10px; font-family: var(--font-disp); font-weight: 800; font-size: 18px; }
.st-btn { width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--line); background: rgba(6,10,24,.7);
  color: var(--ink); font-size: 18px; font-weight: 800; cursor: pointer; line-height: 1; }
.st-btn:hover { border-color: var(--cyan); }
.st-suffix { font-size: 13px; color: var(--muted); }
body:not(.is-host) .seg-btn, body:not(.is-host) .st-btn,
body:not(.is-host) .switch input { pointer-events: none; opacity: .85; }

.switch { position: relative; width: 52px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: rgba(6,10,24,.9); border: 2px solid var(--line); border-radius: 999px; transition: .2s; }
.slider::before { content:''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: var(--muted); border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: rgba(0,229,255,.2); border-color: var(--cyan); }
.switch input:checked + .slider::before { transform: translateX(24px); background: var(--cyan); box-shadow: var(--glow-cyan); }

.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.hint.center { text-align: center; }
.setting-desc { font-size: 12px; color: var(--muted); line-height: 1.55; margin-top: 12px;
  background: rgba(0,229,255,.05); border: 1px solid rgba(0,229,255,.18); border-radius: 10px; padding: 9px 12px; }
.setting-desc b { color: var(--cyan); }
.start-btn, .ready-btn { margin-top: 16px; }
.ready-btn.is-ready { background: linear-gradient(135deg, var(--green), #22a94f); border-color: var(--green); color: #04140a; }
.notice { background: rgba(255,46,151,.08); border: 1px solid rgba(255,46,151,.3); border-radius: 10px;
  padding: 10px 12px; font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.settings-body.locked { opacity: .7; pointer-events: none; }
.ready-count { font-size: 12px; background: rgba(6,10,24,.8); color: var(--ink); padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); }

/* 조작법 안내 */
.controls-guide { margin-top: 16px; }
.cg-sub { font-size: 12px; color: var(--muted); font-weight: 400; }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 18px; }
.key-item { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.key-item b { font-weight: 600; color: var(--muted); }
.keycap { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 26px;
  padding: 0 7px; background: rgba(6,10,24,.9); border: 1px solid var(--line); border-bottom-width: 3px;
  border-radius: 7px; font-family: var(--font-disp); font-weight: 700; font-size: 12px; color: var(--cyan);
  box-shadow: 0 1px 0 rgba(0,0,0,.4); }

/* ===== 게임 ===== */
#screen-game { background: transparent; }
.game-topbar { position: fixed; top: 0; left: 0; right: 0; height: 46px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px; gap: 12px;
  background: rgba(6,10,24,.9); border-bottom: 1px solid var(--line); font-family: var(--font-disp); font-weight: 700; }
.game-status { font-size: 14px; color: var(--muted); }
.alive-count { font-size: 15px; color: var(--green); text-shadow: 0 0 8px rgba(51,224,106,.5); }
.game-timer { font-family: var(--font-disp); font-weight: 800; font-size: 17px; color: var(--yellow); min-width: 60px; text-align: right; }

.arena {
  position: fixed; top: 46px; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px;
  padding: 10px; overflow: hidden;
}
.opp-col { display: flex; flex-wrap: wrap; gap: 10px; align-content: center; justify-content: center;
  align-items: center; overflow-y: auto; max-height: 100%; }
.opp-left { justify-content: flex-end; }
.opp-right { justify-content: flex-start; }

.opp { position: relative; background: rgba(6,10,24,.6); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.opp-canvas { display: block; border-radius: 4px; background: #0c1020; box-shadow: inset 0 0 12px rgba(0,0,0,.5); }
.opp-label { display: flex; align-items: center; gap: 4px; max-width: 100%; }
.opp-av { font-size: 13px; }
.opp-name { font-size: 12px; font-weight: 600; color: var(--ink); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opp-stat { font-family: var(--font-disp); font-size: 10px; color: var(--muted); letter-spacing: .3px; }
.opp-badge { position: absolute; top: 45%; left: 50%; transform: translate(-50%,-50%); font-size: 28px; }
.opp.dead { opacity: .55; filter: grayscale(.6); }
.opp.dead .opp-name { color: var(--magenta); }

/* 중앙 내 보드 */
.my-area { display: flex; align-items: flex-start; justify-content: center; gap: 10px; }
.side { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.side-right { align-items: flex-start; }
.mini-box { background: rgba(6,10,24,.7); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mini-label { font-family: var(--font-disp); font-weight: 700; font-size: 11px; color: var(--muted); letter-spacing: 1px; }
.mini-box canvas { display: block; }
.stat { background: rgba(6,10,24,.7); border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px;
  min-width: 78px; text-align: center; }
.stat span { display: block; font-family: var(--font-disp); font-size: 10px; color: var(--muted); letter-spacing: 1px; }
.stat b { font-family: var(--font-disp); font-weight: 800; font-size: 18px; color: var(--cyan); }

.board-wrap { position: relative; }
#my-canvas { display: block; border: 2px solid rgba(0,229,255,.4); border-radius: 6px;
  box-shadow: 0 0 30px rgba(0,229,255,.25), inset 0 0 40px rgba(0,0,0,.6); background: #0a0e1c; }

/* 라인 클리어 텍스트 이펙트 */
.line-flash { position: absolute; top: 34%; left: 50%; transform: translate(-50%,-50%);
  text-align: center; pointer-events: none; opacity: 0; z-index: 8; }
.line-flash.show { animation: flashpop .8s ease; }
.line-flash .fl-main { display: block; font-family: var(--font-disp); font-weight: 900; font-size: 34px;
  color: #fff; text-shadow: 0 0 16px var(--cyan), 0 0 30px var(--cyan); letter-spacing: 2px; }
.line-flash .fl-4 { color: var(--yellow); text-shadow: 0 0 18px var(--yellow), 0 0 40px var(--magenta); font-size: 42px; }
.line-flash .fl-combo { display: block; margin-top: 4px; font-family: var(--font-disp); font-weight: 800;
  font-size: 18px; color: var(--magenta); text-shadow: 0 0 12px var(--magenta); }
@keyframes flashpop {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(.4); }
  25% { opacity: 1; transform: translate(-50%,-50%) scale(1.15); }
  70% { opacity: 1; transform: translate(-50%,-60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%,-90%) scale(.9); }
}

.countdown { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center;
  background: rgba(6,10,24,.55); border-radius: 6px; }
.countdown span { font-family: var(--font-disp); font-weight: 900; font-size: 22vh; color: #fff;
  text-shadow: 0 0 30px var(--cyan), 0 0 60px var(--magenta); animation: cd .95s ease-in-out; }
@keyframes cd { 0% { transform: scale(2.2); opacity: 0; } 40% { transform: scale(1); opacity: 1; } 100% { transform: scale(.4); opacity: 0; } }

@media (max-width: 900px) {
  .arena { grid-template-columns: 1fr; grid-template-rows: auto auto auto; overflow-y: auto; }
  /* ⛔ .side / .mini-box 만 가로로 눕히면 «부족하다» — .my-area 자체가 여전히 가로라
        [사이드 + 보드 + 사이드] 가 옆으로 늘어서 화면 밖으로 나간다.
        실측(2026-09-03, 440px): 132 + 200 + 258 = 610px → 오른쪽이 잘렸다 (사용자 신고).
     ⇒ 모바일에선 .my-area 를 «세로»로 쌓는다. */
  .my-area { order: -1; flex-direction: column; align-items: center; width: 100%; }
  .side { flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; width: 100%; }
  .side-right { align-items: center; }
  .mini-box { flex-direction: row; }
  /* ⭐ 상대 보드 — 위쪽 «가로 스트립» 한 줄. 넘치면 가로 스크롤 (2026-09-04)
     ⛔ 세로로 쌓으면 내 보드에 밀려 화면 밖으로 나가 «아예 안 보였다» */
  .opp-col { flex-direction: row; flex-wrap: nowrap; max-height: none; overflow-x: auto; overflow-y: hidden; gap: 6px;
    justify-content: flex-start; padding: 0 8px 2px; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; }                      /* 스크롤바는 숨긴다 — 좁은 띠에 막대가 뜨면 지저분하다 */
  .opp-col::-webkit-scrollbar { display: none; }
  .opp-right { display: none; }                 /* 좁은 화면은 스트립 하나로 몬다 */
  .opp { flex: 0 0 auto; padding: 4px; }
  .opp-label { font-size: 10px; }
  .opp-stat { font-size: 9px; }
  /* ⛔ 자동 배치에 맡기면 .my-area 가 1행을 선점해 스트립이 «아래»로 밀린다 (2026-09-04 실측). 행을 «명시»한다 */
  /* ⛔⛔ 그런데 `auto` 로 두면 «내 보드(1fr)»가 남은 높이를 다 가져가며 스트립을 짓눌러
        실측 «2px» 까지 찌부러졌다 — overflow-y:hidden 이라 그 안이 통째로 안 보인다.
        「상대 화면 위아래가 잘려 보인다」의 정체다 (2026-09-08 사용자 신고).
     ⭐ 스트립 높이를 «못 박는다». 1fr 이 아무리 커도 이 줄은 안 줄어든다. */
  .arena { grid-template-rows: 132px 1fr; }
  .opp-col { height: 132px; min-height: 132px; align-items: center; }
  .opp-left { grid-row: 1; grid-column: 1; }
  .my-area  { grid-row: 2; grid-column: 1; }
  .board-wrap { max-width: 100%; }
}

/* 터치 컨트롤 */
.touch-controls { position: fixed; bottom: 0; left: 0; right: 0; z-index: 15; display: none;
  justify-content: space-between; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, rgba(6,10,24,.95), transparent); pointer-events: none; }
.tc-left, .tc-right { display: flex; gap: 8px; pointer-events: auto; }
.tc-btn { width: 58px; height: 58px; border-radius: 14px; border: 2px solid var(--line);
  background: rgba(30,40,78,.9); color: var(--ink); font-family: var(--font-disp); font-weight: 700;
  font-size: 18px; cursor: pointer; user-select: none; touch-action: manipulation; }
.tc-btn:active { background: var(--cyan); color: #04121a; }
.tc-btn.tc-drop { background: rgba(255,46,151,.9); border-color: var(--magenta); font-size: 13px; }
body.touch #touch-controls { display: flex; }

/* 결과 */
.result-modal { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center;
  background: rgba(3,5,14,.75); padding: 20px; backdrop-filter: blur(4px); }
.result-card { position: relative; background: var(--panel); border: 2px solid var(--cyan); border-radius: 20px;
  box-shadow: 0 0 50px rgba(0,229,255,.3); padding: 26px 24px; width: min(460px, 100%); text-align: center;
  overflow: hidden; animation: pop .3s ease; max-height: 92vh; display: flex; flex-direction: column; }
.trophy { font-size: 60px; animation: floaty 1.6s ease-in-out infinite; }
.result-title { font-family: var(--font-disp); font-weight: 900; font-size: 30px; margin: 4px 0 16px;
  color: var(--cyan); text-shadow: 0 0 16px rgba(0,229,255,.6); }
.winner-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; max-height: 34vh; overflow-y: auto; }
.winner-item { display: flex; align-items: center; gap: 12px; background: rgba(255,212,0,.1); border: 2px solid var(--yellow);
  border-radius: 14px; padding: 12px 16px; box-shadow: 0 0 20px rgba(255,212,0,.2); }
.winner-item .medal { font-size: 24px; }
.winner-item .w-emoji { font-size: 22px; }
.winner-item .w-name { font-family: var(--font-disp); font-weight: 800; font-size: 20px; }
.winner-item .w-rank { margin-left: auto; font-family: var(--font-disp); color: var(--muted); font-size: 14px; }
.penalty-head { display: block; font-family: var(--font-disp); font-weight: 800; font-size: 15px; color: var(--magenta);
  text-shadow: 0 0 10px rgba(255,46,151,.5); margin-bottom: 2px; }
.penalty-item { background: rgba(255,46,151,.12); border-color: var(--magenta); box-shadow: 0 0 20px rgba(255,46,151,.25); }
.penalty-item.is-me { background: rgba(255,46,151,.25); border-width: 3px; }
.rank-row.pen { background: rgba(255,46,151,.08); border-radius: 8px; }
.rank-row.pen .rank-no { color: var(--magenta); }
.rank-row.me { outline: 1px solid var(--cyan); border-radius: 8px; }
.result-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.full-rank { margin-top: 12px; text-align: left; border-top: 1px solid var(--line); padding-top: 12px;
  max-height: 30vh; overflow-y: auto; }
.fr-title { font-family: var(--font-disp); font-weight: 700; font-size: 13px; color: var(--muted); }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; font-size: 14px; }
.rank-row .rank-no { font-family: var(--font-disp); font-weight: 700; width: 32px; color: var(--cyan); }
.rank-dot { width: 11px; height: 11px; border-radius: 3px; box-shadow: 0 0 5px currentColor; }
.rank-row .r-score { margin-left: auto; color: var(--muted); font-family: var(--font-disp); font-size: 12px; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 31; overflow: hidden; }
.confetti i { position: absolute; width: 9px; height: 13px; top: -20px; opacity: .9; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(120vh) rotate(720deg); } }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: rgba(6,10,24,.95); color: #fff; border: 1px solid var(--cyan); padding: 12px 20px; border-radius: 12px;
  font-weight: 700; box-shadow: var(--glow-cyan); animation: pop .2s ease; }

/* ===== 채팅 ===== */
.chat { position: fixed; left: 12px; bottom: 12px; z-index: 25; width: 270px; max-width: calc(100vw - 24px);
  background: rgba(10,14,28,.82); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5); overflow: hidden; font-family: var(--font-body);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.chat-head { background: rgba(6,10,24,.9); color: var(--cyan); font-family: var(--font-disp); font-weight: 700;
  padding: 7px 12px; cursor: grab; font-size: 13px; display: flex; justify-content: space-between; align-items: center;
  touch-action: none; user-select: none; }
.chat-head:active { cursor: grabbing; }
.chat.collapsed .chat-body { display: none; }
.chat-log { height: 140px; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.chat-msg { line-height: 1.35; word-break: break-word; }
.chat-msg b { color: var(--cyan); }
.chat-form { display: flex; gap: 6px; padding: 8px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: rgba(6,10,24,.8);
  color: var(--ink); padding: 7px 10px; font-size: 16px; font-family: var(--font-body); outline: none; }
.chat-form input:focus { border-color: var(--cyan); }
.chat-send { border: 1px solid var(--cyan); background: rgba(0,229,255,.15); color: var(--cyan); border-radius: 9px;
  padding: 0 12px; font-family: var(--font-disp); font-weight: 700; cursor: pointer; font-size: 12px; }

/* ============================================================
   진입점 선택 (같이하기 / 혼자하기) + 스코어보드   2026-09-03
   ============================================================ */
.pick-wrap { width: min(560px, 100%); display: flex; flex-direction: column; gap: 18px; }

.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) {
  .pick-grid { grid-template-columns: 1fr; gap: 10px; }
  /* 모바일: 세로로 길쭉해지면 스코어보드가 화면 밖으로 밀린다 → 가로로 눕힌다 */
  .pick-card { display: grid; grid-template-columns: auto 1fr; grid-template-areas: 'i t' 'i s' 'g g'; gap: 2px 14px; padding: 16px; }
  .pick-ico { grid-area: i; align-self: center; }
  .pick-card b { grid-area: t; font-size: 18px; }
  .pick-sub { grid-area: s; }
  .pick-go { grid-area: g; margin-top: 12px; }
}

.pick-card {
  --a: var(--cyan);
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 22px 20px 18px; text-align: left; cursor: pointer;
  font-family: inherit; color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line); border-radius: var(--radius);
  transition: transform .16s cubic-bezier(.2,.7,.3,1), border-color .16s, box-shadow .16s;
}
.pick-card:hover { transform: translateY(-4px); border-color: var(--a); box-shadow: 0 0 26px color-mix(in srgb, var(--a) 38%, transparent); }
.pick-card:active { transform: translateY(0); }
.pick-solo { --a: var(--magenta); }

.pick-ico { color: var(--a); display: block; }
.pick-card b { font-family: var(--font-disp); font-weight: 900; font-size: 21px; letter-spacing: .5px; }
.pick-sub { font-size: 13px; color: var(--muted); line-height: 1.7; }
.pick-go {
  margin-top: 4px; font-size: 12.5px; font-weight: 700; color: var(--a);
  border-top: 1px solid var(--line); padding-top: 10px; width: 100%;
}

/* 스코어보드 */
.board { padding: 18px 18px 14px; }
.board-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.board-head b { font-family: var(--font-disp); font-weight: 900; font-size: 15px; letter-spacing: .5px; color: var(--ink); }
.board-tabs { margin-left: auto; display: flex; gap: 4px; }
.board-tabs .bt {
  font-family: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer;
  color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px;
  transition: color .14s, border-color .14s, background .14s;
}
.board-tabs .bt:hover { color: var(--ink); }
.board-tabs .bt.active { color: #04121a; background: var(--cyan); border-color: var(--cyan); }

.board-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.board-row {
  display: grid; grid-template-columns: 30px 1fr auto; grid-template-areas: 'r n s' 'r m s';
  align-items: center; gap: 0 10px; padding: 8px 6px;
  border-bottom: 1px solid var(--line);
}
.board-row:last-child { border-bottom: 0; }
.b-rank { grid-area: r; font-family: var(--font-disp); font-weight: 900; font-size: 13px; color: var(--muted); text-align: center; }
.board-row.top .b-rank { font-size: 16px; }
.b-name { grid-area: n; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-meta { grid-area: m; font-size: 11px; color: var(--muted); }
.b-score { grid-area: s; font-family: var(--font-disp); font-weight: 900; font-size: 16px; color: var(--cyan); }
.board-row.top .b-score { color: var(--magenta); text-shadow: 0 0 12px rgba(255, 46, 151, .5); }
.board-empty { padding: 18px 6px; text-align: center; font-size: 13px; color: var(--muted); }
.board-note { margin-top: 10px; font-size: 11px; color: var(--muted); text-align: center; }

/* 게임 상단바 — 솔로 최고기록 */
.solo-best { font-family: var(--font-disp); font-weight: 700; font-size: 13px; color: var(--muted); }

/* ⛔ 솔로에선 상대 미니보드 자리를 «비운다» — 안 그러면 빈 칸이 화면을 먹는다 */
#screen-game.solo .opp-col { display: none; }
/* ⚠️ display:none 은 그리드 «자동 배치»에서도 빠진다 → 남은 .my-area 가 «1번 칸»으로 가서
   보드가 왼쪽으로 쏠린다. 그래서 솔로에선 한 칸짜리 그리드로 바꿔 가운데 정렬한다. */
#screen-game.solo .arena { grid-template-columns: 1fr; justify-items: center; }

/* 솔로 결과 */
.solo-result { margin: 4px 0 14px; }
.sr-score { display: flex; align-items: baseline; justify-content: center; gap: 6px; }
.sr-score b {
  font-family: var(--font-disp); font-weight: 900; font-size: clamp(38px, 11vw, 58px); line-height: 1;
  color: var(--cyan); text-shadow: 0 0 24px rgba(0, 229, 255, .55);
}
.sr-score span { font-size: 15px; color: var(--muted); }
.sr-meta { display: flex; justify-content: center; gap: 16px; margin-top: 10px; font-size: 13px; color: var(--muted); }
.sr-meta i { font-style: normal; font-weight: 800; color: var(--ink); }
.sr-rank { margin: 14px 0 10px; text-align: center; font-size: 13.5px; color: var(--muted); }
.sr-rank.hit { color: var(--magenta); font-weight: 800; }
.sr-board { border-top: 1px solid var(--line); padding-top: 6px; max-height: 44vh; overflow-y: auto; }


/* ⛔ 모바일에서 채팅이 «화면 절반»을 덮는다 — 440px 폭에서 280px = 64%.
   실측(2026-09-03): 로비 설정 패널이 통째로 가려져 조작이 안 됐다.
   ⭐ 폭을 줄이는 것만으론 부족해서 «터치 기기는 접힌 채로» 시작한다(app.js). */
@media (max-width: 620px) {
  .chat { width: 158px; }
  .chat-log { height: 88px; }
  .chat-head { padding: 6px 9px; font-size: 12px; }
  .chat-form input { padding: 6px 9px; font-size: 16px; }
  .chat-send { padding: 0 9px; font-size: 12px; }
}


/* ── 뽑기 방식 (2026-09-03) */
.mode-note { margin: -2px 0 10px; font-size: 12.5px; line-height: 1.5; opacity: .9; }
.howto-list .hint { display:block; margin-top:3px; font-size:11.5px; opacity:.62; }
.howto-list i { font-style:normal; opacity:.72; }

/* ===== 모바일: 버튼 홀드 시 선택·복사 팝업 방지 + 채팅 스크롤 허용 (2026-09-04) ===== */
html, body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
button, canvas, .ct-btn, .seg-btn, .switch, .stepper, .tab, [role="button"] {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
canvas, .ct-btn { touch-action: none; }               /* 게임 조작은 스크롤 제스처를 먹지 않게 */
input, textarea { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.chat-log, .chat-body, #chat-log { touch-action: pan-y; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ⭐ 안내(howto) 블록 — 6게임 통일 스타일 (2026-09-04). 원형 번호 + 힌트 줄 */
.howto { margin-top: 14px; border: 1px solid rgba(70,217,245,.25); border-radius: 12px; padding: 14px 16px; background: rgba(0,0,0,.28); }
.howto-title { font-family: var(--font-disp, inherit); font-size: 16px; margin-bottom: 10px; color: #46d9f5; letter-spacing: .3px; }
.howto-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: step; }
.howto-list li { position: relative; padding-left: 30px; font-size: 13.5px; line-height: 1.55; color: var(--muted, #b8c2d6); }
.howto-list li::before { counter-increment: step; content: counter(step); position: absolute; left: 0; top: 1px;
  width: 21px; height: 21px; border-radius: 50%; background: #46d9f5; color: #06141c; font-weight: 800; font-size: 12px;
  display: flex; align-items: center; justify-content: center; }
.howto-list b { color: #fff; }
.howto-list .hint { display: block; margin-top: 3px; font-size: 12px; opacity: .65; }
.howto-list i { font-style: normal; opacity: .75; }
.howto-list .tag { display: inline-block; padding: 1px 6px; border-radius: 999px; font-size: 10.5px; background: rgba(70,217,245,.18); color: #46d9f5; vertical-align: 1px; }

.opp-more { flex:0 0 auto; align-self:center; padding:6px 10px; border-radius:8px; font-size:12px; font-weight:700;
  color: var(--muted); background: rgba(6,10,24,.6); border:1px solid var(--line); }

/* ⭐ 연습시간 배너 (2026-09-04) */
.practice-bar { position: fixed; top: 52px; left: 50%; transform: translateX(-50%); z-index: 30;
  display: flex; align-items: center; gap: 9px; padding: 7px 14px; border-radius: 999px;
  background: rgba(255,255,255,.96); border: 2px solid #2bb673; box-shadow: 0 4px 14px rgba(0,0,0,.2);
  font-size: 13px; color: #2c3a33; max-width: calc(100vw - 20px); }
.pb-tag { font-family: var(--font-disp); font-weight: 800; color: #1f9c58; }
.pb-msg { opacity: .7; }
.pb-left { font-variant-numeric: tabular-nums; font-weight: 800; color: #111; }
.pb-skip { padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 800;
  background: #2bb673; border: none; color: #fff; }
.pb-vote { font-size: 11.5px; opacity: .65; }
@media (max-width: 620px) {
  .practice-bar { font-size: 12px; gap: 7px; padding: 6px 11px; white-space: nowrap; top: 42px; }
  .pb-msg { display: none; }            /* 좁은 화면은 «연습 · 남은시간 · 건너뛰기» 만 */
  .pb-vote { display: none; }
  .pb-skip { padding: 4px 10px; }
}

/* ⭐ 게임 중 채팅 — 반투명(캐릭터 안 가림). 손대면 또렷해진다 */
.chat.ingame { opacity: .48; transition: opacity .18s; }
.chat.ingame:hover, .chat.ingame:focus-within { opacity: 1; }

/* ⭐ 연습 종료 카운트다운 — 화면 «정중앙»에 크게 (2026-09-04) */
.practice-cd { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 6px; pointer-events: none; }
.pc-tx { font-family: var(--font-disp, inherit); font-size: clamp(15px, 4.5vw, 22px); font-weight: 800;
  color: #fff; text-shadow: 0 2px 10px rgba(0,0,0,.75), 0 0 22px rgba(0,0,0,.6); letter-spacing: .5px; }
.pc-num { font-family: var(--font-disp, inherit); font-size: clamp(76px, 26vw, 168px); font-weight: 900; line-height: 1;
  color: #ffd35f; text-shadow: 0 6px 26px rgba(0,0,0,.8), 0 0 40px rgba(255,180,60,.45);
  animation: pc-pop .42s cubic-bezier(.2,1.5,.4,1); }
@keyframes pc-pop { 0% { transform: scale(.55); opacity: 0; } 55% { transform: scale(1.14); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }

/* ⛔ 내용이 없는 안내 상자는 «빈 칸»으로 보인다 — 테두리·배경만 남아 설정 사이에 구멍이 생겼다 (2026-09-04) */
.notice:empty, .mode-note:empty { display: none; }

/* ── 봇 추가 바 (참가자 목록 위) — ⭐ 톤 중립: currentColor·rgba 만 써서 6게임 어디서나 뜬다 */
.botbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 10px; }
.botbar select, .botbar button { font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 8px;
  border: 1px solid rgba(128,128,128,.45); background: rgba(128,128,128,.14); color: inherit; cursor: pointer; }
.botbar button { font-weight: 700; }
.botbar button:hover:not(:disabled) { background: rgba(128,128,128,.28); }
.botbar button:disabled, .botbar select:disabled { opacity: .4; cursor: default; }
.bot-note { font-size: 11px; opacity: .55; }
@media (max-width: 640px) { .bot-note { display: none; } }
/* ⭐ 혼자일 때 — 봇 추가 버튼이 «먼저 눈에 띈다». 권하는 것이지 막는 것이 아니다 */
.botbar.suggest button { border-color: rgba(255,190,90,.75); background: rgba(255,190,90,.2); animation: botpulse 1.9s ease-in-out infinite; }
.botbar.suggest .bot-note { opacity: .8; }
@keyframes botpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,190,90,.42); } 50% { box-shadow: 0 0 0 7px rgba(255,190,90,0); } }

/* ⭐ 접힌 채팅은 «머리만큼만» 좁게 (2026-09-06 사용자: 「닫힌 상태는 가로 폭을 줄여서」).
   ⛔ 예전엔 접혀도 폭이 158~270px 그대로라, 접어도 화면을 그만큼 먹었다. */
.chat.collapsed { width: auto; min-width: 0; }
.chat.collapsed .chat-head { white-space: nowrap; }

/* ⭐ 모달 스크롤 (2026-09-06 사용자: 「모바일에서 팝업에 스크롤이 없어서 동작이 안 된다」)
   ⛔ 30명 순위가 화면을 넘치는데 .result-card 가 overflow:hidden 이라 «버튼을 못 눌러»
      게임 진행이 막혔다. 카드를 자르지 말고 «덮개»를 스크롤시킨다.
   ⭐ margin:auto + align-items:flex-start — 짧으면 가운데, 길면 위부터 스크롤. */
.result-modal { align-items: flex-start; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.result-card { margin: auto; max-height: none; overflow: visible; }
.full-rank, .winner-list { max-height: none; overflow: visible; }

/* ⭐ 상대 미니보드 — 「누구 화면인지 표시가 안 된다」 (2026-09-06).
   모바일 가로 스트립에서 이름·점수가 눌려 안 보였다. 자리를 «확보»한다. */
.opp { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.opp-label { min-height: 14px; flex: 0 0 auto; }
.opp-stat { min-height: 12px; }
@media (max-width: 620px) {
  .opp-name { max-width: 68px; }
  .opp-label { min-height: 13px; }
  .opp-stat { min-height: 11px; font-size: 9.5px; }
}

/* ⭐ 로비 헤더 — 8게임 «한 줄»로 통일 (2026-09-06 사용자 지시, 기준: 다리 건너기)
     방 코드 · 인원 · 링크 복사 · 나가기
   ⛔ 좁은 화면에서 로고까지 넣으면 줄이 접혀 헤더가 세 줄이 된다 (무궁화가 그랬다).
      로고는 폰에서 «뺀다» — 게임 화면 상단바에 이미 마크가 있다. */
@media (max-width: 620px) {
  .lobby-head { flex-wrap: nowrap; gap: 8px; }
  .lobby-head .tp-lobby-brand { display: none; }
  .room-badge { padding: 6px 12px; gap: 6px; flex: 0 1 auto; min-width: 0; }
  .rb-label { font-size: 10px; }
  .rb-code { font-size: 21px; letter-spacing: .10em; }
  .head-actions { gap: 6px; flex-wrap: nowrap; margin-left: auto; }
  .head-actions .btn { padding: 6px 9px; font-size: 12px; white-space: nowrap; }
  .member-count { padding: 4px 8px; font-size: 12px; white-space: nowrap; }
}

/* ⭐ 상대 미니보드 — 이름표를 «캔버스 위에» 얹는다 (2026-09-06)
   ⛔ 흐름 안에 두면 좁은 화면의 가로 스트립에서 «잘려» 「누구 화면인지 표시가 안 된다」가 됐다.
      위에 얹으면 스트립 높이가 어떻든 «항상» 보인다. */
.opp { position: relative; }
.opp-label { position: absolute; top: 2px; left: 2px; right: 2px; z-index: 2;
  background: rgba(6,10,24,.82); border-radius: 6px; padding: 1px 4px; justify-content: center; }
.opp-stat { position: absolute; bottom: 2px; left: 2px; right: 2px; z-index: 2; text-align: center;
  background: rgba(6,10,24,.72); border-radius: 6px; padding: 0 4px; }

@media (max-width: 620px) {
  /* ⛔ 이름이 길면 타일 폭이 늘어나 «5번째만 크게» 보였다 (실측 106 vs 104). 폭을 고정한다 */
  .opp { flex: 0 0 96px !important; width: 96px; }
  /* ⛔ width:100% + height:auto 로 두면 «높이»가 따라 늘어난다 — 캔버스가 10×20 비율이라
        96px 폭이면 «192px 높이»가 되고, 가로 스트립은 overflow-y:hidden 이라 위아래가 «잘린다»
        (2026-09-08 사용자 신고: 「상대 화면 위아래가 잘려 보인다」).
     ⭐ 좁은 화면에서는 «높이»를 기준으로 맞춘다 — 폭은 비율대로 따라온다(58px). */
  .opp canvas { width: auto; height: 104px; max-width: 100%; margin: 0 auto; }   /* 132px 스트립에 이름표까지 들어간다 */
  .opp-col { align-items: center; }
  .opp-name { max-width: 56px; }
  /* ⛔ 채팅 버튼이 조작키(58px + 여백)와 겹쳤다 — 위로 올린다 */
  body.touch .chat.ingame, body.touch .chat { bottom: 152px; }
}
