:root {
  --bg: #0b0b14;
  --panel: rgba(13, 18, 48, 0.9);
  --line: rgba(255, 255, 255, 0.16);
  --cyan: #2ee6ff;
  --pink: #ff4fd8;
  --yellow: #ffe14d;
  --green: #3dff8a;
  --ink: #0b0b14;
  --muted: #b9bdd3;
  --display: 'Black Han Sans', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --pixel: 'Press Start 2P', monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #000; color: #fff;
  font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, sans-serif;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; overscroll-behavior: none;
}
#app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ─────────── 화면 공통 ─────────── */
.screen {
  position: absolute; inset: 0; overflow-y: auto; display: flex; z-index: 10;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: rgba(8, 10, 28, 0.72);
  touch-action: pan-y;
}
#scr-creator, #scr-result, #scr-settings, #scr-help, #scr-pause, #scr-champ, #scr-share, #scr-online { background: rgba(8, 10, 28, 0.86); }
#scr-title { background: radial-gradient(ellipse at center, rgba(8, 10, 28, 0.35), rgba(8, 10, 28, 0.85)); }
.inner { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; max-width: 560px; }
.inner.wide { max-width: 860px; }
h2 { font-family: var(--display); font-weight: 400; margin: 0; font-size: 30px; color: var(--yellow); text-align: center; text-shadow: 0 3px 0 var(--ink); }
.row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.btn {
  font-family: var(--display); font-size: 21px; color: #fff; line-height: 1.15;
  background: #1c2350; border: 3px solid var(--cyan); border-radius: 12px;
  padding: 8px 20px; min-width: 200px; cursor: pointer; box-shadow: 0 4px 0 #05061a;
  transition: transform 0.08s, background 0.1s;
}
.btn small { display: block; font-family: inherit; font-size: 12px; color: var(--muted); letter-spacing: 0.3px; }
.btn.small { font-size: 16px; min-width: 110px; padding: 7px 14px; }
.btn.primary { background: var(--pink); color: var(--ink); border-color: #ffd0f4; box-shadow: 0 4px 0 #a3168a; }
.btn.primary small { color: #3a0634; }
.btn:hover, .btn:focus-visible { outline: none; background: var(--yellow); color: var(--ink); border-color: #fff; transform: translateY(-2px); }
.btn:hover small, .btn:focus-visible small { color: #3a2a00; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #05061a; }
.btn.off { opacity: 0.55; }

/* ─────────── 타이틀 ─────────── */
.logo { text-align: center; }
.logo-top { font-family: var(--pixel); font-size: 15px; color: var(--cyan); letter-spacing: 6px; text-shadow: 3px 3px 0 var(--ink); }
.logo-main {
  font-family: var(--pixel); font-size: 48px; line-height: 1.15; color: var(--yellow); margin-top: 8px;
  text-shadow: 4px 4px 0 #b02a9a, 8px 8px 0 var(--ink);
  animation: bob 2.4s ease-in-out infinite;
}
.logo-main span { font-family: var(--display); font-size: 44px; color: #fff; }
.logo-sub { font-family: var(--display); font-size: 15px; color: #fff; margin-top: 8px; text-shadow: 0 2px 0 var(--ink); }
@keyframes bob { 50% { transform: translateY(-4px); } }
.menu { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.menu .btn { min-width: 0; width: 100%; }
.my-card { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 6px 14px; font-family: var(--display); font-size: 16px; }
.my-card img { width: 30px; height: 20px; border: 1px solid #fff8; }
.my-card .pb { font-family: var(--pixel); font-size: 11px; color: var(--yellow); }
.copyright { font-size: 12px; color: rgba(255, 255, 255, 0.8); text-decoration: none; text-shadow: 0 1px 2px #000; }
.copyright:hover { color: var(--yellow); text-decoration: underline; }
#btn-sound, #btn-menu {
  width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--cyan); background: rgba(0, 0, 0, 0.55); color: #fff; font-size: 18px; cursor: pointer;
}
#btn-sound { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(12px, env(safe-area-inset-bottom)); z-index: 20; }
#hud-btns { position: absolute; right: max(12px, env(safe-area-inset-right)); top: max(10px, env(safe-area-inset-top)); z-index: 5; }

/* ─────────── 선수 만들기 ─────────── */
.creator { margin: auto; display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.4fr); gap: 18px; width: 100%; max-width: 900px; align-items: center; }
.preview { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.card-frame { width: 100%; max-width: 260px; background: linear-gradient(#1c2350, #0d1230); border: 3px solid var(--yellow); border-radius: 16px; padding: 10px; text-align: center; box-shadow: 0 0 0 3px var(--ink), 0 8px 0 #05061a; }
#pv { width: 100%; aspect-ratio: 4 / 3; image-rendering: pixelated; background: #c0533c; border-radius: 8px; display: block; }
.pv-name { font-family: var(--display); font-size: 24px; margin-top: 8px; color: #fff; }
.pv-meta { font-size: 13px; color: var(--muted); display: flex; align-items: center; justify-content: center; gap: 6px; }
.pv-meta img { width: 24px; height: 16px; border: 1px solid #fff8; }
.options { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.options h2 { text-align: left; font-size: 24px; }
.opt { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 8px; }
.opt > span { font-family: var(--display); font-size: 15px; color: var(--muted); }
.opt .ctl { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-family: var(--display); font-size: 14px; color: #fff; background: #1c2350; border: 2px solid var(--line); border-radius: 9px; padding: 5px 10px; cursor: pointer; }
.chip.on { border-color: var(--pink); background: #3a1450; color: #fff; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff4; cursor: pointer; padding: 0; }
.sw.on { border: 3px solid var(--yellow); box-shadow: 0 0 0 2px var(--ink); }
.arrow { width: 34px; height: 32px; border-radius: 8px; border: 2px solid var(--cyan); background: #1c2350; color: #fff; font-size: 14px; cursor: pointer; }
.pick { display: flex; align-items: center; gap: 6px; min-width: 120px; justify-content: center; font-family: var(--display); font-size: 15px; }
.pick img { width: 30px; height: 20px; border: 1px solid #fff8; }
.opt input { font-family: var(--display); font-size: 17px; width: 160px; padding: 6px 10px; border-radius: 9px; border: 2px solid var(--cyan); background: #0d1230; color: #fff; }
.trait-desc { font-size: 12px; color: var(--muted); width: 100%; }

/* ─────────── 설정·도움말 ─────────── */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; max-width: 420px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 10px 14px; font-family: var(--display); font-size: 17px; }
.seg { display: flex; gap: 6px; }
.tips { margin: 0; padding: 14px 18px 14px 34px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; line-height: 1.7; font-size: 15px; max-width: 560px; }
.tips b { color: var(--yellow); font-weight: 600; }
kbd { font-family: var(--pixel); font-size: 10px; background: #1c2350; border: 1px solid var(--cyan); border-bottom-width: 3px; border-radius: 5px; padding: 2px 6px; }

/* ─────────── 경기 중 큰 글자 ─────────── */
#callout {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); z-index: 6; pointer-events: none;
  font-family: var(--display); font-size: clamp(34px, 9vh, 72px); color: #fff; white-space: nowrap; text-align: center;
  text-shadow: 0 4px 0 var(--ink), 0 0 18px rgba(0, 0, 0, 0.6);
}
#callout.pop { animation: pop 0.35s cubic-bezier(.2, 1.6, .4, 1); }
#callout.gun { color: var(--yellow); font-size: clamp(48px, 14vh, 110px); }
#callout.bad { color: #ff5a5a; }
#callout.gold { color: var(--yellow); }
#callout small { display: block; font-size: 0.38em; color: #fff; margin-top: 4px; }
@keyframes pop { 0% { transform: translate(-50%, -50%) scale(0.4); opacity: 0; } 100% { transform: translate(-50%, -50%) scale(1); opacity: 1; } }

/* ─────────── 해설 자막 ─────────── */
#caster {
  position: absolute; left: 50%; bottom: max(8px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 6; pointer-events: none;
  max-width: min(70vw, 620px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(11, 11, 20, 0.85); border-left: 4px solid var(--yellow); border-radius: 0 10px 10px 0;
  padding: 5px 14px; font-family: var(--display); font-size: clamp(14px, 4vh, 19px); color: #fff;
}
#caster::before { content: '🎙️ '; }
#caster.in { animation: casterIn 0.25s ease-out; }
@keyframes casterIn { from { transform: translate(-50%, 8px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

.champ-path { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; }
.champ-step { min-width: 150px; background: var(--panel); border: 3px solid var(--line); border-radius: 14px; padding: 10px 14px; text-align: center; display: flex; flex-direction: column; gap: 4px; }
.champ-step b { font-family: var(--display); font-weight: 400; font-size: 22px; }
.champ-step span { font-size: 13px; color: var(--muted); }
.champ-step.done { border-color: var(--green); }
.champ-step.done b::after { content: ' ✓'; color: var(--green); }
.champ-step.now { border-color: var(--yellow); box-shadow: 0 0 0 3px rgba(255, 225, 77, 0.25); }
.champ-step.out { border-color: #ff5a5a; }
.champ-step.next { opacity: 0.6; }
.champ-arrow { color: var(--muted); font-size: 14px; }
.champ-msg { margin: 0; font-family: var(--display); font-size: 18px; text-align: center; }
.champ-medals { margin: 0; font-size: 14px; color: var(--muted); }
#share-img { width: min(70vh, 360px); border-radius: 12px; border: 3px solid var(--pink); }
a.btn { text-decoration: none; display: inline-block; text-align: center; }
.res-table tr.me2 td { background: rgba(46, 230, 255, 0.18); }

/* ─────────── 결과 ─────────── */
.res-head { font-family: var(--display); font-size: 36px; color: var(--yellow); text-shadow: 0 3px 0 var(--ink); text-align: center; }
.res-head small { display: block; font-size: 15px; color: #fff; }
.respect { margin: 0; font-family: var(--display); font-size: 16px; color: var(--green); text-align: center; }
.res-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; max-width: 640px; }
.res-col { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; display: flex; flex-direction: column; gap: 3px; }
.res-col.me { border-color: var(--pink); }
.stat-line { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.stat-line b { font-family: var(--pixel); font-size: 12px; color: #fff; font-weight: 400; }
.note { font-size: 12.5px; color: var(--muted); margin: 0; text-align: center; }
#share-img { width: min(70vh, 360px); border-radius: 12px; border: 3px solid var(--pink); }
a.btn { text-decoration: none; display: inline-block; text-align: center; }

/* ─────────── 상대 소개 VS ─────────── */
#vs { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 7; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 8px; animation: pop 0.4s cubic-bezier(.2, 1.6, .4, 1); }
.vs-title { font-family: var(--display); font-size: 20px; color: var(--yellow); text-shadow: 0 2px 0 var(--ink); }
.vs-row { display: flex; align-items: center; gap: 14px; }
.vs-card { background: rgba(11, 11, 20, 0.88); border: 3px solid var(--cyan); border-radius: 14px; padding: 8px 14px; min-width: 170px; text-align: center; }
.vs-card.me { border-color: var(--pink); }
.vs-name { display: flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--display); font-size: 20px; }
.vs-name img { width: 30px; height: 20px; border: 1px solid #fff8; }
.vs-style { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.vs-mark { font-family: var(--pixel); font-size: 26px; color: var(--yellow); text-shadow: 3px 3px 0 #b02a9a; }
.champ-opp { display: flex; align-items: center; justify-content: center; gap: 6px; font-family: var(--display); font-size: 15px; color: #fff !important; }
.champ-opp img { width: 22px; height: 15px; }

/* ─────────── 조작 버튼 ─────────── */
#controls { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.pad {
  position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); width: 108px; height: 108px; border-radius: 50%;
  pointer-events: auto; touch-action: none; font-family: var(--display); font-size: 22px; color: #fff; line-height: 1.1;
  background: rgba(28, 35, 80, 0.72); border: 4px solid var(--cyan); box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45);
}
.pad small { display: block; font-size: 12px; color: var(--muted); }
.pad-jab { left: max(16px, env(safe-area-inset-left)); }
.pad-straight { right: max(16px, env(safe-area-inset-right)); border-color: var(--pink); font-size: 18px; }
.pad.on { transform: translateY(3px) scale(0.96); background: rgba(255, 79, 216, 0.45); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45); }
.pad-upper { left: 50%; margin-left: -46px; width: 92px; height: 92px; font-size: 20px; border-color: var(--yellow); opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.pad-upper.ready { opacity: 1; pointer-events: auto; animation: glow 0.6s ease-in-out infinite alternate; }
@keyframes glow { from { box-shadow: 0 0 0 3px rgba(255, 225, 77, 0.3), 0 5px 0 rgba(0, 0, 0, 0.45); } to { box-shadow: 0 0 18px 8px rgba(255, 225, 77, 0.6), 0 5px 0 rgba(0, 0, 0, 0.45); } }
.pad-hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom)); max-width: calc(100% - 280px); white-space: normal; text-align: center; background: rgba(11, 11, 20, 0.6); border-radius: 8px; padding: 4px 10px; font-family: var(--display); font-size: 13px; color: rgba(255, 255, 255, 0.75); text-shadow: 0 1px 2px #000; }
#controls.upper-on .pad-hint { display: none; }
#caster { bottom: auto; top: max(94px, calc(env(safe-area-inset-top) + 82px)); }
#btn-sound { bottom: auto; top: max(10px, env(safe-area-inset-top)); }
#app.fighting #btn-sound { display: none; }

#toast {
  position: absolute; left: 50%; top: 22%; transform: translateX(-50%); z-index: 30; pointer-events: none;
  background: rgba(11, 11, 20, 0.9); border: 2px solid var(--cyan); border-radius: 12px; padding: 8px 16px; font-family: var(--display); font-size: 16px;
  opacity: 0; transition: opacity 0.25s;
}
#toast.show { opacity: 1; }

/* ─────────── 세로 화면 안내 ─────────── */
#rotate { display: none; position: absolute; inset: 0; z-index: 50; background: var(--bg); flex-direction: column; align-items: center; justify-content: center; gap: 10px; font-family: var(--display); }
#rotate div { font-size: 56px; animation: tilt 1.6s ease-in-out infinite; }
#rotate p { margin: 0; font-size: 20px; }
@keyframes tilt { 50% { transform: rotate(-90deg); } }
@media (orientation: portrait) and (max-width: 820px) { #rotate { display: flex; } }

/* ─────────── 낮은 가로 화면 (폰) ─────────── */
@media (max-height: 460px) {
  .champ-step { min-width: 120px; padding: 6px 10px; }
  .champ-step b { font-size: 18px; }
  .inner { gap: 8px; }
  .logo-top { font-size: 11px; }
  .logo-main { font-size: 34px; margin-top: 4px; }
  .logo-main span { font-size: 32px; }
  .logo-sub { font-size: 13px; margin-top: 4px; }
  .btn { font-size: 18px; padding: 6px 14px; }
  .btn small { font-size: 11px; }
  .btn.small { font-size: 14px; padding: 5px 12px; }
  h2 { font-size: 24px; }
  .options h2 { font-size: 20px; }
  .opt { grid-template-columns: 54px minmax(0, 1fr); }
  .chip { font-size: 13px; padding: 4px 8px; }
  .sw { width: 26px; height: 26px; }
  .pv-name { font-size: 20px; }
  .res-head { font-size: 28px; }
  .pad { width: 92px; height: 92px; font-size: 19px; }
  .pad-straight { font-size: 15px; }
  .pad-upper { width: 80px; height: 80px; margin-left: -40px; }
  .pad-hint { max-width: calc(100% - 240px); font-size: 11.5px; }
  .vs-card { min-width: 140px; padding: 6px 10px; }
}

/* ─────────── 복싱 타이틀 ─────────── */
.logo-main { font-family: var(--display); font-size: 60px; color: #fff; }
.logo-main span { font-size: inherit; color: var(--yellow); }
@media (max-height: 460px) { .logo-main { font-size: 42px; } }

/* ─────────── 온라인 1:1 ─────────── */
.on-home, .on-room { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
#on-code { font-family: var(--pixel); font-size: 18px; width: 150px; text-align: center; text-transform: uppercase; padding: 8px; border-radius: 10px; border: 3px solid var(--cyan); background: #0d1230; color: #fff; }
.on-head { display: flex; gap: 18px; align-items: center; justify-content: center; flex-wrap: wrap; }
.room-code { font-family: var(--pixel); font-size: 34px; color: var(--yellow); letter-spacing: 6px; text-shadow: 3px 3px 0 var(--ink); }
.on-link-box { display: flex; flex-direction: column; gap: 6px; align-items: center; }
.on-link { font-size: 12px; color: var(--muted); user-select: all; -webkit-user-select: all; max-width: 320px; word-break: break-all; }
.on-players { display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.on-player { display: flex; align-items: center; gap: 8px; background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 8px 12px; font-family: var(--display); font-size: 17px; min-width: 200px; }
.on-player img { width: 28px; height: 18px; border: 1px solid #fff8; }
.on-player em { font-style: normal; font-size: 11px; background: var(--yellow); color: var(--ink); border-radius: 6px; padding: 1px 6px; margin-left: auto; }
.on-player em.corner { margin-left: 0; color: #fff; }
.on-player em.corner.red { background: #e3242b; }
.on-player em.corner.blue { background: #1d48b8; }
.on-player.me { border-color: var(--pink); }
.on-player.empty { color: var(--muted); border-style: dashed; justify-content: center; font-size: 14px; }
@media (max-height: 460px) { .room-code { font-size: 26px; } .on-player { min-width: 170px; padding: 6px 10px; font-size: 15px; } }

/* ─────────── 반격 찬스·러시 ─────────── */
#chance {
  position: absolute; left: 50%; top: 52%; transform: translate(-50%, -50%); z-index: 8; pointer-events: none; text-align: center;
  font-family: var(--display); font-size: clamp(40px, 12vh, 84px); color: var(--yellow); text-shadow: 0 5px 0 #b02a9a, 0 0 24px rgba(255, 225, 77, 0.8);
  animation: chancePulse 0.35s ease-in-out infinite alternate;
}
#chance small { display: block; font-size: 0.32em; color: #fff; text-shadow: 0 2px 0 var(--ink); }
@keyframes chancePulse { from { transform: translate(-50%, -50%) scale(0.92); } to { transform: translate(-50%, -50%) scale(1.08); } }
#rush {
  position: absolute; left: 50%; top: 60%; transform: translateX(-50%); z-index: 8; pointer-events: none; white-space: nowrap;
  font-family: var(--display); font-size: clamp(26px, 7vh, 46px); color: #fff; background: rgba(176, 42, 154, 0.85); border: 3px solid var(--yellow);
  border-radius: 16px; padding: 6px 18px; animation: chancePulse2 0.2s ease-in-out infinite alternate;
}
#rush.theirs { background: rgba(11, 11, 20, 0.85); border-color: #ff5a5a; }
#rush b { font-family: var(--pixel); font-size: 0.6em; color: var(--yellow); margin-left: 12px; font-weight: 400; }
@keyframes chancePulse2 { from { transform: translateX(-50%) scale(0.97); } to { transform: translateX(-50%) scale(1.04); } }
