: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-result, #scr-settings, #scr-help, #scr-pause, #scr-setup { 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; }

/* ─────────── 설정·도움말 ─────────── */
.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; } }

/* ─────────── 결과 ─────────── */
.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; }
a.btn { text-decoration: none; display: inline-block; text-align: center; }

/* ─────────── 세로 화면 안내 ─────────── */
#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; } }

/* ─────────── 버튼 위치 ─────────── */
#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)); top: max(10px, env(safe-area-inset-top)); 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; }
#app.playing #btn-sound { display: none; }
#toast {
  position: absolute; left: 50%; top: 58%; 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; white-space: nowrap;
}
#toast.show { opacity: 1; }
#callout { background: rgba(11, 13, 36, 0.78); border-radius: 18px; padding: 4px 24px 8px; top: 36%; }
#callout.turn { font-size: clamp(24px, 7vh, 40px); }
#callout.gold { color: var(--yellow); }
#callout.splash { color: #6fd0ff; }
#caster {
  position: absolute; left: 50%; top: max(64px, calc(env(safe-area-inset-top) + 58px)); transform: translateX(-50%); z-index: 6; pointer-events: none;
  max-width: min(60vw, 520px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: rgba(11, 11, 20, 0.75); border-radius: 10px; padding: 3px 12px; font-family: var(--display); font-size: clamp(12px, 3.4vh, 15px); color: #fff;
}
#caster::before { content: '🎙️ '; }

