* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; background: #bcd6ee; font-family: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif; color: #111; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#app canvas { display: block; touch-action: none; }
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; touch-action: manipulation; -webkit-touch-callout: none; }
kbd { display: inline-block; padding: 0 5px; border: 1px solid rgba(0,0,0,.25); border-radius: 4px; font-size: .78em; font-family: inherit; background: rgba(255,255,255,.6); color: #222; }

.panel { background: rgba(255,255,255,.88); border-radius: 10px; padding: 8px 12px; box-shadow: 0 2px 10px rgba(0,0,0,.12); font-size: 14px; }

#hud { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); max-width: min(360px, 60vw); pointer-events: none; }

.server-head { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0 8px; font-size: 14px; }
.server-head span { color: #777; font-size: 12px; }
#serverList { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 40vh; overflow-y: auto; }
.server { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; align-items: center; border: 1px solid #ddd; border-radius: 8px; background: #fafafa; padding: 8px 10px; text-align: left; }
.server:hover:not(:disabled) { border-color: #cd2e3a; background: #fff5f5; }
.server:disabled { opacity: .45; cursor: not-allowed; }
.server.current { border-color: #123a6b; background: #eef3fa; }
.sv-name { font-weight: 700; font-size: 14px; }
.sv-count { font-size: 12px; color: #555; }
.sv-bar { grid-column: 1 / -1; height: 4px; background: #e6e6e6; border-radius: 2px; overflow: hidden; }
.sv-bar i { display: block; height: 100%; background: #cd2e3a; }
#lobbyMsg { min-height: 1em; margin: 8px 0; font-size: 13px; color: #cd2e3a; }
#lobbyMsg:empty { margin: 4px 0; }
#quickBtn { width: 100%; padding: 12px; font-size: 16px; font-weight: 700; border: 0; border-radius: 8px; background: #cd2e3a; color: #fff; }
#feed { list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
#feed li { display: flex; justify-content: space-between; align-items: center; gap: 8px; background: rgba(0,0,0,.55); color: #fff; padding: 5px 10px; border-radius: 8px; margin-bottom: 4px; white-space: nowrap; }
#feed li .t { overflow: hidden; text-overflow: ellipsis; }
#feed li .n { color: #ffd76a; font-variant-numeric: tabular-nums; }
#feed li.bump { animation: bump .35s ease-out; }
@keyframes bump { 0% { transform: scale(1.06); background: rgba(205,46,58,.85); } 100% { transform: scale(1); } }
#feed li.mine { box-shadow: inset 3px 0 0 #cd2e3a; }

/* 함성 게이지 */
#cheer { width: min(240px, 46vw); padding: 7px 10px 8px; border-radius: 10px; background: rgba(0,0,0,.55); color: #fff; font-size: 12px; transition: box-shadow .3s; }
.cheer-top { display: flex; justify-content: space-between; margin-bottom: 5px; }
.cheer-top b { font-variant-numeric: tabular-nums; }
.cheer-track { height: 6px; border-radius: 3px; background: rgba(255,255,255,.2); overflow: hidden; }
#cheerBar { display: block; height: 100%; width: 0; border-radius: 3px; background: linear-gradient(90deg, #0047a0, #cd2e3a); transition: width .3s; }
#cheer[data-level=calm] { opacity: .6; }
#cheer[data-level=hot] { box-shadow: 0 0 12px rgba(205,46,58,.5); }
#cheer[data-level=max] { box-shadow: 0 0 18px rgba(255,90,70,.8); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.03); } }

#ceremony { position: fixed; top: calc(60px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: rgba(18,58,107,.92); color: #fff; font-weight: 700; padding: 10px 18px; border-radius: 999px; box-shadow: 0 3px 12px rgba(0,0,0,.25); white-space: nowrap; font-size: 15px; pointer-events: none; z-index: 5; }


/* 오른쪽 위 바 (인원 · 소리 · 설정 · 내 아바타) */
#topbar { position: fixed; top: calc(12px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right)); display: flex; flex-direction: column; align-items: flex-end; gap: 8px; z-index: 6; }
#topbar .bar { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 16px; border-radius: 999px; background: rgba(22,26,30,.78); border: 1px solid rgba(255,255,255,.14); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #f2f2f2; box-shadow: 0 4px 16px rgba(0,0,0,.25); }
#topbar svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#topbar .count { display: flex; align-items: center; gap: 8px; margin-right: 8px; font-size: 16px; }
#topbar .icon { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: #f2f2f2; }
#topbar .icon:hover { background: rgba(255,255,255,.1); }
#btnSound .off-icon, #btnSound.off .on-icon { display: none; }
#btnSound.off .off-icon { display: block; }
#btnSound.off { color: #9aa0a6; }
#topbar .me { width: 40px; height: 40px; padding: 0; border-radius: 50%; overflow: hidden; border: 2px solid rgba(255,255,255,.35); background: #c9d4dd; margin-left: 4px; }
#meIcon { width: 100%; height: 100%; display: block; }
#topbar .pill { border: 1px solid rgba(255,255,255,.14); border-radius: 999px; padding: 9px 16px; background: rgba(22,26,30,.78); color: #f2f2f2; font-size: 14px; backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); box-shadow: 0 4px 16px rgba(0,0,0,.25); }
#topbar .pill.on { background: rgba(205,46,58,.9); }

#actions { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; justify-content: center; width: min(820px, calc(100vw - 32px)); }
.action { border: 0; border-radius: 999px; padding: 10px 16px; font-weight: 700; box-shadow: 0 3px 10px rgba(0,0,0,.2); background: #fff; color: #111; white-space: nowrap; }
.action.flag { background: #0047a0; color: #fff; }
.action.flag.us { background: #3c3b6e; }
.action.shout { background: #cd2e3a; color: #fff; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.action.pose { background: #fff; color: #123a6b; border: 2px solid #123a6b; }
.action.pose.active { background: #123a6b; color: #fff; }
.action:active { transform: scale(.96); }
.action.cooldown { opacity: .5; }
.in-ceremony .action.flag, .in-ceremony .action.pose { opacity: .4; pointer-events: none; }

.shout-wrap { position: relative; }
#sloganPicker { position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%); background: #fff; border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.25); padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 220px; z-index: 10; }
.pick { border: 0; background: #f4f4f4; border-radius: 8px; padding: 10px 12px; text-align: left; font-weight: 700; white-space: nowrap; }
.pick:hover { background: #ffe3e5; }
.pick kbd { margin-right: 4px; }
.touch .pick kbd { display: none; }

#joystick { position: fixed; left: calc(20px + env(safe-area-inset-left)); bottom: calc(24px + env(safe-area-inset-bottom)); width: 120px; height: 120px; border-radius: 50%; background: rgba(255,255,255,.35); border: 2px solid rgba(255,255,255,.7); touch-action: none; }
#stick { position: absolute; left: 35px; top: 35px; width: 50px; height: 50px; border-radius: 50%; background: rgba(255,255,255,.9); }

#overlay { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(20,30,50,.55); padding: 16px; }
.card { background: #fff; border-radius: 16px; padding: 24px; width: min(380px, 100%); text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.card h1 { margin: 12px 0 4px; font-size: 26px; }
.card .sub { margin: 0 0 16px; color: #555; font-size: 14px; line-height: 1.5; }
#introFlag { width: 150px; height: 100px; border: 1px solid #ddd; }
#nameInput { width: 100%; padding: 12px; font-size: 16px; border: 1px solid #ccc; border-radius: 8px; margin-bottom: 10px; -webkit-user-select: text; user-select: text; }
#enterBtn { width: 100%; padding: 12px; font-size: 16px; font-weight: 700; border: 0; border-radius: 8px; background: #cd2e3a; color: #fff; }
.help { font-size: 12px; color: #666; margin: 14px 0 0; line-height: 1.9; }

/* 모바일: 조이스틱은 왼쪽 아래, 버튼은 오른쪽 아래 2열 */
.touch #actions { left: auto; right: calc(12px + env(safe-area-inset-right)); transform: none; width: auto; max-width: calc(100vw - 170px); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.touch .action { padding: 12px 10px; font-size: 14px; min-height: 46px; }
.touch .action .long { display: none; }
.touch .shout-wrap { grid-column: 1 / -1; order: -1; }
.touch .action.shout { width: 100%; max-width: none; }
.touch #sloganPicker { left: auto; right: 0; transform: none; min-width: min(260px, calc(100vw - 32px)); }
.touch .pick { padding: 14px 12px; font-size: 15px; }

@media (max-width: 600px) {
  #topbar .bar { padding-left: 12px; }
  #topbar .icon, #topbar .me { width: 36px; height: 36px; }
  #hud { max-width: 48vw; }
  #feed { font-size: 12px; }
  #ceremony { top: calc(112px + env(safe-area-inset-top)); font-size: 13px; padding: 8px 14px; white-space: normal; text-align: center; width: max-content; max-width: calc(100vw - 32px); }
}

/* ---------- 후원 버튼 ---------- */
#topbar .pill.donate { background: rgba(156,134,80,.92); color: #fff; }
.link-btn { margin-top: 10px; border: 0; background: none; color: #9c8650; font-weight: 700; font-size: 14px; }

/* ---------- 설정 시트 (밝은 목록형, 태극 빨강·남색) ---------- */
:root { --red: #cd2e3a; --navy: #123a6b; --ink: #1b2430; --muted: #6b7684; --sheet-bg: #f3f4f6; }
#sheetBackdrop { position: fixed; inset: 0; background: rgba(10,16,28,.35); z-index: 20; }
#settingsSheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100vw); overflow-y: auto; z-index: 21; padding: 0 16px 24px; background: var(--sheet-bg); color: var(--ink); box-shadow: -8px 0 30px rgba(0,0,0,.25); border-top: 4px solid; border-image: linear-gradient(90deg, var(--red) 0 50%, var(--navy) 50% 100%) 1; }
#settingsSheet svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sheet-head { position: sticky; top: 0; z-index: 1; display: flex; justify-content: space-between; align-items: center; padding: calc(16px + env(safe-area-inset-top)) 0 10px; background: var(--sheet-bg); }
.sheet-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
#settingsSheet .round { width: 36px; height: 36px; border-radius: 50%; border: 0; background: #e3e6ea; color: var(--ink); display: grid; place-items: center; }
.group-label { margin: 16px 4px 6px; font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.group-foot { margin: 6px 4px 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.group { background: #fff; border-radius: 12px; overflow: hidden; border: 1px solid #e6e8ec; }
.group .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 13px 14px; border-top: 1px solid #eef0f3; }
.group .row:first-child { border-top: 0; }
.group .row.stack { display: block; }
.row-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.group .txt { min-width: 0; }
.group .txt b { display: block; font-size: 15px; font-weight: 700; }
.group .txt small { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
#settingsSheet.muted .row.stack { opacity: .5; }
.slider { display: flex; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); }
.slider span { width: 28px; text-align: right; font-size: 12px; font-variant-numeric: tabular-nums; }
.slider input { --p: 100%; flex: 1; height: 4px; -webkit-appearance: none; appearance: none; border-radius: 2px; background: linear-gradient(to right, var(--navy) var(--p), #dfe3e8 var(--p)); }
.slider input::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--navy); }
.slider input::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 2px solid var(--navy); }
.switch { position: relative; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #d5d9df; transition: background .2s; }
.switch span::after { content: ''; position: absolute; left: 2px; top: 2px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--red); }
.switch input:checked + span::after { transform: translateX(18px); }
.segment { display: flex; background: #eceef2; border-radius: 8px; padding: 2px; }
.segment button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
.segment button.on { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
#settingsSheet .link { border: 0; background: none; color: var(--navy); font-weight: 700; font-size: 14px; }
#settingsSheet details.help { margin-top: 16px; padding: 13px 14px; }
#settingsSheet summary { cursor: pointer; font-weight: 700; font-size: 15px; }
#settingsSheet details p { margin: 10px 0 0; font-size: 13px; color: var(--muted); line-height: 1.9; }

/* ---------- 후원 모달 ---------- */
#donateModal { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(10,14,20,.6); padding: 16px; }
.donate-card { position: relative; width: min(560px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: #fff; border-radius: 20px; padding: 24px; text-align: center; box-shadow: 0 16px 50px rgba(0,0,0,.4); }
.donate-card h2 { margin: 0 0 6px; font-size: 22px; }
.donate-card > p { margin: 0 0 16px; color: #555; font-size: 14px; }
.donate-card .round { display: grid; place-items: center; border-radius: 50%; border: 1px solid #e5e5e5;  position: absolute; top: 14px; right: 14px; width: 38px; height: 38px; background: #f2f2f2; color: #333; border-color: #e5e5e5; }
.donate-card .round svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#donateGrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
#donateGrid figure { margin: 0; padding: 10px; border: 1px solid #eee; border-radius: 14px; background: #fafafa; }
#donateGrid img { width: 100%; height: 240px; object-fit: contain; display: block; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
#donateGrid figcaption { margin-top: 8px; font-weight: 700; font-size: 14px; }
.donate-card .hint { margin: 14px 0 0; font-size: 12px; color: #777; line-height: 1.6; }
@media (max-width: 600px) {
  #cheer { width: 120px; padding: 6px 8px 7px; font-size: 11px; }
  #donateGrid { grid-template-columns: 1fr; }
  #donateGrid img { height: 220px; }
}

/* ---------- 연속 응원 ---------- */
.action.auto { background: #fff; color: #cd2e3a; border: 2px solid #cd2e3a; display: inline-flex; align-items: center; gap: 6px; }
.action.auto .dot { width: 8px; height: 8px; border-radius: 50%; background: #cd2e3a; }
.action.auto.on { background: #cd2e3a; color: #fff; }
.action.auto.on .dot { background: #fff; animation: blink 1s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .2; } }
.touch #btnAuto { grid-column: 1 / -1; justify-content: center; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips .opt { border: 1px solid #d5d9df; background: #fff; color: #6b7684; border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 700; }
.chips .opt.on { background: #123a6b; border-color: #123a6b; color: #fff; }
.group-foot.warn { color: #cd2e3a; font-weight: 700; }
