/* 도와줘 레이드 화면. 3D 캔버스가 화면 전체, 그 위에 위(보스 체력)·아래(내 조작) 두 덩이만 얹는다. */
:root {
  --ink: #120C16; --night: #1A1530; --paper: #FFF6E8; --dim: #C9BBD6; --gold: #FFC83D; --ember: #FF7A2E; --blood: #E5383B;
  --glass: rgba(18, 12, 22, 0.72); --line: rgba(255, 246, 232, 0.16);
  --font: "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  --col: min(100vw, 520px); --side: max(16px, calc((100vw - 520px) / 2 + 16px));
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--night); color: var(--paper); font-family: var(--font); font-weight: 600; overflow: hidden;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
body.no-gl #gl { display: none; }
body.no-gl { background: radial-gradient(120% 80% at 50% 30%, #3A1D3F 0%, #1A1530 55%, #0D0912 100%); }
#veil { position: fixed; inset: 0; display: grid; place-items: center; background: var(--night); color: var(--dim); font-size: 14px; letter-spacing: 0.08em; transition: opacity 0.5s; z-index: 5; }
#veil.off { opacity: 0; pointer-events: none; }

/* ── 위: 보스 ── */
#top {
  position: fixed; top: 0; left: 0; right: 0; z-index: 3;
  padding: calc(env(safe-area-inset-top) + 12px) var(--side) 22px;
  background: linear-gradient(180deg, rgba(13, 9, 18, 0.86) 0%, rgba(13, 9, 18, 0.5) 62%, transparent 100%);
}
.headRow { display: flex; align-items: center; gap: 8px; min-height: 30px; }
.stage { font-size: 11px; font-weight: 800; letter-spacing: 0.12em; padding: 3px 7px; border-radius: 5px; background: var(--gold); color: var(--ink); white-space: nowrap; }
#bossName { font-size: 21px; font-weight: 900; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 2px 0 var(--ink); }
.phase { font-size: 11px; font-weight: 900; letter-spacing: 0.1em; padding: 3px 7px; border-radius: 5px; background: var(--blood); color: #fff; white-space: nowrap; animation: pulse 1.1s ease-in-out infinite; }
.chip { margin-left: auto; font-size: 12px; font-weight: 800; padding: 6px 11px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); white-space: nowrap; }
.chip.hot { background: var(--ember); border-color: transparent; color: var(--ink); }
.chip:active { transform: scale(0.96); }

.hp { position: relative; height: 22px; margin-top: 9px; border-radius: 7px; background: rgba(0, 0, 0, 0.6); border: 2px solid var(--ink); box-shadow: 0 0 0 1px var(--line); overflow: hidden; }
.hp i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 4px; }
#hpLag { background: #FFE9A8; transition: width 0.9s 0.25s ease-out; }
#hpFill { background: linear-gradient(180deg, #FF6B5E 0%, var(--blood) 48%, #A81B2B 100%); transition: width 0.25s ease-out; }
.hp.p1 #hpFill { background: linear-gradient(180deg, #FFA24D 0%, #F0641E 48%, #B03A0A 100%); }
.hp.p2 #hpFill { background: linear-gradient(180deg, #FF5DA2 0%, #D4145A 48%, #7A0B3B 100%); }
.hp .tick { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: rgba(18, 12, 22, 0.75); }
#hpText { position: absolute; inset: 0; display: grid; place-items: center; font-size: 12px; font-weight: 900; font-variant-numeric: tabular-nums; text-shadow: 0 1px 0 var(--ink), 0 0 6px var(--ink); letter-spacing: 0.02em; }
#sub { margin-top: 6px; font-size: 12px; color: var(--dim); text-shadow: 0 1px 0 var(--ink); }
#sub b { color: var(--gold); font-weight: 800; }

/* ── 최근 타격 ── */
#feed { position: fixed; left: calc(50% - var(--col) / 2 + 12px); top: calc(env(safe-area-inset-top) + 118px); z-index: 2; list-style: none; padding: 0; width: 46%; max-width: 220px; pointer-events: none; }
#feed li { font-size: 11px; line-height: 1.5; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 0 var(--ink), 0 0 5px var(--ink); animation: feedIn 0.25s ease-out; }
#feed li b { color: var(--paper); font-weight: 800; }
#feed li.crit b { color: var(--gold); }
#feed li:nth-last-child(n+4) { opacity: 0.55; }

