* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
:root {
  --bg: #0b1030; --bg2: #18225a; --panel: rgba(255,255,255,0.08); --line: rgba(255,255,255,0.16);
  --text: #ffffff; --muted: #aab4d6; --gold: #ffd84a; --accent: #ff7a59; --sky: #7fe3ff;
  --font: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
}
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
#app { position: relative; width: 100%; height: 100%; max-width: 560px; margin: 0 auto; overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; padding: 16px; padding-top: max(16px, env(safe-area-inset-top)); background: radial-gradient(ellipse at 50% 0%, #26338a 0%, var(--bg) 65%); overflow-y: auto; touch-action: pan-y; }
.screen.active { display: flex; }
.screen.game { padding: 0; background: linear-gradient(#141a3e 0%, #141a3e 50%, #a5493d 50%, #a5493d 100%); justify-content: center; max-width: none; touch-action: none; overflow: hidden; }
#app:has(#game.active) { max-width: none; }
canvas#cv { display: block; touch-action: none; }

.stars { position: absolute; inset: 0; pointer-events: none; background-image:
  radial-gradient(2px 2px at 20% 30%, #fff8 50%, transparent 51%), radial-gradient(2px 2px at 70% 12%, #fffa 50%, transparent 51%),
  radial-gradient(1.5px 1.5px at 40% 70%, #fff7 50%, transparent 51%), radial-gradient(2px 2px at 85% 55%, #fff9 50%, transparent 51%),
  radial-gradient(1.5px 1.5px at 10% 85%, #fff6 50%, transparent 51%), radial-gradient(2px 2px at 55% 40%, #fff5 50%, transparent 51%),
  radial-gradient(1.5px 1.5px at 92% 90%, #fff8 50%, transparent 51%), radial-gradient(1.5px 1.5px at 30% 8%, #fff8 50%, transparent 51%); }

/* 타이틀 */
#title { justify-content: space-evenly; text-align: center; }
.moon { position: relative; width: 150px; height: 150px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fffbe6, #f5df8f 60%, #d9b85a); box-shadow: 0 0 60px 18px rgba(255,226,140,0.35); animation: float 4s ease-in-out infinite; }
.crater { position: absolute; border-radius: 50%; background: rgba(190,150,60,0.35); }
.c1 { width: 30px; height: 30px; left: 30px; top: 70px; } .c2 { width: 18px; height: 18px; left: 90px; top: 34px; } .c3 { width: 22px; height: 22px; left: 95px; top: 95px; }
@keyframes float { 50% { transform: translateY(-10px); } }
.logo-main { font-size: 68px; color: var(--gold); text-shadow: 0 4px 0 #b8322e, 0 0 24px rgba(255,216,74,0.5); letter-spacing: 2px; }
.logo-sub { font-size: 18px; color: var(--muted); letter-spacing: 4px; margin-top: 6px; }
.lineup { display: flex; flex-wrap: wrap; gap: 4px 6px; justify-content: center; align-items: flex-end; min-height: 110px; max-width: 360px; }
.lineup canvas { image-rendering: pixelated; width: 52px; height: auto; }
.foot { color: var(--muted); font-size: 18px; }

/* 버튼 */
.btn { font-family: var(--font); font-size: 24px; color: var(--text); background: var(--panel); border: 2px solid var(--line); border-radius: 18px; padding: 14px 20px; cursor: pointer; width: 100%; max-width: 420px; }
.btn.big { font-size: 28px; padding: 18px 20px; }
.btn.primary { background: linear-gradient(180deg, #ff8f6b, #e8573f); border-color: #ffb199; box-shadow: 0 5px 0 #a8321f; }
.btn:active { transform: translateY(3px); box-shadow: none; }
.btn.disabled { opacity: 0.45; }
#title .btn { max-width: 320px; width: 320px; }
#title .records { margin-top: 12px; }

.bar { width: 100%; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.bar h2 { font-size: 30px; font-weight: normal; }
.back { font-family: var(--font); font-size: 22px; width: 52px; height: 52px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; }
.col { width: 100%; display: flex; flex-direction: column; align-items: center; gap: 16px; }

/* 캐릭터 선택 */
#select { padding-bottom: 0; }
.grid { width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding-bottom: 300px; }
.card { position: relative; background: var(--panel); border: 3px solid var(--line); border-radius: 14px; padding: 4px 2px 6px; display: flex; flex-direction: column; align-items: center; cursor: pointer; }
.card canvas { image-rendering: pixelated; width: 70%; height: auto; }
.card .num { font-size: 18px; margin-top: 1px; white-space: nowrap; }
.card .sub { font-size: 12px; color: var(--muted); line-height: 1; }
.detail .name small { font-size: 18px; color: var(--muted); }
.card .type { font-size: 13px; padding: 1px 6px; border-radius: 8px; margin-top: 2px; color: #fff; white-space: nowrap; }
.card.sel { border-color: var(--gold); background: rgba(255,216,74,0.14); }
.card.locked { opacity: 0.4; cursor: default; }
.card.locked canvas { filter: brightness(0) invert(0.35); }
.card .lock { font-size: 15px; color: var(--muted); margin-top: 3px; }
.card .taken { position: absolute; top: 4px; left: 6px; font-size: 14px; background: var(--sky); color: #102040; padding: 1px 6px; border-radius: 8px; }
.detail { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(10,14,44,0.97); border-top: 2px solid var(--line); border-radius: 22px 22px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; }
.detail .top { display: flex; gap: 12px; align-items: center; }
.detail .top canvas.big { image-rendering: pixelated; width: 80px; height: auto; flex: none; }
.detail .info { flex: 1; min-width: 0; }
.detail .name { font-size: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0; }
.chip { font-size: 17px; padding: 3px 10px; border-radius: 12px; background: rgba(255,255,255,0.12); white-space: nowrap; }
.rows { font-size: 18px; color: var(--muted); line-height: 1.45; }
.rows b { color: #fff; font-weight: normal; }
.detail canvas.radar { flex: none; width: 104px; height: 104px; }

/* 설정 */
.vs { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 4px 0 18px; }
.vs canvas { image-rendering: pixelated; width: 96px; height: auto; }
.vs .vs-t { font-size: 40px; color: var(--gold); }
.vs .lbl { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 22px; }
.res-line { position: relative; background: #fff; color: #1a1d3a; font-size: 24px; padding: 10px 20px; border-radius: 18px; max-width: 90%; }
.res-line:empty { display: none; }
.mu { font-size: 20px; color: var(--gold); margin: -8px 0 14px; min-height: 24px; }
.opt-label small { font-size: 16px; opacity: 0.8; }
.sp-row { font-size: 18px; line-height: 1.45; }
.sp-row b { color: var(--gold); font-weight: normal; }
.opt-group { width: 100%; max-width: 420px; }
.opt-label { font-size: 22px; color: var(--muted); margin-bottom: 8px; }
.seg { display: flex; gap: 8px; }
.seg button { flex: 1; font-family: var(--font); font-size: 22px; padding: 14px 6px; border-radius: 14px; border: 2px solid var(--line); background: var(--panel); color: #fff; cursor: pointer; }
.seg button.on { background: var(--gold); color: #2a1d00; border-color: #fff0a8; }

/* 일시정지 */
.overlay { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; background: rgba(5,8,25,0.75); z-index: 10; }
.overlay.active { display: flex; }
.panel { width: 86%; max-width: 400px; background: #141c4c; border: 2px solid var(--line); border-radius: 24px; padding: 24px 20px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.panel h2 { font-size: 34px; font-weight: normal; margin-bottom: 6px; }

.records { font-size: 19px; color: var(--muted); text-align: center; line-height: 1.5; }

/* 결과 */
#result { justify-content: center; gap: 14px; text-align: center; }
#result h1 { font-size: 64px; font-weight: normal; color: var(--gold); text-shadow: 0 4px 0 #b8322e; }
#result h1.lose { color: #cfd6f2; text-shadow: 0 4px 0 #3a4270; }
.res-pose canvas { image-rendering: pixelated; width: 180px; height: auto; }
.res-score { font-size: 30px; line-height: 1.4; }
.res-score small { display: block; font-size: 20px; color: var(--muted); }