/* ─────────── 타이틀 ─────────── */
.logo-top { letter-spacing: 3px; }
.logo-main { font-family: var(--display); font-size: 56px; color: #fff; }
.logo-main span { font-size: inherit; color: #6fd0ff; }

/* ─────────── 대결 준비 ─────────── */
.slots { display: flex; gap: 10px; justify-content: center; width: 100%; flex-wrap: wrap; }
.slot {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px; width: 168px; padding: 8px 6px;
  background: var(--panel); border: 3px solid var(--c, var(--line)); border-radius: 14px; font-family: var(--display);
}
.slot .who { font-family: var(--pixel); font-size: 12px; color: var(--c); }
.slot canvas { width: 66px; height: 48px; image-rendering: pixelated; }
.slot .pick { display: flex; align-items: center; gap: 6px; }
.slot .name { font-size: 16px; min-width: 88px; text-align: center; }
.slot .desc { font-size: 11px; color: var(--muted); font-family: inherit; text-align: center; }
.slot .arrow { width: 30px; height: 28px; border-radius: 8px; border: 2px solid var(--cyan); background: #1c2350; color: #fff; font-size: 13px; cursor: pointer; }
.slot .del { position: absolute; top: 4px; right: 6px; background: none; border: 0; color: var(--muted); font-size: 16px; cursor: pointer; }
.slot.add { justify-content: center; border-style: dashed; color: var(--muted); cursor: pointer; font-size: 16px; min-height: 150px; }
.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; }
.setup-foot { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.set-line { display: flex; align-items: center; gap: 8px; font-family: var(--display); font-size: 15px; }
.set-line > span { color: var(--muted); }

/* ─────────── 조작 버튼 ─────────── */
#controls { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
#controls button { pointer-events: auto; touch-action: none; }
.move { position: absolute; left: max(16px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: flex-end; }
.pad {
  width: 70px; height: 70px; border-radius: 50%; font-size: 24px; color: #fff;
  background: rgba(28, 35, 80, 0.72); border: 3px solid var(--cyan); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.45);
}
.pad.on { transform: translateY(3px) scale(0.96); background: rgba(46, 230, 255, 0.4); }
.fuel { position: absolute; left: 0; right: 0; top: -18px; height: 10px; background: rgba(0, 0, 0, 0.6); border: 2px solid rgba(255, 255, 255, 0.5); border-radius: 6px; }
.fuel i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, #ffd93d, #5dff8a); border-radius: 4px; transition: width 0.1s; }
.fuel.low i { background: #ff5a6e; }
.fuel span { position: absolute; left: 2px; top: -18px; font-family: var(--display); font-size: 12px; color: #fff; text-shadow: 0 1px 2px #000; white-space: nowrap; }
.shoot { position: absolute; right: max(16px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; }
/* 각도 레버: 발사 버튼 위, 위아래로 끌면 바로 포신이 움직임 */
.aim-pad { display: flex; flex-direction: column; align-items: center; gap: 3px; pointer-events: auto; }
.aim-label { display: flex; align-items: center; gap: 4px; background: rgba(11, 13, 36, 0.8); border-radius: 8px; padding: 1px 8px; font-family: var(--pixel); font-size: 12px; color: var(--yellow); }
.aim-label b { font-weight: 400; min-width: 34px; text-align: right; }
.aim-arrow { display: inline-block; color: #fff; font-size: 13px; transition: transform 0.05s; }
.aim-track {
  position: relative; width: 54px; height: clamp(96px, 30vh, 150px); border-radius: 27px; touch-action: none; cursor: ns-resize;
  background: linear-gradient(#ffb3e6, #9fdcff); border: 3px solid #fff; box-shadow: 0 0 0 3px rgba(11, 13, 36, 0.7), 0 4px 0 rgba(0, 0, 0, 0.4);
}
.aim-end { position: absolute; left: 0; right: 0; text-align: center; font-family: var(--display); font-size: 11px; color: #3a1450; pointer-events: none; }
.aim-end.top { top: 5px; } .aim-end.bottom { bottom: 5px; }
.aim-knob {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 32px; transform: translate(-50%, -50%); pointer-events: none;
  border-radius: 16px; background: radial-gradient(circle at 40% 35%, #fff7b0, #ffd93d 45%, #e0a800); border: 3px solid #1b1530;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}
.aim-knob::before, .aim-knob::after { content: ''; position: absolute; left: 12px; right: 12px; height: 2px; background: #1b1530; border-radius: 1px; }
.aim-knob::before { top: 10px; } .aim-knob::after { top: 16px; }
/* 무기 버튼은 아래쪽 가운데 한 줄 (오른쪽 차를 가리지 않게) */
.weapons { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 24px); display: flex; gap: 6px; }
.wp {
  pointer-events: auto; font-family: var(--display); font-size: 13px; color: #fff; text-align: left; min-width: 118px;
  background: rgba(28, 35, 80, 0.8); border: 2px solid var(--line); border-radius: 9px; padding: 4px 8px; cursor: pointer;
}
.wp.on { border-color: var(--yellow); background: rgba(90, 70, 10, 0.85); }
.wp.sp { background: linear-gradient(90deg, rgba(255, 79, 216, 0.55) var(--g, 0%), rgba(28, 35, 80, 0.8) var(--g, 0%)); }
.wp.sp.ready { border-color: var(--pink); animation: glow 0.6s ease-in-out infinite alternate; }
.wp.sp.locked { opacity: 0.6; }
@keyframes glow { from { box-shadow: 0 0 0 2px rgba(255, 79, 216, 0.2); } to { box-shadow: 0 0 12px 4px rgba(255, 79, 216, 0.6); } }
.fire {
  width: 104px; height: 104px; border-radius: 50%; font-family: var(--display); font-size: 24px; color: #fff; line-height: 1.1; border: none;
  background: radial-gradient(circle, #e8384f 0 60%, transparent 61%), conic-gradient(var(--yellow) calc(var(--p, 0) * 1%), rgba(255, 255, 255, 0.25) 0);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.45);
}
.fire small { display: block; font-size: 11px; color: #ffd0d8; }
.fire.on { transform: translateY(3px) scale(0.97); }
.aim-hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: max(62px, calc(env(safe-area-inset-bottom) + 58px)); font-family: var(--display); font-size: 12px; color: rgba(255, 255, 255, 0.75); text-shadow: 0 1px 2px #000; white-space: nowrap; }

/* ─────────── 결과 ─────────── */
.res-table { border-collapse: collapse; font-size: 14px; background: var(--panel); border-radius: 12px; overflow: hidden; }
.res-table th, .res-table td { padding: 5px 12px; text-align: center; }
.res-table th { color: var(--muted); font-weight: 400; font-size: 12px; }
.res-table tr.win td { background: rgba(255, 225, 77, 0.15); }
.res-table td.nm { font-family: var(--display); text-align: left; }

@media (max-height: 460px) {
  .inner { gap: 7px; }
  .logo-top { font-size: 10px; }
  .logo-main { font-size: 38px; margin-top: 4px; }
  .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: 22px; }
  .slot { width: 150px; padding: 6px 4px; }
  .slot canvas { width: 55px; height: 40px; }
  .chip { font-size: 13px; padding: 4px 8px; }
  .pad { width: 60px; height: 60px; font-size: 20px; }
  .fire { width: 86px; height: 86px; font-size: 20px; }
  .aim-track { width: 50px; height: clamp(90px, 28vh, 120px); }
  .wp { font-size: 12px; min-width: 0; padding: 3px 7px; }
  .tips { font-size: 13px; line-height: 1.5; }
}