#banner { position: fixed; left: 50%; top: 31%; transform: translate(-50%, -50%); z-index: 4; width: var(--col); padding: 0 20px; text-align: center; pointer-events: none; font-size: 26px; font-weight: 900; letter-spacing: 0.02em; color: var(--gold); text-shadow: 0 3px 0 var(--ink), 0 0 18px rgba(255, 122, 46, 0.7); opacity: 0; }
#banner.on { animation: banner 2.6s ease-out both; }

/* ── 아래: 내 조작 ── */
#dock {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 3;
  padding: 34px var(--side) calc(env(safe-area-inset-bottom) + 14px);
  background: linear-gradient(0deg, rgba(13, 9, 18, 0.92) 0%, rgba(13, 9, 18, 0.66) 62%, transparent 100%);
}
#guest h2 { font-size: 22px; font-weight: 900; text-shadow: 0 2px 0 var(--ink); }
#guest p { margin: 6px 0 12px; font-size: 13.5px; line-height: 1.5; color: var(--dim); font-weight: 500; }
#joinForm { display: grid; gap: 9px; }
#joinName { width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--glass); font-size: 16px; font-weight: 700; user-select: text; -webkit-user-select: text; outline: none; }
#joinName:focus { border-color: var(--gold); }
#joinName::placeholder { color: rgba(201, 187, 214, 0.6); font-weight: 500; }
.jobs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.jobs button { height: 42px; border-radius: 12px; background: var(--glass); border: 1px solid var(--line); font-size: 14px; font-weight: 800; }
.jobs button[aria-checked="true"] { background: var(--paper); color: var(--ink); border-color: var(--paper); }

