* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #0d1222; color: #fff;
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif; user-select: none; }
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; margin: 0 2px; border-radius: 5px; text-align: center;
  background: #ffffff1a; border: 1px solid #ffffff40; border-bottom-width: 3px; font-family: inherit; font-weight: 700; font-size: 0.85em; line-height: 1.4; }

/* ───── HUD ───── */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud .top { position: absolute; top: 18px; left: 24px; right: 24px; display: flex; align-items: flex-start; gap: 18px; }
#hud .side { flex: 1; display: flex; flex-direction: column; gap: 6px; }
#hud .side.right { align-items: flex-end; }
.nameRow { display: flex; align-items: baseline; gap: 10px; text-shadow: 0 2px 4px #000a; }
.name { font-size: 26px; font-weight: 900; letter-spacing: 1px; }
.ptitle { font-size: 14px; opacity: 0.8; font-weight: 600; }
.hpbar { position: relative; width: 100%; height: 26px; background: #1b1b22cc; border: 3px solid #f4f1e8;
  border-radius: 4px; overflow: hidden; box-shadow: 0 3px 10px #0008; transform: skewX(-12deg); }
.side.right .hpbar { transform: skewX(12deg) scaleX(-1); }
.hpbar .lag, .hpbar .hp { position: absolute; top: 0; bottom: 0; left: 0; width: 100%; }
.hpbar .lag { background: #fff; }
.hpbar .hp { background: linear-gradient(#ffe066, #f4a90f); transition: background 0.2s; }
.hpbar .hp.low { background: linear-gradient(#ff6b6b, #d62828); animation: blink 0.5s infinite alternate; }
@keyframes blink { to { filter: brightness(1.5); } }
.pips { display: flex; gap: 6px; }
.pips i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #f4f1e8; background: #0007; }
.pips i.on { background: radial-gradient(#fff6b0, #f4a90f); box-shadow: 0 0 8px #ffcf40; }
.timer { width: 84px; height: 72px; display: grid; place-items: center; font-size: 46px; font-weight: 900;
  background: #0d1222dd; border: 3px solid #f4f1e8; border-radius: 10px; text-shadow: 0 2px 0 #000; flex: none; }
.timer.low { color: #ff6b6b; }

#hud .bottom { position: absolute; bottom: 20px; left: 24px; right: 24px; display: flex; justify-content: space-between; }
.meterBox { display: flex; align-items: center; gap: 10px; width: 38%; }
.meterBox .mlabel { font-weight: 800; font-size: 15px; text-shadow: 0 2px 3px #000; white-space: nowrap; }
.meterBox .mval { font-weight: 900; font-size: 18px; width: 52px; text-align: center; text-shadow: 0 2px 3px #000; }
.meter { position: relative; flex: 1; height: 16px; background: #0009; border: 2px solid #f4f1e8aa; border-radius: 3px; overflow: hidden; }
.meterBox.right .meter { transform: scaleX(-1); }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #3a7bd5, #00d2ff); }
.meter .tick { position: absolute; left: 25%; top: 0; bottom: 0; width: 2px; background: #fff8; }
.meterBox.ready .fill { background: linear-gradient(90deg, #ff9a00, #ffe14d); box-shadow: 0 0 12px #ffcf40; }
.meterBox.ready .mval { color: #ffe14d; }

.combo, .callout { position: absolute; font-weight: 900; text-shadow: 0 3px 0 #000, 0 0 12px #000; opacity: 0; }
.combo { top: 130px; font-size: 40px; color: #ffe14d; font-style: italic; }
.callout { top: 190px; font-size: 30px; color: #fff; }
.combo.left, .callout.left { left: 40px; }
.combo.right, .callout.right { right: 40px; }
.combo.show { animation: pop 1.1s ease-out forwards; }
.callout.show { animation: pop 1.3s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; transform: scale(1.8); } 12% { opacity: 1; transform: scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-14px); } }

/* ───── 아나운스 ───── */
#announce { position: fixed; left: 0; right: 0; top: 34%; text-align: center; pointer-events: none; opacity: 0; }
#announce.show { opacity: 1; }
#announce .big { font-size: 110px; font-weight: 900; font-style: italic; letter-spacing: 4px; color: #fff;
  text-shadow: 0 6px 0 #b8860b, 0 10px 30px #000c; }
#announce .small { margin-top: 6px; font-size: 28px; font-weight: 800; text-shadow: 0 3px 6px #000; }
#announce.show .big { animation: slam 0.45s cubic-bezier(.2,1.6,.4,1); }
#announce.fight .big { color: #ffe14d; text-shadow: 0 6px 0 #c0392b, 0 10px 30px #000c; }
#announce.ko .big { color: #ff4d5a; text-shadow: 0 6px 0 #5c0b10, 0 10px 30px #000c; font-size: 140px; }
#announce.win .big { color: #ffe14d; text-shadow: 0 6px 0 #8a5a00, 0 10px 30px #000c; }
@keyframes slam { from { transform: scale(2.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ───── 타이틀 ───── */
#title { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 34px;
  background: radial-gradient(ellipse at center, #0d122255 0%, #0d1222ee 75%); }
.logo { text-align: center; }
.logo .kicker { font-size: 18px; letter-spacing: 10px; font-weight: 800; color: #ffcf40; }
.logo h1 { font-size: 104px; font-weight: 900; font-style: italic; line-height: 1.05; letter-spacing: 2px;
  background: linear-gradient(#fff 30%, #ffcf40); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 #8a1c22) drop-shadow(0 14px 24px #000); }
.logo .sub { font-size: 20px; opacity: 0.85; margin-top: 6px; font-weight: 600; }
.menu { display: flex; flex-direction: column; gap: 12px; }
.menu .item { width: 300px; padding: 14px 0; font-family: inherit; font-weight: 800; font-size: 24px; color: #fff; cursor: pointer;
  background: #ffffff10; border: 2px solid #ffffff30; border-radius: 10px; transition: all 0.12s; }
.menu .item b { color: #ffcf40; margin-right: 6px; }
.menu .item.sel, .menu .item:hover { background: #ffcf40; color: #1b1b22; border-color: #fff; transform: scale(1.05); }
.menu .item.sel b, .menu .item:hover b { color: #8a1c22; }
.controls { display: flex; gap: 22px; }
.ctl { background: #0008; border: 1px solid #ffffff25; border-radius: 10px; padding: 14px 18px; font-size: 15px; line-height: 2; }
.ctl h3 { font-size: 17px; margin-bottom: 2px; }
.ctl.p1 h3 { color: #ff6b75; } .ctl.p2 h3 { color: #6ba4ff; }
.ctl small { opacity: 0.6; }
.hint { font-size: 14px; opacity: 0.6; }

/* ───── 궁극기 연출 ───── */
.meterBox.ult .fill { background: linear-gradient(90deg, #ff4d5a, #ffe14d, #5ce07a, #4d8dff); animation: blink 0.35s infinite alternate; }
.meterBox.ult .mval { color: #fff; text-shadow: 0 0 10px #ffcf40, 0 2px 3px #000; }

#flash { position: fixed; inset: 0; pointer-events: none; background: #fff; opacity: 0; }
#flash.on { animation: flash 0.16s ease-out; }
@keyframes flash { from { opacity: 0.45; } to { opacity: 0; } }

#cineDim { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.2s;
  background: radial-gradient(ellipse at center, transparent 30%, #000d 100%); }
#cineDim.on { opacity: 1; }
#letterbox i { position: fixed; left: 0; right: 0; height: 0; background: #000; transition: height 0.25s ease-out; }
#letterbox i:first-child { top: 0; }
#letterbox i:last-child { bottom: 0; }
#letterbox.on i { height: 11vh; }
#hud .top, #hud .bottom { transition: opacity 0.2s; }
body.cine #hud .top, body.cine #hud .bottom { opacity: 0; }

#cutin { position: fixed; left: 0; right: 0; top: 34%; height: 150px; pointer-events: none; opacity: 0; }
#cutin .band { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; padding: 0 12%;
  background: linear-gradient(90deg, transparent, var(--c) 14%, var(--c) 86%, transparent); transform: skewY(-4deg); overflow: hidden; }
#cutin .band::after { content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(-60deg, #ffffff18 0 10px, transparent 10px 34px); }
#cutin.right .band { align-items: flex-end; }
#cutin .who { font-size: 24px; font-weight: 800; opacity: 0.9; text-shadow: 0 2px 3px #0008; }
#cutin .what { font-size: 78px; font-weight: 900; font-style: italic; letter-spacing: 2px; text-shadow: 0 5px 0 #0007; }
#cutin.show.left { animation: cutinL 0.85s ease-out forwards; }
#cutin.show.right { animation: cutinR 0.85s ease-out forwards; }
@keyframes cutinL { 0% { opacity: 0; transform: translateX(-60%); } 15% { opacity: 1; transform: translateX(0); }
  80% { opacity: 1; transform: translateX(3%); } 100% { opacity: 0; transform: translateX(40%); } }
@keyframes cutinR { 0% { opacity: 0; transform: translateX(60%); } 15% { opacity: 1; transform: translateX(0); }
  80% { opacity: 1; transform: translateX(-3%); } 100% { opacity: 0; transform: translateX(-40%); } }

#cineText { position: fixed; left: 0; right: 0; top: 16%; text-align: center; pointer-events: none; opacity: 0;
  font-size: 84px; font-weight: 900; font-style: italic; color: #ffe14d; text-shadow: 0 5px 0 #8a1c22, 0 0 20px #000; }
#cineText.show { animation: pop 0.7s ease-out forwards; }

#stamp { position: fixed; left: 50%; top: 26%; padding: 4px 40px; pointer-events: none; opacity: 0;
  font-size: 130px; font-weight: 900; color: #e01e2b; border: 12px double #e01e2b; border-radius: 20px;
  background: #fff2; transform: translateX(-50%) rotate(-12deg); white-space: nowrap; }
#stamp.show { animation: stampIn 1.9s ease-out forwards; }
@keyframes stampIn {
  0% { opacity: 0; transform: translateX(-50%) rotate(-12deg) scale(3); }
  9% { opacity: 1; transform: translateX(-50%) rotate(-12deg) scale(0.9); }
  15% { transform: translateX(-50%) rotate(-12deg) scale(1); }
  85% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) rotate(-12deg) scale(1); } }

/* ───── 등장 소개 카드 ───── */
#introCard { position: fixed; bottom: 15vh; padding: 14px 34px 16px; pointer-events: none; opacity: 0;
  background: linear-gradient(90deg, var(--c), color-mix(in srgb, var(--c) 60%, transparent)); border-left: 8px solid #fff; }
#introCard.right { right: 0; border-left: none; border-right: 8px solid #fff; text-align: right;
  background: linear-gradient(270deg, var(--c), color-mix(in srgb, var(--c) 60%, transparent)); }
#introCard.left { left: 0; }
#introCard .nm { font-size: 58px; font-weight: 900; font-style: italic; line-height: 1.05; text-shadow: 0 4px 0 #0006; }
#introCard .tt { font-size: 18px; font-weight: 700; opacity: 0.9; letter-spacing: 2px; }
#introCard .ln { font-size: 24px; font-weight: 800; margin-top: 6px; color: #fff8d0; }
#introCard.show.left { animation: cardL 1.15s ease-out forwards; }
#introCard.show.right { animation: cardR 1.15s ease-out forwards; }
@keyframes cardL { 0% { opacity: 0; transform: translateX(-100%); } 30% { opacity: 1; transform: translateX(0); } 100% { opacity: 1; transform: translateX(2%); } }
@keyframes cardR { 0% { opacity: 0; transform: translateX(100%); } 30% { opacity: 1; transform: translateX(0); } 100% { opacity: 1; transform: translateX(-2%); } }

/* ───── 캐릭터 선택 ───── */
#select { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 28px 16px 26px; background: linear-gradient(#0d1222cc, transparent 24%, transparent 55%, #0d1222ee); pointer-events: none; }
#select h2 { font-size: 44px; font-weight: 900; font-style: italic; color: #ffcf40; text-shadow: 0 4px 0 #8a1c22, 0 8px 20px #000; }
#select .cards { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; pointer-events: auto; margin-top: auto; margin-bottom: 12px; }
#select .card { position: relative; width: 210px; padding: 16px 16px 14px; cursor: pointer; background: #141b30e6;
  border: 3px solid #ffffff22; border-top: 6px solid var(--c); border-radius: 12px; transition: transform 0.12s, border-color 0.12s; }
#select .card .nm { font-size: 30px; font-weight: 900; }
#select .card .tt { font-size: 13px; opacity: 0.7; margin-bottom: 8px; }
#select .card .sk { font-size: 13px; font-weight: 700; opacity: 0.85; }
#select .card.p1, #select .card.p2 { transform: translateY(-8px); }
#select .card.p1 { border-color: #ff5a64; }
#select .card.p2 { border-color: #4d8dff; }
#select .card.p1.p2 { border-color: #c77dff; }
#select .card.ok { box-shadow: 0 0 0 3px #ffcf40, 0 0 30px #ffcf4088; }
#select .badges { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; }
#select .badges b { display: none; padding: 1px 7px; border-radius: 6px; font-size: 12px; }
#select .card.p1 .b1 { display: block; background: #ff5a64; }
#select .card.p2 .b2 { display: block; background: #4d8dff; }
#select .selHint { font-size: 14px; opacity: 0.85; text-align: center; }
#onlinePanel .charRow { display: flex; gap: 8px; }
#btnConnect.pulse { animation: pulse 0.9s ease-in-out infinite alternate; }
@keyframes pulse { to { box-shadow: 0 0 0 4px #ffcf40aa, 0 0 18px #ffcf40; } }
#onlinePanel .charRow button { padding: 10px 4px; font-size: 16px; background: #ffffff14; color: #fff; border: 2px solid #ffffff30; }
#onlinePanel .charRow button.on { background: var(--c); border-color: #fff; }

/* ───── 온라인 ───── */
#onlinePanel { position: fixed; inset: 0; display: grid; place-items: center; background: #0d1222cc; }
#onlinePanel .box { width: min(440px, calc(100vw - 32px)); padding: 28px 30px; text-align: center; background: #141b30; border: 2px solid #ffffff30; border-radius: 16px;
  box-shadow: 0 20px 60px #000a; display: flex; flex-direction: column; gap: 14px; }
#onlinePanel h2 { font-size: 34px; font-weight: 900; color: #ffcf40; }
#onlinePanel .sub { opacity: 0.7; font-size: 14px; margin-top: -8px; }
#onlinePanel .row { display: flex; gap: 10px; }
#onlinePanel button { flex: 1; padding: 12px; font-family: inherit; font-size: 18px; font-weight: 800; color: #1b1b22; cursor: pointer;
  background: #ffcf40; border: none; border-radius: 10px; }
#onlinePanel button:hover { filter: brightness(1.1); }
#onlinePanel button.ghost { background: transparent; color: #fff; border: 1px solid #ffffff40; flex: none; }
#onlinePanel .label { font-size: 13px; opacity: 0.7; letter-spacing: 2px; }
#onlinePanel .code { display: flex; gap: 10px; align-items: center; justify-content: center; }
#roomCode { font-size: 48px; font-weight: 900; letter-spacing: 8px; font-family: Consolas, monospace; color: #fff; }
#btnCopy { flex: none !important; padding: 8px 14px !important; font-size: 14px !important; }
#hostBox { display: flex; flex-direction: column; gap: 8px; }
#btnLink { width: 100%; background: #4d8dff !important; color: #fff !important; }
#onlinePanel .linkHint { font-size: 12px; opacity: 0.6; }
#joinBox { display: flex; gap: 10px; }
#joinBox:not(.hidden) { display: flex; }
#joinCode { flex: 1; padding: 12px; font-size: 26px; font-weight: 900; letter-spacing: 6px; text-align: center; text-transform: uppercase;
  font-family: Consolas, monospace; background: #0d1222; color: #fff; border: 2px solid #ffffff40; border-radius: 10px; outline: none; }
#joinCode:focus { border-color: #ffcf40; }
#netStatus { min-height: 22px; font-size: 15px; opacity: 0.9; }
#netStatus.err { color: #ff8a8a; }
#netInfo { position: absolute; top: 96px; left: 0; right: 0; text-align: center; font-size: 13px; font-weight: 700; opacity: 0.75; text-shadow: 0 1px 3px #000; }
#netWait { position: fixed; left: 50%; bottom: 70px; transform: translateX(-50%); padding: 8px 18px; border-radius: 20px; background: #000a;
  font-weight: 700; pointer-events: none; opacity: 0; transition: opacity 0.2s; }
#netWait.show { opacity: 1; }

#pause { position: fixed; inset: 0; display: grid; place-items: center; background: #0009; }
#pause .box { text-align: center; } #pause h2 { font-size: 64px; font-weight: 900; margin-bottom: 10px; }
