:root {
  --gold: #ffd25a; --gold2: #ff9a1a; --red: #ff2a3a; --blue: #3d7cff; --ink: #07080c;
  --p1: #3d9bff; --p2: #ff4a5a; --panel: rgba(8, 10, 18, 0.82);
  --kr: 'Black Han Sans', 'Malgun Gothic', sans-serif;
  --en: 'Russo One', 'Black Han Sans', sans-serif;
  --body: 'Noto Sans KR', 'Malgun Gothic', sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; color: #fff; font-family: var(--body); user-select: none; }
#game { position: fixed; inset: 0; }
#game canvas { display: block; width: 100%; height: 100%; }
#vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%); z-index: 1; transition: background .3s; }
#vignette.rage { background: radial-gradient(ellipse at center, transparent 30%, rgba(120,0,0,0.75) 100%); }
#flash { position: fixed; inset: 0; pointer-events: none; background: #fff; opacity: 0; z-index: 50; }

.screen { position: fixed; inset: 0; display: none; z-index: 10; }
.screen.show { display: block; }
.hint { position: absolute; bottom: 22px; left: 0; right: 0; text-align: center; font-size: 14px; color: #c8cfe0; text-shadow: 0 2px 4px #000; letter-spacing: .5px; }

/* ---------------- 로딩 ---------------- */
#loading { background: #05060a; display: none; }
#loading.show { display: flex; align-items: center; justify-content: center; }
.load-text { font-family: var(--kr); font-size: 40px; color: var(--gold); animation: blink 1s infinite; }

/* ---------------- 로고 ---------------- */
.logo { position: absolute; left: 50%; top: 16%; transform: translateX(-50%); text-align: center; }
.logo-top { font-family: var(--kr); font-size: clamp(28px, 4vw, 54px); letter-spacing: 18px; color: #fff; text-shadow: 0 0 18px rgba(80,140,255,.9), 0 4px 0 #0a2a6a; margin-bottom: -10px; }
.logo-main { font-family: var(--kr); font-size: clamp(110px, 17vw, 240px); line-height: 1; letter-spacing: 6px;
  background: linear-gradient(180deg, #fff6d0 0%, #ffd25a 35%, #c46a10 52%, #ffe28a 60%, #8a3a00 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 #2a0a00) drop-shadow(0 0 30px rgba(255,120,0,.55));
  animation: logoIn .9s cubic-bezier(.2,1.6,.4,1) both; }
.logo-sub { font-family: var(--kr); font-size: clamp(16px, 1.8vw, 24px); letter-spacing: 4px; color: #ffefe0; margin-top: 4px; text-shadow: 0 2px 6px #000; }
.logo.small { top: 6%; }
.logo.small .logo-main { font-size: clamp(70px, 9vw, 120px); }
.logo.small .logo-top { font-size: clamp(20px, 2.4vw, 32px); letter-spacing: 12px; }
@keyframes logoIn { 0% { transform: scale(2.4); opacity: 0; filter: blur(12px); } 100% { transform: scale(1); opacity: 1; } }
.press { position: absolute; bottom: 20%; width: 100%; text-align: center; font-family: var(--kr); font-size: 30px; animation: blink 1.2s infinite; text-shadow: 0 0 12px #f80, 0 3px 0 #000; }
.press span { display: block; font-family: var(--en); font-size: 16px; letter-spacing: 6px; color: var(--gold); margin-top: 6px; }
.title-foot { position: absolute; bottom: 16px; width: 100%; text-align: center; font-size: 12px; color: #889; }
@keyframes blink { 50% { opacity: .35; } }
#title { background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(0,0,0,.05) 40%, rgba(0,0,0,.6)); }

/* ---------------- 메뉴 ---------------- */
#menu { background: linear-gradient(90deg, rgba(0,0,0,.75), rgba(0,0,0,.2) 60%, rgba(0,0,0,0)); }
#menu .logo { left: 8%; transform: none; text-align: left; }
.menu-list { list-style: none; }
#menu .menu-list { position: absolute; left: 8%; top: 36%; }
.menu-list li { font-family: var(--kr); font-size: 28px; padding: 6px 26px 6px 18px; margin: 4px 0; color: #a8b0c4; cursor: pointer;
  clip-path: polygon(0 0, 100% 0, calc(100% - 16px) 100%, 0 100%); transition: all .12s; min-width: 330px; position: relative; }
.menu-list li small { font-family: var(--body); font-size: 14px; color: #8890a4; margin-left: 10px; font-weight: 700; }
.menu-list li.on { background: linear-gradient(90deg, var(--red), #b0101c 70%, transparent); color: #fff; padding-left: 30px; text-shadow: 0 2px 0 #500; }
.menu-list li.on small { color: #ffd0d0; }
.menu-list li.on::before { content: '▶'; position: absolute; left: 8px; font-size: 16px; top: 14px; color: var(--gold); }
.menu-desc { position: absolute; left: 8%; bottom: 56px; max-width: 520px; font-size: 16px; color: #dfe4f0; text-shadow: 0 2px 4px #000; min-height: 24px; }

/* ---------------- 모달 ---------------- */
.modal { background: rgba(0,0,0,.65); z-index: 30; }
.modal.show { display: flex; align-items: center; justify-content: center; }
.modal-box { background: linear-gradient(160deg, #141a2c, #0a0c14); border: 2px solid #3a4460; border-top: 4px solid var(--red); padding: 28px 36px 64px; min-width: 420px; position: relative; box-shadow: 0 20px 60px #000; max-height: 92vh; overflow: hidden; }
.modal-box.wide { width: min(1100px, 94vw); }
.modal-title { font-family: var(--kr); font-size: 32px; margin-bottom: 18px; color: var(--gold); }
#pause .menu-list li { font-size: 26px; min-width: 360px; }

/* 커맨드 리스트 */
.ml-legend { font-size: 14px; color: #aab; margin-bottom: 10px; }
.ml-body { max-height: 62vh; overflow-y: auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 24px; }
.ml-row { display: grid; grid-template-columns: 1fr auto 44px; align-items: center; gap: 10px; padding: 6px 10px; background: rgba(255,255,255,.04); border-left: 3px solid #445; }
.ml-row.special { border-left-color: var(--gold); background: rgba(255,210,90,.07); }
.ml-row.rage { border-left-color: var(--red); background: rgba(255,40,60,.12); }
.ml-name { font-weight: 700; font-size: 15px; }
.ml-name small { display: block; font-weight: 400; font-size: 12px; color: #9aa3b8; }
.ml-cmd { font-family: var(--en); font-size: 17px; white-space: nowrap; }
.ml-hit { font-size: 12px; text-align: center; padding: 2px 0; border-radius: 3px; font-weight: 700; }
.ml-hit.h { background: #8a6a10; } .ml-hit.m { background: #1d5ab0; } .ml-hit.l { background: #a02030; } .ml-hit.t { background: #6a2a9a; }
.btn { display: inline-block; width: 22px; height: 22px; line-height: 22px; border-radius: 50%; text-align: center; font-size: 13px; color: #000; font-family: var(--en); margin: 0 1px; vertical-align: middle; box-shadow: inset 0 -2px 0 rgba(0,0,0,.3); }
.btn.b1 { background: #ffd04a; } .btn.b2 { background: #ff8a3a; } .btn.b3 { background: #5ad0ff; } .btn.b4 { background: #8affa0; }
.arr { color: var(--gold); font-weight: 900; }

/* 조작법 */
.howto-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 30px; font-size: 15px; }
.ht-col h3 { font-family: var(--kr); font-weight: 400; color: var(--gold); margin: 6px 0 8px; font-size: 20px; }
.ht-col.full { grid-column: 1 / -1; }
.ht-col td { padding: 4px 10px 4px 0; vertical-align: top; }
.ht-col td:first-child { color: #9aa3b8; white-space: nowrap; }
.ht-col ul { padding-left: 18px; line-height: 1.75; }
kbd { display: inline-block; background: #e8ecf4; color: #111; border-radius: 4px; padding: 0 6px; font-family: var(--en); font-size: 13px; box-shadow: 0 2px 0 #889; margin: 0 1px; }

/* ---------------- 캐릭터 선택 ---------------- */
#select { background: linear-gradient(180deg, rgba(0,0,0,.65), rgba(0,0,0,0) 22%, rgba(0,0,0,0) 62%, rgba(0,0,0,.85)); }
.sel-title { position: absolute; top: 22px; width: 100%; text-align: center; font-family: var(--kr); font-size: 38px; color: #fff; text-shadow: 0 3px 0 #a01020, 0 0 20px rgba(255,40,60,.6); }
.sel-title span { display: block; font-family: var(--en); font-size: 14px; letter-spacing: 6px; color: var(--gold); text-shadow: none; }
.sel-grid { position: absolute; bottom: 70px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; }
.sel-card { width: 128px; height: 150px; position: relative; background: #111522; border: 3px solid #2a3248; overflow: hidden; clip-path: polygon(12px 0, 100% 0, calc(100% - 12px) 100%, 0 100%); }
.sel-card img { width: 100%; height: 118px; object-fit: cover; display: block; background: linear-gradient(180deg, #2a3a5a, #10141e); }
.sel-card .cn { position: absolute; bottom: 0; width: 100%; text-align: center; font-family: var(--kr); font-size: 19px; background: #0a0c14; padding: 3px 0 4px; }
.sel-card.p1 { border-color: var(--p1); box-shadow: inset 0 0 0 3px var(--p1); }
.sel-card.p2 { border-color: var(--p2); box-shadow: inset 0 0 0 3px var(--p2); }
.sel-card.p1.p2 { border-color: #c050ff; }
.sel-card .tag { position: absolute; top: 4px; font-family: var(--en); font-size: 13px; padding: 1px 8px; color: #fff; }
.sel-card .tag.t1 { left: 12px; background: var(--p1); } .sel-card .tag.t2 { right: 12px; background: var(--p2); }
.sel-side { position: absolute; top: 110px; width: 330px; padding: 16px 20px; background: var(--panel); border-top: 4px solid var(--p1); }
.sel-side.p1 { left: 3%; } .sel-side.p2 { right: 3%; border-top-color: var(--p2); text-align: right; }
.sel-side .who { font-family: var(--en); font-size: 14px; letter-spacing: 3px; color: #aab; }
.sel-side .nm { font-family: var(--kr); font-size: 48px; line-height: 1.1; }
.sel-side .en { font-family: var(--en); font-size: 13px; color: var(--gold); letter-spacing: 2px; }
.sel-side .ti { font-weight: 700; margin: 6px 0; color: #ffd0a0; }
.sel-side .ds { font-size: 14px; color: #ccd3e2; line-height: 1.5; margin-bottom: 10px; }
.stat { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 3px 0; }
.sel-side.p2 .stat { flex-direction: row-reverse; }
.stat label { width: 46px; color: #9aa3b8; }
.stat .pips { display: flex; gap: 3px; }
.sel-side.p2 .stat .pips { flex-direction: row-reverse; }
.stat .pip { width: 22px; height: 9px; background: #2a3044; transform: skewX(-20deg); }
.stat .pip.on { background: linear-gradient(90deg, var(--gold2), var(--gold)); }
.sel-side .ready { margin-top: 10px; font-family: var(--kr); font-size: 26px; color: var(--gold); animation: blink .6s infinite; }
.sel-side .cpu { font-family: var(--en); font-size: 13px; background: #445; display: inline-block; padding: 2px 8px; margin-top: 6px; }
.sel-stage { position: absolute; bottom: 234px; left: 50%; transform: translateX(-50%); font-family: var(--kr); font-size: 20px; background: var(--panel); padding: 6px 22px; border: 1px solid #3a4460; white-space: nowrap; }
.sel-stage b { color: var(--gold); font-weight: 400; }

/* ---------------- VS ---------------- */
#vs { background: #05060a; overflow: hidden; }
.vs-half { position: absolute; top: 0; bottom: 0; width: 56%; overflow: hidden; }
.vs-half.l { left: 0; clip-path: polygon(0 0, 100% 0, 80% 100%, 0 100%); background: linear-gradient(135deg, #0a2a6a, #05060a); animation: vsL .5s ease-out both; }
.vs-half.r { right: 0; clip-path: polygon(20% 0, 100% 0, 100% 100%, 0 100%); background: linear-gradient(225deg, #6a0a18, #05060a); animation: vsR .5s ease-out both; }
@keyframes vsL { from { transform: translateX(-100%); } } @keyframes vsR { from { transform: translateX(100%); } }
.vs-portrait { position: absolute; top: 8%; width: 70%; height: 70%; background-size: contain; background-repeat: no-repeat; background-position: center; filter: drop-shadow(0 0 30px rgba(0,0,0,.8)); }
.vs-half.l .vs-portrait { left: 6%; } .vs-half.r .vs-portrait { right: 6%; }
.vs-name { position: absolute; bottom: 18%; font-family: var(--kr); font-size: 90px; text-shadow: 0 6px 0 #000; }
.vs-half.l .vs-name { left: 6%; } .vs-half.r .vs-name { right: 6%; }
.vs-quote { position: absolute; bottom: 11%; font-size: 22px; font-weight: 700; color: #ffe0b0; text-shadow: 0 2px 4px #000; }
.vs-half.l .vs-quote { left: 6%; } .vs-half.r .vs-quote { right: 6%; }
.vs-mark { position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); font-family: var(--en); font-size: 180px; color: var(--gold);
  text-shadow: 0 0 40px #f80, 0 8px 0 #6a2a00; animation: vsMark .6s .3s cubic-bezier(.2,1.8,.4,1) both; }
@keyframes vsMark { from { transform: translate(-50%, -50%) scale(4); opacity: 0; } }
.vs-stage { position: absolute; bottom: 4%; width: 100%; text-align: center; font-family: var(--kr); font-size: 22px; color: #ccd; }

/* ---------------- HUD ---------------- */
#hud { pointer-events: none; }
.bar-wrap { position: absolute; top: 22px; width: 42%; display: flex; align-items: flex-start; gap: 10px; }
.bar-wrap.p1 { left: 2%; } .bar-wrap.p2 { right: 2%; }
.portrait { width: 74px; height: 74px; border: 3px solid #fff; background-size: cover; background-position: center; flex: none; box-shadow: 0 4px 12px #000; background-color: #223; }
.bar-wrap.p1 .portrait { border-color: var(--p1); } .bar-wrap.p2 .portrait { border-color: var(--p2); }
.bar-col { flex: 1; }
.bar { position: relative; height: 30px; background: #1a0a0a; border: 3px solid #e8e8f0; transform: skewX(-18deg); overflow: hidden; box-shadow: 0 4px 10px rgba(0,0,0,.7); }
.bar-wrap.p2 .bar { transform: skewX(18deg); }
.bar .hp, .bar .trail { position: absolute; top: 0; bottom: 0; }
.bar-wrap.p1 .hp, .bar-wrap.p1 .trail { left: 0; } .bar-wrap.p2 .hp, .bar-wrap.p2 .trail { right: 0; }
.bar .trail { background: #ff2030; }
.bar .hp { background: linear-gradient(180deg, #fff9b0 0%, #ffd23a 40%, #e09a00 100%); transition: background .3s; }
.bar .hp.low { background: linear-gradient(180deg, #ffd0a0, #ff7a1a 50%, #c03a00); }
.bar .rage-glow { position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255,40,0,.6), transparent); opacity: 0; animation: rageSweep 1s linear infinite; }
.bar .rage-glow.on { opacity: 1; }
@keyframes rageSweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.bar-info { display: flex; align-items: center; gap: 12px; margin-top: 6px; padding: 0 10px; }
.bar-wrap.p2 .bar-info { justify-content: flex-end; }
.pname { font-family: var(--kr); font-size: 26px; text-shadow: 0 2px 0 #000, 0 0 10px rgba(0,0,0,.8); }
.rounds { display: flex; gap: 6px; }
.rounds i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #ddd; background: rgba(0,0,0,.5); display: block; }
.rounds i.won { background: radial-gradient(circle at 35% 35%, #fff6b0, #ffb000); border-color: #fff; box-shadow: 0 0 10px #fa0; }
.rage-tag { font-family: var(--kr); font-size: 18px; color: #fff; background: linear-gradient(90deg, #ff3a00, #b00010); padding: 1px 10px; transform: skewX(-15deg); display: none; animation: blink .5s infinite; }
.rage-tag.on { display: inline-block; }
.timer-box { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); text-align: center; }
.timer-label { font-family: var(--kr); font-size: 13px; color: #ccd; letter-spacing: 2px; }
.timer { font-family: var(--en); font-size: 58px; line-height: 1; text-shadow: 0 4px 0 #000, 0 0 16px rgba(255,180,0,.5); }
.timer.warn { color: #ff4a4a; animation: blink .5s infinite; }
.combo { position: absolute; top: 160px; font-family: var(--en); opacity: 0; transition: opacity .2s; text-shadow: 0 4px 0 #000; }
.combo.p1 { left: 3%; } .combo.p2 { right: 3%; text-align: right; }
.combo.show { opacity: 1; }
.combo b { font-size: 64px; color: var(--gold); display: inline-block; }
.combo b.bump { animation: bump .15s; }
.combo span { font-size: 22px; margin-left: 6px; }
.combo i { display: block; font-style: normal; font-size: 18px; color: #ffd0d0; }
@keyframes bump { 50% { transform: scale(1.35); } }
.pop { position: absolute; top: 290px; font-family: var(--kr); font-size: 34px; opacity: 0; text-shadow: 0 3px 0 #000; }
.pop.p1 { left: 3%; } .pop.p2 { right: 3%; }
.pop.show { animation: pop 1.1s ease-out both; }
@keyframes pop { 0% { opacity: 0; transform: translateX(-30px) skewX(-10deg); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; transform: translateY(-10px); } }
#announce { position: absolute; top: 38%; left: 0; right: 0; text-align: center; transform: translateY(-50%); }
.ann-main { font-family: var(--kr); font-size: clamp(80px, 12vw, 170px); line-height: 1; opacity: 0;
  background: linear-gradient(180deg, #fff 0%, #ffe27a 45%, #ff7a00 55%, #ffd04a 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 0 #3a0a00) drop-shadow(0 0 24px rgba(255,90,0,.7)); }
.ann-main.en { font-family: var(--en); }
.ann-main.red { background: linear-gradient(180deg, #fff 0%, #ff8a8a 40%, #e00010 60%, #ff5050 100%); -webkit-background-clip: text; background-clip: text; }
.ann-sub { font-family: var(--kr); font-size: clamp(22px, 2.6vw, 38px); margin-top: 10px; opacity: 0; text-shadow: 0 3px 0 #000; }
.ann-main.show { animation: annIn .35s cubic-bezier(.2,1.6,.4,1) both; } .ann-sub.show { animation: annSub .4s .1s ease-out both; }
.ann-main.hide, .ann-sub.hide { animation: annOut .25s ease-in both; }
@keyframes annIn { from { transform: scale(3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes annSub { from { transform: translateY(20px); opacity: 0; } to { opacity: 1; } }
@keyframes annOut { from { opacity: 1; } to { opacity: 0; transform: scale(1.3); } }
#rageBanner { position: absolute; top: 58%; left: 0; right: 0; opacity: 0; }
#rageBanner.show { animation: rb 2.4s ease-out both; }
.rb-strip { background: linear-gradient(90deg, transparent, rgba(160,0,10,.92) 15%, rgba(255,40,30,.95) 50%, rgba(160,0,10,.92) 85%, transparent); padding: 10px 0 14px; text-align: center; transform: skewY(-3deg); border-top: 3px solid #ffd25a; border-bottom: 3px solid #ffd25a; }
.rb-name { font-family: var(--kr); font-size: 64px; text-shadow: 0 4px 0 #300; }
.rb-line { font-size: 22px; font-weight: 900; color: #ffe8c0; }
@keyframes rb { 0% { opacity: 0; transform: translateX(-60%); } 10% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateX(30%); } }
#trainPanel { position: absolute; left: 2%; top: 150px; width: 300px; background: var(--panel); padding: 12px 14px; font-size: 13px; display: none; border-left: 3px solid var(--gold); line-height: 1.6; }
#trainPanel.show { display: block; }
#trainPanel b { color: var(--gold); }
.hud-hint { position: absolute; bottom: 12px; width: 100%; text-align: center; font-size: 13px; color: rgba(255,255,255,.6); text-shadow: 0 1px 2px #000; }

/* ---------------- 결과 ---------------- */
#result { background: linear-gradient(90deg, rgba(0,0,0,0) 40%, rgba(0,0,0,.85)); }
.res-box { position: absolute; right: 6%; top: 18%; width: 460px; }
.res-win { font-family: var(--kr); font-size: 70px; line-height: 1.1; color: var(--gold); text-shadow: 0 5px 0 #4a1a00; animation: annIn .4s both; }
.res-win small { display: block; font-size: 26px; color: #fff; }
.res-quote { font-size: 24px; font-weight: 900; margin: 18px 0 14px; padding: 14px 18px; background: #fff; color: #111; position: relative; border-radius: 6px; }
.res-quote::before { content: ''; position: absolute; left: -16px; top: 22px; border: 10px solid transparent; border-right: 16px solid #fff; }
.res-stats { font-size: 15px; color: #ccd; margin-bottom: 18px; line-height: 1.6; }
#result .menu-list li { font-size: 26px; }

/* ---------------- 엔딩 ---------------- */
#ending { background: rgba(0,0,0,.55); }
.end-box { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); text-align: center; width: min(900px, 90vw); }
.end-title { font-family: var(--kr); font-size: 120px; background: linear-gradient(180deg, #fff, #ffd25a 50%, #ff8a00); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 6px 0 #4a1a00); animation: annIn .6s both; }
.end-text { font-size: 22px; line-height: 1.8; margin-top: 16px; text-shadow: 0 2px 4px #000; white-space: pre-line; }

@media (max-width: 900px) {
  .sel-side { width: 230px; } .sel-side .nm { font-size: 34px; } .sel-card { width: 92px; height: 120px; } .sel-card img { height: 90px; }
  .vs-name { font-size: 54px; } .pname { font-size: 18px; } .portrait { width: 52px; height: 52px; }
  .ml-body { grid-template-columns: 1fr; } .howto-grid { grid-template-columns: 1fr; }
}