.big { display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 58px; border-radius: 16px; font-size: 20px; font-weight: 900; letter-spacing: 0.04em; color: var(--ink); text-decoration: none;
  background: linear-gradient(180deg, #FFD966 0%, var(--gold) 45%, #F29A1F 100%); border-bottom: 5px solid #A85A00; box-shadow: 0 6px 22px rgba(255, 122, 46, 0.35); transition: transform 0.06s, border-width 0.06s, filter 0.2s; }
.big:active:not(:disabled) { transform: translateY(3px); border-bottom-width: 2px; }
.big:disabled { filter: grayscale(0.85) brightness(0.62); box-shadow: none; cursor: default; }
.coin { display: inline-block; width: 0.82em; height: 0.82em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #FFF2B0 0%, #FFC83D 45%, #C77A00 100%); box-shadow: inset 0 0 0 1.5px rgba(120, 70, 0, 0.55); vertical-align: -0.06em; flex: none; }
/* 무기 강화 단추: 골드가 찰수록 밝은 띠가 차오르고, 다 차면 누를 수 있다 */
.up { position: relative; overflow: hidden; min-height: 66px; margin-top: 10px; padding: 0 16px; justify-content: space-between; letter-spacing: 0; }
.up > * { position: relative; }
.upFill { position: absolute !important; inset: 0 auto 0 0; width: 0; background: rgba(255, 255, 255, 0.34); transition: width 0.25s linear; }
.upL { display: grid; justify-items: start; gap: 1px; }
.upL b { font-size: 22px; line-height: 1.1; }
.upL small { font-size: 12.5px; font-weight: 800; opacity: 0.72; font-variant-numeric: tabular-nums; }
.upCost { display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 12px; background: rgba(18, 12, 22, 0.16); font-size: 17px; font-variant-numeric: tabular-nums; }
.up.poor { filter: saturate(0.5) brightness(0.72); box-shadow: none; }
.up.poor .upCost { font-size: 14px; }
.up.ready { animation: ready 1.4s ease-in-out infinite; }
.up.ready .upFill { width: 0 !important; }
.meGold { display: inline-flex; align-items: center; gap: 5px; font-size: 14px; }
.meGold b { color: var(--paper); font-weight: 800; }
.meGold small { font-size: 11.5px; color: var(--dim); }
#attackSub { margin-top: 8px; min-height: 16px; text-align: center; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }

.meRow { display: flex; align-items: center; gap: 8px; }
.meRow.thin { margin-top: 6px; font-size: 12.5px; color: var(--dim); font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.meRow .chip { margin-left: 0; }
.meName { font-size: 17px; font-weight: 900; max-width: 56%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-shadow: 0 2px 0 var(--ink); text-align: left; }
.mePower { margin-left: auto; display: flex; align-items: baseline; gap: 6px; padding: 4px 10px 4px 12px; border-radius: 10px; background: var(--glass); border: 1px solid var(--line); }
.mePower small { font-size: 11px; color: var(--dim); font-weight: 700; }
.mePower b { font-size: 20px; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; }
.mePower.rise b { animation: powerUp 0.7s ease-out; }

/* ── 시트 ── */
#sheet { position: fixed; inset: 0; z-index: 10; display: flex; align-items: flex-end; justify-content: center; background: rgba(8, 5, 12, 0.6); animation: fade 0.18s ease-out; }
.card { position: relative; width: var(--col); max-height: 82vh; overflow-y: auto; padding: 22px 18px calc(env(safe-area-inset-bottom) + 20px); border-radius: 22px 22px 0 0; background: #1D1626; border-top: 1px solid var(--line); animation: rise 0.24s cubic-bezier(0.2, 0.9, 0.3, 1); }
.card h3 { font-size: 19px; font-weight: 900; margin-bottom: 12px; }
.card h4 { font-size: 13px; font-weight: 800; color: var(--dim); margin: 18px 0 8px; letter-spacing: 0.04em; }
.x { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; font-size: 26px; line-height: 1; color: var(--dim); }
.rows { display: grid; gap: 2px; }
.rows > div { display: flex; align-items: center; gap: 8px; padding: 9px 2px; border-bottom: 1px solid rgba(255, 246, 232, 0.07); font-size: 14px; font-variant-numeric: tabular-nums; }
.rows > div > span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows > div > b { font-weight: 800; }
.rows > div > em { font-style: normal; width: 26px; color: var(--dim); font-weight: 800; }
.rows > div.sum { border-bottom: 0; font-size: 17px; }
.rows > div.sum b { color: var(--gold); font-size: 22px; }
.rows > div.mine { color: var(--gold); }
.rows > div.top1 em { color: var(--gold); }
.rows > div > span > small { margin-left: 6px; color: var(--dim); font-size: 12px; font-weight: 700; }
.how { padding-left: 18px; display: grid; gap: 6px; font-size: 13px; line-height: 1.45; color: var(--dim); font-weight: 500; }
.empty { padding: 18px 0; color: var(--dim); font-size: 14px; font-weight: 500; }
.field { display: flex; gap: 8px; }
.field input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--line); background: var(--ink); font-size: 16px; font-weight: 700; user-select: text; -webkit-user-select: text; outline: none; }
.field input:focus { border-color: var(--gold); }
.field button { padding: 0 16px; border-radius: 11px; background: var(--paper); color: var(--ink); font-weight: 800; font-size: 14px; }
.note { margin-top: 6px; font-size: 12px; color: var(--dim); font-weight: 500; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 190px); transform: translateX(-50%); z-index: 12; max-width: calc(var(--col) - 40px); padding: 10px 16px; border-radius: 12px; background: var(--paper); color: var(--ink); font-size: 13.5px; font-weight: 800; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
#toast.on { opacity: 1; }

/* 릴스 촬영 화면: 조작 덩이를 감춘다 */
body.reel #dock, body.reel #lang, body.reel #feed { display: none; }

@keyframes pulse { 50% { filter: brightness(1.35); transform: scale(1.05); } }
@keyframes feedIn { from { opacity: 0; transform: translateX(-8px); } }
@keyframes banner { 0% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); } 12% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 78% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -62%) scale(1); } }
@keyframes powerUp { 30% { transform: scale(1.25); color: #fff; } }
@keyframes ready { 50% { filter: brightness(1.12); box-shadow: 0 6px 30px rgba(255, 170, 46, 0.6); } }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@media (max-height: 640px) { #guest p { margin: 4px 0 8px; font-size: 12.5px; } .big { min-height: 50px; } .up { min-height: 56px; } #banner { font-size: 22px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
